Re: [PATCH v3 3/8] staging: rtl8192u: User memset to initialize memory, instead of loop.

2018-06-25 Thread Andy Shevchenko
On Sun, Jun 24, 2018 at 6:34 PM, John Whitmore  wrote:
> Replaced memory initialising loop with memset, as suggested by Andy Shevchenko
>

Suggested-by ?

> Signed-off-by: John Whitmore 
> ---
>  drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c 
> b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> index 4bfadb49c363..ccb7bdf5ad5d 100644
> --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
> @@ -742,8 +742,6 @@ void HTConstructRT2RTAggElement(struct ieee80211_device 
> *ieee, u8 *posRT2RTAgg,
>   */
>  static u8 HT_PickMCSRate(struct ieee80211_device *ieee, u8 *pOperateMCS)
>  {
> -   u8  i;
> -
> if (!pOperateMCS) {
> IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null 
> in HT_PickMCSRate()\n");
> return false;
> @@ -756,8 +754,7 @@ static u8 HT_PickMCSRate(struct ieee80211_device *ieee, 
> u8 *pOperateMCS)
> //legacy rate routine handled at selectedrate
>
> //no MCS rate
> -   for (i = 0; i <= 15; i++)
> -   pOperateMCS[i] = 0;
> +   memset(pOperateMCS, 0, 16);
> break;
>
> case IEEE_N_24G://assume CCK rate ok
> --
> 2.17.1
>



-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: fix brace coding style issues

2018-06-25 Thread Andy Shevchenko
On Fri, Jun 22, 2018 at 1:28 PM, Dan Carpenter  wrote:
> On Thu, Jun 21, 2018 at 08:21:55PM +0200, Michael Straube wrote:
>> Remove braces from single line if statements.
>> Also fix a comparsion to NULL in one of the conditions.
>> Issues found by checkpatch.
>>
>> Signed-off-by: Michael Straube 
>> ---
>>  drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c 
>> b/drivers/staging/rtl8723bs/core/rtw_debug.c
>> index f852fde47350..2244ed72ab9c 100644
>> --- a/drivers/staging/rtl8723bs/core/rtw_debug.c
>> +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
>> @@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, const 
>> char __user *buffer, si
>>   if (count < 1)
>>   return -EFAULT;
>>
>> - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
>> + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp)))
>>   sscanf(tmp, "%u", &g_wait_hiq_empty);
>> - }
>
>
> The original code is kind of bad.  The NULL check isn't required.
> The sscanf call should have error checking.  The error code is wrong if
> the copy from user fails.  The tmp buffer isn't NUL terminated.
>
> if (copy_from_user(tmp, buffer, sizeof(tmp)))
> return -EFAULT;
> tmp[sizeof(tmp) - 1] = '\0';
>
> if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1)
> return -EINVAL;
>
> return count;

Shouldn't this be

kstrtouint_from_user()

instead of all those lines?

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: do not use assignment in if condition

2018-06-25 Thread Andy Shevchenko
On Fri, Jun 22, 2018 at 8:28 PM, Joe Perches  wrote:
> On Fri, 2018-06-22 at 14:48 +0200, Michael Straube wrote:
>> On 06/22/18 12:57, Dan Carpenter wrote:

> Output from checkpatch is not gospel and can be ignored
> whenever appropriate.
>
> I think the below is ok:
>
> if ((is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) &&
> ((addr = of_get_property(np, "local-mac-address", &len)) &&
>  len == ETH_ALEN))
> memcpy(mac_addr, addr, ETH_ALEN);
> else
> memcpy(mac_addr, ""\x00\xe0\x4c\x87\x00\x00", ETH_ALEN);
>
> Although the last memcpy of a fixed mac address could
> probably use eth_random_addr to reduce the likelihood
> of mac address collision

...and first one looks like ether_addr_copy().

> so maybe
>
> if ((is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) &&
> ((addr = of_get_property(np, "local-mac-address", &len)) &&
>
>  len == ETH_ALEN))
> memcpy(mac_addr, addr, ETH_ALEN);
> else
> eth_random_addr(mac_addr);
>
>> If yes, I'm not sure how to proceed as these are the very first patches I 
>> send.
>> Should I send a v2 patch with both changes or just a v2 with "np" removed and
>> another one for adding 'is_broadcast_ether_addr' and 'is_zero_ether_addr' 
>> checks?



-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: refactor rtw_macaddr_cfg()

2018-06-25 Thread Andy Shevchenko
On Sat, Jun 23, 2018 at 12:45 PM, Michael Straube
 wrote:
> Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
> testing each byte of the mac[] array for 0xff and 0x00 shortens the
> code and improves readability.
>
> If np == NULL, of_get_property() returns NULL, hence the "np" check
> is not needed.
>
> Instead of a fixed default mac address use a random one to reduce the
> likelihood of mac address collision.
>
> Thanks to Joe Perches and Dan Carpenter.

> +   if ((addr = of_get_property(np, "local-mac-address", &len)) &&
> len == ETH_ALEN) {
> memcpy(mac_addr, addr, ETH_ALEN);

ether_addr_copy()?

> } else {

> +   eth_random_addr(mac_addr);
> +   DBG_871X("MAC Address from efuse error, assign random 
> one !!!\n");
> }

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3] staging: pi433: replace simple switch statements

2018-06-25 Thread marcus . wolf
Reviewed-by: Marcus Wolf 

Thank you Valentin, very nice patch :-)

Valentin Vidic schrieb am 24.06.2018 18:31:

Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
v2: use correct type for const arrays
v3: add missing static keyword for af_map

 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..341d6901a801 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const u8 mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the
FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) &
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const u8 modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, u8
power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_

Re: [PATCH v3 7/8] staging: rtl8192u: Correct if statement - Coding Style

2018-06-25 Thread John Whitmore
On Sun, Jun 24, 2018 at 08:59:22AM -0700, Joe Perches wrote:
> Rather than doing individual patches for each line
> with a whitespace issue, I think it'd be better to
> do a single driver wide patch.
> 
> Perhaps use a tool like:
> 
> $ git ls-files drivers/staging/rtl8192u |
>   xargs ./scripts/checkpatch.pl -f --fix-inplace --types=spacing
> 
> where:
> 
> $ git diff -w drivers/staging/rtl8192u/
> 
> should not show a single difference.
> 
> Then compile and commit that as a single patch with
> something like "use a more typical spacing style"
> as the commit message.
> 

Thank you for that command. Hadn't found the "--types=spacing" option.

I'd fixed all the spacing issues in that file in a previous patch set. That
space issue was in a commented out section of code, which is why I missed it
previously. I think that file has all space issues cleared so there's only the
single fix in this patch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: pi433: add SPDX-License-Identifier tag

2018-06-25 Thread Valentin Vidic
Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c   | 1 +
 drivers/staging/pi433/pi433_if.h   | 3 ++-
 drivers/staging/pi433/rf69.c   | 1 +
 drivers/staging/pi433/rf69.h   | 3 ++-
 drivers/staging/pi433/rf69_enum.h  | 3 ++-
 drivers/staging/pi433/rf69_registers.h | 3 ++-
 6 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b061f77dda41..e2b8a518dafe 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * userspace interface for pi433 radio module
  *
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index b6e214c29ddf..0e0c1b0ab1a6 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * include/linux/TODO
  *
  * userspace interface for pi433 radio module
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..e4a1e64c868a 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * abstraction of the spi interface of HopeRf rf69 radio module
  *
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..2cec9a9c34d2 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * hardware abstraction/register access for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 493bd0025453..de3b7e32dad7 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * enumerations for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_registers.h 
b/drivers/staging/pi433/rf69_registers.h
index 33fd91518bb0..ea19c1ca7509 100644
--- a/drivers/staging/pi433/rf69_registers.h
+++ b/drivers/staging/pi433/rf69_registers.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * register description for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
-- 
2.18.0.rc2

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


[PATCH] staging: pi433: cleanup comments in rf69.h

2018-06-25 Thread Valentin Vidic
Fixes checkpatch warning:

  WARNING: line over 80 characters

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..d80c41966d39 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -20,10 +20,11 @@
 #include "rf69_enum.h"
 #include "rf69_registers.h"
 
-#define F_OSC  3200  /* in Hz */
-#define FREQUENCY  43392 /* in Hz, modifying this value impacts CE 
certification */
-#define FIFO_SIZE  66  /* in byte */
-#define FIFO_THRESHOLD 15  /* in byte */
+/* NOTE: Modifying FREQUENCY value impacts CE certification */
+#define F_OSC  3200/* Hz */
+#define FREQUENCY  43392   /* Hz */
+#define FIFO_SIZE  66  /* bytes */
+#define FIFO_THRESHOLD 15  /* bytes */
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
-- 
2.18.0.rc2

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


Re: [PATCH] staging: rtl8723bs: fix brace coding style issues

2018-06-25 Thread Dan Carpenter
On Mon, Jun 25, 2018 at 12:47:44PM +0300, Andy Shevchenko wrote:
> On Fri, Jun 22, 2018 at 1:28 PM, Dan Carpenter  
> wrote:
> > On Thu, Jun 21, 2018 at 08:21:55PM +0200, Michael Straube wrote:
> >> Remove braces from single line if statements.
> >> Also fix a comparsion to NULL in one of the conditions.
> >> Issues found by checkpatch.
> >>
> >> Signed-off-by: Michael Straube 
> >> ---
> >>  drivers/staging/rtl8723bs/core/rtw_debug.c | 6 ++
> >>  1 file changed, 2 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c 
> >> b/drivers/staging/rtl8723bs/core/rtw_debug.c
> >> index f852fde47350..2244ed72ab9c 100644
> >> --- a/drivers/staging/rtl8723bs/core/rtw_debug.c
> >> +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
> >> @@ -618,9 +618,8 @@ ssize_t proc_set_wait_hiq_empty(struct file *file, 
> >> const char __user *buffer, si
> >>   if (count < 1)
> >>   return -EFAULT;
> >>
> >> - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
> >> + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp)))
> >>   sscanf(tmp, "%u", &g_wait_hiq_empty);
> >> - }
> >
> >
> > The original code is kind of bad.  The NULL check isn't required.
> > The sscanf call should have error checking.  The error code is wrong if
> > the copy from user fails.  The tmp buffer isn't NUL terminated.
> >
> > if (copy_from_user(tmp, buffer, sizeof(tmp)))
> > return -EFAULT;
> > tmp[sizeof(tmp) - 1] = '\0';
> >
> > if (sscanf(tmp, "%u", &g_wait_hiq_empty) != 1)
> > return -EINVAL;
> >
> > return count;
> 
> Shouldn't this be
> 
> kstrtouint_from_user()
> 
> instead of all those lines?

