Re: [PATCH] ion: Consider ion pool pages as indirectly reclaimable

2018-04-27 Thread vjitta

On 2018-04-27 10:40, vji...@codeaurora.org wrote:

On 2018-04-25 21:17, Laura Abbott wrote:

On 04/24/2018 08:43 PM, vji...@codeaurora.org wrote:

From: Vijayanand Jitta 

An issue is observed where mallocs are failing due to overcommit 
failure.

The failure happens when there is high ION page pool since ION page
pool is not considered reclaimable by the overcommit calculation 
code.
This change considers ion pool pages as indirectly reclaimable and 
thus

accounted as available memory in the overcommit calculation.

Signed-off-by: Vijayanand Jitta 
---
  drivers/staging/android/ion/ion_page_pool.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/staging/android/ion/ion_page_pool.c 
b/drivers/staging/android/ion/ion_page_pool.c

index db8f614..9bc56eb 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -32,6 +32,9 @@ static void ion_page_pool_add(struct ion_page_pool 
*pool, struct page *page)

list_add_tail(&page->lru, &pool->low_items);
pool->low_count++;
}
+
+	mod_node_page_state(page_pgdat(page), 
NR_INDIRECTLY_RECLAIMABLE_BYTES,

+   (1 << (PAGE_SHIFT + pool->order)));
mutex_unlock(&pool->mutex);
  }
  @@ -50,6 +53,8 @@ static struct page *ion_page_pool_remove(struct 
ion_page_pool *pool, bool high)

}
list_del(&page->lru);
+	mod_node_page_state(page_pgdat(page), 
NR_INDIRECTLY_RECLAIMABLE_BYTES,

+   -(1 << (PAGE_SHIFT + pool->order)));
return page;
  }



I'm sure this fixes the problem but I don't think we want to
start throwing page adjustments into Ion. Why isn't this
memory already considered reclaimable by existing calculations?

Thanks,
Laura


You can refer to discussion here https://lkml.org/lkml/2018/3/5/361 
introducing
NR_INDIRECTLY_RECLAIMABLE_BYTES for the memory which is not currently 
considered

as reclaimable

Thanks,
Vijay


There was also discussion specific to ion in that thread you can find it 
here

https://lkml.org/lkml/2018/4/25/642

Thanks,
Vijay
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread Arvind Yadav
Replace the manual validity checks for the GPIO with the
gpio_is_valid().

Signed-off-by: Arvind Yadav 
---
 drivers/staging/greybus/arche-platform.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 83254a7..fc6bf60 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,9 +448,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
"svc,reset-gpio",
0);
-   if (arche_pdata->svc_reset_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
dev_err(dev, "failed to get reset-gpio\n");
-   return arche_pdata->svc_reset_gpio;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, "svc-reset");
if (ret) {
@@ -468,9 +468,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
  "svc,sysboot-gpio",
  0);
-   if (arche_pdata->svc_sysboot_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
dev_err(dev, "failed to get sysboot gpio\n");
-   return arche_pdata->svc_sysboot_gpio;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_sysboot_gpio, "sysboot0");
if (ret) {
@@ -487,9 +487,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_refclk_req = of_get_named_gpio(np,
"svc,refclk-req-gpio",
0);
-   if (arche_pdata->svc_refclk_req < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
dev_err(dev, "failed to get svc clock-req gpio\n");
-   return arche_pdata->svc_refclk_req;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_refclk_req,
"svc-clk-req");
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 5/5] X86: Hyper-V: Consolidate the allocation of the hypercall input page

2018-04-27 Thread Thomas Gleixner
On Fri, 27 Apr 2018, KY Srinivasan wrote:

> 
> 
> > -Original Message-
> > From: Thomas Gleixner 
> > Sent: Thursday, April 26, 2018 3:24 PM
> > To: KY Srinivasan 
> > Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-
> > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> > a...@canonical.com; jasow...@redhat.com; h...@zytor.com; Stephen
> > Hemminger ; Michael Kelley (EOSG)
> > ; vkuzn...@redhat.com
> > Subject: Re: [PATCH 5/5] X86: Hyper-V: Consolidate the allocation of the
> > hypercall input page
> > 
> > On Wed, 25 Apr 2018, k...@linuxonhyperv.com wrote:
> > 
> > > From: "K. Y. Srinivasan" 
> > >
> > > Consolidate the allocation of the hypercall input page.
> > 
> > Again. You can provide the new way of allocation first, then you don't have
> > to add code first in order to remove it later again. 
> 
> I have implemented the new way upfront for the new code - the IPI code
> [PATCH 2/5] X86: Hyper-V: Enable IPI enlightenments.
> What I am doing here using that infrastructure for the TLB flush 
> enlightenments
> and getting rid of unnecessary code.

Ok. I maybe misread it, but a bit more elaborate change log might help to
avoid that.

Thanks,

tglx
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 16/16] staging: ks7010: refactor ks_wlan_translate_scan function

2018-04-27 Thread Dan Carpenter
This really should have been broken up into several patches.  I've
reviewed the first 15 patches and they were straight forward.  Then I
postponed because it was just so grizzly to figure out what was going
on...

On Wed, Apr 25, 2018 at 04:01:55PM +0200, Sergio Paracuellos wrote:
> This commit refactors ks_wlan_translate_scan function with
> the following changes:
> 
> - reorder local variables
> - use ether_addr_copy to copy ethernet addresses
> - change style in 'current_ev' variable assignments
> - make use of some ternaries avoiding if-else code
> - use preferred style for comments
> - extract common code into a new ks_wlan_add_leader_event
>   function
> 

I have s script to ignore comment changes and review patches that
extract code into new functions but since this stuff is all jumbled
together then I have to review it manually.  Five of these things take
about 10 seconds to review when they're on their own, so 50 seconds
altogether.  Extracting the code takes maybe a minute to review.  So
let's say a total of two minutes.

But to review it after it's mixed up and then mashed into a pile takes
probably 15 minutes.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/5] X86: Hyper-V: Enable IPI enlightenments

2018-04-27 Thread kbuild test robot
Hi Srinivasan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[also build test WARNING on next-20180426]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/kys-linuxonhyperv-com/X86-Hyper-V-APIC-enlightenments/20180427-114416
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> arch/x86/hyperv/hv_init.c:105:30: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got const [noderef] *__vpp_verify @@
   arch/x86/hyperv/hv_init.c:105:30:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/hv_init.c:105:30:got void [noderef] **
   arch/x86/hyperv/hv_init.c:229:30: sparse: incorrect type in initializer 
(different address spaces) @@expected void const [noderef] 
*__vpp_verify @@got const [noderef] *__vpp_verify @@
   arch/x86/hyperv/hv_init.c:229:30:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/hv_init.c:229:30:got void [noderef] **
>> arch/x86/hyperv/hv_init.c:275:31: sparse: incorrect type in assignment 
>> (different address spaces) @@expected void [noderef] **extern 
>> [addressable] [toplevel] hyperv_pcpu_input_arg @@got addressable] 
>> [toplevel] hyperv_pcpu_input_arg @@
   arch/x86/hyperv/hv_init.c:275:31:expected void [noderef] **extern 
[addressable] [toplevel] hyperv_pcpu_input_arg
   arch/x86/hyperv/hv_init.c:275:31:got void *[noderef] *
   arch/x86/include/asm/paravirt.h:150:9: sparse: cast truncates bits from 
constant value (8000 becomes 0)
--
>> arch/x86/hyperv/hv_apic.c:118:41: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got const [noderef] *__vpp_verify @@
   arch/x86/hyperv/hv_apic.c:118:41:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/hv_apic.c:118:41:got void [noderef] **

vim +105 arch/x86/hyperv/hv_init.c

98  
99  static int hv_cpu_init(unsigned int cpu)
   100  {
   101  u64 msr_vp_index;
   102  struct hv_vp_assist_page **hvp = 
&hv_vp_assist_page[smp_processor_id()];
   103  void **input_arg;
   104  
 > 105  input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg);
   106  *input_arg = page_address(alloc_page(GFP_ATOMIC));
   107  
   108  hv_get_vp_index(msr_vp_index);
   109  
   110  hv_vp_index[smp_processor_id()] = msr_vp_index;
   111  
   112  if (msr_vp_index > hv_max_vp_index)
   113  hv_max_vp_index = msr_vp_index;
   114  
   115  if (!hv_vp_assist_page)
   116  return 0;
   117  
   118  if (!*hvp)
   119  *hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
   120  
   121  if (*hvp) {
   122  u64 val;
   123  
   124  val = vmalloc_to_pfn(*hvp);
   125  val = (val << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) |
   126  HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;
   127  
   128  wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, val);
   129  }
   130  
   131  return 0;
   132  }
   133  
   134  static void (*hv_reenlightenment_cb)(void);
   135  
   136  static void hv_reenlightenment_notify(struct work_struct *dummy)
   137  {
   138  struct hv_tsc_emulation_status emu_status;
   139  
   140  rdmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
   141  
   142  /* Don't issue the callback if TSC accesses are not emulated */
   143  if (hv_reenlightenment_cb && emu_status.inprogress)
   144  hv_reenlightenment_cb();
   145  }
   146  static DECLARE_DELAYED_WORK(hv_reenlightenment_work, 
hv_reenlightenment_notify);
   147  
   148  void hyperv_stop_tsc_emulation(void)
   149  {
   150  u64 freq;
   151  struct hv_tsc_emulation_status emu_status;
   152  
   153  rdmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
   154  emu_status.inprogress = 0;
   155  wrmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
   156  
   157  rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq);
   158  tsc_khz = div64_u64(freq, 1000);
   159  }
   160  EXPORT_SYMBOL_GPL(hyperv_stop_tsc_emulation);
   161  
   162  static inline bool hv_reenlightenment_available(void)
   163  {
   164  /*
   165   * Check for required features and priviliges to make TSC 
frequency
   166   * change notifications work.
   167   */
   168  return ms_hyperv.features & HV_X64_

Re: [PATCH 5/5] X86: Hyper-V: Consolidate the allocation of the hypercall input page

2018-04-27 Thread kbuild test robot
Hi Srinivasan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc2]
[also build test WARNING on next-20180426]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/kys-linuxonhyperv-com/X86-Hyper-V-APIC-enlightenments/20180427-114416
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> arch/x86/hyperv/mmu.c:86:22: sparse: incorrect type in initializer 
>> (different address spaces) @@expected void const [noderef] 
>> *__vpp_verify @@got const [noderef] *__vpp_verify @@
   arch/x86/hyperv/mmu.c:86:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:86:22:got void [noderef] **
   arch/x86/hyperv/mmu.c:171:22: sparse: incorrect type in initializer 
