Re: [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv

2018-04-30 Thread Dilger, Andreas
On Apr 30, 2018, at 16:56, Wenwen Wang  wrote:
> 
> In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space
> using Its address, i.e., lumv1 =  If the lmm_magic field of lumv3 is
> LOV_USER_MAGIC_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 

Thanks for the updated patch.

Reviewed-by: Andreas Dilger 

> ---
> 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(, lumv3p, sizeof(lumv3)))
>   return -EFAULT;
> + if (lumv3.lmm_magic != LOV_USER_MAGIC_V3)
> + return -EINVAL;
>   }
> 
>   if (is_root_inode(inode))
> -- 
> 2.7.4
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation







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


Re: [PATCH 09/30] staging: mt7621-mmc: Remove function uffs

2018-04-30 Thread NeilBrown
On Mon, Apr 30 2018, Christian Lütke-Stetzkamp wrote:

> On Mon, Apr 30, 2018 at 08:28:26AM +1000, NeilBrown wrote:
>> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote:
>> 
>> > The function uffs that is implemented by this driver returns the same
>> > values as the kernel function ffs. So the uffs function is removed and
>> > the calls to it are replaced with calls to ffs.
>> 
>> This difference is that uffs receives and returns an "unsigned int".
>> Maybe not a significant difference, but worth mentioning that you
>> noticed it and reasoned that it wasn't significant.
>>
> Yes the type of the uffs function is unsigned int but I tested it for
> all values, that the number returned is the same (in binary form). So
> I don't think that it is significant.
>
>> > @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, 
>> > u32 bs)
>> >  do {  \
>> >volatile unsigned int tv = sdr_read32(reg); \
>> >tv &= ~(field); \
>> > -  tv |= ((val) << (uffs((unsigned int)field) - 1));   \
>> > +  tv |= ((val) << (ffs((unsigned int)field) - 1));\
>> 
>> Given that ffs() takes an "int", it is odd to cast "field" to an
>> unsigned int to pass it.
>> "field" is always a constant int, so no cast is needed.
>
> That's correct, but I took it that way, because that is how the mtk-sd
> driver does it. This makes the similarities more significant, but if
> you like I'll change it.

Ahhh, OK.  I guess it makes sense to say "bug-for-bug" (sort-of)
compatible with the mtk-sd driver code.  I'll try to remember to fix
that up once this all lands.

Thanks,
NeilBrown


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


[PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv

2018-04-30 Thread Wenwen Wang
In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space
using Its address, i.e., lumv1 =  If the lmm_magic field of lumv3 is
LOV_USER_MAGIC_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(, 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: [PATCH] staging: luster: llite: fix a potential missing-check bug when copying lumv

2018-04-30 Thread Wenwen Wang
On Mon, Apr 30, 2018 at 5:38 PM, Dilger, Andreas
 wrote:
> On Apr 29, 2018, at 07:20, Greg Kroah-Hartman  
> wrote:
>>
>> On Sat, Apr 28, 2018 at 04:04:25PM +, Dilger, Andreas wrote:
>>> On Apr 27, 2018, at 17:45, Wenwen Wang  wrote:
 [PATCH] staging: luster: llite: fix potential missing-check bug when 
 copying lumv
>>>
>>> (typo) s/luster/lustre/
>>>
 In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space
 using Its address, i.e., lumv1 =  If the lmm_magic field of lumv3 is
 LOV_USER_MAGIV_V3, lumv3 will be modified by the second copy from the user
>>>
>>> (typo) s/MAGIV/MAGIC/
>>>
 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 isn't a serious bug in the end.  The LOV_USER_MAGIC_V3 check just 
>>> copies
>>> a bit more data from userspace (the lmm_pool field).  It would be more of a
>>> problem if the reverse was possible (copy smaller V1 buffer, but change the
>>> magic to LOV_USER_MAGIC_V3 afterward), but this isn't possible since the 
>>> second
>>> copy is not done if there is a V1 magic.  If the user changes from V3 magic
>>> to V1 in a racy manner it means less data will be used than copied, which
>>> is harmless.
>>>
 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.
>>>
>>> This isn't a bad idea in any case, since it verifies the data copied from
>>> userspace is still valid.
>>
>> So you agree with this patch?  Or do not?
>>
>> confused,
>
> I don't think it fixes a real bug, but it makes the code a bit more clear,
> so I'm OK to land it (with minor corrections to commit message per above).
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation
>

Thanks! I will re-submit the patch with the corrected commit message.

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


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

2018-04-30 Thread Dilger, Andreas
On Apr 29, 2018, at 07:20, Greg Kroah-Hartman  
wrote:
> 
> On Sat, Apr 28, 2018 at 04:04:25PM +, Dilger, Andreas wrote:
>> On Apr 27, 2018, at 17:45, Wenwen Wang  wrote:
>>> [PATCH] staging: luster: llite: fix potential missing-check bug when 
>>> copying lumv
>> 
>> (typo) s/luster/lustre/
>> 
>>> In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space
>>> using Its address, i.e., lumv1 =  If the lmm_magic field of lumv3 is
>>> LOV_USER_MAGIV_V3, lumv3 will be modified by the second copy from the user
>> 
>> (typo) s/MAGIV/MAGIC/
>> 
>>> 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 isn't a serious bug in the end.  The LOV_USER_MAGIC_V3 check just copies
>> a bit more data from userspace (the lmm_pool field).  It would be more of a
>> problem if the reverse was possible (copy smaller V1 buffer, but change the
>> magic to LOV_USER_MAGIC_V3 afterward), but this isn't possible since the 
>> second
>> copy is not done if there is a V1 magic.  If the user changes from V3 magic
>> to V1 in a racy manner it means less data will be used than copied, which
>> is harmless.
>> 
>>> 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.
>> 
>> This isn't a bad idea in any case, since it verifies the data copied from
>> userspace is still valid.
> 
> So you agree with this patch?  Or do not?
> 
> confused,

I don't think it fixes a real bug, but it makes the code a bit more clear,
so I'm OK to land it (with minor corrections to commit message per above).

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation







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


Re: [PATCH 00/30] staging: mt7621-mmc: Next cleanups

2018-04-30 Thread Christian Lütke-Stetzkamp
On Mon, Apr 30, 2018 at 08:57:38AM +1000, NeilBrown wrote:
> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote:
> 
> > Here are the next cleanups for the mt7621-mmc driver. It contains the
> > removal of some unused things, the removal of the non DMA code and
> > always using linked DMA mode together with some minor cleanups.
> 
> Thanks for these.
> As mentioned separately I found one bug, but the relevant code becomes
> inactive and can now be removed.

I totally overlooked the part of the function, where the bug is, was
already moving towards the removal, sorry. The removal will be in the
next series.

> I'm happy for this to go in as-is with a couple of fix-ups to come in
> the next batch.
> 
> I've tested and I can still access my sd card with no apparent issues.
> 
>  Reviewed-by: NeilBrown 

Thanks for your fast review,
Christian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 24/30] staging: mt7621-mmc: Inline function msdc_set_blknum

2018-04-30 Thread Christian Lütke-Stetzkamp
On Mon, Apr 30, 2018 at 08:51:45AM +1000, NeilBrown wrote:
> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote:
> 
> > The function msdc_set_blknum consists of one (real) line of code and
> > is only called once, so inline it makes the code shorter and more
> > readable.
> >
> > Signed-off-by: Christian Lütke-Stetzkamp 
> > ---
> >  drivers/staging/mt7621-mmc/sd.c | 10 +-
> >  1 file changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/mt7621-mmc/sd.c 
> > b/drivers/staging/mt7621-mmc/sd.c
> > index c9f0180f3220..00c862b02419 100644
> > --- a/drivers/staging/mt7621-mmc/sd.c
> > +++ b/drivers/staging/mt7621-mmc/sd.c
> > @@ -1182,14 +1182,6 @@ static void msdc_dma_setup(struct msdc_host *host, 
> > struct msdc_dma *dma,
> > msdc_dma_config(host, dma);
> >  }
> >  
> > -/* set block number before send command */
> > -static void msdc_set_blknum(struct msdc_host *host, u32 blknum)
> > -{
> > -   void __iomem *base = host->base;
> > -
> > -   sdr_write32(SDC_BLK_NUM, blknum);
> > -}
> > -
> 
> This change is correct, but the reason isn't obvious.
> In mt6575_sd.h are:
> 
> #define SDC_BLK_NUM REG_ADDR(SDC_BLK_NUM)
> 
> #define REG_ADDR(x) (base + OFFSET_##x)
> 
> So the above becomes
> 
>sdr_write32((base + OFFSET_SDC_BLK_NUM), blknum);
> 
> so the base is important.
> 
> msdc_do_request() starts with
> 
>   void __iomem *base = host->base;
> 
> and never changes host.  So that "base" that is used in the new code is
> the same as the "base" used in the old code.
> 
> Ugh.. what a horrible way to write code!

Yes it is horrible and in a future cleanup I will remove all the
things depending on that "magic" base variable. But currently this is
the common (bad) idiom all over this driver and I would like to
address them all at once.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 11/30] staging: mt7621-mmc: Replace macro sdr_get_field with function

2018-04-30 Thread Christian Lütke-Stetzkamp
On Mon, Apr 30, 2018 at 08:33:07AM +1000, NeilBrown wrote:
> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote:
> 
> > Currently sdr_get_field is a macro, to bring the code in line with the
> > upstream driver mtk-sd, it is changed to a function.
> >
> > Signed-off-by: Christian Lütke-Stetzkamp 
> > ---
> >  drivers/staging/mt7621-mmc/mt6575_sd.h | 10 +-
> >  drivers/staging/mt7621-mmc/sd.c| 14 --
> >  2 files changed, 13 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
> > b/drivers/staging/mt7621-mmc/mt6575_sd.h
> > index 90b4ee6b396b..195c7333f77d 100644
> > --- a/drivers/staging/mt7621-mmc/mt6575_sd.h
> > +++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
> > @@ -980,10 +980,10 @@ static inline void sdr_set_field(void __iomem *reg, 
> > u32 field, u32 val)
> > writel(tv, reg);
> >  }
> >  
> > -#define sdr_get_field(reg, field, val) 
> > \
> > -do {   \
> > -   volatile unsigned int tv = sdr_read32(reg); \
> > -   val = ((tv & (field)) >> (ffs((unsigned int)field) - 1));   \
> > -} while (0)
> > +static inline void sdr_get_field(void __iomem *reg, u32 field, u32 *val)
> > +{
> > +   unsigned int tv = readl(reg);
> > +   *val = ((tv & field) >> (ffs((unsigned int)field) - 1));
> > +}
> 
> Converting this to a function it good, but it should return val rather
> than set *val.