I wasn't sure kstrtoint() was the exact same as sscanf()...  If so then
sure.

regards,
dan carpenter

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


Re: [PATCH v3 3/8] staging: rtl8192u: User memset to initialize memory, instead of loop.

2018-06-25 Thread John Whitmore
On Mon, Jun 25, 2018 at 12:06:30PM +0300, Andy Shevchenko wrote:
> On Sun, Jun 24, 2018 at 6:34 PM, John Whitmore  
> wrote:
> > Replaced memory initialising loop with memset, as suggested by Andy 
> > Shevchenko
> >
> 
> Suggested-by ?
>

Em, not sure how to respond, it certainly wasn't my idea. I was just making
coding style changes, badly. ;)

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


Re: [PATCH v3] staging: pi433: replace simple switch statements

2018-06-25 Thread Dan Carpenter
I'd still prefer if we just removed this abstraction entirely and used
OPMODE_MODE_TRANSMIT everywhere instead of bringing "transmit" into it.

I know that every author thinks their abstraction will definitely be
useful in the future, but generally kernel style is to remove
abstractions.

But I guess this code is an improvement over the original so the patch
is fine.

regards,
dan carpenter

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


Re: [PATCH v3 3/8] staging: rtl8192u: User memset to initialize memory, instead of loop.

2018-06-25 Thread Justin Skists


> On 25 June 2018 at 13:36 John Whitmore  wrote:
> 
> 
> On Mon, Jun 25, 2018 at 12:06:30PM +0300, Andy Shevchenko wrote:
> > On Sun, Jun 24, 2018 at 6:34 PM, John Whitmore  
> > wrote:
> > > Replaced memory initialising loop with memset, as suggested by Andy 
> > > Shevchenko
> > >
> > 
> > Suggested-by ?
> >
> 
> Em, not sure how to respond, it certainly wasn't my idea. I was just making
> coding style changes, badly. ;)

Suggested-by is a tag for patches, to give credit. For example:

https://elixir.bootlin.com/linux/v4.18-rc1/source/Documentation/process/submitting-patches.rst

See section "13) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: 
and Fixes:"

Hope that helps,
Justin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: media: omap4iss: Added SPDX license identifiers

2018-06-25 Thread Daniel Graefe
Added missing SPDX license identifiers to all files of the omap4iss
driver.

Most files already have license texts which clearly state them to be
licensed under GPL 2.0 or later. SPDX identifiers were added accordingly.

Some files do not have any license text. SPDX identifiers for GPL 2.0
were added to them, in accordance with the default license of the
kernel.

Signed-off-by: Daniel Graefe 
Signed-off-by: Roman Sommer 
---
 drivers/staging/media/omap4iss/Kconfig   | 2 ++
 drivers/staging/media/omap4iss/Makefile  | 3 +++
 drivers/staging/media/omap4iss/iss.c | 1 +
 drivers/staging/media/omap4iss/iss.h | 1 +
 drivers/staging/media/omap4iss/iss_csi2.c| 1 +
 drivers/staging/media/omap4iss/iss_csi2.h| 1 +
 drivers/staging/media/omap4iss/iss_csiphy.c  | 1 +
 drivers/staging/media/omap4iss/iss_csiphy.h  | 1 +
 drivers/staging/media/omap4iss/iss_ipipe.c   | 1 +
 drivers/staging/media/omap4iss/iss_ipipe.h   | 1 +
 drivers/staging/media/omap4iss/iss_ipipeif.c | 1 +
 drivers/staging/media/omap4iss/iss_ipipeif.h | 1 +
 drivers/staging/media/omap4iss/iss_regs.h| 1 +
 drivers/staging/media/omap4iss/iss_resizer.c | 1 +
 drivers/staging/media/omap4iss/iss_resizer.h | 1 +
 drivers/staging/media/omap4iss/iss_video.c   | 1 +
 drivers/staging/media/omap4iss/iss_video.h   | 1 +
 17 files changed, 20 insertions(+)

diff --git a/drivers/staging/media/omap4iss/Kconfig 
b/drivers/staging/media/omap4iss/Kconfig
index 273..841cc0b 100644
--- a/drivers/staging/media/omap4iss/Kconfig
+++ b/drivers/staging/media/omap4iss/Kconfig
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
 config VIDEO_OMAP4
tristate "OMAP 4 Camera support"
depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C
diff --git a/drivers/staging/media/omap4iss/Makefile 
b/drivers/staging/media/omap4iss/Makefile
index a716ce9..e64d489 100644
--- a/drivers/staging/media/omap4iss/Makefile
+++ b/drivers/staging/media/omap4iss/Makefile
@@ -1,4 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+#
 # Makefile for OMAP4 ISS driver
+#
 
 omap4-iss-objs += \
iss.o iss_csi2.o iss_csiphy.o iss_ipipeif.o iss_ipipe.o iss_resizer.o 
iss_video.o
diff --git a/drivers/staging/media/omap4iss/iss.c 
b/drivers/staging/media/omap4iss/iss.c
index b1036ba..0c41939 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * TI OMAP4 ISS V4L2 Driver
  *
diff --git a/drivers/staging/media/omap4iss/iss.h 
b/drivers/staging/media/omap4iss/iss.h
index 760ee27..b16a5c0 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * TI OMAP4 ISS V4L2 Driver
  *
diff --git a/drivers/staging/media/omap4iss/iss_csi2.c 
b/drivers/staging/media/omap4iss/iss_csi2.c
index f6acc54..cdfd12f 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * TI OMAP4 ISS V4L2 Driver - CSI PHY module
  *
diff --git a/drivers/staging/media/omap4iss/iss_csi2.h 
b/drivers/staging/media/omap4iss/iss_csi2.h
index 24ab378..cee02ee 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.h
+++ b/drivers/staging/media/omap4iss/iss_csi2.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * TI OMAP4 ISS V4L2 Driver - CSI2 module
  *
diff --git a/drivers/staging/media/omap4iss/iss_csiphy.c 
b/drivers/staging/media/omap4iss/iss_csiphy.c
index 748607f..253b6aa 100644
--- a/drivers/staging/media/omap4iss/iss_csiphy.c
+++ b/drivers/staging/media/omap4iss/iss_csiphy.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * TI OMAP4 ISS V4L2 Driver - CSI PHY module
  *
diff --git a/drivers/staging/media/omap4iss/iss_csiphy.h 
b/drivers/staging/media/omap4iss/iss_csiphy.h
index a0f2d97..f264c51 100644
--- a/drivers/staging/media/omap4iss/iss_csiphy.h
+++ b/drivers/staging/media/omap4iss/iss_csiphy.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * TI OMAP4 ISS V4L2 Driver - CSI PHY module
  *
diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c 
b/drivers/staging/media/omap4iss/iss_ipipe.c
index d86ef8a..9f90641 100644
--- a/drivers/staging/media/omap4iss/iss_ipipe.c
+++ b/drivers/staging/media/omap4iss/iss_ipipe.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * TI OMAP4 ISS V4L2 Driver - ISP IPIPE module
  *
diff --git a/drivers/staging/media/omap4iss/iss_ipipe.h 
b/drivers/staging/media/omap4iss/iss_ipipe.h
index d5b441d..54718f0 100644
--- a/drivers/staging/media/omap4iss/iss_ipipe.h
+++ b/drivers/staging/media/omap4iss/iss_ipipe.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * TI OMAP4 ISS V4L2 Driver - ISP IPIPE module
  *
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c 
b/drivers/staging/media/omap4iss/iss_ipipeif.c
index cb88b2b..6cc9a43 1006

Re: [PATCH v3] staging: pi433: replace simple switch statements

2018-06-25 Thread marcus . wolf
Hi Dan,

I'd like to mention once more, that the idea of the abstraction was to 
support multiple modules of Hope-RF.
If the decision of the "team" of developer of this driver is, that it 
should be reduced to a Pi433 or RFM69CW driver only, I fully agree, 
that the abstraction layer isn't necessary (tough improving readability).

But if the "team" wants to extend the driver - here I explicitly want to 
Name Marcin Ciupak and Hogo Lefeuvre, both were discussing this with me - 
I highly recommend to keep the abstraction layer.

And once again, I have to announce, that - if noone appears, who wants to 
help me with selling Pi433 - I can't effort to let Pi433 on the market 
longer then end of this year. From this Point of view on long term it 
might be senseless to prepare a Pi433-only driver.

Cheers,
Marcus

Dan Carpenter schrieb am 25.06.2018 14:35:
> I'd still prefer if we just removed this abstraction entirely and used
> OPMODE_MODE_TRANSMIT everywhere instead of bringing "transmit" into it.
> 
> I know that every author thinks their abstraction will definitely be
> useful in the future, but generally kernel style is to remove
> abstractions.
> 
> But I guess this code is an improvement over the original so the patch
> is fine.
> 
> regards,
> dan carpenter
> 
>

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


Re: [PATCH v3] staging: pi433: replace simple switch statements

2018-06-25 Thread Dan Carpenter
If there are going to be actual users in the specific near term then
that's fine.  Otherwise if we're talking a year out, then it's too far
away to predict what will happen a year from now so we should delete
the dead weight.

regards,
dan carpenter

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


Re: [PATCH] staging: media: omap4iss: Added SPDX license identifiers

2018-06-25 Thread Laurent Pinchart
Hi Daniel,

Thank you for the patch.