(different address spaces) @@expected void const [noderef] 
*__vpp_verify @@got const [noderef] *__vpp_verify @@
   arch/x86/hyperv/mmu.c:171:22:expected void const [noderef] 
*__vpp_verify
   arch/x86/hyperv/mmu.c:171:22:got void [noderef] **

vim +86 arch/x86/hyperv/mmu.c

65  
66  static void hyperv_flush_tlb_others(const struct cpumask *cpus,
67  const struct flush_tlb_info *info)
68  {
69  int cpu, vcpu, gva_n, max_gvas;
70  struct hv_flush_pcpu **flush_pcpu;
71  struct hv_flush_pcpu *flush;
72  u64 status = U64_MAX;
73  unsigned long flags;
74  
75  trace_hyperv_mmu_flush_tlb_others(cpus, info);
76  
77  if (!hv_hypercall_pg)
78  goto do_native;
79  
80  if (cpumask_empty(cpus))
81  return;
82  
83  local_irq_save(flags);
84  
85  flush_pcpu = (struct hv_flush_pcpu **)
  > 86   this_cpu_ptr(hyperv_pcpu_input_arg);
87  
88  flush = *flush_pcpu;
89  
90  if (unlikely(!flush)) {
91  local_irq_restore(flags);
92  goto do_native;
93  }
94  
95  if (info->mm) {
96  /*
97   * AddressSpace argument must match the CR3 with PCID 
bits
98   * stripped out.
99   */
   100  flush->address_space = virt_to_phys(info->mm->pgd);
   101  flush->address_space &= CR3_ADDR_MASK;
   102  flush->flags = 0;
   103  } else {
   104  flush->address_space = 0;
   105  flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
   106  }
   107  
   108  flush->processor_mask = 0;
   109  if (cpumask_equal(cpus, cpu_present_mask)) {
   110  flush->flags |= HV_FLUSH_ALL_PROCESSORS;
   111  } else {
   112  for_each_cpu(cpu, cpus) {
   113  vcpu = hv_cpu_number_to_vp_number(cpu);
   114  if (vcpu >= 64)
   115  goto do_native;
   116  
   117  __set_bit(vcpu, (unsigned long *)
   118&flush->processor_mask);
   119  }
   120  }
   121  
   122  /*
   123   * We can flush not more than max_gvas with one hypercall. 
Flush the
   124   * whole address space if we were asked to do more.
   125   */
   126  max_gvas = (PAGE_SIZE - sizeof(*flush)) / 
sizeof(flush->gva_list[0]);
   127  
   128  if (info->end == TLB_FLUSH_ALL) {
   129  flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY;
   130  status = 
hv_do_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE,
   131   flush, NULL);
   132  } else if (info->end &&
   133 ((info->end - info->start)/HV_TLB_FLUSH_UNIT) > 
max_gvas) {
   134  status = 
hv_do_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE,
   135   flush, NULL);
   136  } else {
   137  gva_n = fill_gva_list(flush->gva_list, 0,
   138info->start, info->end);
   139  status = 
hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST,
   140   gva_n, 0, flush, NULL);
   141  }
   142  
   143  local_irq_restore(flags);
   144  
   145  if (!(status & HV_HYPERCALL_RESULT_MASK))
   146  return;
   147  do_native:
   148  native_flush_tlb_others(cpus, info);
   14

Re: [PATCH 2/5] X86: Hyper-V: Enable IPI enlightenments

2018-04-27 Thread kbuild test robot
Hi Srinivasan,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.17-rc2]
[also build test ERROR on next-20180426]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/kys-linuxonhyperv-com/X86-Hyper-V-APIC-enlightenments/20180427-114416
config: i386-randconfig-s1-04271426 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/hyperv/hv_apic.c: In function 'hv_apic_read':
   arch/x86/hyperv/hv_apic.c:73:10: error: implicit declaration of function 
'native_apic_mem_read' [-Werror=implicit-function-declaration]
  return native_apic_mem_read(reg);
 ^~~~
   arch/x86/hyperv/hv_apic.c: In function 'hv_apic_write':
   arch/x86/hyperv/hv_apic.c:87:3: error: implicit declaration of function 
'native_apic_mem_write' [-Werror=implicit-function-declaration]
  native_apic_mem_write(reg, val);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_send_ipi':
   arch/x86/hyperv/hv_apic.c:155:3: error: invalid use of undefined type 
'struct apic'
  orig_apic.send_IPI(cpu, vector);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_send_ipi_mask':
   arch/x86/hyperv/hv_apic.c:161:3: error: invalid use of undefined type 
'struct apic'
  orig_apic.send_IPI_mask(mask, vector);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_send_ipi_mask_allbutself':
   arch/x86/hyperv/hv_apic.c:174:3: error: invalid use of undefined type 
'struct apic'
  orig_apic.send_IPI_mask_allbutself(mask, vector);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_send_ipi_all':
   arch/x86/hyperv/hv_apic.c:185:3: error: invalid use of undefined type 
'struct apic'
  orig_apic.send_IPI_all(vector);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_send_ipi_self':
   arch/x86/hyperv/hv_apic.c:191:3: error: invalid use of undefined type 
'struct apic'
  orig_apic.send_IPI_self(vector);
  ^
   arch/x86/hyperv/hv_apic.c: In function 'hv_apic_init':
   arch/x86/hyperv/hv_apic.c:204:16: error: 'apic' undeclared (first use in 
this function)
  orig_apic = *apic;
   ^~~~
   arch/x86/hyperv/hv_apic.c:204:16: note: each undeclared identifier is 
reported only once for each function it appears in
>> arch/x86/hyperv/hv_apic.c:204:3: error: 'orig_apic' has an incomplete type 
>> 'struct apic'
  orig_apic = *apic;
  ^
   arch/x86/hyperv/hv_apic.c:217:3: error: implicit declaration of function 
'apic_set_eoi_write' [-Werror=implicit-function-declaration]
  apic_set_eoi_write(hv_apic_eoi_write);
  ^~
   arch/x86/hyperv/hv_apic.c: At top level:
>> arch/x86/hyperv/hv_apic.c:39:20: error: storage size of 'orig_apic' isn't 
>> known
static struct apic orig_apic;
   ^
   cc1: some warnings being treated as errors

vim +204 arch/x86/hyperv/hv_apic.c

38  
  > 39  static struct apic orig_apic;
40  
41  static u64 hv_apic_icr_read(void)
42  {
43  u64 reg_val;
44  
45  rdmsrl(HV_X64_MSR_ICR, reg_val);
46  return reg_val;
47  }
48  
49  static void hv_apic_icr_write(u32 low, u32 id)
50  {
51  u64 reg_val;
52  
53  reg_val = SET_APIC_DEST_FIELD(id);
54  reg_val = reg_val << 32;
55  reg_val |= low;
56  
57  wrmsrl(HV_X64_MSR_ICR, reg_val);
58  }
59  
60  static u32 hv_apic_read(u32 reg)
61  {
62  u32 reg_val, hi;
63  
64  switch (reg) {
65  case APIC_EOI:
66  rdmsr(HV_X64_MSR_EOI, reg_val, hi);
67  return reg_val;
68  case APIC_TASKPRI:
69  rdmsr(HV_X64_MSR_TPR, reg_val, hi);
70  return reg_val;
71  
72  default:
73  return native_apic_mem_read(reg);
74  }
75  }
76  
77  static void hv_apic_write(u32 reg, u32 val)
78  {
79  switch (reg) {
80  case APIC_EOI:
81  wrmsr(HV_X64_MSR_EOI, val, 0);
82  break;
83  case APIC_TASKPRI:
84  wrmsr(HV_X64_MSR_TPR, val, 0);
85  break;
86  default:
87  native_apic_mem_write(reg, val);
88  }
89  }
90  
91  static void hv_apic_eoi_write(u32 reg, u32 val)
92  {

Re: [greybus-dev] [PATCH] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread Alex Elder
On 04/27/2018 05:52 AM, Arvind Yadav wrote:
> Replace the manual validity checks for the GPIO with the
> gpio_is_valid().

I haven't looked through the code paths very closely, but I
think that get_named_gpio() might return -EPROBE_DEFER, which
would be something we want to pass to the caller.

So rather than returning -ENODEV and hiding the reason the
call to of_get_named_gpio() failed, you should continue
returning the errno it supplies (if not a valid gpio number).

-Alex

> Signed-off-by: Arvind Yadav 
> ---
>  drivers/staging/greybus/arche-platform.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/greybus/arche-platform.c 
> b/drivers/staging/greybus/arche-platform.c
> index 83254a7..fc6bf60 100644
> --- a/drivers/staging/greybus/arche-platform.c
> +++ b/drivers/staging/greybus/arche-platform.c
> @@ -448,9 +448,9 @@ static int arche_platform_probe(struct platform_device 
> *pdev)
>   arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>   "svc,reset-gpio",
>   0);
> - if (arche_pdata->svc_reset_gpio < 0) {
> + if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>   dev_err(dev, "failed to get reset-gpio\n");
> - return arche_pdata->svc_reset_gpio;
> + return -ENODEV;
>   }
>   ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, "svc-reset");
>   if (ret) {
> @@ -468,9 +468,9 @@ static int arche_platform_probe(struct platform_device 
> *pdev)
>   arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
> "svc,sysboot-gpio",
> 0);
> - if (arche_pdata->svc_sysboot_gpio < 0) {
> + if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>   dev_err(dev, "failed to get sysboot gpio\n");
> - return arche_pdata->svc_sysboot_gpio;
> + return -ENODEV;
>   }
>   ret = devm_gpio_request(dev, arche_pdata->svc_sysboot_gpio, "sysboot0");
>   if (ret) {
> @@ -487,9 +487,9 @@ static int arche_platform_probe(struct platform_device 
> *pdev)
>   arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>   "svc,refclk-req-gpio",
>   0);
> - if (arche_pdata->svc_refclk_req < 0) {
> + if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>   dev_err(dev, "failed to get svc clock-req gpio\n");
> - return arche_pdata->svc_refclk_req;
> + return -ENODEV;
>   }
>   ret = devm_gpio_request(dev, arche_pdata->svc_refclk_req,
>   "svc-clk-req");
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread Arvind Yadav