Yes, I completely agree, that your proposal is easier to understand,
again the reason for me to choose the current version is the current
code in the mtk-sd driver.

> >  
> >  #endif
> > diff --git a/drivers/staging/mt7621-mmc/sd.c 
> > b/drivers/staging/mt7621-mmc/sd.c
> > index 00dacf8c9625..f4da48a5772b 100644
> > --- a/drivers/staging/mt7621-mmc/sd.c
> > +++ b/drivers/staging/mt7621-mmc/sd.c
> > @@ -1577,8 +1577,8 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, 
> > struct mmc_command *cmd)
> >==*/
> >  
> > // save the previous tune result
> > -   sdr_get_field(MSDC_IOCON,MSDC_IOCON_RSPL,orig_rsmpl);
> > -   sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, orig_rrdly);
> > +   sdr_get_field(MSDC_IOCON,MSDC_IOCON_RSPL,_rsmpl);
> > +   sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY, _rrdly);
> 
> So this becomes
> 
> > +   orig_rsmpl = sdr_get_field(MSDC_IOCON,MSDC_IOCON_RSPL);
> > +   orig_rrdly = sdr_get_field(MSDC_PAD_TUNE, MSDC_PAD_TUNE_CMDRRDLY);
> 
> which is much easier to understand at first glance.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH][staging-next] staging: rtl8723bs: spelling mistake: "dismatch" -> "mismatch"

2018-04-30 Thread Bastien Nocera
On Mon, 2018-04-30 at 15:19 +0100, Colin King wrote:
> +   P2P_STATE_RECV_INVITE_REQ_DISMATCH =
> 17,/*  receiving the P2P Inviation request and mismatch
> with the profile. */

Might as well fix the "inviation" as well, no? :)

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


Re: [PATCH 09/30] staging: mt7621-mmc: Remove function uffs

2018-04-30 Thread Christian Lütke-Stetzkamp
On Mon, Apr 30, 2018 at 08:28:26AM +1000, NeilBrown wrote:
> On Sun, Apr 29 2018, Christian Lütke-Stetzkamp wrote:
> 
> > The function uffs that is implemented by this driver returns the same
> > values as the kernel function ffs. So the uffs function is removed and
> > the calls to it are replaced with calls to ffs.
> 
> This difference is that uffs receives and returns an "unsigned int".
> Maybe not a significant difference, but worth mentioning that you
> noticed it and reasoned that it wasn't significant.
>
Yes the type of the uffs function is unsigned int but I tested it for
all values, that the number returned is the same (in binary form). So
I don't think that it is significant.