On Monday, 25 June 2018 16:21:32 EEST Daniel Graefe wrote:
> Added missing SPDX license identifiers to all files of the omap4iss
> driver.
> 
> Most files already have license texts which clearly state them to be
> licensed under GPL 2.0 or later. SPDX identifiers were added accordingly.
> 
> Some files do not have any license text. SPDX identifiers for GPL 2.0
> were added to them, in accordance with the default license of the
> kernel.
> 
> Signed-off-by: Daniel Graefe 
> Signed-off-by: Roman Sommer 
> ---
>  drivers/staging/media/omap4iss/Kconfig   | 2 ++
>  drivers/staging/media/omap4iss/Makefile  | 3 +++
>  drivers/staging/media/omap4iss/iss.c | 1 +
>  drivers/staging/media/omap4iss/iss.h | 1 +
>  drivers/staging/media/omap4iss/iss_csi2.c| 1 +
>  drivers/staging/media/omap4iss/iss_csi2.h| 1 +
>  drivers/staging/media/omap4iss/iss_csiphy.c  | 1 +
>  drivers/staging/media/omap4iss/iss_csiphy.h  | 1 +
>  drivers/staging/media/omap4iss/iss_ipipe.c   | 1 +
>  drivers/staging/media/omap4iss/iss_ipipe.h   | 1 +
>  drivers/staging/media/omap4iss/iss_ipipeif.c | 1 +
>  drivers/staging/media/omap4iss/iss_ipipeif.h | 1 +
>  drivers/staging/media/omap4iss/iss_regs.h| 1 +
>  drivers/staging/media/omap4iss/iss_resizer.c | 1 +
>  drivers/staging/media/omap4iss/iss_resizer.h | 1 +
>  drivers/staging/media/omap4iss/iss_video.c   | 1 +
>  drivers/staging/media/omap4iss/iss_video.h   | 1 +
>  17 files changed, 20 insertions(+)
> 
> diff --git a/drivers/staging/media/omap4iss/Kconfig
> b/drivers/staging/media/omap4iss/Kconfig index 273..841cc0b 100644
> --- a/drivers/staging/media/omap4iss/Kconfig
> +++ b/drivers/staging/media/omap4iss/Kconfig
> @@ -1,3 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
>  config VIDEO_OMAP4
>   tristate "OMAP 4 Camera support"
>   depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C
> diff --git a/drivers/staging/media/omap4iss/Makefile
> b/drivers/staging/media/omap4iss/Makefile index a716ce9..e64d489 100644
> --- a/drivers/staging/media/omap4iss/Makefile
> +++ b/drivers/staging/media/omap4iss/Makefile
> @@ -1,4 +1,7 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
>  # Makefile for OMAP4 ISS driver
> +#
> 
>  omap4-iss-objs += \
>   iss.o iss_csi2.o iss_csiphy.o iss_ipipeif.o iss_ipipe.o iss_resizer.o
> iss_video.o diff --git a/drivers/staging/media/omap4iss/iss.c
> b/drivers/staging/media/omap4iss/iss.c index b1036ba..0c41939 100644
> --- a/drivers/staging/media/omap4iss/iss.c
> +++ b/drivers/staging/media/omap4iss/iss.c
> @@ -1,3 +1,4 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later

The SPDX identifier used for "GPL v2.0 or later" in the kernel is GPL-2.0+, as 
documented in Documentation/process/license-rules.rst. I'm aware that that 
identifier has been deprecated by the FSF in favour of the GPL-2.0-or-later 
identifier, but until Documentation/process/license-rules.rst gets updated, 
please use GPL-2.0+.

>  /*
>   * TI OMAP4 ISS V4L2 Driver
>   *

Could you please remove the boilerplate license text, as it's not needed 
anymore ?

Those two comments apply to all the other files.

[snip$

-- 
Regards,

Laurent Pinchart



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


[PATCH v2] staging: rtl8723bs: remove rtw_set_tx_chksum_offload()

2018-06-25 Thread Michael Straube
The function rtw_set_tx_chksum_offload() has empty definition.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c  | 2 --
 drivers/staging/rtl8723bs/include/xmit_osdep.h | 2 --
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c  | 5 -
 3 files changed, 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index aaabffb0a199..3e7c1f07b8b4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -845,8 +845,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt 
*pkt, struct pkt_attrib
 
/* pattrib->priority = 5; force to used VI queue, for testing */
 
-   rtw_set_tx_chksum_offload(pkt, pattrib);
-
 exit:
return res;
 }
diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h 
b/drivers/staging/rtl8723bs/include/xmit_osdep.h
index 377b453de199..a61412b54ec0 100644
--- a/drivers/staging/rtl8723bs/include/xmit_osdep.h
+++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h
@@ -33,8 +33,6 @@ void rtw_os_xmit_schedule(struct adapter *padapter);
 int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf 
*pxmitbuf, u32 alloc_sz, u8 flag);
 void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf 
*pxmitbuf, u32 free_sz, u8 flag);
 
-extern void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib);
-
 extern uint rtw_remainder_len(struct pkt_file *pfile);
 extern void _rtw_open_pktfile(_pkt *pkt, struct pkt_file *pfile);
 extern uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen);
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c 
b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 4da0c6f323d1..2cf903c66854 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -46,11 +46,6 @@ sint rtw_endofpktfile(struct pkt_file *pfile)
return false;
 }
 
-void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib)
-{
-
-}
-
 int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf 
*pxmitbuf, u32 alloc_sz, u8 flag)
 {
if (alloc_sz > 0) {
-- 
2.18.0

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


[PATCH v2 1/4] staging: rtl8723bs: fix comparsion to NULL - coding style

2018-06-25 Thread Michael Straube
Fix comparsion to NULL issues found by checkpatch.
Use !x instead of x == NULL.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 0822e440204e..e55895632921 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -747,7 +747,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
u8 match = false;
u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
 
-   if (ie_ptr == NULL)
+   if (!ie_ptr)
return match;
 
eid = ie_ptr[0];
@@ -1163,7 +1163,7 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
const unsigned char *addr;
int len;
 
-   if (mac_addr == NULL)
+   if (!mac_addr)
return;
 
if (rtw_initmac) {  /*  Users specify the mac address */
-- 
2.18.0

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


[PATCH v2 2/4] staging: rtl8723bs: refactor rtw_macaddr_cfg()

2018-06-25 Thread Michael Straube
Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
testing each byte of the mac[] array for 0xff and 0x00 shortens the
code and improves readability.

If np == NULL, of_get_property() returns NULL, hence the "np" check
is not needed.

Instead of a fixed default mac address use a random one to reduce the
likelihood of mac address collision.

Thanks to Joe Perches and Dan Carpenter.

Signed-off-by: Michael Straube 
---
 .../staging/rtl8723bs/core/rtw_ieee80211.c| 19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index e55895632921..7aa00d1391f7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1177,24 +1177,13 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
memcpy(mac, mac_addr, ETH_ALEN);
}
 
-   if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) &&
-(mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
-   ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
-(mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) {
-   if (np &&
-   (addr = of_get_property(np, "local-mac-address", &len)) &&
+   if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
+   if ((addr = of_get_property(np, "local-mac-address", &len)) &&
len == ETH_ALEN) {
memcpy(mac_addr, addr, ETH_ALEN);
} else {
-   mac[0] = 0x00;
-   mac[1] = 0xe0;
-   mac[2] = 0x4c;
-   mac[3] = 0x87;
-   mac[4] = 0x00;
-   mac[5] = 0x00;
-   /*  use default mac addresss */
-   memcpy(mac_addr, mac, ETH_ALEN);
-   DBG_871X("MAC Address from efuse error, assign default 
one !!!\n");
+   eth_random_addr(mac_addr);
+   DBG_871X("MAC Address from efuse error, assign random 
one !!!\n");
}
}
 
-- 
2.18.0

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


[PATCH v2 4/4] staging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()

2018-06-25 Thread Michael Straube
Use the mac_pton() helper to convert the mac address string.

The functions key_char2num() and key_2char2num() are not used
anywhere else and can be removed.

This also has the benefit of validating the input since mac_pton()
returns false if the string is not valid.

Signed-off-by: Michael Straube 
---
 .../staging/rtl8723bs/core/rtw_ieee80211.c| 30 +++
 .../staging/rtl8723bs/os_dep/ioctl_linux.c|  3 --
 2 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 8af4a89e632f..62d19cfebb06 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1137,25 +1137,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
 
 }
 
-static u8 key_char2num(u8 ch);
-static u8 key_char2num(u8 ch)
-{
-   if ((ch >= '0') && (ch <= '9'))
-   return ch - '0';
-   else if ((ch >= 'a') && (ch <= 'f'))
-   return ch - 'a' + 10;
-   else if ((ch >= 'A') && (ch <= 'F'))
-   return ch - 'A' + 10;
-   else
-   return 0xff;
-}
-
-u8 key_2char2num(u8 hch, u8 lch);
-u8 key_2char2num(u8 hch, u8 lch)
-{
-   return ((key_char2num(hch) << 4) | key_char2num(lch));
-}
-
 void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
 {
u8 mac[ETH_ALEN];
@@ -1166,14 +1147,11 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
if (!mac_addr)
return;
 
-   if (rtw_initmac) {  /*  Users specify the mac address */
-   int jj, kk;
-
-   for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) {
-   mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk 
+ 1]);
-   }
+   if (rtw_initmac && mac_pton(rtw_initmac, mac)) {
+   /* Users specify the mac address */
ether_addr_copy(mac_addr, mac);
-   } else{ /*  Use the mac address stored in the Efuse */
+   } else{
+   /* Use the mac address stored in the Efuse */
ether_addr_copy(mac, mac_addr);
}
 
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 39502156f652..4eb51f45b387 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -32,9 +32,6 @@
 #define WEXT_CSCAN_HOME_DWELL_SECTION  'H'
 #define WEXT_CSCAN_TYPE_SECTION'T'
 
-
-extern u8 key_2char2num(u8 hch, u8 lch);
-
 static u32 rtw_rates[] = {100, 200, 550, 1100,
600, 900, 1200, 1800, 2400, 3600, 4800, 
5400};
 
-- 
2.18.0

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


[PATCH v2 3/4] staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()

2018-06-25 Thread Michael Straube
Use ether_addr_copy() instead of memcpy() to copy the mac address.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 7aa00d1391f7..8af4a89e632f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1172,15 +1172,15 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) {
mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk 
+ 1]);
}
-   memcpy(mac_addr, mac, ETH_ALEN);
+   ether_addr_copy(mac_addr, mac);
} else{ /*  Use the mac address stored in the Efuse */
-   memcpy(mac, mac_addr, ETH_ALEN);
+   ether_addr_copy(mac, mac_addr);
}
 