On Friday 27 April 2018 05:47 PM, Alex Elder wrote:

On 04/27/2018 05:52 AM, Arvind Yadav wrote:

Replace the manual validity checks for the GPIO with the
gpio_is_valid().

I haven't looked through the code paths very closely, but I
think that get_named_gpio() might return -EPROBE_DEFER, which
would be something we want to pass to the caller.

Yes of_get_name_gpio() can return other error value apart from
-EPROBE_DEFER.

So rather than returning -ENODEV and hiding the reason the
call to of_get_named_gpio() failed, you should continue
returning the errno it supplies (if not a valid gpio number).

-Alex

I have return -ENODEV because invalid gpio pin can be positive.
static inline bool gpio_is_valid(int number)
{
return number >= 0 && number < ARCH_NR_GPIOS;
}
Here if number > ARCH_NR_GPIOS then it's invalid but return value
will be positive.

We can return like this
" return (gpio > 0) ? -ENODEV: gpio;"

But not sure this is worth to handle this.

~arvind



Signed-off-by: Arvind Yadav 
---
  drivers/staging/greybus/arche-platform.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 83254a7..fc6bf60 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,9 +448,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
"svc,reset-gpio",
0);
-   if (arche_pdata->svc_reset_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
dev_err(dev, "failed to get reset-gpio\n");
-   return arche_pdata->svc_reset_gpio;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, "svc-reset");
if (ret) {
@@ -468,9 +468,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
  "svc,sysboot-gpio",
  0);
-   if (arche_pdata->svc_sysboot_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
dev_err(dev, "failed to get sysboot gpio\n");
-   return arche_pdata->svc_sysboot_gpio;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_sysboot_gpio, "sysboot0");
if (ret) {
@@ -487,9 +487,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_refclk_req = of_get_named_gpio(np,
"svc,refclk-req-gpio",
0);
-   if (arche_pdata->svc_refclk_req < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
dev_err(dev, "failed to get svc clock-req gpio\n");
-   return arche_pdata->svc_refclk_req;
+   return -ENODEV;
}
ret = devm_gpio_request(dev, arche_pdata->svc_refclk_req,
"svc-clk-req");



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread Alex Elder
On 04/27/2018 07:50 AM, Arvind Yadav wrote:
> 
> 
> On Friday 27 April 2018 05:47 PM, Alex Elder wrote:
>> On 04/27/2018 05:52 AM, Arvind Yadav wrote:
>>> Replace the manual validity checks for the GPIO with the
>>> gpio_is_valid().
>> I haven't looked through the code paths very closely, but I
>> think that get_named_gpio() might return -EPROBE_DEFER, which
>> would be something we want to pass to the caller.
> Yes of_get_name_gpio() can return other error value apart from
> -EPROBE_DEFER.
>> So rather than returning -ENODEV and hiding the reason the
>> call to of_get_named_gpio() failed, you should continue
>> returning the errno it supplies (if not a valid gpio number).
>>
>>     -Alex
> I have return -ENODEV because invalid gpio pin can be positive.
> static inline bool gpio_is_valid(int number)
> {
>     return number >= 0 && number < ARCH_NR_GPIOS;
> }
> Here if number > ARCH_NR_GPIOS then it's invalid but return value
> will be positive.

Your reasoning is good.  However in all three of these cases,
the GPIO number you're checking is the value returned from
of_get_named_gpio().  The return value is a "GPIO number to
use with Linux generic GPIO API, or one of the errno value."

So unless the API of of_get_named_gpio() changes, you can be
sure that if the value returned is invalid, it is a negative
errno.  (And if the API did change, the person making that
change would be responsible for fixing all callers to ensure
the change didn't break them.)

This distinction may be why the code you're changing was only
testing for negative, rather than using gpio_is_valid() (you'll
see it's used elsewhere in the Greybus code--even in the same
source files.)

Anyway, changing the code to use gpio_is_valid() is fine.  But
you should avoid obscuring the reason for the error that the
return value from of_get_named_gpio() provides.

-Alex

> We can return like this
>     " return (gpio > 0) ? -ENODEV: gpio;"
> 
> But not sure this is worth to handle this.
> 
> ~arvind
>>
>>> Signed-off-by: Arvind Yadav 
>>> ---
>>>   drivers/staging/greybus/arche-platform.c | 12 ++--
>>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/staging/greybus/arche-platform.c 
>>> b/drivers/staging/greybus/arche-platform.c
>>> index 83254a7..fc6bf60 100644
>>> --- a/drivers/staging/greybus/arche-platform.c
>>> +++ b/drivers/staging/greybus/arche-platform.c
>>> @@ -448,9 +448,9 @@ static int arche_platform_probe(struct platform_device 
>>> *pdev)
>>>   arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>>>   "svc,reset-gpio",
>>>   0);
>>> -    if (arche_pdata->svc_reset_gpio < 0) {
>>> +    if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>>>   dev_err(dev, "failed to get reset-gpio\n");
>>> -    return arche_pdata->svc_reset_gpio;
>>> +    return -ENODEV;
>>>   }
>>>   ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, 
>>> "svc-reset");
>>>   if (ret) {
>>> @@ -468,9 +468,9 @@ static int arche_platform_probe(struct platform_device 
>>> *pdev)
>>>   arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
>>>     "svc,sysboot-gpio",
>>>     0);
>>> -    if (arche_pdata->svc_sysboot_gpio < 0) {
>>> +    if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>>>   dev_err(dev, "failed to get sysboot gpio\n");
>>> -    return arche_pdata->svc_sysboot_gpio;
>>> +    return -ENODEV;
>>>   }
>>>   ret = devm_gpio_request(dev, arche_pdata->svc_sysboot_gpio, 
>>> "sysboot0");
>>>   if (ret) {
>>> @@ -487,9 +487,9 @@ static int arche_platform_probe(struct platform_device 
>>> *pdev)
>>>   arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>>>   "svc,refclk-req-gpio",
>>>   0);
>>> -    if (arche_pdata->svc_refclk_req < 0) {
>>> +    if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>>>   dev_err(dev, "failed to get svc clock-req gpio\n");
>>> -    return arche_pdata->svc_refclk_req;
>>> +    return -ENODEV;
>>>   }
>>>   ret = devm_gpio_request(dev, arche_pdata->svc_refclk_req,
>>>   "svc-clk-req");
>>>
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 16/16] staging: ks7010: refactor ks_wlan_translate_scan function

2018-04-27 Thread Sergio Paracuellos
On Fri, Apr 27, 2018 at 02:00:29PM +0300, Dan Carpenter wrote:
> This really should have been broken up into several patches.  I've
> reviewed the first 15 patches and they were straight forward.  Then I
> postponed because it was just so grizzly to figure out what was going
> on...

Thanks for pointing this out. Because it was all related together
and changes were pretty straighforward I prefer to put them all
in the same patch and resume changes properly in the commit message. 
I'll try to group changes more properly from now. 

> 
> On Wed, Apr 25, 2018 at 04:01:55PM +0200, Sergio Paracuellos wrote:
> > This commit refactors ks_wlan_translate_scan function with
> > the following changes:
> > 
> > - reorder local variables
> > - use ether_addr_copy to copy ethernet addresses
> > - change style in 'current_ev' variable assignments
> > - make use of some ternaries avoiding if-else code
> > - use preferred style for comments
> > - extract common code into a new ks_wlan_add_leader_event
> >   function
> > 
> 
> I have s script to ignore comment changes and review patches that
> extract code into new functions but since this stuff is all jumbled
> together then I have to review it manually.  Five of these things take
> about 10 seconds to review when they're on their own, so 50 seconds
> altogether.  Extracting the code takes maybe a minute to review.  So
> let's say a total of two minutes.
> 
> But to review it after it's mixed up and then mashed into a pile takes
> probably 15 minutes.
> 

Thanks for your time for reviewing this, Dan.

> regards,
> dan carpenter
> 

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/10] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute

2018-04-27 Thread Sergio Paracuellos
This commit cleans code for the event SME_MIC_FAILURE_REQUEST
changing if logic to handle invalid value first and using a
local variable.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 965a23d..5dceadc 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2070,10 +2070,10 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 }
 
 /* execute sme */