> > @@ -1004,13 +975,13 @@ static inline void sdr_clr_bits(void __iomem *reg, 
> > u32 bs)
> >  do {   \
> > volatile unsigned int tv = sdr_read32(reg); \
> > tv &= ~(field); \
> > -   tv |= ((val) << (uffs((unsigned int)field) - 1));   \
> > +   tv |= ((val) << (ffs((unsigned int)field) - 1));\
> 
> Given that ffs() takes an "int", it is odd to cast "field" to an
> unsigned int to pass it.
> "field" is always a constant int, so no cast is needed.

That's correct, but I took it that way, because that is how the mtk-sd
driver does it. This makes the similarities more significant, but if
you like I'll change it.

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


[PATCH][staging-next][V2] staging: rtl8723bs: fix spelling mistakes: "dismatch" and "Inviation"

2018-04-30 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistakes in message text and comments

"dismatch" -> "mismatch"
"Inviation" -> "Invitation"

Signed-off-by: Colin Ian King 
---

V2: Add Inviation fix as noted by Bastien Nocera
---
 drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c |  2 +-
 drivers/staging/rtl8723bs/include/wifi.h| 12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c 
b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
index 33610d39333f..828bc0d045a0 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
@@ -2198,7 +2198,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
BTC_MSG_ALGORITHM,
ALGO_TRACE_FW_DETAIL,
(
-   "[BTCoex], PsTdma type dismatch!!!, curPsTdma 
=%d, recordPsTdma =%d\n",
+   "[BTCoex], PsTdma type mismatch!!!, curPsTdma 
=%d, recordPsTdma =%d\n",
pCoexDm->curPsTdma,
pCoexDm->psTdmaDuAdjType
)
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 530d698f50d9..d53a4483ea9f 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -976,7 +976,7 @@ enum HT_CAP_AMPDU_FACTOR {
 #defineP2P_STATUS_FAIL_INCOMPATIBLE_PROVSION   0x0A
 #defineP2P_STATUS_FAIL_USER_REJECT 0x0B
 
-/* Value of Inviation Flags Attribute */
+/* Value of Invitation Flags Attribute */
 #defineP2P_INVITATION_FLAGS_PERSISTENT BIT(0)
 
 #defineDMP_P2P_DEVCAP_SUPPORT  (P2P_DEVCAP_SERVICE_DISCOVERY | \
@@ -1082,15 +1082,15 @@ enum P2P_STATE {
P2P_STATE_GONEGO_ING = 9,   
/*  Doing the group owner negoitation handshake */
P2P_STATE_GONEGO_OK = 10,   
/*  finish the group negoitation handshake with success */
P2P_STATE_GONEGO_FAIL = 11, /*  
finish the group negoitation handshake with failure */
-   P2P_STATE_RECV_INVITE_REQ_MATCH = 12,   /*  receiving the 
P2P Inviation request and match with the profile. */
+   P2P_STATE_RECV_INVITE_REQ_MATCH = 12,   /*  receiving the 
P2P Invitation request and match with the profile. */
P2P_STATE_PROVISIONING_ING = 13,/*  
Doing the P2P WPS */
P2P_STATE_PROVISIONING_DONE = 14,   /*  Finish 
the P2P WPS */
P2P_STATE_TX_INVITE_REQ = 15,   /*  
Transmit the P2P Invitation request */
P2P_STATE_RX_INVITE_RESP_OK = 16,   /*  
Receiving the P2P Invitation response */
-   P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*  receiving the 
P2P Inviation request and dismatch with the profile. */
-   P2P_STATE_RECV_INVITE_REQ_GO = 18,  /*  
receiving the P2P Inviation request and this wifi is GO. */
-   P2P_STATE_RECV_INVITE_REQ_JOIN = 19,/*  
receiving the P2P Inviation request to join an existing P2P Group. */
-   P2P_STATE_RX_INVITE_RESP_FAIL = 20, /*  
recveing the P2P Inviation response with failure */
+   P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*  receiving the 
P2P Invitation request and mismatch with the profile. */
+   P2P_STATE_RECV_INVITE_REQ_GO = 18,  /*  
receiving the P2P Invitation request and this wifi is GO. */
+   P2P_STATE_RECV_INVITE_REQ_JOIN = 19,/*  
receiving the P2P Invitation request to join an existing P2P Group. */
+   P2P_STATE_RX_INVITE_RESP_FAIL = 20, /*  
recveing the P2P Invitation response with failure */
P2P_STATE_RX_INFOR_NOREADY = 21,/*  receiving 
p2p negoitation response with information is not available */
P2P_STATE_TX_INFOR_NOREADY = 22,/*  sending p2p 
negoitation response with information is not available */
 };
-- 
2.17.0

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


Re: [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access

2018-04-30 Thread Ajay Singh
Reviewed-by: Ajay Singh 

On Mon, 30 Apr 2018 07:50:40 -0500
"Gustavo A. R. Silva"  wrote:

> If i < slot_id is initially true then it will remain true. Also,
> as i is being decremented it will end up accessing memory out of
> bounds.
> 
> Fix this by incrementing *i* instead of decrementing it.

Nice catch!
Thanks for submitting the changes.

> 
> Addresses-Coverity-ID: 1468454 ("Infinite loop")
> Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free
> kmalloc memory on failure cases")
> Signed-off-by: Gustavo A. R. Silva 
> ---
> 
> BTW... at first sight it seems to me that variables slot_id
> and i should be of type unsigned instead of signed.

Yes, 'slot_id' & 'i' can be changed to unsigned int.

> 
>  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index
> 3ca0c97..67104e8 100644 ---
> a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -608,7
> +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request
> *request, out_free:
>  
> - for (i = 0; i < slot_id ; i--)
> + for (i = 0; i < slot_id; i++)
>   kfree(ntwk->net_info[i].ssid);
>  
>   kfree(ntwk->net_info);



Regards,
Ajay

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


[PATCH][staging-next] staging: rtl8723bs: spelling mistake: "dismatch" -> "mismatch"

2018-04-30 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in message text and comment

Signed-off-by: Colin Ian King 
---
 drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c | 2 +-
 drivers/staging/rtl8723bs/include/wifi.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c 
b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
index 33610d39333f..828bc0d045a0 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
@@ -2198,7 +2198,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
BTC_MSG_ALGORITHM,
ALGO_TRACE_FW_DETAIL,
(
-   "[BTCoex], PsTdma type dismatch!!!, curPsTdma 
=%d, recordPsTdma =%d\n",
+   "[BTCoex], PsTdma type mismatch!!!, curPsTdma 
=%d, recordPsTdma =%d\n",
pCoexDm->curPsTdma,
pCoexDm->psTdmaDuAdjType
)
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 530d698f50d9..c56f887df101 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -1087,7 +1087,7 @@ enum P2P_STATE {
P2P_STATE_PROVISIONING_DONE = 14,   /*  Finish 
the P2P WPS */
P2P_STATE_TX_INVITE_REQ = 15,   /*  
Transmit the P2P Invitation request */
P2P_STATE_RX_INVITE_RESP_OK = 16,   /*  
Receiving the P2P Invitation response */
-   P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*  receiving the 
P2P Inviation request and dismatch with the profile. */
+   P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*  receiving the 
P2P Inviation request and mismatch with the profile. */
P2P_STATE_RECV_INVITE_REQ_GO = 18,  /*  
receiving the P2P Inviation request and this wifi is GO. */
P2P_STATE_RECV_INVITE_REQ_JOIN = 19,/*  
receiving the P2P Inviation request to join an existing P2P Group. */
P2P_STATE_RX_INVITE_RESP_FAIL = 20, /*  
recveing the P2P Inviation response with failure */
-- 
2.17.0

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


[PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication

2018-04-30 Thread Sergio Paracuellos
Local variable 'connect_code' is declared as unsigned short in
hostif_connect_indication function. Its value is got calling
get_word which returns an 'u16' so change its type to u16
which is preferred.

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 d4ce986..fde5b6e 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -655,7 +655,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
 static
 void hostif_connect_indication(struct ks_wlan_private *priv)
 {
-   unsigned short connect_code;
+   u16 connect_code;
unsigned int tmp = 0;
unsigned int old_status = priv->connect_status;
struct net_device *netdev = priv->net_dev;
-- 
2.7.4

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


[PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm

2018-04-30 Thread Sergio Paracuellos
Local variable 'result_code' is declared as unsigned int in
hostif_bss_scan_confirm function. Its value is got calling
get_dword which returns an 'u32' so change its type to u32
which is preferred

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 fde5b6e..cf33a1c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -845,7 +845,7 @@ void hostif_associate_indication(struct ks_wlan_private 
*priv)
 static
 void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
 {
-   unsigned int result_code;
+   u32 result_code;
struct net_device *dev = priv->net_dev;
union iwreq_data wrqu;
 
-- 
2.7.4

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


[PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function

2018-04-30 Thread Sergio Paracuellos
Handle invalid values first and assign good ones at the
end if it is the case. This makes code simplier.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 53288c8..62a9d55 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1960,17 +1960,14 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
 
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
-   /* for SLEEP MODE */
-   if (*uwrq == D_11B_ONLY_MODE) { /* 0 */
-   priv->reg.phy_type = D_11B_ONLY_MODE;
-   } else if (*uwrq == D_11G_ONLY_MODE) {  /* 1 */
-   priv->reg.phy_type = D_11G_ONLY_MODE;
-   } else if (*uwrq == D_11BG_COMPATIBLE_MODE) {   /* 2 */
-   priv->reg.phy_type = D_11BG_COMPATIBLE_MODE;
-   } else {
+
+   if (*uwrq != D_11B_ONLY_MODE &&
+   *uwrq != D_11G_ONLY_MODE &&
+   *uwrq != D_11BG_COMPATIBLE_MODE)
return -EINVAL;
-   }
 
+   /* for SLEEP MODE */
+   priv->reg.phy_type = *uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS;/* Call commit handler */
 }
-- 
2.7.4

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


[PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function

2018-04-30 Thread Sergio Paracuellos
This commit refactor a bit ks_get_wireless_stats using
ternary operator for return code. It also change a comment
to use preferred style.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 30f8cee..ee164ab 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1743,14 +1743,11 @@ static struct iw_statistics 
*ks_get_wireless_stats(struct net_device *dev)
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_statistics *wstats = >wstats;
 
-   if (!atomic_read(_phyinfo)) {
-   if (priv->dev_state < DEVICE_STATE_READY)
-   return NULL;/* not finished initialize */
-   else
-   return wstats;
-   }
+   if (!atomic_read(_phyinfo))
+   return (priv->dev_state < DEVICE_STATE_READY) ? NULL : wstats;
 
-   /* Packets discarded in the wireless adapter due to wireless
+   /*
+* Packets discarded in the wireless adapter due to wireless
 * specific problems
 */
wstats->discard.nwid = 0;   /* Rx invalid nwid  */
-- 
2.7.4

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


[PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function

2018-04-30 Thread Sergio Paracuellos
This commit refactors ks_wlan_set_mlme function changing
switch-case block for more simple if paths improving
readability.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 62a9d55..30f8cee 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1787,23 +1787,20 @@ static int ks_wlan_set_mlme(struct net_device *dev,
 {
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
-   __u32 mode;
+   __u32 mode = 1;
 
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
 
-   /* for SLEEP MODE */
-   switch (mlme->cmd) {
-   case IW_MLME_DEAUTH:
-   if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
-   return 0;
-   /* fall through */
-   case IW_MLME_DISASSOC:
-   mode = 1;
-   return ks_wlan_set_stop_request(dev, NULL, , NULL);
-   default:
-   return -EOPNOTSUPP; /* Not Support */
-   }
+   if (mlme->cmd != IW_MLME_DEAUTH &&
+   mlme->cmd != IW_MLME_DISASSOC)
+   return -EOPNOTSUPP;
+
+   if (mlme->cmd == IW_MLME_DEAUTH &&
+   mlme->reason_code == WLAN_REASON_MIC_FAILURE)
+   return 0;
+
+   return ks_wlan_set_stop_request(dev, NULL, , NULL);
 }
 
 static int ks_wlan_get_firmware_version(struct net_device *dev,
-- 
2.7.4

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


[PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function

2018-04-30 Thread Sergio Paracuellos
This commit refactors ks_wlan_set_sleep_mode function
avoiding to use switch-case statement ans using simple
if logic to handle invalid values first. This simplifies
data paths as well as improves readability.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index a5401db..53288c8 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device 
*dev,
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
-   if (*uwrq == SLP_SLEEP) {
-   priv->sleep_mode = *uwrq;
-   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
-
-   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
-   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
-
-   } else if (*uwrq == SLP_ACTIVE) {
-   priv->sleep_mode = *uwrq;
-   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
-   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
-   } else {
+   if (*uwrq != SLP_SLEEP &&
+   *uwrq != SLP_ACTIVE) {
netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq);
return -EINVAL;
}
 
+   priv->sleep_mode = *uwrq;
+   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
+
+   if (*uwrq == SLP_SLEEP)
+   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
+
+   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
+
return 0;
 }
 
-- 
2.7.4

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


[PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch

2018-04-30 Thread Sergio Paracuellos
WLAN_EID_DS_PARAMS case inside switch case is just doing nothing
and it is located inside other cases. There is a place inside
the switch with other don't do anything cases are located. Move
this to that place.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 366801f..8bd2797 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -232,8 +232,6 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
(RATE_SET_MAX_SIZE - ap->rate_set.size);
}
break;
-   case WLAN_EID_DS_PARAMS:
-   break;
case WLAN_EID_RSN:
ap->rsn_ie.id = *bp;
ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
@@ -247,7 +245,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
  ap->wpa_ie.body);
}
break;
-
+   case WLAN_EID_DS_PARAMS:
case WLAN_EID_FH_PARAMS:
case WLAN_EID_CF_PARAMS:
case WLAN_EID_TIM:
-- 
2.7.4

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


[PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm

2018-04-30 Thread Sergio Paracuellos
This commit changes types for local variables declared in
hostif_phy_information_confirm function to use the preferred
one 'u8' and 'u32'. Its values are get using get_byte and get_dword
functions which returns 'u8' and 'u32' so it makes sense.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index cf33a1c..7b6a385 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -866,10 +866,10 @@ static
 void hostif_phy_information_confirm(struct ks_wlan_private *priv)
 {
struct iw_statistics *wstats = >wstats;
-   unsigned char rssi, signal, noise;
-   unsigned char link_speed;
-   unsigned int transmitted_frame_count, received_fragment_count;
-   unsigned int failed_count, fcs_error_count;
+   u8 rssi, signal, noise;
+   u8 link_speed;
+   u32 transmitted_frame_count, received_fragment_count;
+   u32 failed_count, fcs_error_count;
 
rssi = get_byte(priv);
signal = get_byte(priv);
-- 
2.7.4

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


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

2018-04-30 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, , 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, , 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, , 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,
   >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,
   >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,
   >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 21/47] staging: ks7010: use ether_addr_copy in get_current_ap

2018-04-30 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 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm

2018-04-30 Thread Sergio Paracuellos
This commit simplify conditional paths in LOCAL_EEPROM_SUM case
inside hostif_mib_get_confirm function. It change logic to handle
invalid values first and assign good ones at the end if it is the
case.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 7a51123..3db5679 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -504,18 +504,15 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
break;
case LOCAL_EEPROM_SUM:
memcpy(>eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
-   if (priv->eeprom_sum.type == 0) {
-   priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
-   } else if (priv->eeprom_sum.type == 1) {
-   if (priv->eeprom_sum.result == 0) {
-   priv->eeprom_checksum = EEPROM_NG;
-   netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
-   } else if (priv->eeprom_sum.result == 1) {
-   priv->eeprom_checksum = EEPROM_OK;
-   }
-   } else {
+   if (priv->eeprom_sum.type != 0 &&
+   priv->eeprom_sum.type != 1) {
netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
+   return;
}
+   priv->eeprom_checksum = (priv->eeprom_sum.type == 0) ?
+EEPROM_CHECKSUM_NONE :
+(priv->eeprom_sum.result == 0) ?
+EEPROM_NG : EEPROM_OK;
break;
default:
netdev_err(priv->net_dev, "mib_attribute=%08x\n",
-- 
2.7.4

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


[PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs

2018-04-30 Thread Sergio Paracuellos
Local variable 'byte' in ks7010_sdio_init_irqs is declared as
unsigned char and can be declared as u8 which is preferred.
It is being used in calls to ks7010_sdio_writeb which is already
expected an u8.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index db954f1..9085ed7 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -904,7 +904,7 @@ static int ks7010_sdio_setup_irqs(struct sdio_func *func)
 static void ks7010_sdio_init_irqs(struct sdio_func *func,
  struct ks_wlan_private *priv)
 {
-   unsigned char byte;
+   u8 byte;
int ret;
 
/*
-- 
2.7.4

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


[PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start

2018-04-30 Thread Sergio Paracuellos
Instead of use memcpy for copying ethernet addresses, use
ether_addr_copy that do the same.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index bb8ec04..a5401db 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2633,7 +2633,7 @@ int ks_wlan_net_start(struct net_device *dev)
timer_setup(_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
 
/* dummy address set */
-   memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
+   ether_addr_copy(priv->eth_addr, dummy_addr);
ether_addr_copy(dev->dev_addr, priv->eth_addr);
 
/* The ks_wlan-specific entries in the device structure. */
-- 
2.7.4

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


[PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct

2018-04-30 Thread Sergio Paracuellos
Field rsn_enabled included in wpa_status struct is declared as
unsigned int but it is only be set using 0 and 1 values and
in conditional if code is just being used as a boolean. Change
its type to be a boolean.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 0ab2e1b..8cd3dac 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2296,7 +2296,7 @@ static inline void hostif_sme_init(struct ks_wlan_private 
*priv)
 static inline void hostif_wpa_init(struct ks_wlan_private *priv)
 {
memset(>wpa, 0, sizeof(priv->wpa));
-   priv->wpa.rsn_enabled = 0;
+   priv->wpa.rsn_enabled = false;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index dd42692..655f1e3 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -338,7 +338,7 @@ struct mic_failure {
 
 struct wpa_status {
int wpa_enabled;
-   unsigned int rsn_enabled;
+   bool rsn_enabled;
int version;
int pairwise_suite; /* unicast cipher */
int group_suite;/* multicast cipher */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 838db49..8b4a1ed6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1372,14 +1372,14 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
case IW_AUTH_WPA_VERSION_DISABLED:
priv->wpa.version = value;
if (priv->wpa.rsn_enabled)
-   priv->wpa.rsn_enabled = 0;
+   priv->wpa.rsn_enabled = false;
priv->need_commit |= SME_RSN;
break;
case IW_AUTH_WPA_VERSION_WPA:
case IW_AUTH_WPA_VERSION_WPA2:
priv->wpa.version = value;
if (!(priv->wpa.rsn_enabled))
-   priv->wpa.rsn_enabled = 1;
+   priv->wpa.rsn_enabled = true;
priv->need_commit |= SME_RSN;
break;
default:
-- 
2.7.4

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


[PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody

2018-04-30 Thread Sergio Paracuellos
This commit changes custom implementation of CIRC_CNT_TO_END.
Just use the linux kernel header one to simplify code.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 359187e..7a51123 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -6,6 +6,7 @@
  *   Copyright (C) 2009 Renesas Technology Corp.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -26,9 +27,8 @@ static inline void inc_smeqtail(struct ks_wlan_private *priv)
 
 static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv)
 {
-   unsigned int sme_cnt = priv->sme_i.qtail - priv->sme_i.qhead;
-
-   return (sme_cnt + SME_EVENT_BUFF_SIZE) % SME_EVENT_BUFF_SIZE;
+   return CIRC_CNT_TO_END(priv->sme_i.qhead, priv->sme_i.qtail,
+  SME_EVENT_BUFF_SIZE);
 }
 
 static inline u8 get_byte(struct ks_wlan_private *priv)
-- 
2.7.4

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


[PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file

2018-04-30 Thread Sergio Paracuellos
Header file ks_wlan.h has a lot of nonsense comments along
the different declarations included on it. Most of them are
just the same as the variable name. Just remove them all.

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

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index ad349ef..fb080fe 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -9,35 +9,35 @@
 #ifndef _KS_WLAN_H
 #define _KS_WLAN_H
 
-#include   /* struct atomic_t */
+#include 
 #include 
-#include   /* struct completion */
-#include/* struct net_device_stats,  struct sk_buff */
-#include/* wait_queue_head_t */
-#include /* spinlock_t */
+#include 
+#include 
+#include 
+#include 
 #include 
 
 struct ks_wlan_parameter {
-   u8 operation_mode;  /* Operation Mode */
-   u8 channel; /*  Channel */
-   u8 tx_rate; /*  Transmit Rate */
+   u8 operation_mode;
+   u8 channel;
+   u8 tx_rate;
struct {
u8 size;
u8 body[16];
} rate_set;
-   u8 bssid[ETH_ALEN]; /* BSSID */
+   u8 bssid[ETH_ALEN];
struct {
u8 size;
u8 body[32 + 1];
-   } ssid; /*  SSID */
-   u8 preamble;/*  Preamble */
+   } ssid;
+   u8 preamble;
u8 power_mgmt;
-   u32 scan_type;  /*  AP List Scan Type */
+   u32 scan_type;
 #define BEACON_LOST_COUNT_MIN 0
 #define BEACON_LOST_COUNT_MAX 65535
-   u32 beacon_lost_count;  /*  Beacon Lost Count */
-   u32 rts;/*  RTS Threashold */
-   u32 fragment;   /*  Fragmentation Threshold */
+   u32 beacon_lost_count;
+   u32 rts;
+   u32 fragment;
u32 privacy_invoked;
u32 wep_index;
struct {
@@ -45,9 +45,9 @@ struct ks_wlan_parameter {
u8 val[13 * 2 + 1];
} wep_key[4];
u16 authenticate_type;
-   u16 phy_type;   /* 11b/11g/11bg mode type */
-   u16 cts_mode;   /* for 11g/11bg mode cts mode */
-   u16 phy_info_timer; /* phy information timer */
+   u16 phy_type;
+   u16 cts_mode;
+   u16 phy_info_timer;
 };
 
 enum {
@@ -155,7 +155,7 @@ enum {
SME_WEP_SET_CONFIRM,
SME_TERMINATE,
 
-   SME_EVENT_SIZE  /* end */
+   SME_EVENT_SIZE
 };
 
 /* SME Status */
@@ -330,7 +330,7 @@ struct mic_failure {
u16 failure;/* MIC Failure counter 0 or 1 or 2 */
u16 counter;/* 1sec counter 0-60 */
u32 last_failure_time;
-   int stop;   /* stop flag */
+   int stop;
 };
 
 struct wpa_status {
@@ -339,7 +339,7 @@ struct wpa_status {
int version;
int pairwise_suite; /* unicast cipher */
int group_suite;/* multicast cipher */
-   int key_mgmt_suite; /* authentication key management suite */
+   int key_mgmt_suite;
int auth_alg;
int txkey;
struct wpa_key key[WPA_KEY_INDEX_MAX];
@@ -485,17 +485,16 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
 
-   bool mac_address_valid; /* Mac Address Status */
+   bool mac_address_valid;
 
int dev_state;
 
struct sk_buff *skb;
unsigned int cur_rx;/* Index into the Rx buffer of next Rx pkt. */
-   /* spinlock_t lock; */
 #define FORCE_DISCONNECT0x8000
 #define CONNECT_STATUS_MASK 0x7FFF
-   u32 connect_status; /* connect status */
-   int infra_status;   /* Infractructure status */
+   u32 connect_status;
+   int infra_status;
u8 scan_ssid_len;
u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
struct local_gain gain;
-- 
2.7.4

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


[PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check

2018-04-30 Thread Sergio Paracuellos
Local variable 'event' is declared as unsigned short in hostif_event_check
function. Its value is got calling get_word which returns an 'u16'
so change its type to u16 which is preferred.

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 3db5679..1a034d5 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -912,7 +912,7 @@ void hostif_mic_failure_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_event_check(struct ks_wlan_private *priv)
 {
-   unsigned short event;
+   u16 event;
 
event = get_word(priv);
switch (event) {
-- 
2.7.4

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


[PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c

2018-04-30 Thread Sergio Paracuellos
Fix some checkpatch complains about long lines in some
parts of the code. It also fix some lines where spaces
instead of tabs were inserted.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 1a59218..644a083 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -153,7 +153,8 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
if (is_connect_status(priv->connect_status)) {
ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
-  "IWEVENT: connect bssid=%pM\n", 
wrqu.ap_addr.sa_data);
+  "IWEVENT: connect bssid=%pM\n",
+  wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, , NULL);
}
netdev_dbg(priv->net_dev, "Link AP\n"
@@ -254,7 +255,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
case WLAN_EID_ERP_INFO:
break;
default:
-   netdev_err(priv->net_dev, "unknown Element ID=%d\n", 
*bp);
+   netdev_err(priv->net_dev,
+  "unknown Element ID=%d\n", *bp);
break;
}
 
@@ -322,7 +324,8 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
mic_failure->failure = 2;
mic_failure->counter =
(uint16_t)((now - 
mic_failure->last_failure_time) / HZ);
-   if (!mic_failure->counter)  /*  range 1-60 
*/
+   /*  range 1-60 */
+   if (!mic_failure->counter)
mic_failure->counter = 1;
}
priv->wpa.mic_failure.last_failure_time = now;
@@ -712,7 +715,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
int i;
struct ap_info *ap_info;
 
-   netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
+   netdev_dbg(priv->net_dev,
+  "scan_ind_count = %d\n", priv->scan_ind_count);
ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
@@ -849,8 +853,8 @@ void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
union iwreq_data wrqu;
 
result_code = get_dword(priv);
-   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", 
result_code,
-  priv->scan_ind_count);
+   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n",
+  result_code, priv->scan_ind_count);
 
priv->sme_i.sme_flag &= ~SME_AP_SCAN;
hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
@@ -903,7 +907,8 @@ void hostif_phy_information_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
 {
-   netdev_dbg(priv->net_dev, "mic_failure=%u\n", 
priv->wpa.mic_failure.failure);
+   netdev_dbg(priv->net_dev, "mic_failure=%u\n",
+  priv->wpa.mic_failure.failure);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
 }
 
@@ -1050,8 +1055,9 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
/* skb check */
eth = (struct ethhdr *)skb->data;
if (!ether_addr_equal(>eth_addr[0], eth->h_source)) {
-   netdev_err(priv->net_dev, "invalid mac address !!\n");
-   netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", 
eth->h_source);
+   netdev_err(priv->net_dev,
+  "Invalid mac address: ethernet->h_source=%pM\n",
+  eth->h_source);
ret = -ENXIO;
goto err_kfree;
}
@@ -1066,7 +1072,6 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
/* EtherType/Length check */
if (*(buffer + 1) + (*buffer << 8) > 1500) {
/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
-   /* netdev_dbg(priv->net_dev, "Send [SNAP]Type 
%x\n",ProtocolEAP); */
/* SAP/CTL/OUI(6 byte) add */
*p++ = 0xAA;/* DSAP */
*p++ = 0xAA;/* SSAP */
@@ -1149,7 +1154,8 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
priv->wpa.mic_failure.failure > 0) {
if (keyinfo & WPA_KEY_INFO_ERROR &&
keyinfo & WPA_KEY_INFO_REQUEST) {
-   netdev_err(priv->net_dev, " MIC ERROR Report SET : 
%04X\n", keyinfo);
+   

[PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx

2018-04-30 Thread Sergio Paracuellos
Local variable event in ks_wlan_hw_rx function is declared
as unsigned short and can be declared as u16 which is preferred
style.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 0c487ed..0b1e352 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -425,7 +425,7 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
int ret;
struct rx_device_buffer *rx_buffer;
struct hostif_hdr *hdr;
-   unsigned short event = 0;
+   u16 event = 0;
 
/* receive data */
if (rxq_count(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
-- 
2.7.4

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


[PATCH 27/47] staging: use ether_addr_copy in get_ap_information function

2018-04-30 Thread Sergio Paracuellos
This commit make use of ether_addr_copy to copy ethernet
address instead of copy it using memcpy.

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 00d6318..366801f 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -200,7 +200,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
 
memset(ap, 0, sizeof(struct local_ap));
 
-   memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+   ether_addr_copy(ap->bssid, ap_info->bssid);
ap->rssi = ap_info->rssi;
ap->sq = ap_info->sq;
ap->noise = ap_info->noise;
-- 
2.7.4

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


[PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address

2018-04-30 Thread Sergio Paracuellos
Use ether_addr_copy to copy ethernet address instad of using
memcpy in ks_wlan_set_mac_address function.

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

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 8b4a1ed6..bb8ec04 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2500,7 +2500,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void 
*addr)
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
-   memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
+   ether_addr_copy(priv->eth_addr, mac_addr->sa_data);
 
priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
-- 
2.7.4

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


[PATCH 31/47] staging: ks7010: add blank line between after definitions

2018-04-30 Thread Sergio Paracuellos
Add blank line after definitions in hostif_aplist_init function
to fix a checkpatch script complain about that.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 644a083..30c2d3a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2255,6 +2255,7 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 
event)
 static inline void hostif_aplist_init(struct ks_wlan_private *priv)
 {
size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap);
+
priv->aplist.size = 0;
memset(>aplist.ap[0], 0, size);
 }
-- 
2.7.4

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


[PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute

2018-04-30 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 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt

2018-04-30 Thread Sergio Paracuellos
Local variables 'status', 'rsize' and 'byte' are declared as
unsigned char and can be declared as u8 which is preferred.
They are being used in ks7010_sdio_readb calls which is already
expected an u8.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index dab44bb..db954f1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -542,7 +542,7 @@ static void ks_sdio_interrupt(struct sdio_func *func)
int ret;
struct ks_sdio_card *card;
struct ks_wlan_private *priv;
-   unsigned char status, rsize, byte;
+   u8 status, rsize, byte;
 
card = sdio_get_drvdata(func);
priv = card->priv;
-- 
2.7.4

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


[PATCH 29/47] staging: ks7010: factor out send_request_to_device function

2018-04-30 Thread Sergio Paracuellos
In all functions related with requests to the device the same
patter in used and is also adding a comment to make clear the
intention of the code. Just factor out the pattern into a new
send_request_to_device function to improve readability and make
clear code intention.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 8bd2797..1a59218 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1172,6 +1172,13 @@ static inline void ps_confirm_wait_inc(struct 
ks_wlan_private *priv)
atomic_inc(>psstatus.confirm_wait);
 }
 
+static inline void send_request_to_device(struct ks_wlan_private *priv,
+ void *data, size_t size)
+{
+   ps_confirm_wait_inc(priv);
+   ks_wlan_hw_tx(priv, data, size, NULL, NULL);
+}
+
 static
 void hostif_mib_get_request(struct ks_wlan_private *priv,
unsigned long mib_attribute)
@@ -1184,9 +1191,7 @@ void hostif_mib_get_request(struct ks_wlan_private *priv,
 
pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static void hostif_mib_set_request(struct ks_wlan_private *priv,
@@ -1208,9 +1213,7 @@ static void hostif_mib_set_request(struct ks_wlan_private 
*priv,
pp->mib_value.type = cpu_to_le16(type);
memcpy(>mib_value.body, data, size);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp) + size));
 }
 
 static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
@@ -1250,9 +1253,7 @@ void hostif_start_request(struct ks_wlan_private *priv, 
unsigned char mode)
 
pp->mode = cpu_to_le16((uint16_t)mode);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1299,9 +1300,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private 
*priv)
init_request(priv, >request);
pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1340,9 +1339,7 @@ void hostif_infrastructure_set_request(struct 
ks_wlan_private *priv, int event)
pp->channel_list.size = 14;
}
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1359,9 +1356,7 @@ void hostif_adhoc_set_request(struct ks_wlan_private 
*priv)
pp->ssid.size = priv->reg.ssid.size;
memcpy(>ssid.body[0], >reg.ssid.body[0], priv->reg.ssid.size);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1381,9 +1376,7 @@ void hostif_adhoc_set2_request(struct ks_wlan_private 
*priv)
pp->channel_list.size = 1;
memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1395,9 +1388,7 @@ void hostif_stop_request(struct ks_wlan_private *priv)
if (!pp)
return;
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1417,9 +1408,7 @@ void hostif_phy_information_request(struct 
ks_wlan_private *priv)
pp->time = cpu_to_le16((uint16_t)0);
}
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1437,9 +1426,7 @@ void hostif_power_mgmt_request(struct 

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

2018-04-30 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 17/47] staging: ks7010: conver MIB attributes preprocessor defs into an enum

2018-04-30 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)
+ * 

[PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup

2018-04-30 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 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function

2018-04-30 Thread Sergio Paracuellos
Event to send to init the card are always the same so change
code to be more readable putting them into an array and
enqueuing also using a for loop.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 9085ed7..0c487ed 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -806,24 +806,19 @@ static int ks7010_upload_firmware(struct ks_sdio_card 
*card)
 
 static void ks7010_sme_enqueue_events(struct ks_wlan_private *priv)
 {
-   hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM);
-
-   /* load initial wireless parameter */
-   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST);
-   hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST);
-   hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST);
-   hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST);
-   hostif_sme_enqueue(priv, SME_START_REQUEST);
+   static const u16 init_events[] = {
+   SME_GET_EEPROM_CKSUM, SME_STOP_REQUEST,
+   SME_RTS_THRESHOLD_REQUEST, SME_FRAGMENTATION_THRESHOLD_REQUEST,
+   SME_WEP_INDEX_REQUEST, SME_WEP_KEY1_REQUEST,
+   SME_WEP_KEY2_REQUEST, SME_WEP_KEY3_REQUEST,
+   SME_WEP_KEY4_REQUEST, SME_WEP_FLAG_REQUEST,
+   SME_RSN_ENABLED_REQUEST, SME_MODE_SET_REQUEST,
+   SME_START_REQUEST
+   };
+   int ev;
+
+   for (ev = 0; ev < ARRAY_SIZE(init_events); ev++)
+   hostif_sme_enqueue(priv, init_events[ev]);
 }
 
 static void ks7010_card_init(struct ks_wlan_private *priv)
-- 
2.7.4

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


[PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request

2018-04-30 Thread Sergio Paracuellos
Parameters for hostif_power_mgmt_request are declared as unsigned
long and then are forced to be change to be u32. Also the caller
declares explicitly unsigned long parameters just to assign them
and pass into the function. Change types for those to be u32 instead
so no conversion is needed at all and code gets more clear.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 08f95f7..3a6385c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1419,8 +1419,7 @@ void hostif_phy_information_request(struct 
ks_wlan_private *priv)
 
 static
 void hostif_power_mgmt_request(struct ks_wlan_private *priv,
-  unsigned long mode, unsigned long wake_up,
-  unsigned long receive_dtims)
+  u32 mode, u32 wake_up, u32 receive_dtims)
 {
struct hostif_power_mgmt_request *pp;
 
@@ -1428,9 +1427,9 @@ void hostif_power_mgmt_request(struct ks_wlan_private 
*priv,
if (!pp)
return;
 
-   pp->mode = cpu_to_le32((uint32_t)mode);
-   pp->wake_up = cpu_to_le32((uint32_t)wake_up);
-   pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
+   pp->mode = cpu_to_le32(mode);
+   pp->wake_up = cpu_to_le32(wake_up);
+   pp->receive_dtims = cpu_to_le32(receive_dtims);
 
send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
@@ -1884,7 +1883,7 @@ void hostif_sme_multicast_set(struct ks_wlan_private 
*priv)
 static
 void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
 {
-   unsigned long mode, wake_up, receive_dtims;
+   u32 mode, wake_up, receive_dtims;
 
switch (priv->reg.power_mgmt) {
case POWER_MGMT_SAVE1:
-- 
2.7.4

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


[PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue

2018-04-30 Thread Sergio Paracuellos
Declaration of second parameter 'event' in ks_hostif .h and .c
file is different using uint16_t and unsigned short respectively.
Just unify both using 'u16' which is preferred instead.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 drivers/staging/ks7010/ks_hostif.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ea484f2..965a23d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2259,7 +2259,7 @@ void hostif_sme_task(unsigned long dev)
 }
 
 /* send to Station Management Entity module */
-void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event)
 {
/* enqueue sme event */
if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index cb906f0..974e639 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -542,7 +542,7 @@ static inline bool is_hif_conf(unsigned short event)
 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb);
 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
unsigned int size);
-void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event);
 int hostif_init(struct ks_wlan_private *priv);
 void hostif_exit(struct ks_wlan_private *priv);
 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
-- 
2.7.4

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


[PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data

2018-04-30 Thread Sergio Paracuellos
Use ether_addr_copy kernel function to copy an ethernet address
instead of a simple memcpy with ETH_ALEN size.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 8cd3dac..00d6318 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -151,8 +151,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
wrqu.data.flags = 0;
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
if (is_connect_status(priv->connect_status)) {
-   memcpy(wrqu.ap_addr.sa_data,
-  priv->current_ap.bssid, ETH_ALEN);
+   ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
   "IWEVENT: connect bssid=%pM\n", 
wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, , NULL);
-- 
2.7.4

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


[PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication

2018-04-30 Thread Sergio Paracuellos
Local variable 'auth_type' is declared as unsigned short in
hostif_data_indication function. Its value is got calling get_word
which returns an 'u16' so change its type to u16 which is preferred.

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 1a034d5..d4ce986 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -351,7 +351,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 {
unsigned int rx_ind_size;   /* indicate data size */
struct sk_buff *skb;
-   unsigned short auth_type;
+   u16 auth_type;
unsigned char temp[256];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
-- 
2.7.4

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


[PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request

2018-04-30 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(>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(>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, );
+  MIB_VALUE_TYPE_INT, , 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,
-  >reg.wep_key[0].val[0]);
+  >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,
-  >reg.wep_key[1].val[0]);
+  >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,
-  >reg.wep_key[2].val[0]);
+  >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,
-  >reg.wep_key[3].val[0]);
+  >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(priv, DOT11_PRIVACY_INVOKED,
-  

[PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function

2018-04-30 Thread Sergio Paracuellos
This commit make use of two introduced local variables
to make more readable code of hostif_sme_set_rsn function.
It just assign those local variables in different cases
where are needed and extract common code to assign them
at the end.

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

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 30c2d3a..08f95f7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1613,12 +1613,13 @@ struct rsn_mode {
__le16 rsn_capability;
 } __packed;
 
-static
-void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 {
struct wpa_suite wpa_suite;
struct rsn_mode rsn_mode;
size_t size;
+   u32 mode;
+   const u8 *buf = NULL;
 
memset(_suite, 0, sizeof(wpa_suite));
 
@@ -1627,47 +1628,29 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, 
int type)
wpa_suite.size = cpu_to_le16((uint16_t)1);
switch (priv->wpa.pairwise_suite) {
case IW_AUTH_CIPHER_NONE:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
 
+   if (buf)
+   memcpy(_suite.suite[0][0], buf, CIPHER_ID_LEN);
size = sizeof(wpa_suite.size) +
   (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
hostif_mib_set_request_ostring(priv,
@@ -1677,46 +1660,28 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, 
int type)
case SME_RSN_MCAST_REQUEST:
switch (priv->wpa.group_suite) {
case IW_AUTH_CIPHER_NONE:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- 

[PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum

2018-04-30 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/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header

2018-04-30 Thread Sergio Paracuellos
ks_wlan_private struct has a pointer to struct ks_sdio_card in its
fields. Because of that a forward declaration in needed in ks_wlan.h
header and also it makes necessary to have ks_sdio_card public in
a ks7010_sdio.h header. Changing this pointer into a void pointer
makes no longer necessary to have ks7010_sdio.h header as well as
removes the forward dependency in ks_wlan.h. Declaration of
ks_sdio_card has been moved to ks7010_sdio.c source file and To make
code cleaner inside this file a new ks7010_to_func function has been
added. The code has been updated to this changes.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 52 +---
 drivers/staging/ks7010/ks7010_sdio.h | 26 --
 drivers/staging/ks7010/ks_wlan.h |  4 +--
 3 files changed, 37 insertions(+), 45 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 9c22a76..d71c826 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -16,7 +16,6 @@
 #include 
 #include "ks_wlan.h"
 #include "ks_hostif.h"
-#include "ks7010_sdio.h"
 
 #define ROM_FILE "ks7010sd.rom"
 
@@ -97,11 +96,31 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
+/**
+ * struct ks_sdio_card - SDIO device data.
+ *
+ * Structure is used as the  sdio_func private data.
+ *
+ * @func: Pointer to the SDIO function device.
+ * @priv: Pointer to the  net_device private data.
+ */
+struct ks_sdio_card {
+   struct sdio_func *func;
+   struct ks_wlan_private *priv;
+};
+
+static struct sdio_func *ks7010_to_func(struct ks_wlan_private *priv)
+{
+   struct ks_sdio_card *ks_sdio = priv->if_hw;
+
+   return ks_sdio->func;
+}
+
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 u32 address, u8 *byte)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
int ret;
 
*byte = sdio_readb(func, address, );
@@ -113,7 +132,7 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
u8 *buffer, unsigned int length)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
 
return sdio_memcpy_fromio(func, buffer, address, length);
 }
@@ -122,7 +141,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, 
u32 address,
 static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
  u32 address, u8 byte)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
int ret;
 
sdio_writeb(func, byte, address, );
@@ -134,7 +153,7 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
 static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address,
 u8 *buffer, unsigned int length)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
 
return sdio_memcpy_toio(func, address, buffer, length);
 }
@@ -449,12 +468,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
 
 static void ks7010_rw_function(struct work_struct *work)
 {
-   struct ks_wlan_private *priv;
+   struct ks_wlan_private *priv = container_of(work,
+   struct ks_wlan_private,
+   rw_dwork.work);
+   struct sdio_func *func = ks7010_to_func(priv);
unsigned char byte;
int ret;
 
-   priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
-
/* wait after DOZE */
if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after DOZE\n");
@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work)
/* wait after WAKEUP */
while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
-   dev_info(>ks_sdio_card->func->dev,
-"wake: %lu %lu\n",
+   dev_info(>dev, "wake: %lu %lu\n",
 priv->last_wakeup + msecs_to_jiffies(30), jiffies);
msleep(30);
}
 
-   sdio_claim_host(priv->ks_sdio_card->func);
+   sdio_claim_host(func);
 
/* power save wakeup */
if (atomic_read(>psstatus.status) == PS_SNOOZE) {
@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work)
_ks_wlan_hw_power_save(priv);
 
 release_host:
-   

[PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line

2018-04-30 Thread Sergio Paracuellos
This commit avoids a long line changing a bit message in
_ks_wlan_hw_power_save function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index d71c826..078f37e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -235,7 +235,12 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private 
*priv)
if (atomic_read(>psstatus.status) == PS_SNOOZE)
return;
 
-   netdev_dbg(priv->net_dev, 
"\npsstatus.status=%d\npsstatus.confirm_wait=%d\npsstatus.snooze_guard=%d\ncnt_txqbody=%d\n",
+   netdev_dbg(priv->net_dev,
+  "STATUS:\n"
+  "- psstatus.status = %d\n"
+  "- psstatus.confirm_wait = %d\n"
+  "- psstatus.snooze_guard = %d\n"
+  "- txq_count = %d\n",
   atomic_read(>psstatus.status),
   atomic_read(>psstatus.confirm_wait),
   atomic_read(>psstatus.snooze_guard),
-- 
2.7.4

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


[PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save

2018-04-30 Thread Sergio Paracuellos
Local variable 'byte' in _ks_wlan_hw_power_save function is declared
as unsigned char and can be declared as u8 which is preferred. It
is being using with ks7010_sdio_readb which expects u8 already.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 71e12d6..3574a22 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -217,7 +217,7 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
 
 static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 {
-   unsigned char byte;
+   u8 byte;
int ret;
 
if (priv->reg.power_mgmt == POWER_MGMT_ACTIVE)
-- 
2.7.4

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


[PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function

2018-04-30 Thread Sergio Paracuellos
Local variable 'byte' in ks7010_rw_function is declared as unsigned
char and can be declared as u8 which is preferred. It is being used
in ks7010_sdio_readb which is already expecting an u8.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 3574a22..dab44bb 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -477,7 +477,7 @@ static void ks7010_rw_function(struct work_struct *work)
struct ks_wlan_private,
rw_dwork.work);
struct sdio_func *func = ks7010_to_func(priv);
-   unsigned char byte;
+   u8 byte;
int ret;
 
/* wait after DOZE */
-- 
2.7.4

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


[PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function

2018-04-30 Thread Sergio Paracuellos
Parameter buffer in write_to_device function is declared as
a pointer to unsigned char and can be declared as an u8 type
which is preferred. Internally it calls to ks7010_sdio_write
which is using also u8 as parameter type. Update calls to this
function as well.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 078f37e..71e12d6 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -318,7 +318,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
 }
 
 /* write data */
-static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
+static int write_to_device(struct ks_wlan_private *priv, u8 *buffer,
   unsigned long size)
 {
struct hostif_hdr *hdr;
@@ -1071,8 +1071,7 @@ static int send_stop_request(struct sdio_func *func)
pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
 
sdio_claim_host(func);
-   write_to_device(card->priv, (unsigned char *)pp,
-   hif_align_size(sizeof(*pp)));
+   write_to_device(card->priv, (u8 *)pp, hif_align_size(sizeof(*pp)));
sdio_release_host(func);
 
kfree(pp);
-- 
2.7.4

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


[PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header

2018-04-30 Thread Sergio Paracuellos
There are some definitions for rx and tx queues in ks7010_sdio
which is not the best place to put them. Changing them into the
ks_wlan header file there is no need to explicity include ks7010_sdio.h
which makes no sense at all and can be resolved easily using
forward declarations. The functions related with the queues circular
buffers have been moved also into this header.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c |  45 --
 drivers/staging/ks7010/ks7010_sdio.h |  63 +---
 drivers/staging/ks7010/ks_wlan.h | 112 ++-
 3 files changed, 112 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 6a5565d..9c22a76 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -8,7 +8,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -98,50 +97,6 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
-static inline void inc_txqhead(struct ks_wlan_private *priv)
-{
-   priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_txqtail(struct ks_wlan_private *priv)
-{
-   priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool txq_has_space(struct ks_wlan_private *priv)
-{
-   return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
-  TX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline void inc_rxqhead(struct ks_wlan_private *priv)
-{
-   priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_rxqtail(struct ks_wlan_private *priv)
-{
-   priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool rxq_has_space(struct ks_wlan_private *priv)
-{
-   return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
-  RX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline unsigned int txq_count(struct ks_wlan_private *priv)
-{
-   return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
-  TX_DEVICE_BUFF_SIZE);
-}
-
-static inline unsigned int rxq_count(struct ks_wlan_private *priv)
-{
-   return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
-  RX_DEVICE_BUFF_SIZE);
-}
-
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 u32 address, u8 *byte)
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 831b2f1..891a09f 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -8,6 +8,8 @@
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
 
+struct ks_wlan_private;
+
 /**
  * struct ks_sdio_card - SDIO device data.
  *
@@ -21,65 +23,4 @@ struct ks_sdio_card {
struct ks_wlan_private *priv;
 };
 
-/* Tx Device struct */
-#defineTX_DEVICE_BUFF_SIZE 1024
-
-/**
- * struct tx_device_buffer - Queue item for the tx queue.
- * @sendp: Pointer to the send request data.
- * @size: Size of @sendp data.
- * @complete_handler: Function called once data write to device is complete.
- * @arg1: First argument to @complete_handler.
- * @arg2: Second argument to @complete_handler.
- */
-struct tx_device_buffer {
-   unsigned char *sendp;
-   unsigned int size;
-   void (*complete_handler)(struct ks_wlan_private *priv,
-struct sk_buff *skb);
-   struct sk_buff *skb;
-};
-
-/**
- * struct tx_device - Tx buffer queue.
- * @tx_device_buffer: Queue buffer.
- * @qhead: Head of tx queue.
- * @qtail: Tail of tx queue.
- * @tx_dev_lock: Queue lock.
- */
-struct tx_device {
-   struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
-   unsigned int qhead;
-   unsigned int qtail;
-   spinlock_t tx_dev_lock; /* protect access to the queue */
-};
-
-/* Rx Device struct */
-#defineRX_DATA_SIZE(2 + 2 + 2347 + 1)
-#defineRX_DEVICE_BUFF_SIZE 32
-
-/**
- * struct rx_device_buffer - Queue item for the rx queue.
- * @data: rx data.
- * @size: Size of @data.
- */
-struct rx_device_buffer {
-   unsigned char data[RX_DATA_SIZE];
-   unsigned int size;
-};
-
-/**
- * struct rx_device - Rx buffer queue.
- * @rx_device_buffer: Queue buffer.
- * @qhead: Head of rx queue.
- * @qtail: Tail of rx queue.
- * @rx_dev_lock: Queue lock.
- */
-struct rx_device {
-   struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
-   unsigned int qhead;
-   unsigned int qtail;
-   spinlock_t rx_dev_lock; /* protect access to the queue */
-};
-
 #endif /* _KS7010_SDIO_H */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 5070af8..d73f622 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ 

[PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code

2018-04-30 Thread Sergio Paracuellos
Commit 92c1552caef3661f049c4e967550e933599e2663 removes WPS hardcoded
definition and its related conditional preprocessor code. There
was some missing stuff already in this files. Remove it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 drivers/staging/ks7010/ks_hostif.h | 2 --
 2 files changed, 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index c0a9a67..ea484f2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -611,10 +611,8 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
case DOT11_PMK_TSC:
case LOCAL_PMK:
case LOCAL_GAIN:
-#ifdef WPS
case LOCAL_WPS_ENABLE:
case LOCAL_WPS_PROBE_REQ:
-#endif /* WPS */
case LOCAL_REGION:
default:
break;
@@ -644,7 +642,6 @@ void hostif_sleep_confirm(struct ks_wlan_private *priv)
 static
 void hostif_start_confirm(struct ks_wlan_private *priv)
 {
-#ifdef WPS
union iwreq_data wrqu;
 
wrqu.data.length = 0;
@@ -654,7 +651,6 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
eth_zero_addr(wrqu.ap_addr.sa_data);
wireless_send_event(priv->net_dev, SIOCGIWAP, , NULL);
}
-#endif
netdev_dbg(priv->net_dev, " scan_ind_count=%d\n", priv->scan_ind_count);
hostif_sme_enqueue(priv, SME_START_CONFIRM);
 }
@@ -2174,7 +2170,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_SET_PMKSA:
hostif_sme_set_pmksa(priv);
break;
-#ifdef WPS
case SME_WPS_ENABLE_REQUEST:
hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
   sizeof(priv->wps.wps_enabled),
@@ -2186,7 +2181,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
   priv->wps.ielen,
   MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
break;
-#endif /* WPS */
case SME_MODE_SET_REQUEST:
hostif_sme_mode_setup(priv);
break;
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 172d38f..cb906f0 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -124,10 +124,8 @@ struct channel_list {
 
 #define LOCAL_REGION  0xF10A0100   /* Region setting */
 
-#ifdef WPS
 #define LOCAL_WPS_ENABLE  0xF10B0100   /* WiFi Protected Setup 
*/
 #define LOCAL_WPS_PROBE_REQ   0xF10C0100   /* WPS Probe Request */
-#endif /* WPS */
 
 #define LOCAL_GAIN0xF10D0100   /* Carrer sense 
threshold for demo ato show */
 #define LOCAL_EEPROM_SUM  0xF10E0100   /* EEPROM checksum 
information */
-- 
2.7.4

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


[PATCH 01/47] staging: ks7010: add SPDX identifiers to all files

2018-04-30 Thread Sergio Paracuellos
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging ks7010 files to have a proper SPDX
identifier, based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

Extra GPL text wording can be removed as it is no longer needed at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c   | 5 +
 drivers/staging/ks7010/ks7010_sdio.h   | 5 +
 drivers/staging/ks7010/ks_hostif.c | 5 +
 drivers/staging/ks7010/ks_hostif.h | 5 +
 drivers/staging/ks7010/ks_wlan.h   | 5 +
 drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +
 drivers/staging/ks7010/ks_wlan_net.c   | 5 +
 drivers/staging/ks7010/michael_mic.c   | 5 +
 drivers/staging/ks7010/michael_mic.h   | 5 +
 9 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b29f48c..6a5565d 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1,13 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
  *   Copyright (C) 2016 Sang Engineering, Wolfram Sang
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 95ac86b..831b2f1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 9a05374..c0a9a67 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1,12 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *   Driver for KeyStream wireless LAN cards.
  *
  *   Copyright (C) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 05ff5ca..172d38f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_HOSTIF_H_
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 2894b0c..5070af8 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream IEEE802.11 b/g wireless LAN cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_H
diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h 
b/drivers/staging/ks7010/ks_wlan_ioctl.h
index e45a332..97c7d95 100644
--- a/drivers/staging/ks7010/ks_wlan_ioctl.h
+++ b/drivers/staging/ks7010/ks_wlan_ioctl.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream 11b/g wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_IOCTL_H
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 

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

2018-04-30 Thread Sergio Paracuellos
This patch series are all of my patches that haven't been
applied yet. Most of them are from previous series and 
there are also a few new patches included.

Sergio Paracuellos (47):
  staging: ks7010: add SPDX identifiers to all files
  staging: ks7010: move tx and rx queues definitions into ks_wlan.h
header
  staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header
  staging: ks7010: change netdev_dbg msg to avoid a long line
  staging: ks7010: remove missing WPS preprocessor conditional code
  staging: ks7010: use u8 instead of unsigned char in write_to_device
function
  staging: ks7010: change local variable type in _ks_wlan_hw_power_save
  staging: ks7010: change local variable type in ks7010_rw_function
  staging: ks7010: change some local variables type in ks_sdio_interrupt
  staging: ks7010: change local variable type in ks7010_sdio_init_irqs
  staging: ks7010: use the same parameter for 'event' in
hostif_sme_enqueue
  staging: ks7010: refactor ks7010_sme_enqueue_events function
  staging: ks7010: change local variable type in ks_wlan_hw_rx
  staging: ks7010: remove nonsense comment in ks_wlan.h file
  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
  staging: ks7010: change type for rsn_enabled in wpa_status struct
  staging: ks7010: use ether_addr_copy to copy ethernet address sa_data
  staging: use ether_addr_copy in get_ap_information function
  staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside
switch
  staging: ks7010: factor out send_request_to_device function
  staging: ks7010: fix some style issues in ks_hostif.c
  staging: ks7010: add blank line between after definitions
  staging: ks7010: refactor hostif_sme_set_rsn function
  staging: ks7010: change parameter types in hostif_power_mgmt_request
  staging: ks7010: refactor hostif_sme_power_mgmt_set function
  staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address
  staging: ks7010: use ether_addr_copy in ks_wlan_net_start
  staging: ks7010: refactor ks_wlan_set_sleep_mode function
  staging: ks7010: refactor ks_wlan_set_phy_type function
  staging: ks7010: refactor ks_wlan_set_mlme function
  staging: ks7010: refactor ks_get_wireless_stats function
  staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody
  staging: ks7010: refactor LOCAL_EEPROM_SUM case in
hostif_mib_get_confirm
  staging: ks7010: use u16 instead of unsigned short in
hostif_event_check
  staging: ks7010: use u16 instead of unsigned short in
hostif_data_indication
  staging: ks7010: use u16 instead of unsigned short in
hostif_connect_indication
  staging: ks7010: use u32 instead of unsigned int in
hostif_bss_scan_confirm
  staging: ks7010: review local variable types in
hostif_phy_information_confirm

 drivers/staging/ks7010/ks7010_sdio.c   | 145 +++-
 drivers/staging/ks7010/ks7010_sdio.h   |  88 -
 drivers/staging/ks7010/ks_hostif.c | 661 ++---
 drivers/staging/ks7010/ks_hostif.h | 184 +
 drivers/staging/ks7010/ks_wlan.h   | 171 +++--
 drivers/staging/ks7010/ks_wlan_ioctl.h |   5 +-
 drivers/staging/ks7010/ks_wlan_net.c   |  88 ++---
 drivers/staging/ks7010/michael_mic.c   |   5 +-
 drivers/staging/ks7010/michael_mic.h   |   5 +-
 9 files changed, 629 insertions(+), 723 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h

-- 
2.7.4

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


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

2018-04-30 Thread Sergio Paracuellos
On Sun, Apr 29, 2018 at 03:23:02PM +0200, Greg KH wrote:
> On Fri, Apr 27, 2018 at 04:05:54PM +0200, Sergio Paracuellos wrote:
> > 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(-)
> 
> I now have 31+ emails from you in my to-review queue.  These are
> multiple series of patches, yet I have no idea what order they are in at
> all.
> 
> Please make it easy on me, make it obvious what to do, and what to apply
> in what order.
> 
> I'm dropping all of your emails now, please resend everything I have not
> applied, in a _SINGLE_ patch series so I can handle it properly.

Ack! I'll resend all of them in one patch series.

> 
> thanks,
> 
> greg k-h

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


Re: [PATCH 04/40] proc: introduce proc_create_seq{,_data}

2018-04-30 Thread David Howells
Christoph Hellwig  wrote:

> +
> +struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
> + struct proc_dir_entry *parent, const struct seq_operations *ops,
> + void *data)
> +{
> ...
> +EXPORT_SYMBOL(proc_create_seq_data);

Please add documentation comments to exported functions when you add them.

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


[PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access

2018-04-30 Thread Gustavo A. R. Silva
If i < slot_id is initially true then it will remain true. Also,
as i is being decremented it will end up accessing memory out of
bounds.

Fix this by incrementing *i* instead of decrementing it.

Addresses-Coverity-ID: 1468454 ("Infinite loop")
Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free kmalloc
memory on failure cases")
Signed-off-by: Gustavo A. R. Silva 
---

BTW... at first sight it seems to me that variables slot_id
and i should be of type unsigned instead of signed.

 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 3ca0c97..67104e8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -608,7 +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request 
*request,
 
 out_free:
 
-   for (i = 0; i < slot_id ; i--)
+   for (i = 0; i < slot_id; i++)
kfree(ntwk->net_info[i].ssid);
 
kfree(ntwk->net_info);
-- 
2.7.4

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


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

2018-04-30 Thread Dan Carpenter
On Sun, Apr 29, 2018 at 03:58:55PM -0500, Wenwen Wang wrote:
> It is worth fixing this bug, since it offers an opportunity for adversaries
> to provide inconsistent user data. In addition to the unwanted version
> LOV_USER_MAGIC_V1, a malicious user can also use the version
> LMV_USER_MAGIC, which is also unexpected but allowed in the function
> ll_dir_setstripe(). These inconsistent data can cause potential logical
> errors in the following execution. Hence it is necessary to re-verify the
> data copied from userspace.
> 

This change doesn't really prevent any bugs in current kernels since
LMV_USER_MAGIC is the same thing as LOV_USER_MAGIC_V1 and the users are
allowed to use LOV_USER_MAGIC_V1 if they want.

But we should probably verify it just to make the code easier to read
and because there are static analysis tools which will warn about read
verify re-read type bugs.

regards,
dan carpenter


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


Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI)

2018-04-30 Thread Mats Karrman

Hi Li Jun,

Are you working on an updated version of this patch series?
I'm pondering other changes that builds on these patches (the documentation
and the fwnode added to the tcpc_dev and tcpm primarily).

Btw, there is a semi-colon missing in your example below.

BR // Mats

On 2018-03-28 18:06, Li Jun wrote:


TCPCI stands for typec port controller interface, its implementation
has full typec port control with power delivery support, it's a
standard i2c slave with GPIO input as irq interface, detail see spec
"Universal Serial Bus Type-C Port Controller Interface Specification
Revision 1.0, Version 1.1"

Signed-off-by: Li Jun 
---
  .../devicetree/bindings/usb/typec-tcpci.txt| 33 ++
  1 file changed, 33 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-tcpci.txt 
b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
new file mode 100644
index 000..7a7a8e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
@@ -0,0 +1,33 @@
+TCPCI(Typec port cotroller interface) binding
+-
+
+Required properties:
+- compatible:   should be "usb-tcpci,chip-specific-string".
+- reg:  the i2c slave address of typec port controller device.
+- interrupt-parent: the phandle to the interrupt controller which provides
+the interrupt.
+- interrupts:   interrupt specification for tcpci alert.
+
+Required sub-node:
+- connector: The "usb-c-connector" attached to the tcpci chip, the bindings
+  of connector node are specified in
+  Documentation/devicetree/bindings/connector/usb-connector.txt
+
+Example:
+
+ptn5110@50 {
+   compatible = "usb-tcpci,ptn5110";
+   reg = <0x50>;
+   interrupt-parent = <>;
+   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+   usb_con: connector {
+   compatible = "usb-c-connector";
+   label = "USB-C";
+   port-type = "dual";
+   try-power-role = "sink"


Here!


+   source-pdos = <0x380190c8>;
+   sink-pdos = <0x380190c8 0x3802d0c8>;
+   op-sink-microwatt-hours = <900>;
+   };
+};


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