if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
if ((addr = of_get_property(np, "local-mac-address", &len)) &&
len == ETH_ALEN) {
-   memcpy(mac_addr, addr, ETH_ALEN);
+   ether_addr_copy(mac_addr, addr);
} else {
eth_random_addr(mac_addr);
DBG_871X("MAC Address from efuse error, assign random 
one !!!\n");
-- 
2.18.0

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


[PATCH v2] staging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.

2018-06-25 Thread Karim Eshapa
Doing some macro replacement to start an array of structures
so it can be reused by manipulating it with different values.

Signed-off-by: Karim Eshapa 
---
 .../staging/iio/impedance-analyzer/ad5933.c   | 57 +++
 1 file changed, 19 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c 
b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 3bcf49466361..14df89510396 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -116,45 +116,26 @@ static struct ad5933_platform_data ad5933_default_pdata  
= {
.vref_mv = 3300,
 };
 
+#define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \
+   _scan_index, _realbits) { \
+   .type = (_type), \
+   .extend_name = (_extend_name), \
+   .info_mask_separate = (_info_mask_separate), \
+   .address = (_address), \
+   .scan_index = (_scan_index), \
+   .scan_type = { \
+   .sign = 's', \
+   .realbits = (_realbits), \
+   .storagebits = 16, \
+   }, \
+}
+
 static const struct iio_chan_spec ad5933_channels[] = {
-   {
-   .type = IIO_TEMP,
-   .indexed = 1,
-   .channel = 0,
-   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-   BIT(IIO_CHAN_INFO_SCALE),
-   .address = AD5933_REG_TEMP_DATA,
-   .scan_index = -1,
-   .scan_type = {
-   .sign = 's',
-   .realbits = 14,
-   .storagebits = 16,
-   },
-   }, { /* Ring Channels */
-   .type = IIO_VOLTAGE,
-   .indexed = 1,
-   .channel = 0,
-   .extend_name = "real",
-   .address = AD5933_REG_REAL_DATA,
-   .scan_index = 0,
-   .scan_type = {
-   .sign = 's',
-   .realbits = 16,
-   .storagebits = 16,
-   },
-   }, {
-   .type = IIO_VOLTAGE,
-   .indexed = 1,
-   .channel = 0,
-   .extend_name = "imag",
-   .address = AD5933_REG_IMAG_DATA,
-   .scan_index = 1,
-   .scan_type = {
-   .sign = 's',
-   .realbits = 16,
-   .storagebits = 16,
-   },
-   },
+   AD5933_CHANNEL(IIO_TEMP, NULL, BIT(IIO_CHAN_INFO_RAW) |
+   BIT(IIO_CHAN_INFO_SCALE), AD5933_REG_TEMP_DATA, -1, 14),
+   /* Ring Channels */
+   AD5933_CHANNEL(IIO_VOLTAGE, "real", 0, AD5933_REG_REAL_DATA, 0, 16),
+   AD5933_CHANNEL(IIO_VOLTAGE, "imag", 0, AD5933_REG_IMAG_DATA, 1, 16),
 };
 
 static int ad5933_i2c_write(struct i2c_client *client, u8 reg, u8 len, u8 
*data)
-- 
2.17.1

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


Re: [PATCH v3 3/8] staging: rtl8192u: User memset to initialize memory, instead of loop.

2018-06-25 Thread John Whitmore
On Mon, Jun 25, 2018 at 02:05:04PM +0100, Justin Skists wrote:
> 
> > On 25 June 2018 at 13:36 John Whitmore  wrote:
> > 
> > 
> > On Mon, Jun 25, 2018 at 12:06:30PM +0300, Andy Shevchenko wrote:
> > > On Sun, Jun 24, 2018 at 6:34 PM, John Whitmore  
> > > wrote:
> > > > Replaced memory initialising loop with memset, as suggested by Andy 
> > > > Shevchenko
> > > >
> > > 
> > > Suggested-by ?
> > >
> > 
> > Em, not sure how to respond, it certainly wasn't my idea. I was just making
> > coding style changes, badly. ;)
> 
> Suggested-by is a tag for patches, to give credit. For example:
> 
> https://elixir.bootlin.com/linux/v4.18-rc1/source/Documentation/process/submitting-patches.rst
> 
> See section "13) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: 
> and Fixes:"
> 
> Hope that helps,
> Justin.

Oops... that helps thank you. I have to re-read that document, it obvioiusly
didn't all sink in :(

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


[PATCH] staging: rtl8188eu: add SPDX identifiers

2018-06-25 Thread Michael Straube
This satisfies a checkpatch warning and is the preferred
method for notating the license.

The SPDX identifier is a legally binding shorthand, which
can be used instead of the full boiler plate text.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c| 10 +-
 drivers/staging/rtl8188eu/core/rtw_cmd.c   | 10 +-
 drivers/staging/rtl8188eu/core/rtw_debug.c | 10 +-
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 10 +-
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 10 +-
 drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 10 +-
 drivers/staging/rtl8188eu/core/rtw_iol.c   | 11 +--
 drivers/staging/rtl8188eu/core/rtw_led.c   | 11 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c  | 10 +-
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  | 10 +-
 drivers/staging/rtl8188eu/core/rtw_pwrctrl.c   | 10 +-
 drivers/staging/rtl8188eu/core/rtw_recv.c  | 10 +-
 drivers/staging/rtl8188eu/core/rtw_rf.c| 10 +-
 drivers/staging/rtl8188eu/core/rtw_security.c  | 10 +-
 drivers/staging/rtl8188eu/core/rtw_sreset.c| 10 +-
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c   | 10 +-
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 10 +-
 drivers/staging/rtl8188eu/core/rtw_xmit.c  | 10 +-
 drivers/staging/rtl8188eu/hal/bb_cfg.c | 10 +-
 drivers/staging/rtl8188eu/hal/fw.c | 13 +
 drivers/staging/rtl8188eu/hal/hal_com.c| 10 +-
 drivers/staging/rtl8188eu/hal/hal_intf.c   | 10 +-
 drivers/staging/rtl8188eu/hal/mac_cfg.c| 18 +-
 drivers/staging/rtl8188eu/hal/odm.c| 10 +-
 drivers/staging/rtl8188eu/hal/odm_HWConfig.c   | 10 +-
 drivers/staging/rtl8188eu/hal/odm_RTL8188E.c   | 10 +-
 drivers/staging/rtl8188eu/hal/phy.c| 10 +-
 drivers/staging/rtl8188eu/hal/pwrseq.c | 10 +-
 drivers/staging/rtl8188eu/hal/pwrseqcmd.c  | 10 +-
 drivers/staging/rtl8188eu/hal/rf.c | 10 +-
 drivers/staging/rtl8188eu/hal/rf_cfg.c | 18 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c   | 10 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_dm.c| 10 +-
 .../staging/rtl8188eu/hal/rtl8188e_hal_init.c  | 10 +-
 .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c| 10 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c  | 10 +-
 drivers/staging/rtl8188eu/hal/rtl8188eu_led.c  | 10 +-
 drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 10 +-
 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 10 +-
 drivers/staging/rtl8188eu/hal/usb_halinit.c| 10 +-
 .../staging/rtl8188eu/include/Hal8188EPhyCfg.h | 10 +-
 .../staging/rtl8188eu/include/Hal8188EPhyReg.h | 10 +-
 drivers/staging/rtl8188eu/include/HalVerDef.h  | 10 +-
 .../staging/rtl8188eu/include/basic_types.h| 12 ++--
 drivers/staging/rtl8188eu/include/drv_types.h  | 10 +-
 drivers/staging/rtl8188eu/include/fw.h | 13 +
 drivers/staging/rtl8188eu/include/hal_com.h| 10 +-
 drivers/staging/rtl8188eu/include/hal_intf.h   | 10 +-
 drivers/staging/rtl8188eu/include/ieee80211.h  | 10 +-
 drivers/staging/rtl8188eu/include/mlme_osdep.h | 10 +-
 drivers/staging/rtl8188eu/include/mon.h| 10 +-
 .../staging/rtl8188eu/include/mp_custom_oid.h  | 10 +-
 drivers/staging/rtl8188eu/include/odm.h| 10 +-
 .../staging/rtl8188eu/include/odm_HWConfig.h   | 11 +--
 .../staging/rtl8188eu/include/odm_RTL8188E.h   | 10 +-
 .../rtl8188eu/include/odm_RegDefine11N.h   | 10 +-
 drivers/staging/rtl8188eu/include/odm_debug.h  | 10 +-
 .../staging/rtl8188eu/include/odm_precomp.h| 10 +-
 drivers/staging/rtl8188eu/include/odm_reg.h| 10 +-
 drivers/staging/rtl8188eu/include/odm_types.h  | 10 +-
 drivers/staging/rtl8188eu/include/osdep_intf.h | 10 +-
 .../staging/rtl8188eu/include/osdep_service.h  | 10 +-
 drivers/staging/rtl8188eu/include/pwrseq.h | 11 +--
 drivers/staging/rtl8188eu/include/pwrseqcmd.h  | 10 +-
 drivers/staging/rtl8188eu/include/recv_osdep.h | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_cmd.h   | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_dm.h| 10 +-
 .../staging/rtl8188eu/include/rtl8188e_hal.h   | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_led.h   | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_recv.h  | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_spec.h  | 10 +-
 .../staging/rtl8188eu/include/rtl8188e_xmit.h  | 10 +-
 .../staging/rtl8188eu/include/rtw_android.h| 10 +-
 drivers/staging/rtl8188eu/include/rtw_ap.h | 10 +

RE: [PATCH 2/4] x86/hyper-v: use 'fast' hypercall for HVCALL_SEND_IPI

2018-06-25 Thread Michael Kelley (EOSG)
> -Original Message-
> From: Vitaly Kuznetsov 
> Sent: Friday, June 22, 2018 10:06 AM
> To: x...@kernel.org
> Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; KY Srinivasan
> ; Haiyang Zhang ; Stephen 
> Hemminger
> ; Thomas Gleixner ; Ingo Molnar
> ; H. Peter Anvin ; Tianyu Lan
> ; Michael Kelley (EOSG) 
> 
> Subject: [PATCH 2/4] x86/hyper-v: use 'fast' hypercall for HVCALL_SEND_IPI
> 
> Current Hyper-V TLFS (v5.0b) claims that HvCallSendSyntheticClusterIpi
> hypercall can't be 'fast' (passing parameters through registers) but
> apparently this is not true, Windows always uses 'fast' version. We can
> do the same in Linux too.
> 
> Signed-off-by: Vitaly Kuznetsov 

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