-static
-void hostif_sme_execute(struct ks_wlan_private *priv, int event)
+static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 {
__le32 val;
+   u16 failure;
 
switch (event) {
case SME_START:
@@ -2099,18 +2099,15 @@ void hostif_sme_execute(struct ks_wlan_private *priv, 
int event)
hostif_phy_information_request(priv);
break;
case SME_MIC_FAILURE_REQUEST:
-   if (priv->wpa.mic_failure.failure == 1) {
-   hostif_mic_failure_request(priv,
-  
priv->wpa.mic_failure.failure - 1,
-  0);
-   } else if (priv->wpa.mic_failure.failure == 2) {
-   hostif_mic_failure_request(priv,
-  
priv->wpa.mic_failure.failure - 1,
-  
priv->wpa.mic_failure.counter);
-   } else {
-   netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: 
failure count=%u error?\n",
-  priv->wpa.mic_failure.failure);
+   failure = priv->wpa.mic_failure.failure;
+   if (failure != 1 && failure != 2) {
+   netdev_err(priv->net_dev,
+  "SME_MIC_FAILURE_REQUEST: failure count=%u 
error?\n",
+  failure);
+   return;
}
+   hostif_mic_failure_request(priv, failure - 1, (failure == 1) ?
+   0 : priv->wpa.mic_failure.counter);
break;
case SME_MIC_FAILURE_CONFIRM:
if (priv->wpa.mic_failure.failure == 2) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/10] staging: ks7010: convert MIB preprocessor defs into an enum

2018-04-27 Thread Sergio Paracuellos
This commit just change some preprocessor definitions related
with MIB data types into an enumeration which is much cleaner
for this here.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 974e639..a913e02 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -135,14 +135,25 @@ struct hostif_mib_get_request {
__le32 mib_attribute;
 } __packed;
 
+/**
+ * enum mib_data_type - Message Information Base data type.
+ * @MIB_VALUE_TYPE_NULL: NULL type
+ * @MIB_VALUE_TYPE_INT: INTEGER type
+ * @MIB_VALUE_TYPE_BOOL: BOOL type
+ * @MIB_VALUE_TYPE_COUNT32: unused
+ * @MIB_VALUE_TYPE_OSTRING: Chunk of memory
+ */
+enum mib_data_type {
+   MIB_VALUE_TYPE_NULL = 0,
+   MIB_VALUE_TYPE_INT,
+   MIB_VALUE_TYPE_BOOL,
+   MIB_VALUE_TYPE_COUNT32,
+   MIB_VALUE_TYPE_OSTRING
+};
+
 struct hostif_mib_value {
__le16 size;
__le16 type;
-#define MIB_VALUE_TYPE_NULL 0
-#define MIB_VALUE_TYPE_INT  1
-#define MIB_VALUE_TYPE_BOOL 2
-#define MIB_VALUE_TYPE_COUNT32  3
-#define MIB_VALUE_TYPE_OSTRING  4
u8 body[0];
 } __packed;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/10] staging: ks7010: conver MIB attributes preprocessor defs into an enum

2018-04-27 Thread Sergio Paracuellos
This commit just change some preprocessor definitions related
with MIB attributes into an enumeration which is much cleaner
for this here. Also add kerneldoc to avoid long comment lines.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 130 -
 1 file changed, 85 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index a913e02..d576341 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -84,51 +84,91 @@ struct channel_list {
u8 pad;
 } __packed;
 
-/* MIB Attribute */
-#define DOT11_MAC_ADDRESS 0x21010100   /* MAC Address (R) */
-#define DOT11_PRODUCT_VERSION 0x31024100   /* FirmWare Version (R) 
*/
-#define DOT11_RTS_THRESHOLD   0x21020100   /* RTS Threshold (R/W) 
*/
-#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100   /* Fragment Threshold 
(R/W) */
-#define DOT11_PRIVACY_INVOKED 0x15010100   /* WEP ON/OFF (W) */
-#define DOT11_WEP_DEFAULT_KEY_ID  0x15020100   /* WEP Index (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE1  0x13020101   /* WEP Key#1(TKIP AES: 
PairwiseTemporalKey) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE2  0x13020102   /* WEP Key#2(TKIP AES: 
GroupKey1) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE3  0x13020103   /* WEP Key#3(TKIP AES: 
GroupKey2) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE4  0x13020104   /* WEP Key#4 (W) */
-#define DOT11_WEP_LIST0x13020100   /* WEP LIST */
-#defineDOT11_DESIRED_SSID0x11090100/* SSID */
-#defineDOT11_CURRENT_CHANNEL 0x45010100/* channel set 
*/
-#defineDOT11_OPERATION_RATE_SET  0x0100/* rate set */
-
-#define LOCAL_AP_SEARCH_INTEAVAL  0xF1010100   /* AP search interval 
(R/W) */
-#define LOCAL_CURRENTADDRESS  0xF1050100   /* MAC Address change 
(W) */
-#define LOCAL_MULTICAST_ADDRESS   0xF1060100   /* Multicast Address 
(W) */
-#define LOCAL_MULTICAST_FILTER0xF1060200   /* Multicast Address 
Filter enable/disable (W) */
-#define LOCAL_SEARCHED_AP_LIST0xF1030100   /* AP list (R) */
-#define LOCAL_LINK_AP_STATUS  0xF1040100   /* Link AP status (R) */
-#defineLOCAL_PACKET_STATISTICS   0xF1020100/* tx,rx 
packets statistics */
-#define LOCAL_AP_SCAN_LIST_TYPE_SET  0xF1030200/* AP_SCAN_LIST_TYPE */
-
-#define DOT11_RSN_ENABLED 0x15070100   /* WPA enable/disable 
(W) */
-#define LOCAL_RSN_MODE0x56010100   /* RSN mode WPA/WPA2 
(W) */
-#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100   /* GroupKeyCipherSuite 
(W) */
-#define DOT11_RSN_CONFIG_UNICAST_CIPHER   0x52020100   /* 
PairwiseKeyCipherSuite (W) */
-#define DOT11_RSN_CONFIG_AUTH_SUITE   0x53020100   /* 
AuthenticationKeyManagementSuite (W) */
-#define DOT11_RSN_CONFIG_VERSION  0x51020100   /* RSN version (W) */
-#define LOCAL_RSN_CONFIG_ALL  0x5F010100   /* RSN CONFIG ALL (W) */
-#define DOT11_PMK_TSC 0x55010100   /* PMK_TSC (W) */
-#define DOT11_GMK1_TSC0x55010101   /* GMK1_TSC (W) */
-#define DOT11_GMK2_TSC0x55010102   /* GMK2_TSC (W) */
-#define DOT11_GMK3_TSC0x55010103   /* GMK3_TSC */
-#define LOCAL_PMK 0x58010100   /* Pairwise Master Key 
cache (W) */
-
-#define LOCAL_REGION  0xF10A0100   /* Region setting */
-
-#define LOCAL_WPS_ENABLE  0xF10B0100   /* WiFi Protected Setup 
*/
-#define LOCAL_WPS_PROBE_REQ   0xF10C0100   /* WPS Probe Request */
-
-#define LOCAL_GAIN0xF10D0100   /* Carrer sense 
threshold for demo ato show */
-#define LOCAL_EEPROM_SUM  0xF10E0100   /* EEPROM checksum 
information */
+/**
+ * enum mib_attribute - Management Information Base attribute
+ * Attribute value used for accessing and updating MIB
+ *
+ * @DOT11_MAC_ADDRESS: MAC Address (R)
+ * @DOT11_PRODUCT_VERSION: FirmWare Version (R)
+ * @DOT11_RTS_THRESHOLD: RTS Threshold (R/W)
+ * @DOT11_FRAGMENTATION_THRESHOLD: Fragment Threshold (R/W)
+ * @DOT11_PRIVACY_INVOKED: WEP ON/OFF (W)
+ * @DOT11_WEP_DEFAULT_KEY_ID: WEP Index (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE1: WEP Key#1(TKIP AES: PairwiseTemporalKey) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE2: WEP Key#2(TKIP AES: GroupKey1) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE3: WEP Key#3(TKIP AES: GroupKey2) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE4: WEP Key#4 (W)
+ * @DOT11_WEP_LIST: WEP LIST
+ * @DOT11_DESIRED_SSID: SSID
+ * @DOT11_CURRENT_CHANNEL: channel set
+ * @DOT11_OPERATION_RATE_SET: rate set
+ * @LOCAL_AP_SEARCH_INTERVAL: AP search interval (R/W)
+ * @LOCAL_CURRENTADDRESS: MAC Address change (W)
+ * @LOCAL_MULTICAST_ADDRESS: Multicast Address (W)
+ * @LOCAL_MULTICAST_FILTER: Multicast Address Filter ena

[PATCH 05/10] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request

2018-04-27 Thread Sergio Paracuellos
This commit changes parameter types to use enum mib_attribute, enum
mib_data_type and size_t for size instead of unsigned short. It also
reorder them in a more sense way. Code is updated in different
calls to use new parameters order using 'size' auxiliar local variables
in some of them to improve readability a bit.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 144 +++--
 1 file changed, 74 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 5dceadc..9b25221 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1192,10 +1192,10 @@ void hostif_mib_get_request(struct ks_wlan_private 
*priv,
ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
 }
 
-static
-void hostif_mib_set_request(struct ks_wlan_private *priv,
-   unsigned long mib_attribute, unsigned short size,
-   unsigned short type, void *vp)
+static void hostif_mib_set_request(struct ks_wlan_private *priv,
+  enum mib_attribute attr,
+  enum mib_data_type type,
+  void *data, size_t size)
 {
struct hostif_mib_set_request_t *pp;
 
@@ -1206,10 +1206,10 @@ void hostif_mib_set_request(struct ks_wlan_private 
*priv,
if (!pp)
return;
 
-   pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
-   pp->mib_value.size = cpu_to_le16((uint16_t)size);
-   pp->mib_value.type = cpu_to_le16((uint16_t)type);
-   memcpy(&pp->mib_value.body, vp, size);
+   pp->mib_attribute = cpu_to_le32(attr);
+   pp->mib_value.size = cpu_to_le16((u16)size);
+   pp->mib_value.type = cpu_to_le16(type);
+   memcpy(&pp->mib_value.body, data, size);
 
/* send to device request */
ps_confirm_wait_inc(priv);
@@ -1557,44 +1557,44 @@ void hostif_sme_set_wep(struct ks_wlan_private *priv, 
int type)
case SME_WEP_INDEX_REQUEST:
val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-  sizeof(val), MIB_VALUE_TYPE_INT, &val);
+  MIB_VALUE_TYPE_INT, &val, sizeof(val));
break;
case SME_WEP_KEY1_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE1,
-  priv->reg.wep_key[0].size,
   MIB_VALUE_TYPE_OSTRING,