RE: Will the name of hyperv_clocksource_tsc_page or hyperv_clocksource pages change?

2018-06-25 Thread Alma Eyre (Sonata Software North America)
Thank you everybody for your help. I have passed this information along to the 
customer and asked for the reason they want to refer to the name of the 
clocksource.

エアー・アルマ
Professional Direct Delivery Manager
Email: v-ale...@microsoft.com

Microsoft Azure Professional Direct Services
日本 +81 1-2051-4100(無料)
日本 +81 3-6743-9670(有料)  
電子メール: pdaz...@microsoft.com


-Original Message-
From: Greg KH  
Sent: Friday, June 22, 2018 10:51 PM
To: Peter Zijlstra 
Cc: Alma Eyre (Sonata Software North America) ; Haiyang 
Zhang ; de...@linuxdriverproject.org; Vitaly Kuznetsov 
; Linus Torvalds ; Thomas 
Gleixner 
Subject: Re: Will the name of hyperv_clocksource_tsc_page or hyperv_clocksource 
pages change?

On Fri, Jun 22, 2018 at 10:22:28AM +0200, Peter Zijlstra wrote:
> On Fri, Jun 22, 2018 at 03:17:25AM +, Alma Eyre (Sonata Software North 
> America) wrote:
> > Hello,
> > 
> > This is Alma supporting Azure for Japanese customers. I had a 
> > question from a customer that I could not find the answers for. I 
> > saw this
> > github(https://na01.safelinks.protection.outlook.com/?url=https%3A%2
> > F%2Fgithub.com%2Ftorvalds%2Flinux%2Fcommit%2F88c9281a9fba67636ab26c1
> > fd6afbc78a632374f&data=02%7C01%7Cv-aleyre%40microsoft.com%7Cfd2c
> > bcc41da54a65be1908d5d8cd635c%7C72f988bf86f141af91ab2d7cd011db47%7C1%
> > 7C0%7C636653299021462729&sdata=B0KCAukioytYR0RlTPr2n3KVCrKzkRem2
> > ir1aBiXXoA%3D&reserved=0) page, and I was wondering if someone 
> > on this list might be able to answer the question.
> > 
> > Will the name of hyperv_clocksource_tsc_page or hyperv_clocksource 
> > pages change?
> 
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
> b.com%2Ftorvalds%2Flinux%2Fblob%2Fe7aa8c2eb11ba69b1b69099c3c7bd6be3087
> b0ba%2FDocumentation%2Fprocess%2Fstable-api-nonsense.rst&data=02%7
> C01%7Cv-aleyre%40microsoft.com%7Cfd2cbcc41da54a65be1908d5d8cd635c%7C72
> f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636653299021462729&sdata=
> URuIH1hhfWowC4yfkZxZB8Gg9%2Fo6rEkzufMOUSgjJug%3D&reserved=0

Or better yet, in a pretty html format:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kernel.org%2Fdoc%2Fhtml%2Flatest%2Fprocess%2Fstable-api-nonsense.html&data=02%7C01%7Cv-aleyre%40microsoft.com%7Cfd2cbcc41da54a65be1908d5d8cd635c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636653299021462729&sdata=UBkvgJz9XcURXiTPbV1CImpK9DsnbK9HTgFwZCKjcJU%3D&reserved=0

But, this is a name of a clocksource, not really an internal kernel api.

Alma, what external tool depends on the specific name of a kernel clock?
Why would it matter what the name of it is?

thanks,

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


RE: [PATCH 3/4] x86/hyper-v: use cheaper HVCALL_SEND_IPI hypercall when possible

2018-06-25 Thread Michael Kelley (EOSG)
> -Original Message-
> From: Vitaly Kuznetsov 
> Sent: Friday, June 22, 2018 10:06 AM
> To: x...@kernel.org
> Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; KY Srinivasan
> ; Haiyang Zhang ; Stephen 
> Hemminger
> ; Thomas Gleixner ; Ingo Molnar
> ; H. Peter Anvin ; Tianyu Lan
> ; Michael Kelley (EOSG) 
> 
> Subject: [PATCH 3/4] x86/hyper-v: use cheaper HVCALL_SEND_IPI hypercall when 
> possible
> 
> When there is no need to send an IPI to a CPU with VP number > 64
> we can do the job with fast HVCALL_SEND_IPI hypercall.
> 
> Signed-off-by: Vitaly Kuznetsov 

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


Re: Do Qualcomm drivers use DMA buffers for request_firmware_into_buf()?

2018-06-25 Thread Bjorn Andersson
On Thu 07 Jun 11:42 PDT 2018, Ard Biesheuvel wrote:

> On 7 June 2018 at 20:21, Bjorn Andersson  wrote:
> > On Thu 07 Jun 09:33 PDT 2018, Greg Kroah-Hartman wrote:
[..]
> >>
> >> Why not just use kmalloc, it will always return a DMAable buffer.
> >>
> >
> > For the buffers being targeted by request_firmware_into_buf() the
> > problem is that some of them has requirements of physical placement and
> > they are all too big for kmalloc() (i.e. tens of mb).
> >
> >
> > For the dma_alloc_coherent() buffer that was mentioned earlier, which is
> > not related to the firmware loading, it's not used because the buffer is
> > passed to secure world, which temporarily locks Linux out from the
> > memory region. Traditionally this region was kmalloc'ed downstream, but
> > due to speculative access violations this code moved to use the DMA
> > streaming API, although there's no actual DMA going on.
> >
> 
> OK, so you are relying on the fact that dma_alloc_coherent() gives you
> a device mapping (because the qcom_scm device is described as non
> cache coherent), but this sounds risky to me. The linear alias of that
> memory will still be mapped cacheable, and could potentially still be
> accessed speculatively AFAIK.
> 

Yes and we are aware of the risk of having the linear alias present, but
have yet to find a suitable way to handle this.

The proposed mechanism was to use reserved-memory and memremap() the
region while it should be available in Linux, but while this would work
for some cases (e.g. memory regions for semi-static firmware executed by
co-processors) it doesn't handle the scenarios where the memory-need is
dynamic.

So suggestions are very welcome on how to better handle this.

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


Re: [PATCH v3 5/8] staging: rtl8192u: Use %s and __func__ instead of hardcoded string - Style

2018-06-25 Thread Greg KH
On Sun, Jun 24, 2018 at 04:34:51PM +0100, John Whitmore wrote:
> Changed a number of hard coded function names to use %s and __func__
> 
> Mailing list response suggest that there is a better method for debugging
> using netdev_dbg(). I can't argue with that, but for the moment this change
> will clear the checkpatch.pl Warning.
> 
> Signed-off-by: John Whitmore 
> ---
>  drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

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


Re: [PATCH v3 3/8] staging: rtl8192u: User memset to initialize memory, instead of loop.

2018-06-25 Thread Greg Kroah-Hartman
On Mon, Jun 25, 2018 at 08:50:26PM +0100, John Whitmore wrote:
> On Mon, Jun 25, 2018 at 02:05:04PM +0100, Justin Skists wrote:
> > 
> > > On 25 June 2018 at 13:36 John Whitmore  wrote:
> > > 
> > > 
> > > On Mon, Jun 25, 2018 at 12:06:30PM +0300, Andy Shevchenko wrote:
> > > > On Sun, Jun 24, 2018 at 6:34 PM, John Whitmore 
> > > >  wrote:
> > > > > Replaced memory initialising loop with memset, as suggested by Andy 
> > > > > Shevchenko
> > > > >
> > > > 
> > > > Suggested-by ?
> > > >
> > > 
> > > Em, not sure how to respond, it certainly wasn't my idea. I was just 
> > > making
> > > coding style changes, badly. ;)
> > 
> > Suggested-by is a tag for patches, to give credit. For example:
> > 
> > https://elixir.bootlin.com/linux/v4.18-rc1/source/Documentation/process/submitting-patches.rst
> > 
> > See section "13) Using Reported-by:, Tested-by:, Reviewed-by:, 
> > Suggested-by: and Fixes:"
> > 
> > Hope that helps,
> > Justin.
> 
> Oops... that helps thank you. I have to re-read that document, it obvioiusly
> didn't all sink in :(

I've dropped this patch, can you fix it up and resend?

thanks,

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


[PATCH 06/12] staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()

2018-06-25 Thread Ajay Singh
Rename wilc_enqueue_cmd() to wilc_enqueue_work() because its used to
enqueue the work queue. Also removed the function header comment for
wilc_enqueue_cmd() as its not correct.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 90 +++
 1 file changed, 42 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 17c20b9..6d27a9d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -227,13 +227,7 @@ wilc_alloc_work(struct wilc_vif *vif, void 
(*work_fun)(struct work_struct *),
return msg;
 }
 
-/*!
- *  @authorsyounan
- *  @date  1 Sep 2010
- *  @note  copied from FLO glue implementatuion
- *  @version   1.0
- */
-static int wilc_enqueue_cmd(struct host_if_msg *msg)
+static int wilc_enqueue_work(struct host_if_msg *msg)
 {
INIT_WORK(&msg->work, msg->fn);
if (!hif_workqueue || !queue_work(hif_workqueue, &msg->work))
@@ -903,7 +897,7 @@ static void handle_connect(struct work_struct *work)
struct host_if_drv *hif_drv = vif->hif_drv;
 
if (msg->vif->hif_drv->usr_scan_req.scan_result) {
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
goto error;
 
@@ -2353,7 +2347,7 @@ static void listen_timer_cb(struct timer_list *t)
 
msg->body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "wilc_mq_send fail\n");
kfree(msg);
@@ -2521,7 +2515,7 @@ static void timer_scan_cb(struct timer_list *t)
if (IS_ERR(msg))
return;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
kfree(msg);
 }
@@ -2538,7 +2532,7 @@ static void timer_connect_cb(struct timer_list *t)
if (IS_ERR(msg))
return;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
kfree(msg);
 }