-  &priv->reg.wep_key[0].val[0]);
+  &priv->reg.wep_key[0].val[0],
+  priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE2,
-  priv->reg.wep_key[1].size,
   MIB_VALUE_TYPE_OSTRING,
-  &priv->reg.wep_key[1].val[0]);
+  &priv->reg.wep_key[1].val[0],
+  priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE3,
-  priv->reg.wep_key[2].size,
   MIB_VALUE_TYPE_OSTRING,
-  &priv->reg.wep_key[2].val[0]);
+  &priv->reg.wep_key[2].val[0],
+  priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE4,
-  priv->reg.wep_key[3].size,
   MIB_VALUE_TYPE_OSTRING,
-  &priv->reg.wep_key[3].val[0]);
+  &priv->reg.wep_key[3].val[0],
+  priv->reg.wep_key[3].size);
break;
case SME_WEP_FLAG_REQUEST:
val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
hostif_mib_set_request(pr

[PATCH 04/10] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header

2018-04-27 Thread Sergio Paracuellos
This commit changes some type cast in rate related preprocessor
definitions included in ks_hostif header file to use preferred
u8 type.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index d576341..ca7dc8f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED  5
 
 /* 11b rate */
-#define TX_RATE_1M (uint8_t)(10 / 5)   /* 11b 11g basic rate */
-#define TX_RATE_2M (uint8_t)(20 / 5)   /* 11b 11g basic rate */
-#define TX_RATE_5M (uint8_t)(55 / 5)   /* 11g basic rate */
-#define TX_RATE_11M(uint8_t)(110 / 5)  /* 11g basic rate */
+#define TX_RATE_1M (u8)(10 / 5)/* 11b 11g basic rate */
+#define TX_RATE_2M (u8)(20 / 5)/* 11b 11g basic rate */
+#define TX_RATE_5M (u8)(55 / 5)/* 11g basic rate */
+#define TX_RATE_11M(u8)(110 / 5)   /* 11g basic rate */
 
 /* 11g rate */
-#define TX_RATE_6M (uint8_t)(60 / 5)   /* 11g basic rate */
-#define TX_RATE_12M(uint8_t)(120 / 5)  /* 11g basic rate */
-#define TX_RATE_24M(uint8_t)(240 / 5)  /* 11g basic rate */
-#define TX_RATE_9M (uint8_t)(90 / 5)
-#define TX_RATE_18M(uint8_t)(180 / 5)
-#define TX_RATE_36M(uint8_t)(360 / 5)
-#define TX_RATE_48M(uint8_t)(480 / 5)
-#define TX_RATE_54M(uint8_t)(540 / 5)
+#define TX_RATE_6M (u8)(60 / 5)/* 11g basic rate */
+#define TX_RATE_12M(u8)(120 / 5)   /* 11g basic rate */
+#define TX_RATE_24M(u8)(240 / 5)   /* 11g basic rate */
+#define TX_RATE_9M (u8)(90 / 5)
+#define TX_RATE_18M(u8)(180 / 5)
+#define TX_RATE_36M(u8)(360 / 5)
+#define TX_RATE_48M(u8)(480 / 5)
+#define TX_RATE_54M(u8)(540 / 5)
 
 static inline bool is_11b_rate(u8 rate)
 {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/10] staging: ks7010: use ether_addr_copy in get_current_ap

2018-04-27 Thread Sergio Paracuellos
Instead of use memcpy to copy ethernet addresses use
ether_addr_copy created for that.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index b22dc0c..f8bca54 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -110,7 +110,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
return -EPERM;
}
 
-   memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+   ether_addr_copy(ap->bssid, ap_info->bssid);
memcpy(ap->ssid.body, priv->reg.ssid.body,
   priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/10] staging: ks7010: next cleanups

2018-04-27 Thread Sergio Paracuellos
Cleanups continues with this patch series. Main changes are 
related with MIB where some preprocessor stuff has been change
in favour of an enumeration and some helper functions to increase
code readability has been included. Other changes are minor 
cleanups in different part of code.

Sergio Paracuellos (10):
  staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in
hostif_sme_execute
  staging: ks7010: convert MIB preprocessor defs into an enum
  staging: ks7010: conver MIB attributes preprocessor defs into an enum
  staging: ks7010: change some casts from uint8_t to u8 in ks_hostif
header
  staging: ks7010: change parameter types and reorder them in
hostif_mib_set_request
  staging: ks7010: add new helpers to achieve mib set request and
simplify code
  staging: ks7010: use ether_addr_copy in get_current_ap
  staging: ks7010: move two preprocessor definitions to ks_wlan.h
  staging: ks7010: avoid two long lines in hostif_sme_mode_setup
  staging: ks7010: remove non sense comments in ks_hostif.c source file

 drivers/staging/ks7010/ks_hostif.c   | 320 +--
 drivers/staging/ks7010/ks_hostif.h   | 175 ---
 drivers/staging/ks7010/ks_wlan.h |   3 +
 drivers/staging/ks7010/ks_wlan_net.c |   4 +-
 4 files changed, 275 insertions(+), 227 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/10] staging: ks7010: avoid two long lines in hostif_sme_mode_setup

2018-04-27 Thread Sergio Paracuellos
This commit avoid two checkpatch script complains about
two long lines.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 0054c48..b812011 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1886,9 +1886,11 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
break;
case MODE_INFRASTRUCTURE:
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
-   hostif_infrastructure_set_request(priv, 
HIF_INFRA_SET_REQ);
+   hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET_REQ);
} else {
-   hostif_infrastructure_set_request(priv, 
HIF_INFRA_SET2_REQ);
+   hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET2_REQ);
netdev_dbg(priv->net_dev,
   "Infra bssid = %pM\n", priv->reg.bssid);
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/10] staging: ks7010: move two preprocessor definitions to ks_wlan.h

2018-04-27 Thread Sergio Paracuellos
In ks_wlan_translate_scan function there are two preprocessor
definitions:

- RSN_INFO_ELEM_ID
- GENERIC_INFO_ELEM_ID

These can be moved to common ks_wlan.h because they can be used
in get_current_ap function instead of use hardcoded values.
GENERIC_INFO_ELEM_ID has been renamed to WPA_INFO_ELEM_ID which
is more clear.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c   | 4 ++--
 drivers/staging/ks7010/ks_wlan.h | 3 +++
 drivers/staging/ks7010/ks_wlan_net.c | 4 +---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index f8bca54..0054c48 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -132,12 +132,12 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
ap_info->rsn.size : RSN_IE_BODY_MAX;
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
-   ap->rsn_ie.id = 0x30;
+   ap->rsn_ie.id = RSN_INFO_ELEM_ID;
ap->rsn_ie.size = size;
memcpy(ap->rsn_ie.body, ap_info->rsn.body, size);
} else if ((ap_info->rsn_mode & RSN_MODE_WPA) &&
   (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
-   ap->wpa_ie.id = 0xdd;
+   ap->wpa_ie.id = WPA_INFO_ELEM_ID;
ap->wpa_ie.size = size;
memcpy(ap->wpa_ie.body, ap_info->rsn.body, size);
} else {
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index fb080fe..dd42692 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -190,6 +190,9 @@ struct rsn_ie {
u8 body[RSN_IE_BODY_MAX];
 } __packed;
 
+#define WPA_INFO_ELEM_ID 0xdd
+#define RSN_INFO_ELEM_ID 0x30
+
 #define WPS_IE_BODY_MAX 255
 struct wps_ie {
u8 id;  /* 221 'dd  00 50 F2 04' */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index e964779..838db49 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1268,14 +1268,12 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
if ((current_val - current_ev) > IW_EV_LCP_LEN)
current_ev = current_val;
 
-#define GENERIC_INFO_ELEM_ID 0xdd
-#define RSN_INFO_ELEM_ID 0x30
if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0)
current_ev = ks_wlan_add_leader_event(rsn_leader, end_buf,
  current_ev, &ap->rsn_ie,
  &iwe, info);
 
-   if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0)
+   if (ap->wpa_ie.id == WPA_INFO_ELEM_ID && ap->wpa_ie.size != 0)
current_ev = ks_wlan_add_leader_event(wpa_leader, end_buf,
  current_ev, &ap->wpa_ie,
  &iwe, info);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/10] staging: ks7010: add new helpers to achieve mib set request and simplify code

2018-04-27 Thread Sergio Paracuellos
New three functions have been created to centralice and simplify
calls related with set MIB requests:

- hostif_mib_set_request_int
- hostif_mib_set_request_bool
- hostif_mib_set_request_ostring

Using these in different calls simplify functions related with
this mainly when types are bool and int because no more conversions
are needed in the caller functions. Those conversion details are
now located in the new helpers improving a lot readability. Calls
in hostif_sme_set_wep function has change also some if's to check
invalid value first avoiding one level indentation.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 225 ++---
 1 file changed, 109 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 9b25221..b22dc0c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1216,6 +1216,32 @@ static void hostif_mib_set_request(struct 
ks_wlan_private *priv,
ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
 }
 