@@ -2563,7 +2557,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
msg->body.key_info.action = REMOVEKEY;
msg->body.key_info.attr.wep.index = index;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
netdev_err(vif->ndev, "Request to remove WEP key\n");
else
@@ -2593,7 +2587,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 
index)
msg->body.key_info.action = DEFAULTKEY;
msg->body.key_info.attr.wep.index = index;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
netdev_err(vif->ndev, "Default key index\n");
else
@@ -2630,7 +2624,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const 
u8 *key, u8 len,
msg->body.key_info.attr.wep.key_len = len;
msg->body.key_info.attr.wep.index = index;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
goto free_key;
 
@@ -2675,7 +2669,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const 
u8 *key, u8 len,
msg->body.key_info.attr.wep.mode = mode;
msg->body.key_info.attr.wep.auth_type = auth_type;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result)
goto free_key;
 
@@ -2741,7 +2735,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 
ptk_key_len,
msg->body.key_info.attr.wpa.mac_addr = mac_addr;
msg->body.key_info.attr.wpa.mode = cipher_mode;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "PTK Key\n");
goto free_key;
@@ -2821,7 +2815,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 
*rx_gtk, u8 gtk_key_len,
msg->body.key_info.attr.wpa.key_len = key_len;
msg->body.key_info.attr.wpa.seq_len = key_rsc_len;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "RX GTK\n");
goto free_key;
@@ -2863,7 +2857,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif,
   &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
}
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "PMKID Info\n");
kfree(msg);
@@ -2883,7 +2877,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 
*mac_addr)
 
msg->body.get_mac_info.mac_addr = mac_addr;
 
-   result = wilc_enqueue_cmd(msg);
+   result = wilc_

[PATCH 02/12] staging: wilc1000: remove unused marco related to HIF commands

2018-06-25 Thread Ajay Singh
After removing the multiplexing of hif commands in hif_if_work()
macros prefix with 'HOST_IF_MSG_' are not required. Also 'id' field in
host_if_msg is not required anymore.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 36 ---
 1 file changed, 36 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4f6008e..998e0ab 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1,41 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "wilc_wfi_netdevice.h"
 
-#define HOST_IF_MSG_SCAN0
-#define HOST_IF_MSG_CONNECT 1
-#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO2
-#define HOST_IF_MSG_KEY 3
-#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
-#define HOST_IF_MSG_RCVD_SCAN_COMPLETE  5
-#define HOST_IF_MSG_CFG_PARAMS  6
-#define HOST_IF_MSG_SET_CHANNEL 7
-#define HOST_IF_MSG_DISCONNECT  8
-#define HOST_IF_MSG_GET_RSSI9
-#define HOST_IF_MSG_ADD_BEACON  11
-#define HOST_IF_MSG_DEL_BEACON  12
-#define HOST_IF_MSG_ADD_STATION 13
-#define HOST_IF_MSG_DEL_STATION 14
-#define HOST_IF_MSG_EDIT_STATION15
-#define HOST_IF_MSG_SCAN_TIMER_FIRED16
-#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
-#define HOST_IF_MSG_POWER_MGMT  18
-#define HOST_IF_MSG_GET_INACTIVETIME19
-#define HOST_IF_MSG_REMAIN_ON_CHAN  20
-#define HOST_IF_MSG_REGISTER_FRAME  21
-#define HOST_IF_MSG_LISTEN_TIMER_FIRED  22
-#define HOST_IF_MSG_SET_WFIDRV_HANDLER  24
-#define HOST_IF_MSG_GET_MAC_ADDRESS 26
-#define HOST_IF_MSG_SET_OPERATION_MODE  27
-#define HOST_IF_MSG_SET_IPADDRESS   28
-#define HOST_IF_MSG_GET_IPADDRESS   29
-#define HOST_IF_MSG_GET_STATISTICS  31
-#define HOST_IF_MSG_SET_MULTICAST_FILTER32
-#define HOST_IF_MSG_DEL_BA_SESSION  34
-#define HOST_IF_MSG_DEL_ALL_STA 36
-#define HOST_IF_MSG_SET_TX_POWER   38
-#define HOST_IF_MSG_GET_TX_POWER   39
-#define HOST_IF_MSG_EXIT100
-
 #define HOST_IF_SCAN_TIMEOUT4000
 #define HOST_IF_CONNECT_TIMEOUT 9500
 
@@ -180,7 +145,6 @@ union message_body {
 };
 
 struct host_if_msg {
-   u16 id;
union message_body body;
struct wilc_vif *vif;
struct work_struct work;
-- 
2.7.4

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


[PATCH 08/12] staging: wilc1000: handle freeing of key data in wilc_add_ptk()

2018-06-25 Thread Ajay Singh
Handle freeing of memory allocated to store the 'key' in wilc_add_ptk()
function. Once work completion notification is received, free the
memory allocated to avoid missing of free in work function sepecially
for error scenario.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2cc9689..2062f4e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1724,7 +1724,6 @@ static void handle_key(struct work_struct *work)
 
 out_wpa_ptk:
complete(&msg->work_comp);
-   kfree(hif_key->attr.wpa.key);
break;
 
case PMKSA:
@@ -2735,8 +2734,6 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 
ptk_key_len,
}
 
wait_for_completion(&msg->work_comp);
-   kfree(msg);
-   return 0;
 
 free_key:
kfree(msg->body.key_info.attr.wpa.key);
-- 
2.7.4

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


[PATCH 04/12] staging: wilc1000: added 'work_comp' completion as part of host_if_msg

2018-06-25 Thread Ajay Singh
Added 'work_comp' completion in 'host_if_msg'. It allows handling the
sync call to wait for sepecific completion event.
The commands can be run in sync way waiting for their specific
completion event.
Added is_sync flag in wilc_create_work_queue() to handle the sync call to
host interface.

After adding completion as part of host_if_msg now
below completion are not required
 comp_test_key_block;
 comp_test_disconn_block
 comp_get_rssi
 comp_inactive_time
 hif_wait_response

Modified wilc_get_statistics() API to handle get statistic in sync &
async way.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 256 +++---
 drivers/staging/wilc1000/host_interface.h |   7 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |   2 +-
 3 files changed, 132 insertions(+), 133 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index cb627b0..27516f7 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -149,6 +149,8 @@ struct host_if_msg {
struct wilc_vif *vif;
struct work_struct work;
void (*fn)(struct work_struct *ws);
+   struct completion work_comp;
+   bool is_sync;
 };
 
 struct join_bss_param {
@@ -186,7 +188,6 @@ static u8 p2p_listen_state;
 static struct workqueue_struct *hif_workqueue;
 static struct completion hif_thread_comp;
 static struct completion hif_driver_comp;
-static struct completion hif_wait_response;
 static struct mutex hif_deinit_lock;
 static struct timer_list periodic_rssi;
 static struct wilc_vif *periodic_rssi_vif;
@@ -205,8 +206,10 @@ static void *host_int_parse_join_bss_param(struct 
network_info *info);
 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
 static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt);
 
+/* 'msg' should be free by the caller for syc */
 static struct host_if_msg*
-wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *))
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
+   bool is_sync)
 {
struct host_if_msg *msg;
 
@@ -218,6 +221,9 @@ wilc_alloc_work(struct wilc_vif *vif, void 
(*work_fun)(struct work_struct *))
return ERR_PTR(-ENOMEM);
msg->fn = work_fun;
msg->vif = vif;
+   msg->is_sync = is_sync;
+   if (is_sync)
+   init_completion(&msg->work_comp);
 
return msg;
 }
@@ -434,8 +440,8 @@ static void handle_get_mac_address(struct work_struct *work)
 
if (ret)
netdev_err(vif->ndev, "Failed to get mac address\n");
-   complete(&hif_wait_response);
-   kfree(msg);
+   complete(&msg->work_comp);
+   /* free 'msg' data later, in caller */
complete(&hif_thread_comp);
 }
 
@@ -1618,7 +1624,7 @@ static void handle_key(struct work_struct *work)
  wilc_get_vif_idx(vif));
}
 out_wep:
-   complete(&hif_drv->comp_test_key_block);
+   complete(&msg->work_comp);
break;
 
case WPA_RX_GTK:
@@ -1682,7 +1688,7 @@ static void handle_key(struct work_struct *work)
kfree(key_buf);
}
 out_wpa_rx_gtk:
-   complete(&hif_drv->comp_test_key_block);
+   complete(&msg->work_comp);
kfree(hif_key->attr.wpa.key);
kfree(hif_key->attr.wpa.seq);
break;
@@ -1739,19 +1745,21 @@ static void handle_key(struct work_struct *work)
}
 
 out_wpa_ptk:
-   complete(&hif_drv->comp_test_key_block);
+   complete(&msg->work_comp);
kfree(hif_key->attr.wpa.key);
break;
 
case PMKSA:
result = wilc_pmksa_key_copy(vif, hif_key);
+   /*free 'msg', this case it not a sync call*/
+   kfree(msg);
break;
}
 
if (result)
netdev_err(vif->ndev, "Failed to send key config packet\n");
 
-   kfree(msg);
+   /* free 'msg' data in caller sync call */
complete(&hif_thread_comp);
 }
 
@@ -1825,8 +1833,8 @@ static void handle_disconnect(struct work_struct *work)
 
 out:
 
-   complete(&hif_drv->comp_test_disconn_block);
-   kfree(msg);
+   complete(&msg->work_comp);
+   /* free 'msg' in caller after receiving completion */
complete(&hif_thread_comp);
 }
 
@@ -1856,8 +1864,8 @@ static void handle_get_rssi(struct work_struct *work)
if (result)
netdev_err(vif->ndev, "Failed to get RSSI value\n");
 
-   complete(&vif->hif_drv->comp_get_rssi);
-   kfree(msg);
+   complete(&msg->work_comp);
+   /* free 'msg' data in caller */
complete(&hif_thread_comp);
 }
 
@@ -1912,9 +1920,12 @@ static void handle_get_statistics(struct work_struct 
*work)
   

[PATCH 07/12] staging: wilc1000: handle freeing of key data in wep add key

2018-06-25 Thread Ajay Singh
Modified the code to free the allocated memory, used to store the key in
wilc_add_wep_key_bss_sta() and wilc_add_wep_key_bss_ap().
After work completion notification is received, free the
memory allocated to avoid missing of free in work function.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6d27a9d..2cc9689 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1551,8 +1551,6 @@ static void handle_key(struct work_struct *work)
memcpy(&key_buf[2], hif_key->attr.wep.key,
   hif_key->attr.wep.key_len);
 