+static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
+ enum mib_attribute attr, int val)
+{
+   __le32 v = cpu_to_le32((u32)val);
+   size_t size = sizeof(v);
+
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, &v, size);
+}
+
+static inline void hostif_mib_set_request_bool(struct ks_wlan_private *priv,
+  enum mib_attribute attr,
+  bool val)
+{
+   __le32 v = cpu_to_le32((u32)val);
+   size_t size = sizeof(v);
+
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, &v, size);
+}
+
+static inline void hostif_mib_set_request_ostring(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ void *data, size_t size)
+{
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_OSTRING, data, size);
+}
+
 static
 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
 {
@@ -1548,53 +1574,48 @@ void hostif_receive(struct ks_wlan_private *priv, 
unsigned char *p,
hostif_event_check(priv);
 }
 
-static
-void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
 {
-   __le32 val;
-
switch (type) {
case SME_WEP_INDEX_REQUEST:
-   val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
-   hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-  MIB_VALUE_TYPE_INT, &val, sizeof(val));
+   hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+  priv->reg.wep_index);
break;
case SME_WEP_KEY1_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE1,
-  MIB_VALUE_TYPE_OSTRING,
   &priv->reg.wep_key[0].val[0],
   priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE2,
-  MIB_VALUE_TYPE_OSTRING,
   &priv->reg.wep_key[1].val[0],
   priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE3,
-  MIB_VALUE_TYPE_OSTRING,
   &priv->reg.wep_key[2].val[0],
   priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
  

[PATCH 10/10] staging: ks7010: remove non sense comments in ks_hostif.c source file

2018-04-27 Thread Sergio Paracuellos
Comments which say the same as the code are not useful at all
so just remove them.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index b812011..0ab2e1b 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -467,10 +467,10 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
u16 mib_val_size;
u16 mib_val_type;
 
-   mib_status = get_dword(priv);   /* MIB status */
-   mib_attribute = get_dword(priv);/* MIB atttibute */
-   mib_val_size = get_word(priv);  /* MIB value size */
-   mib_val_type = get_word(priv);  /* MIB value type */
+   mib_status = get_dword(priv);
+   mib_attribute = get_dword(priv);
+   mib_val_size = get_word(priv);
+   mib_val_type = get_word(priv);
 
if (mib_status) {
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
@@ -527,11 +527,11 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
 static
 void hostif_mib_set_confirm(struct ks_wlan_private *priv)
 {
-   u32 mib_status; /* +04 MIB Status */
-   u32 mib_attribute;  /* +08 MIB attribute */
+   u32 mib_status;
+   u32 mib_attribute;
 
-   mib_status = get_dword(priv);   /* MIB Status */
-   mib_attribute = get_dword(priv);/* MIB attribute */
+   mib_status = get_dword(priv);
+   mib_attribute = get_dword(priv);
 
if (mib_status) {
/* in case of error */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc/dpio: Fix the error handling in probe()

2018-04-27 Thread Dan Carpenter
First of all devm_memremap() function returns an error pointer, it
doesn't return NULL.  And second we need to set the error code on these
paths.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
index 9e125769a4e7..11a90a90d827 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -150,14 +150,16 @@ static int dpaa2_dpio_probe(struct fsl_mc_device 
*dpio_dev)
desc.regs_cena = devm_memremap(dev, dpio_dev->regions[1].start,
   resource_size(&dpio_dev->regions[1]),
   MEMREMAP_WC);
-   if (!desc.regs_cena) {
+   if (IS_ERR(desc.regs_cena)) {
dev_err(dev, "devm_memremap failed\n");
+   err = PTR_ERR(desc.regs_cena);
goto err_allocate_irqs;
}
 
desc.regs_cinh = devm_ioremap(dev, dpio_dev->regions[1].start,
  resource_size(&dpio_dev->regions[1]));
if (!desc.regs_cinh) {
+   err = -ENOMEM;
dev_err(dev, "devm_ioremap failed\n");
goto err_allocate_irqs;
}
@@ -175,6 +177,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
priv->io = dpaa2_io_create(&desc);
if (!priv->io) {
dev_err(dev, "dpaa2_io_create failed\n");
+   err = -ENOMEM;
goto err_dpaa2_io_create;
}
 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[GIT PULL] Staging driver fixes for 4.17-rc3

2018-04-27 Thread Greg KH
The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/ 
tags/tty-4.17-rc3

for you to fetch changes up to bcdd0ca8cb8730573afebcaae4138f8f4c8eaa20:

  tty: Use __GFP_NOFAIL for tty_ldisc_get() (2018-04-25 15:03:44 +0200)


TTY/Serial fixes for 4.17-rc3

Here are some tty and serial driver fixes for reported issues for
4.17-rc3.

Nothing major, but a number of small things:
- device tree fixes/updates for serial ports
- earlycon fixes
- n_gsm fixes
- tty core change reverted to help resolve syszkaller reports
- other serial driver small fixes

All of these have been in linux-next with no reported issues.

Signed-off-by: Greg Kroah-Hartman 


Biju Das (1):
  serial: sh-sci: Document r8a77470 bindings

Daniel Kurtz (1):
  earlycon: Use a pointer table to fix __earlycon_table stride

Geert Uytterhoeven (2):
  dt-bindings: meson-uart: DT fix s/clocks-names/clock-names/
  dt-bindings: mvebu-uart: DT fix s/interrupts-names/interrupt-names/

Karthikeyan Ramasubramanian (1):
  tty: serial: qcom_geni_serial: Use signed variable to get IRQ

Marc Zyngier (1):
  serial: mvebu-uart: Fix local flags handling on termios update

Michal Simek (1):
  tty: serial: xuartps: Setup early console when uartclk is also passed

Stefan Agner (2):
  serial: imx: warn user when using unsupported configuration
  serial: imx: fix cached UCR2 read on software reset

Tetsuo Handa (3):
  tty: Avoid possible error pointer dereference at tty_ldisc_restore().
  tty: Don't call panic() at tty_ldisc_init()
  tty: Use __GFP_NOFAIL for tty_ldisc_get()

Tony Lindgren (2):
  tty: n_gsm: Fix long delays with control frame timeouts in ADM mode
  tty: n_gsm: Fix DLCI handling for ADM mode if debug & 2 is not set

 .../bindings/serial/amlogic,meson-uart.txt |  2 +-
 .../devicetree/bindings/serial/mvebu-uart.txt  |  2 +-
 .../bindings/serial/renesas,sci-serial.txt |  2 ++
 drivers/of/fdt.c   |  7 --
 drivers/tty/n_gsm.c| 23 -
 drivers/tty/serial/earlycon.c  |  6 +++--
 drivers/tty/serial/imx.c   | 19 +-
 drivers/tty/serial/mvebu-uart.c|  1 -
 drivers/tty/serial/qcom_geni_serial.c  | 10 +---
 drivers/tty/serial/xilinx_uartps.c |  2 +-
 drivers/tty/tty_io.c   |  5 +++-
 drivers/tty/tty_ldisc.c| 29 ++
 include/asm-generic/vmlinux.lds.h  |  2 +-
 include/linux/serial_core.h| 21 ++--
 include/linux/tty.h|  2 +-
 15 files changed, 93 insertions(+), 40 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [GIT PULL] Staging driver fixes for 4.17-rc3

2018-04-27 Thread Greg KH
On Fri, Apr 27, 2018 at 04:39:54PM +0200, Greg KH wrote:
> The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:
> 
>   Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/ 
> tags/tty-4.17-rc3

Crap, no, this is the tty tree, sorry about that, let me redo this...

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[GIT PULL] Staging driver fixes for 4.17-rc3 - take 2

2018-04-27 Thread Greg KH
Now with the correct message:
--

The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/ 
tags/staging-4.17-rc3

for you to fetch changes up to b00e2fd10429eddf4a181ad30af010e56c2303f9:

  staging: wilc1000: fix NULL pointer exception in 
host_int_parse_assoc_resp_info() (2018-04-23 15:57:38 +0200)


Staging fixes for 4.17-rc3

Here are 2 staging driver fixups for 4.17-rc3.

The first is the remaining stragglers of the irda code removal that you
pointed out during the merge window.  The second is a fix for the
wilc1000 driver due to a patch that got merged in 4.17-rc1.

Both of these have been in linux-next for a while with no reported
issues.

Signed-off-by: Greg Kroah-Hartman 


Ajay Singh (1):
  staging: wilc1000: fix NULL pointer exception in 
host_int_parse_assoc_resp_info()

Greg Kroah-Hartman (1):
  staging: irda: remove remaining remants of irda code removal

 Documentation/ioctl/ioctl-number.txt  |  2 --
 Documentation/networking/ip-sysctl.txt| 15 ---
 Documentation/process/magic-number.rst|  3 ---
 MAINTAINERS   | 10 --
 drivers/staging/wilc1000/host_interface.c |  2 +-
 include/uapi/linux/sysctl.h   | 18 --
 kernel/sysctl_binary.c| 20 +---
 7 files changed, 2 insertions(+), 68 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 5/9] staging: iio: ad2s1200: Add documentation for device tree binding

2018-04-27 Thread Rob Herring
On Mon, Apr 23, 2018 at 12:03:47AM +0200, David Veenstra wrote:
> Add documentation for the added device tree bindings.
> 
> Signed-off-by: David Veenstra 
> ---
> Changes in v3:
>  - Documentation is added to Documentation/devicetree/bindings/iio/resolver
>instead of staging directory.
>  - Add mention to ad2s1205 device.
> 
>  .../devicetree/bindings/iio/resolver/ad2s1200.txt| 16 
> 
>  1 file changed, 16 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt 
> b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> new file mode 100644
> index ..46b51db38368
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> @@ -0,0 +1,16 @@
> +Analog Devices AD2S1200 and AD2S1205 Resolver-to-Digital Converter
> +
> +Required properties:
> + - compatible : should be "adi,ad2s1200" or "adi,ad2s1205"
> + - reg : the SPI chip select number of the device
> + - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200
> + - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200

Are these gpios something that would be common to resolvers (whatever 
that is) or specific to this chip. For the latter, you need vendor 
prefixes.

> +
> +Example:
> +
> + resolver {

Missing unit address.

> + compatible = "adi,ad2s1200";
> + reg = <4>;
> + sample-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
> + rdvel-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
> + };
> -- 
> 2.16.2
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 5/9] staging: iio: ad2s1200: Add documentation for device tree binding

2018-04-27 Thread Rob Herring
On Mon, Apr 23, 2018 at 12:03:47AM +0200, David Veenstra wrote:
> Add documentation for the added device tree bindings.
> 
> Signed-off-by: David Veenstra 
> ---
> Changes in v3:
>  - Documentation is added to Documentation/devicetree/bindings/iio/resolver
>instead of staging directory.

Also, update the subject. This is not part of staging. "dt-bindings: iio: .." 
is the preferred subject prefix.

>  - Add mention to ad2s1205 device.
> 
>  .../devicetree/bindings/iio/resolver/ad2s1200.txt| 16 
> 
>  1 file changed, 16 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt 
> b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> new file mode 100644
> index ..46b51db38368
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
> @@ -0,0 +1,16 @@
> +Analog Devices AD2S1200 and AD2S1205 Resolver-to-Digital Converter
> +
> +Required properties:
> + - compatible : should be "adi,ad2s1200" or "adi,ad2s1205"
> + - reg : the SPI chip select number of the device
> + - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200
> + - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200
> +
> +Example:
> +
> + resolver {
> + compatible = "adi,ad2s1200";
> + reg = <4>;
> + sample-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
> + rdvel-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
> + };
> -- 
> 2.16.2
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [v2, 1/3] staging: fsl-dpaa2/eth: Add support for hardware timestamping

2018-04-27 Thread Greg Kroah-Hartman
On Thu, Apr 26, 2018 at 06:23:47PM +0800, Yangbo Lu wrote:
> From: Ioana Radulescu 
> 
> Hardware timestamping is supported both on Rx and Tx paths.
> On Rx, timestamping is enabled for all frames. On Tx, we
> only instruct the hardware to timestamp the frames marked
> accordingly by the stack.
> 
> Signed-off-by: Ioana Radulescu 
> Signed-off-by: Yangbo Lu 
> ---
> Changes for v2:
>   - Addressed sparse issues.
>   - Used tx_tstamp/rx_tstamp instead of ts_tx_en/ts_rx_en.
>   - Used DPAA2_PTP_CLK_PERIOD_NS instead.

Why are you adding new features to this driver instead of working on
getting it out of the staging directory?  What is remaining left to do
to get it moved out?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 3/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl

2018-04-27 Thread Greg KH
On Tue, Mar 27, 2018 at 02:13:33PM -0400, Roy Pledge wrote:
> Move the NXP DPIO (Datapath I/O Driver) out of the
> drivers/staging directory and into the drivers/soc/fsl directory.
> 
> The DPIO driver enables access to Queue and Buffer Manager (QBMAN)
> hardware on NXP DPAA2 devices. This is a prerequisite to moving the
> DPAA2 Ethernet driver out of staging.
> 
> Signed-off-by: Roy Pledge 

Ah, this needs to go in before the ethernet driver can move out, sorry
about that.

Can you redo these last two patches against my staging-next branch so
that we have a chance that they will apply?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 08/15] media: dt-bindings: add bindings for i.MX7 media driver

2018-04-27 Thread Rob Herring
On Mon, Apr 23, 2018 at 02:47:43PM +0100, Rui Miguel Silva wrote:
> Add bindings documentation for i.MX7 media drivers.
> 
> Signed-off-by: Rui Miguel Silva 
> ---
>  .../devicetree/bindings/media/imx7.txt| 158 ++
>  1 file changed, 158 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/imx7.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/imx7.txt 
> b/Documentation/devicetree/bindings/media/imx7.txt
> new file mode 100644
> index ..7e058ea25102
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/imx7.txt
> @@ -0,0 +1,158 @@
> +Freescale i.MX7 Media Video Device
> +==
> +
> +Video Media Controller node
> +---
> +
> +This is the media controller node for video capture support. It is a
> +virtual device that lists the camera serial interface nodes that the
> +media device will control.
> +
> +Required properties:
> +- compatible : "fsl,imx7-capture-subsystem";
> +- ports  : Should contain a list of phandles pointing to camera
> + sensor interface port of CSI
> +
> +example:
> +
> +capture-subsystem {
> + compatible = "fsl,imx7-capture-subsystem";
> + ports = <&csi>;

Why do you need this node? Just have the driver match on the CSI node.

> +};
> +
> +
> +mipi_csi2 node
> +--
> +
> +This is the device node for the MIPI CSI-2 receiver core in i.MX7 SoC. It is
> +compatible with previous version of Samsung D-phy.

Compatible with Samsung?

> +
> +Required properties:
> +
> +- compatible: "fsl,imx7-mipi-csi2";
> +- reg   : base address and length of the register set for the device;
> +- interrupts: should contain MIPI CSIS interrupt;
> +- clocks: list of clock specifiers, see
> +Documentation/devicetree/bindings/clock/clock-bindings.txt for 
> details;
> +- clock-names   : must contain "mipi" and "phy" entries, matching entries in 
> the
> +  clock property;
> +- power-domains : a phandle to the power domain, see
> +  Documentation/devicetree/bindings/power/power_domain.txt for 
> details.
> +- reset-names   : should include following entry "mrst";
> +- resets: a list of phandle, should contain reset entry of
> +  reset-names;
> +- phy-supply: from the generic phy bindings, a phandle to a regulator 
> that
> +   provides power to VBUS;

VBUS? Copy-n-paste from USB something?

> +- bus-width : maximum number of data lanes supported (SoC specific);

Don't we have a standard lanes property for CSI (or DSI)? bus-width is 
for parallel buses and goes in endpoint nodes. (But maybe it got used 
here too).

> +
> +Optional properties:
> +
> +- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
> + value when this property is not specified is 166 MHz;
> +
> +port node
> +-
> +
> +- reg  : (required) can take the values 0 or 1, where 0 is 
> the
> + related sink port and port 1 should be the source one;
> +
> +endpoint node
> +-
> +
> +- data-lanes: (required) an array specifying active physical MIPI-CSI2
> + data input lanes and their mapping to logical lanes; the
> + array's content is unused, only its length is meaningful;

Ah yes, like this. :) So why do you need bus-width too?

> +
> +- csis-hs-settle : (optional) differential receiver (HS-RX) settle time;

units?

> +- csis-clk-settle : (optional) D-PHY control register;
> +- csis-wclk : CSI-2 wrapper clock selection. If this property is present
> +   external clock from CMU will be used, or the bus clock if
> +   if it's not specified.

boolean?

These 3 need vendor properties.

> +
> +example:
> +
> + mipi_csi: mipi-csi@3075 {
> +clock-frequency = <16600>;
> +status = "okay";
> +#address-cells = <1>;
> +#size-cells = <0>;
> +
> + compatible = "fsl,imx7-mipi-csi2";
> + reg = <0x3075 0x1>;
> + interrupts = ;
> + clocks = <&clks IMX7D_MIPI_CSI_ROOT_CLK>,
> + <&clks IMX7D_MIPI_DPHY_ROOT_CLK>;
> + clock-names = "mipi", "phy";
> + power-domains = <&pgc_mipi_phy>;
> + phy-supply = <®_1p0d>;
> + resets = <&src IMX7_RESET_MIPI_PHY_MRST>;
> + reset-names = "mrst";
> + bus-width = <4>;
> + status = "disabled";
> +
> +port@0 {
> +reg = <0>;
> +
> +mipi_from_sensor: endpoint {
> +remote-endpoint = <&ov2680_to_mipi>;
> +data-lanes = <1>;
> +csis-hs-settle = <3>;
> +csis-clk-settle = <0>;
> +

Re: [PATCH] ion: Consider ion pool pages as indirectly reclaimable

2018-04-27 Thread Laura Abbott

On 04/27/2018 02:29 AM, vji...@codeaurora.org wrote:

On 2018-04-27 10:40, vji...@codeaurora.org wrote:

On 2018-04-25 21:17, Laura Abbott wrote:

On 04/24/2018 08:43 PM, vji...@codeaurora.org wrote:

From: Vijayanand Jitta 

An issue is observed where mallocs are failing due to overcommit failure.
The failure happens when there is high ION page pool since ION page
pool is not considered reclaimable by the overcommit calculation code.
This change considers ion pool pages as indirectly reclaimable and thus
accounted as available memory in the overcommit calculation.

Signed-off-by: Vijayanand Jitta 
---
  drivers/staging/android/ion/ion_page_pool.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/staging/android/ion/ion_page_pool.c 
b/drivers/staging/android/ion/ion_page_pool.c
index db8f614..9bc56eb 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -32,6 +32,9 @@ static void ion_page_pool_add(struct ion_page_pool *pool, 
struct page *page)
  list_add_tail(&page->lru, &pool->low_items);
  pool->low_count++;
  }
+
+    mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+    (1 << (PAGE_SHIFT + pool->order)));
  mutex_unlock(&pool->mutex);
  }
  @@ -50,6 +53,8 @@ static struct page *ion_page_pool_remove(struct 
ion_page_pool *pool, bool high)
  }
    list_del(&page->lru);
+    mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+    -(1 << (PAGE_SHIFT + pool->order)));
  return page;
  }



I'm sure this fixes the problem but I don't think we want to
start throwing page adjustments into Ion. Why isn't this
memory already considered reclaimable by existing calculations?

Thanks,
Laura


You can refer to discussion here https://lkml.org/lkml/2018/3/5/361 introducing
NR_INDIRECTLY_RECLAIMABLE_BYTES for the memory which is not currently considered
as reclaimable

Thanks,
Vijay


There was also discussion specific to ion in that thread you can find it here
https://lkml.org/lkml/2018/4/25/642

Thanks,
Vijay


Thanks for pointing that thread out. I'm still a little wary since
Ion is in staging but if the rest of mm are okay with it

Acked-by: Laura Abbott 

Thanks,
Laura

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3] staging: wlan-ng: prism2sta: fixed indent coding style issues.

2018-04-27 Thread Efstratios Gavas
Fixed format/style issues found with checkpatch. No code changes.
Corrected alignment of variables after open parenthesis and line breaks.
Checkpatch now returns clean except for line over 80 char warnings.

Signed-off-by: Efstratios Gavas 
---
v2(unlabled): changed title info
v3: improved changlog description
---
 drivers/staging/wlan-ng/prism2sta.c | 52 +
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index fed0b8ceca6f..914970249680 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -764,16 +764,16 @@ static int prism2sta_getcardinfo(struct wlandevice 
*wlandev)
 