-   kfree(hif_key->attr.wep.key);
-
wid_list[2].id = (u16)WID_WEP_KEY_VALUE;
wid_list[2].type = WID_STR;
wid_list[2].size = hif_key->attr.wep.key_len + 2;
@@ -1573,7 +1571,6 @@ static void handle_key(struct work_struct *work)
memcpy(key_buf + 1, &hif_key->attr.wep.key_len, 1);
memcpy(key_buf + 2, hif_key->attr.wep.key,
   hif_key->attr.wep.key_len);
-   kfree(hif_key->attr.wep.key);
 
wid.id = (u16)WID_ADD_WEP_KEY;
wid.type = WID_STR;
@@ -2629,8 +2626,6 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const 
u8 *key, u8 len,
goto free_key;
 
wait_for_completion(&msg->work_comp);
-   kfree(msg);
-   return 0;
 
 free_key:
kfree(msg->body.key_info.attr.wep.key);
@@ -2674,8 +2669,6 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const 
u8 *key, u8 len,
goto free_key;
 
wait_for_completion(&msg->work_comp);
-   kfree(msg);
-   return 0;
 
 free_key:
kfree(msg->body.key_info.attr.wep.key);
-- 
2.7.4

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


[PATCH 05/12] staging: wilc1000: remove 'hif_thread_comp' completions

2018-06-25 Thread Ajay Singh
Remove 'hif_thread_comp' completions as its not required after adding
completion event as part work data to handle each sync call.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 35 ---
 1 file changed, 35 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 27516f7..17c20b9 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -186,7 +186,6 @@ static struct host_if_drv *terminated_handle;
 bool wilc_optaining_ip;
 static u8 p2p_listen_state;
 static struct workqueue_struct *hif_workqueue;
-static struct completion hif_thread_comp;
 static struct completion hif_driver_comp;
 static struct mutex hif_deinit_lock;
 static struct timer_list periodic_rssi;
@@ -286,7 +285,6 @@ static void handle_set_channel(struct work_struct *work)
if (ret)
netdev_err(vif->ndev, "Failed to set channel\n");
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_set_wfi_drv_handler(struct work_struct *work)
@@ -334,7 +332,6 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
 
 free_msg:
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_set_operation_mode(struct work_struct *work)
@@ -359,7 +356,6 @@ static void handle_set_operation_mode(struct work_struct 
*work)
if (ret)
netdev_err(vif->ndev, "Failed to set driver handler\n");
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_set_ip_address(struct work_struct *work)
@@ -390,7 +386,6 @@ static void handle_set_ip_address(struct work_struct *work)
if (ret)
netdev_err(vif->ndev, "Failed to set IP address\n");
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_get_ip_address(struct work_struct *work)
@@ -419,7 +414,6 @@ static void handle_get_ip_address(struct work_struct *work)
if (ret)
netdev_err(vif->ndev, "Failed to get IP address\n");
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_get_mac_address(struct work_struct *work)
@@ -442,7 +436,6 @@ static void handle_get_mac_address(struct work_struct *work)
netdev_err(vif->ndev, "Failed to get mac address\n");
complete(&msg->work_comp);
/* free 'msg' data later, in caller */
-   complete(&hif_thread_comp);
 }
 
 static void handle_cfg_param(struct work_struct *work)
@@ -739,7 +732,6 @@ static void handle_cfg_param(struct work_struct *work)
 unlock:
mutex_unlock(&hif_drv->cfg_values_lock);
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_scan(struct work_struct *work)
@@ -857,7 +849,6 @@ static void handle_scan(struct work_struct *work)
kfree(hdn_ntwk_wid_val);
 
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
@@ -1163,7 +1154,6 @@ static void handle_connect(struct work_struct *work)
 
kfree(cur_byte);
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_connect_timeout(struct work_struct *work)
@@ -1235,7 +1225,6 @@ static void handle_connect_timeout(struct work_struct 
*work)
 
 out:
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static void handle_rcvd_ntwrk_info(struct work_struct *work)
@@ -1304,7 +1293,6 @@ static void handle_rcvd_ntwrk_info(struct work_struct 
*work)
}
 
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
@@ -1495,7 +1483,6 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
 
 free_msg:
kfree(msg);
-   complete(&hif_thread_comp);
 }
 
 static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key)
@@ -1760,7 +1747,6 @@ static void handle_key(struct work_struct *work)
netdev_err(vif->ndev, "Failed to send key config packet\n");
 
/* free 'msg' data in caller sync call */
-   complete(&hif_thread_comp);
 }
 
 static void handle_disconnect(struct work_struct *work)
@@ -1835,7 +1821,6 @@ static void handle_disconnect(struct work_struct *work)
 
complete(&msg->work_comp);
/* free 'msg' in caller after receiving completion */
-   complete(&hif_thread_comp);
 }
 
 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
@@ -1866,7 +1851,6 @@ static void handle_get_rssi(struct work_struct *work)
 
complete(&msg->work_comp);
/* free 'msg' data in caller */
-   complete(&hif_thread_comp);
 }
 
 static void handle_get_statistics(struct work_struct *work)
@@ -1925,8 +1909,6 @@ static void handle_get_statistics(struct work_struct 
*work)
complete(&msg->work_comp);
else
kfree(msg);
-
-   complete(&hif_thread_comp);
 }
 
 static void handl

[PATCH 01/12] staging: wilc1000: remove host_if_work() to handle TODO list issue

2018-06-25 Thread Ajay Singh
Remove multiplexing of command at host_if_work().
Make use of function pointer instead of command ID to track individual
work_struct separately.

Modified the handler function to take work_struct pointer as argument
and its return type is changes to void. Now prototype of 'handle_'
function is same work_struct i.e. 'void (*fun)(struct struct *)' to
register with work_queue.
Removed host_if_work() because its not required now.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 574 +++---
 1 file changed, 278 insertions(+), 296 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 0aaae33..4f6008e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -184,6 +184,7 @@ struct host_if_msg {
union message_body body;
struct wilc_vif *vif;
struct work_struct work;
+   void (*fn)(struct work_struct *ws);
 };
 
 struct join_bss_param {
@@ -239,7 +240,6 @@ static u32 clients_count;
 static void *host_int_parse_join_bss_param(struct network_info *info);
 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
 static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt);
-static void host_if_work(struct work_struct *work);
 
 /*!
  *  @authorsyounan
@@ -255,7 +255,7 @@ static int wilc_enqueue_cmd(struct host_if_msg *msg)
if (!new_msg)
return -ENOMEM;
 
-   INIT_WORK(&new_msg->work, host_if_work);
+   INIT_WORK(&new_msg->work, msg->fn);
queue_work(hif_workqueue, &new_msg->work);
return 0;
 }
@@ -284,9 +284,11 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
return wilc->vif[index];
 }
 
-static void handle_set_channel(struct wilc_vif *vif,
-  struct channel_attr *hif_set_ch)
+static void handle_set_channel(struct work_struct *work)
 {
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_vif *vif = msg->vif;
+   struct channel_attr *hif_set_ch = &msg->body.channel_info;
int ret = 0;
struct wid wid;
 
@@ -300,27 +302,28 @@ static void handle_set_channel(struct wilc_vif *vif,
 
if (ret)
netdev_err(vif->ndev, "Failed to set channel\n");
+   kfree(msg);
+   complete(&hif_thread_comp);
 }
 
-static int handle_set_wfi_drv_handler(struct wilc_vif *vif,
- struct drv_handler *hif_drv_handler)
+static void handle_set_wfi_drv_handler(struct work_struct *work)
 {
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_vif *vif = msg->vif;
+   struct drv_handler *hif_drv_handler = &msg->body.drv;
int ret = 0;
struct wid wid;
u8 *currbyte, *buffer;
struct host_if_drv *hif_drv = NULL;
 
-   if (!vif->hif_drv)
-   return -EINVAL;
-
-   if (!hif_drv_handler)
-   return -EINVAL;
+   if (!vif->hif_drv || !hif_drv_handler)
+   goto free_msg;
 
hif_drv = vif->hif_drv;
 
buffer = kzalloc(DRV_HANDLER_SIZE, GFP_KERNEL);
if (!buffer)
-   return -ENOMEM;
+   goto free_msg;
 
currbyte = buffer;
*currbyte = hif_drv->driver_handler_id & DRV_HANDLER_MASK;
@@ -340,20 +343,22 @@ static int handle_set_wfi_drv_handler(struct wilc_vif 
*vif,
 
ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
   hif_drv->driver_handler_id);
-   if (ret) {
+   if (ret)
netdev_err(vif->ndev, "Failed to set driver handler\n");
-   complete(&hif_driver_comp);
-   kfree(buffer);
-   return ret;
-   }
+
complete(&hif_driver_comp);
kfree(buffer);
-   return 0;
+
+free_msg:
+   kfree(msg);
+   complete(&hif_thread_comp);
 }
 
-static void handle_set_operation_mode(struct wilc_vif *vif,
- struct op_mode *hif_op_mode)
+static void handle_set_operation_mode(struct work_struct *work)
 {
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_vif *vif = msg->vif;
+   struct op_mode *hif_op_mode = &msg->body.mode;
int ret = 0;
struct wid wid;
 
@@ -370,10 +375,16 @@ static void handle_set_operation_mode(struct wilc_vif 
*vif,
 
if (ret)
netdev_err(vif->ndev, "Failed to set driver handler\n");
+   kfree(msg);
+   complete(&hif_thread_comp);
 }
 
-static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
+static void handle_set_ip_address(struct work_struct *work)
 {
+   struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
+   struct wilc_vif *vif = msg->vif;
+   u8 *ip_addr = msg->body.ip_info.ip_addr;
+   

[PATCH 03/12] staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()

2018-06-25 Thread Ajay Singh
Instead of allocating the host_if_cmd in wilc_enqueue_cmd() now moved
the allocation of cmd in the caller. Added the NULL check for
'hif_workqueue' before posting the work queue in wilc_enqueue_cmd().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 943 +-
 1 file changed, 544 insertions(+), 399 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 998e0ab..cb627b0 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -205,6 +205,23 @@ static void *host_int_parse_join_bss_param(struct 
network_info *info);
 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
 static s32 handle_scan_done(struct wilc_vif *vif, enum scan_event evt);
 
+static struct host_if_msg*
+wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *))
+{
+   struct host_if_msg *msg;
+
+   if (!work_fun)
+   return ERR_PTR(-EINVAL);
+
+   msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
+   if (!msg)
+   return ERR_PTR(-ENOMEM);
+   msg->fn = work_fun;
+   msg->vif = vif;
+
+   return msg;
+}
+
 /*!
  *  @authorsyounan
  *  @date  1 Sep 2010
@@ -213,14 +230,10 @@ static s32 handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt);
  */
 static int wilc_enqueue_cmd(struct host_if_msg *msg)
 {
-   struct host_if_msg *new_msg;
-
-   new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC);
-   if (!new_msg)
-   return -ENOMEM;
+   INIT_WORK(&msg->work, msg->fn);
+   if (!hif_workqueue || !queue_work(hif_workqueue, &msg->work))
+   return -EINVAL;
 
-   INIT_WORK(&new_msg->work, msg->fn);
-   queue_work(hif_workqueue, &new_msg->work);
return 0;
 }
 
@@ -896,8 +909,8 @@ static void handle_connect(struct work_struct *work)
result = wilc_enqueue_cmd(msg);
if (result)
goto error;
+
usleep_range(2 * 1000, 2 * 1000);
-   kfree(msg);
return;
}
 
@@ -2348,18 +2361,21 @@ static void listen_timer_cb(struct timer_list *t)
  remain_on_ch_timer);
struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif;
s32 result = 0;
-   struct host_if_msg msg;
+   struct host_if_msg *msg;
 
del_timer(&vif->hif_drv->remain_on_ch_timer);
 
-   memset(&msg, 0, sizeof(struct host_if_msg));
-   msg.fn = handle_listen_state_expired;
-   msg.vif = vif;
-   msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
+   msg = wilc_alloc_work(vif, handle_listen_state_expired);
+   if (IS_ERR(msg))
+   return;
+
+   msg->body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
 
-   result = wilc_enqueue_cmd(&msg);
-   if (result)
+   result = wilc_enqueue_cmd(msg);
+   if (result) {
netdev_err(vif->ndev, "wilc_mq_send fail\n");
+   kfree(msg);
+   }
 }
 
 static void handle_power_management(struct work_struct *work)
@@ -2452,6 +2468,7 @@ static void handle_set_tx_pwr(struct work_struct *work)
complete(&hif_thread_comp);
 }
 
+/* Note: 'msg' will be free after using data */
 static void handle_get_tx_pwr(struct work_struct *work)
 {
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
@@ -2471,7 +2488,6 @@ static void handle_get_tx_pwr(struct work_struct *work)
netdev_err(vif->ndev, "Failed to get TX PWR\n");
 
complete(&hif_wait_response);
-   kfree(msg);
complete(&hif_thread_comp);
 }
 
@@ -2523,13 +2539,16 @@ static void timer_scan_cb(struct timer_list *t)
 {
struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer);
struct wilc_vif *vif = hif_drv->scan_timer_vif;
-   struct host_if_msg msg;
+   struct host_if_msg *msg;
+   int result;
 
-   memset(&msg, 0, sizeof(struct host_if_msg));
-   msg.vif = vif;
-   msg.fn = handle_scan_timer;
+   msg = wilc_alloc_work(vif, handle_scan_timer);
+   if (IS_ERR(msg))
+   return;
 
-   wilc_enqueue_cmd(&msg);
+   result = wilc_enqueue_cmd(msg);
+   if (result)
+   kfree(msg);
 }
 
 static void timer_connect_cb(struct timer_list *t)
@@ -2537,19 +2556,22 @@ static void timer_connect_cb(struct timer_list *t)
struct host_if_drv *hif_drv = from_timer(hif_drv, t,
  connect_timer);
struct wilc_vif *vif = hif_drv->connect_timer_vif;
-   struct host_if_msg msg;
+   struct host_if_msg *msg;
+   int result;
 
-   memset(&msg, 0, sizeof(struct host_if_msg));
-   msg.vif = vif;
-   msg.fn = handle_connect_timeout;
+   msg = wilc_alloc_work(vif, handle_connect_timeout);
+   if (IS_ERR(msg

[PATCH 00/12] staging: wilc1000: address TODO item to remove host_if_work()

2018-06-25 Thread Ajay Singh
The current patch series contains changes to address TODO item [1].

[1]. Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the multiplexer
that is currently part of host_if_work(), allowing movement of the
implementation of each message handler into the callsite of the function
that currently queues the 'host_if_msg'.


Ajay Singh (12):
  staging: wilc1000: remove host_if_work() to handle TODO list issue
  staging: wilc1000: remove unused marco related to HIF commands
  staging: wilc1000: move the allocation of cmd out of
wilc_enqueue_cmd()
  staging: wilc1000: added 'work_comp' completion as part of host_if_msg
  staging: wilc1000: remove 'hif_thread_comp' completions
  staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()
  staging: wilc1000: handle freeing of key data in wep add key
  staging: wilc1000: handle freeing of key data in wilc_add_ptk()
  staging: wilc1000: handle freeing of 'key' & 'seq' data in
wilc_add_rx_gtk()
  staging: wilc1000: avoid use of static variable 'inactive_time'
  staging: wilc1000: avoid use of static variable 'rssi'
  staging: wilc1000: updated TODO file

 drivers/staging/wilc1000/TODO |5 -
 drivers/staging/wilc1000/host_interface.c | 1548 +++--
 drivers/staging/wilc1000/host_interface.h |7 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |2 +-
 4 files changed, 799 insertions(+), 763 deletions(-)

-- 
2.7.4

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


[PATCH 10/12] staging: wilc1000: avoid use of static variable 'inactive_time'

2018-06-25 Thread Ajay Singh
Avoided the use of static variable 'inactive_time' and move it as part of
'sta_inactive_t' structure.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2251c39f..f61a20d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -110,6 +110,7 @@ struct set_ip_addr {
 };
 
 struct sta_inactive_t {
+   u32 inactive_time;
u8 mac[6];
 };
 
@@ -198,7 +199,6 @@ static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
 static s8 rssi;
 static u8 set_ip[2][4];
 static u8 get_ip[2][4];
-static u32 inactive_time;
 static u32 clients_count;
 
 static void *host_int_parse_join_bss_param(struct network_info *info);
@@ -1927,7 +1927,7 @@ static void handle_get_inactive_time(struct work_struct 
*work)
 
wid.id = (u16)WID_GET_INACTIVE_TIME;
wid.type = WID_INT;
-   wid.val = (s8 *)&inactive_time;
+   wid.val = (s8 *)&hif_sta_inactive->inactive_time;
wid.size = sizeof(u32);
 
result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
@@ -3095,7 +3095,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 
*mac,
else
wait_for_completion(&msg->work_comp);
 
-   *out_val = inactive_time;
+   *out_val = msg->body.mac_info.inactive_time;
kfree(msg);
 
return result;
-- 
2.7.4

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


[PATCH 11/12] staging: wilc1000: avoid use of static variable 'rssi'

2018-06-25 Thread Ajay Singh
Instead of static variable now allocating the data and passing to
handle_get_rssi() to fill the rssi information.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f61a20d..52c0c10 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -196,7 +196,6 @@ u8 
wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
 
 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
 
-static s8 rssi;
 static u8 set_ip[2][4];
 static u8 get_ip[2][4];
 static u32 clients_count;
@@ -1829,7 +1828,7 @@ static void handle_get_rssi(struct work_struct *work)
 
wid.id = (u16)WID_RSSI;
wid.type = WID_CHAR;
-   wid.val = &rssi;
+   wid.val = msg->body.data;
wid.size = sizeof(char);
 
result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
@@ -3115,14 +3114,21 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
if (IS_ERR(msg))
return PTR_ERR(msg);
 
+   msg->body.data = kzalloc(sizeof(s8), GFP_KERNEL);
+   if (!msg->body.data) {
+   kfree(msg);
+   return -ENOMEM;
+   }
+
result = wilc_enqueue_work(msg);
if (result) {
netdev_err(vif->ndev, "Failed to send get host ch param\n");
} else {
wait_for_completion(&msg->work_comp);
-   *rssi_level = rssi;
+   *rssi_level = *msg->body.data;
}
 
+   kfree(msg->body.data);
kfree(msg);
 
return result;
-- 
2.7.4

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


[PATCH 09/12] staging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()

2018-06-25 Thread Ajay Singh
Handle freeing of memory allocated to keep 'key' & 'seq' in wilc_add_rx_gtk().
Once completion event is received, free the memory allocated for
to avoid missing of free in work function.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2062f4e..2251c39f 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1667,8 +1667,6 @@ static void handle_key(struct work_struct *work)
}
 out_wpa_rx_gtk:
complete(&msg->work_comp);
-   kfree(hif_key->attr.wpa.key);
-   kfree(hif_key->attr.wpa.seq);
break;
 
case WPA_PTK:
@@ -2812,8 +2810,6 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 
*rx_gtk, u8 gtk_key_len,
}
 
wait_for_completion(&msg->work_comp);
-   kfree(msg);
-   return 0;
 
 free_key:
kfree(msg->body.key_info.attr.wpa.key);
-- 
2.7.4

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


[PATCH 12/12] staging: wilc1000: updated TODO file

2018-06-25 Thread Ajay Singh
Item [1] in TODO list is already addressed, so removed it from TODO file.

[1]. Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the
multiplexerthat is currently part of host_if_work(), allowing movement
of the implementation of each message handler into the callsite of the
function that currently queues the 'host_if_msg'.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/TODO | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO
index d123324..725bede 100644
--- a/drivers/staging/wilc1000/TODO
+++ b/drivers/staging/wilc1000/TODO
@@ -1,10 +1,5 @@
 TODO:
 - rework comments and function headers(also coding style)
-- Move handling for each individual members of 'union message_body' out
-  into a separate 'struct work_struct' and completely remove the multiplexer
-  that is currently part of host_if_work(), allowing movement of the
-  implementation of each message handler into the callsite of the function
-  that currently queues the 'host_if_msg'.
 - make spi and sdio components coexist in one build
 - support soft-ap and p2p mode
 - support resume/suspend function
-- 
2.7.4

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