if (hw->cap_sup_sta.id == 0x04) {
netdev_info(wlandev->netdev,
-  "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
-  hw->cap_sup_sta.role, hw->cap_sup_sta.id,
-  hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
-  hw->cap_sup_sta.top);
+   
"STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
+   hw->cap_sup_sta.role, hw->cap_sup_sta.id,
+   hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
+   hw->cap_sup_sta.top);
} else {
netdev_info(wlandev->netdev,
-  "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
-  hw->cap_sup_sta.role, hw->cap_sup_sta.id,
-  hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
-  hw->cap_sup_sta.top);
+   
"AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
+   hw->cap_sup_sta.role, hw->cap_sup_sta.id,
+   hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
+   hw->cap_sup_sta.top);
}
 
/* Compatibility range, primary f/w actor, CFI supplier */
@@ -1189,7 +1189,6 @@ void prism2sta_processing_defer(struct work_struct *data)
inf = (struct hfa384x_inf_frame *)skb->data;
prism2sta_inf_authreq_defer(wlandev, inf);
}
-
}
 
/* Now let's handle the linkstatus stuff */
@@ -1241,9 +1240,9 @@ void prism2sta_processing_defer(struct work_struct *data)
/* Collect the BSSID, and set state to allow tx */
 
result = hfa384x_drvr_getconfig(hw,
-   HFA384x_RID_CURRENTBSSID,
-   wlandev->bssid,
-   WLAN_BSSID_LEN);
+   
HFA384x_RID_CURRENTBSSID,
+   wlandev->bssid,
+   WLAN_BSSID_LEN);
if (result) {
pr_debug
("getconfig(0x%02x) failed, result = %d\n",
@@ -1260,14 +1259,13 @@ void prism2sta_processing_defer(struct work_struct 
*data)
 HFA384x_RID_CURRENTSSID, result);
return;
}
-   prism2mgmt_bytestr2pstr(
-   (struct hfa384x_bytestr *)&ssid,
-   (struct p80211pstrd *)&wlandev->ssid);
+   prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
+   (struct p80211pstrd 
*)&wlandev->ssid);
 
/* Collect the port status */
result = hfa384x_drvr_getconfig16(hw,
-   HFA384x_RID_PORTSTATUS,
-   &portstatus);
+ 
HFA384x_RID_PORTSTATUS,
+ &portstatus);
if (result) {
pr_debug
("getconfig(0x%02x) failed, result = %d\n",
@@ -1404,7 +1402,7 @@ void prism2sta_processing_defer(struct work_struct *data)
   &joinreq,
   HFA384x_RID_JOINREQUEST_LEN);
netdev_info(wlandev->netdev,
-  "linkstatus=ASSOCFAIL (re-submitting join)\n");
+   "linkstatus=ASSOCFAIL (re-submitting 
join)\n");
} else {
netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL 
(unhandled)\n");
}
@@ -1501,7 +1499,7 @@ static void prism2sta_inf_assocstatus(struct wlandevice 
*wlandev,
  

[PATCH] staging: luster: llite: fix a potential missing-check bug when copying lumv

2018-04-27 Thread Wenwen Wang
In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space
using Its address, i.e., lumv1 = &lumv3. If the lmm_magic field of lumv3 is
LOV_USER_MAGIV_V3, lumv3 will be modified by the second copy from the user
space. The second copy is necessary, because the two versions (i.e.,
lov_user_md_v1 and lov_user_md_v3) have different data formats and lengths.
However, given that the user data resides in the user space, a malicious
user-space process can race to change the data between the two copies. By
doing so, the attacker can provide a data with an inconsistent version,
e.g., v1 version + v3 data. This can lead to logical errors in the
following execution in ll_dir_setstripe(), which performs different actions
according to the version specified by the field lmm_magic.

This patch rechecks the version field lmm_magic in the second copy.  If the
version is not as expected, i.e., LOV_USER_MAGIC_V3, an error code will be
returned: -EINVAL.

Signed-off-by: Wenwen Wang 
---
 drivers/staging/lustre/lustre/llite/dir.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index d10d272..80d44ca 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1185,6 +1185,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3)))
return -EFAULT;
+   if (lumv3.lmm_magic != LOV_USER_MAGIC_V3)
+   return -EINVAL;
}
 
if (is_root_inode(inode))
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread arvindY



On Friday 27 April 2018 06:32 PM, Alex Elder wrote:

On 04/27/2018 07:50 AM, Arvind Yadav wrote:


On Friday 27 April 2018 05:47 PM, Alex Elder wrote:

On 04/27/2018 05:52 AM, Arvind Yadav wrote:

Replace the manual validity checks for the GPIO with the
gpio_is_valid().

I haven't looked through the code paths very closely, but I
think that get_named_gpio() might return -EPROBE_DEFER, which
would be something we want to pass to the caller.

Yes of_get_name_gpio() can return other error value apart from
-EPROBE_DEFER.

So rather than returning -ENODEV and hiding the reason the
call to of_get_named_gpio() failed, you should continue
returning the errno it supplies (if not a valid gpio number).

 -Alex

I have return -ENODEV because invalid gpio pin can be positive.
static inline bool gpio_is_valid(int number)
{
 return number >= 0 && number < ARCH_NR_GPIOS;
}
Here if number > ARCH_NR_GPIOS then it's invalid but return value
will be positive.

Your reasoning is good.  However in all three of these cases,
the GPIO number you're checking is the value returned from
of_get_named_gpio().  The return value is a "GPIO number to
use with Linux generic GPIO API, or one of the errno value."

So unless the API of of_get_named_gpio() changes, you can be
sure that if the value returned is invalid, it is a negative
errno.  (And if the API did change, the person making that
change would be responsible for fixing all callers to ensure
the change didn't break them.)

This distinction may be why the code you're changing was only
testing for negative, rather than using gpio_is_valid() (you'll
see it's used elsewhere in the Greybus code--even in the same
source files.)

Anyway, changing the code to use gpio_is_valid() is fine.  But
you should avoid obscuring the reason for the error that the
return value from of_get_named_gpio() provides.

-Alex


Yes, It'll be fine to return a invalid gpio as error instead of
-ENODEV. I will send an updated patch.

~arvind



We can return like this
 " return (gpio > 0) ? -ENODEV: gpio;"

But not sure this is worth to handle this.

~arvind

Signed-off-by: Arvind Yadav 
---
   drivers/staging/greybus/arche-platform.c | 12 ++--
   1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 83254a7..fc6bf60 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,9 +448,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
   arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
   "svc,reset-gpio",
   0);
-if (arche_pdata->svc_reset_gpio < 0) {
+if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
   dev_err(dev, "failed to get reset-gpio\n");
-return arche_pdata->svc_reset_gpio;
+return -ENODEV;
   }
   ret = devm_gpio_request(dev, arche_pdata->svc_reset_gpio, "svc-reset");
   if (ret) {
@@ -468,9 +468,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
   arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
 "svc,sysboot-gpio",
 0);
-if (arche_pdata->svc_sysboot_gpio < 0) {
+if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
   dev_err(dev, "failed to get sysboot gpio\n");
-return arche_pdata->svc_sysboot_gpio;
+return -ENODEV;
   }
   ret = devm_gpio_request(dev, arche_pdata->svc_sysboot_gpio, "sysboot0");
   if (ret) {
@@ -487,9 +487,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
   arche_pdata->svc_refclk_req = of_get_named_gpio(np,
   "svc,refclk-req-gpio",
   0);
-if (arche_pdata->svc_refclk_req < 0) {
+if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
   dev_err(dev, "failed to get svc clock-req gpio\n");
-return arche_pdata->svc_refclk_req;
+return -ENODEV;
   }
   ret = devm_gpio_request(dev, arche_pdata->svc_refclk_req,
   "svc-clk-req");



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: greybus: Use gpio_is_valid()

2018-04-27 Thread Arvind Yadav
Replace the manual validity checks for the GPIO with the
gpio_is_valid().

Signed-off-by: Arvind Yadav 
---
chnage in v2 :
 Returning invalid gpio as error instead of -ENODEV.

 drivers/staging/greybus/arche-platform.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 83254a7..c3a7da5 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
"svc,reset-gpio",
0);
-   if (arche_pdata->svc_reset_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
dev_err(dev, "failed to get reset-gpio\n");
return arche_pdata->svc_reset_gpio;
}
@@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
  "svc,sysboot-gpio",
  0);
-   if (arche_pdata->svc_sysboot_gpio < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
dev_err(dev, "failed to get sysboot gpio\n");
return arche_pdata->svc_sysboot_gpio;
}
@@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device 
*pdev)
arche_pdata->svc_refclk_req = of_get_named_gpio(np,
"svc,refclk-req-gpio",
0);
-   if (arche_pdata->svc_refclk_req < 0) {
+   if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
dev_err(dev, "failed to get svc clock-req gpio\n");
return arche_pdata->svc_refclk_req;
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv3] staging: wlan-ng: prism2sta: fixed indent coding style issues.

2018-04-27 Thread Greg Kroah-Hartman
On Fri, Apr 27, 2018 at 09:33:34PM +, Efstratios Gavas wrote:
> Fixed format/style issues found with checkpatch. No code changes.
> Corrected alignment of variables after open parenthesis and line breaks.
> Checkpatch now returns clean except for line over 80 char warnings.
> 
> Signed-off-by: Efstratios Gavas 
> ---
> v2(unlabled): changed title info
> v3: improved changlog description
> ---
>  drivers/staging/wlan-ng/prism2sta.c | 52 
> +
>  1 file changed, 24 insertions(+), 28 deletions(-)

Why was this sent twice?  Which one should I take?

I'm dropping both, please only send 1 patch next time.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel