All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] staging: ks7010: refactor host interface
@ 2017-04-26  0:55 Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 01/19] staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP Tobin C. Harding
                   ` (19 more replies)
  0 siblings, 20 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

This is an attempt to improve the readability of the host interface
code, and ease future development. Refactoring only, no changes to the
functionality of the code.

Patch 01 renames a constant to use adjective instead of noun.

Patch 02 removes redundant code.

Patch 03 removes unused local variable.

Patch 04 moves null check closer to memory allocation.

Patch 05 removes magic numbers.

Patch 06 removes duplicate code.

Patch 07 refactors call to kmalloc(), uses local variable to separate
expression, calculating size of allocation, from call to kmalloc().

Patch 08 adds a helper function to reduce code duplication.

Patch 09 abstracts connection status flag access.

Patch 10 adds enumeration type 'sleep_mode_type' instead of preprocessor defines.

Patch 11 fixes checkpatch warning, multiple new lines.

Patch 12 makes uniform the abbreviation used for 'management' when
naming identifiers.

Patch 13 removes unnecessary void * cast from calls to netdev_priv().

Patch 14 inverts 'if' statement conditional, adding 'continue'
statement to continue loop. Reduces indentation of subsequent code.

Patch 15 cleans up macro definition, removes commented out code and
braces. This macro causes two checkpatch checks to be emitted
(MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE), please review carefully.

Patch 16 adds enumeration type 'multi_cast_filter_type' instead of preprocessor defines.

Patch 17 fixes/adds enumeration tags.

Patch 18 renames header and source files 'ks_hostif' to 'hostif'.

Patch 19 renames header and source files 'ks7010_sdio' to 'sdio'.

Patch series was created using `git format-patch -M ...`

Series is untested, builds on x86_64 and PowerPC.

Tobin C. Harding (19):
  staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP
  staging: ks7010: remove unnecessary address check
  staging: ks7010: remove unused local variable eap_key
  staging: ks7010: move skb null check near allocation
  staging: ks7010: remove magic numbers
  staging: ks7010: remove duplicate code
  staging: ks7010: clean memory allocation
  staging: ks7010: add hostif_generic_request()
  staging: ks7010: abstract connection status
  staging: ks7010: add enum sleep_mode_type
  staging: ks7010: fix checkpatch LINE_SPACING
  staging: ks7010: make abbreviation mgmt uniform
  staging: ks7010: remove cast from netdev_priv()
  staging: ks7010: continue from loop on unmatched mac
  staging: ks7010: clean up macro ps_confirm_wait_inc
  staging: ks7010: add enum multicast_filter_type
  staging: ks7010: fix enumeration tags
  staging: ks7010: rename ks_hostif to hostif
  staging: ks7010: rename ks_hostif to hostif

 drivers/staging/ks7010/Makefile                  |   2 +-
 drivers/staging/ks7010/eap_packet.h              |   2 +
 drivers/staging/ks7010/{ks_hostif.c => hostif.c} | 366 +++++++++------------
 drivers/staging/ks7010/{ks_hostif.h => hostif.h} |  43 +--
 drivers/staging/ks7010/ks_wlan.h                 |   6 +-
 drivers/staging/ks7010/ks_wlan_net.c             | 388 ++++++++++-------------
 drivers/staging/ks7010/{ks7010_sdio.c => sdio.c} |  12 +-
 drivers/staging/ks7010/{ks7010_sdio.h => sdio.h} |   0
 8 files changed, 358 insertions(+), 461 deletions(-)
 rename drivers/staging/ks7010/{ks_hostif.c => hostif.c} (89%)
 rename drivers/staging/ks7010/{ks_hostif.h => hostif.h} (97%)
 rename drivers/staging/ks7010/{ks7010_sdio.c => sdio.c} (99%)
 rename drivers/staging/ks7010/{ks7010_sdio.h => sdio.h} (100%)

-- 
2.7.4

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/19] staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 02/19] staging: ks7010: remove unnecessary address check Tobin C. Harding
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Constant SLP_SLEEP is ambiguous, if it were named SLP_ASLEEP the code
would be less ambiguous and easier to read.

Rename constand SLP_SLEEP to SLP_ASLEEP.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks7010_sdio.c |   2 +-
 drivers/staging/ks7010/ks_hostif.c   |   4 +-
 drivers/staging/ks7010/ks_hostif.h   |   2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 112 +++++++++++++++++------------------
 4 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index ec11799..5f6a022 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -103,7 +103,7 @@ static void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
 			DPRINTK(1, " error : GCR_B\n");
 			goto set_sleep_mode;
 		}
-		DPRINTK(3, "sleep_mode=SLP_SLEEP\n");
+		DPRINTK(3, "sleep_mode=SLP_ASLEEP\n");
 		atomic_set(&priv->sleepstatus.status, 1);
 		priv->last_doze = jiffies;
 	} else {
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 7151f16..ee262b2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1727,7 +1727,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
 
 	DPRINTK(3, "mode=%lu\n", mode);
 
-	if (mode == SLP_SLEEP) {
+	if (mode == SLP_ASLEEP) {
 		/* make primitive */
 		pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
 		if (!pp) {
@@ -2315,7 +2315,7 @@ void hostif_sme_sleep_set(struct ks_wlan_private *priv)
 {
 	DPRINTK(3, "\n");
 	switch (priv->sleep_mode) {
-	case SLP_SLEEP:
+	case SLP_ASLEEP:
 		hostif_sleep_request(priv, priv->sleep_mode);
 		break;
 	case SLP_ACTIVE:
diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index d773432..2d9a342 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -544,7 +544,7 @@ struct hostif_phy_information_confirm_t {
 
 /* sleep mode */
 #define SLP_ACTIVE  0
-#define SLP_SLEEP   1
+#define SLP_ASLEEP  1
 struct hostif_sleep_request_t {
 	struct hostif_hdr header;
 } __packed;
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 0ef52c8..0c36290 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -180,7 +180,7 @@ static int ks_wlan_get_name(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -204,7 +204,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	int channel;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -249,7 +249,7 @@ static int ks_wlan_get_freq(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	int f;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -273,7 +273,7 @@ static int ks_wlan_set_essid(struct net_device *dev,
 
 	DPRINTK(2, " %d\n", dwrq->flags);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -327,7 +327,7 @@ static int ks_wlan_get_essid(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -359,7 +359,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -391,7 +391,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -412,7 +412,7 @@ static int ks_wlan_set_nick(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -433,7 +433,7 @@ static int ks_wlan_get_nick(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -452,7 +452,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	int i = 0;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -687,7 +687,7 @@ static int ks_wlan_get_rate(struct net_device *dev,
 	DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n",
 		in_interrupt(), atomic_read(&update_phyinfo));
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -710,7 +710,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	int rthr = vwrq->value;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -731,7 +731,7 @@ static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -750,7 +750,7 @@ static int ks_wlan_set_frag(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	int fthr = vwrq->value;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -773,7 +773,7 @@ static int ks_wlan_get_frag(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -793,7 +793,7 @@ static int ks_wlan_set_mode(struct net_device *dev,
 
 	DPRINTK(2, "mode=%d\n", *uwrq);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -825,7 +825,7 @@ static int ks_wlan_get_mode(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -858,7 +858,7 @@ static int ks_wlan_set_encode(struct net_device *dev,
 
 	DPRINTK(2, "flags=%04X\n", dwrq->flags);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -969,7 +969,7 @@ static int ks_wlan_get_encode(struct net_device *dev,
 	char zeros[16];
 	int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1025,7 +1025,7 @@ static int ks_wlan_get_txpow(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_param *vwrq, char *extra)
 {
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1047,7 +1047,7 @@ static int ks_wlan_get_retry(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_param *vwrq, char *extra)
 {
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1070,7 +1070,7 @@ static int ks_wlan_get_range(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1199,7 +1199,7 @@ static int ks_wlan_set_power(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	if (vwrq->disabled) {
@@ -1223,7 +1223,7 @@ static int ks_wlan_get_power(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (priv->reg.powermgt > 0)
@@ -1241,7 +1241,7 @@ static int ks_wlan_get_iwstats(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	vwrq->qual = 0;	/* not supported */
@@ -1285,7 +1285,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
 
 	int i;
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	for (i = 0; i < priv->aplist.size; i++) {
@@ -1317,7 +1317,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1512,7 +1512,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (priv->sme_i.sme_flag & SME_AP_SCAN) {
@@ -1572,7 +1572,7 @@ static int ks_wlan_set_genie(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	return 0;
@@ -1590,7 +1590,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
 
 	DPRINTK(2, "index=%d:value=%08X\n", index, value);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	switch (index) {
@@ -1724,7 +1724,7 @@ static int ks_wlan_get_auth_mode(struct net_device *dev,
 
 	DPRINTK(2, "index=%d\n", index);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1777,7 +1777,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
 	DPRINTK(2, "flags=%04X:: ext_flags=%08X\n", dwrq->flags,
 		enc->ext_flags);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1863,7 +1863,7 @@ static int ks_wlan_get_encode_ext(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -1890,7 +1890,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2013,7 +2013,7 @@ static int ks_wlan_set_stop_request(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2036,7 +2036,7 @@ static int ks_wlan_set_mlme(struct net_device *dev,
 
 	DPRINTK(2, ":%d :%d\n", mlme->cmd, mlme->reason_code);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2070,7 +2070,7 @@ static int ks_wlan_set_preamble(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2093,7 +2093,7 @@ static int ks_wlan_get_preamble(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2108,7 +2108,7 @@ static int ks_wlan_set_powermgt(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2140,7 +2140,7 @@ static int ks_wlan_get_powermgt(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 
 	/* for SLEEP MODE */
@@ -2155,7 +2155,7 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq == ACTIVE_SCAN) {	/* 0 */
@@ -2176,7 +2176,7 @@ static int ks_wlan_get_scan_type(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->reg.scan_type;
@@ -2190,7 +2190,7 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX)
@@ -2213,7 +2213,7 @@ static int ks_wlan_get_beacon_lost(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->reg.beacon_lost_count;
@@ -2227,7 +2227,7 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq == D_11B_ONLY_MODE) {	/* 0 */
@@ -2251,7 +2251,7 @@ static int ks_wlan_get_phy_type(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->reg.phy_type;
@@ -2265,7 +2265,7 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq == CTS_MODE_FALSE) {	/* 0 */
@@ -2292,7 +2292,7 @@ static int ks_wlan_get_cts_mode(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->reg.cts_mode;
@@ -2308,7 +2308,7 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (*uwrq == SLP_SLEEP) {
+	if (*uwrq == SLP_ASLEEP) {
 		priv->sleep_mode = *uwrq;
 		netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
 
@@ -2350,7 +2350,7 @@ static int ks_wlan_set_wps_enable(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq == 0 || *uwrq == 1)
@@ -2371,7 +2371,7 @@ static int ks_wlan_get_wps_enable(struct net_device *dev,
 	    (struct ks_wlan_private *)netdev_priv(dev);
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->wps.wps_enabled;
@@ -2391,7 +2391,7 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	DPRINTK(2, "dwrq->length=%d\n", dwrq->length);
@@ -2424,7 +2424,7 @@ static int ks_wlan_set_tx_gain(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq >= 0 && *uwrq <= 0xFF)	/* 0-255 */
@@ -2448,7 +2448,7 @@ static int ks_wlan_get_tx_gain(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->gain.TxGain;
@@ -2463,7 +2463,7 @@ static int ks_wlan_set_rx_gain(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	if (*uwrq >= 0 && *uwrq <= 0xFF)	/* 0-255 */
@@ -2487,7 +2487,7 @@ static int ks_wlan_get_rx_gain(struct net_device *dev,
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
 
-	if (priv->sleep_mode == SLP_SLEEP)
+	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
 	*uwrq = priv->gain.RxGain;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/19] staging: ks7010: remove unnecessary address check
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 01/19] staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 03/19] staging: ks7010: remove unused local variable eap_key Tobin C. Harding
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Currently source and destination ethernet addresses are checked twice,
once in hostif_data_indication() and then again in
hostif_data_indication_wpa(). The second of these functions is called
from the first right after the address check is done. This check is a
duplicate and is unnecessary.

Remove unnecessary duplicate address check.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index ee262b2..2dd3047 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -326,10 +326,6 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
 	eth_hdr = (struct ether_hdr *)(priv->rxp);
 	eth_proto = ntohs(eth_hdr->h_proto);
 
-	/* source address check */
-	if (memcmp(&eth_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN) == 0)
-		return 0;
-
 	if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
 		DPRINTK(1, "invalid data format\n");
 		priv->nstats.rx_errors++;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/19] staging: ks7010: remove unused local variable eap_key
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 01/19] staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 02/19] staging: ks7010: remove unnecessary address check Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 04/19] staging: ks7010: move skb null check near allocation Tobin C. Harding
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Code declares and assigns to a local variable that is never used, it
can be safely removed.

Remove unused local variable.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 2dd3047..fab3afe 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -399,7 +399,6 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 	struct ether_hdr *eth_hdr;
 	unsigned short eth_proto;
 	struct ieee802_1x_hdr *aa1x_hdr;
-	struct wpa_eapol_key *eap_key;
 	int ret;
 
 	DPRINTK(3, "\n");
@@ -456,10 +455,8 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 
 			aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
 			if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-			    priv->wpa.rsn_enabled) {
-				eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1);
+			    priv->wpa.rsn_enabled)
 				atomic_set(&priv->psstatus.snooze_guard, 1);
-			}
 
 			/* rx indication */
 			skb->dev = priv->net_dev;
@@ -487,10 +484,8 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 
 			aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
 			if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-			    priv->wpa.rsn_enabled) {
-				eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1);
+			    priv->wpa.rsn_enabled)
 				atomic_set(&priv->psstatus.snooze_guard, 1);
-			}
 
 			/* rx indication */
 			skb->dev = priv->net_dev;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/19] staging: ks7010: move skb null check near allocation
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (2 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 03/19] staging: ks7010: remove unused local variable eap_key Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 05/19] staging: ks7010: remove magic numbers Tobin C. Harding
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Currently, after allocating an sk_buff, driver fills the sk_buff
within code block guarded by a NULL check on the sk_buff. If a NULL
check is done immediately after the allocation, and code returns on
error, then the subsequent code need not be guarded and the level of
indentation may be reduced. This aids the readability of the code and
makes explicit the error path.

Check for NULL directly after allocating the sk_buff, return if
allocation fails. Reduce indentation of subsequent code. Do not change
the program logic.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 80 ++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index fab3afe..11adc5f 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -446,56 +446,60 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 	case 0xAA:	/* SNAP */
 		rx_ind_size = priv->rx_size - 6;
 		skb = dev_alloc_skb(rx_ind_size);
-		DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
-
-		if (skb) {
-			memcpy(skb_put(skb, 12), priv->rxp, 12);	/* 8802/FDDI MAC copy */
-			/* (SNAP+UI..) skip */
-			memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18, rx_ind_size - 12);	/* copy after Type */
-
-			aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
-			if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-			    priv->wpa.rsn_enabled)
-				atomic_set(&priv->psstatus.snooze_guard, 1);
-
-			/* rx indication */
-			skb->dev = priv->net_dev;
-			skb->protocol = eth_type_trans(skb, skb->dev);
-			priv->nstats.rx_packets++;
-			priv->nstats.rx_bytes += rx_ind_size;
-			netif_rx(skb);
-		} else {
+		if (!skb) {
 			priv->nstats.rx_dropped++;
+			return;
 		}
+		DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
+
+		memcpy(skb_put(skb, 12), priv->rxp, 12);	/* 8802/FDDI MAC copy */
+		/* (SNAP+UI..) skip */
+		memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18,
+		       rx_ind_size - 12);	/* copy after Type */
+
+		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
+		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
+		    priv->wpa.rsn_enabled)
+			atomic_set(&priv->psstatus.snooze_guard, 1);
+
+		/* rx indication */
+		skb->dev = priv->net_dev;
+		skb->protocol = eth_type_trans(skb, skb->dev);
+		priv->nstats.rx_packets++;
+		priv->nstats.rx_bytes += rx_ind_size;
+		netif_rx(skb);
+
 		break;
 	case 0xF0:	/* NETBEUI/NetBIOS */
 		rx_ind_size = (priv->rx_size + 2);
 		skb = dev_alloc_skb(rx_ind_size);
+		if (!skb) {
+			priv->nstats.rx_dropped++;
+			return;
+		}
 		DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size);
 
-		if (skb) {
-			memcpy(skb_put(skb, 12), priv->rxp, 12);	/* 8802/FDDI MAC copy */
+		memcpy(skb_put(skb, 12), priv->rxp, 12);	/* 8802/FDDI MAC copy */
 
-			temp[0] = (((rx_ind_size - 12) >> 8) & 0xff);	/* NETBEUI size add */
-			temp[1] = ((rx_ind_size - 12) & 0xff);
-			memcpy(skb_put(skb, 2), temp, 2);
+		temp[0] = (((rx_ind_size - 12) >> 8) & 0xff);	/* NETBEUI size add */
+		temp[1] = ((rx_ind_size - 12) & 0xff);
+		memcpy(skb_put(skb, 2), temp, 2);
 
-			memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12, rx_ind_size - 14);	/* copy after Type */
+		memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12,
+		       rx_ind_size - 14);	/* copy after Type */
 
-			aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
-			if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-			    priv->wpa.rsn_enabled)
-				atomic_set(&priv->psstatus.snooze_guard, 1);
+		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
+		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
+		    priv->wpa.rsn_enabled)
+			atomic_set(&priv->psstatus.snooze_guard, 1);
+
+		/* rx indication */
+		skb->dev = priv->net_dev;
+		skb->protocol = eth_type_trans(skb, skb->dev);
+		priv->nstats.rx_packets++;
+		priv->nstats.rx_bytes += rx_ind_size;
+		netif_rx(skb);
 
-			/* rx indication */
-			skb->dev = priv->net_dev;
-			skb->protocol = eth_type_trans(skb, skb->dev);
-			priv->nstats.rx_packets++;
-			priv->nstats.rx_bytes += rx_ind_size;
-			netif_rx(skb);
-		} else {
-			priv->nstats.rx_dropped++;
-		}
 		break;
 	default:	/* other rx data */
 		DPRINTK(2, "invalid data format\n");
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/19] staging: ks7010: remove magic numbers
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (3 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 04/19] staging: ks7010: move skb null check near allocation Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 06/19] staging: ks7010: remove duplicate code Tobin C. Harding
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver includes magic numbers. Defining constants or using existing
constants aids the readability of the code.

Magic number '12' is used for two ethernet addresses (6 bytes
each). ETH_ALEN is already defined within the kernel to 6. We can us
the expression '2 * ETH_ALEN' to make this code explicit.

Magic number '20' refers to the data size, in bytes, of a struct
ether_hdr (described in eap_packet.h). We can define a constant for
this purpose, making the code explicit and easier to read.

Define constant. Remove magic numbers, using newly defined constant
and/or expression using existing kernel constant.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/eap_packet.h |  2 ++
 drivers/staging/ks7010/ks_hostif.c  | 25 ++++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h
index 7a3decf..b2d25ef 100644
--- a/drivers/staging/ks7010/eap_packet.h
+++ b/drivers/staging/ks7010/eap_packet.h
@@ -9,6 +9,8 @@
 #define ETH_ALEN 6
 #endif
 
+#define ETHER_HDR_SIZE 20
+
 struct ether_hdr {
 	unsigned char h_dest[ETH_ALEN];	/* destination eth addr */
 	unsigned char h_source[ETH_ALEN];	/* source ether addr    */
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 11adc5f..6f90e23 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -399,6 +399,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 	struct ether_hdr *eth_hdr;
 	unsigned short eth_proto;
 	struct ieee802_1x_hdr *aa1x_hdr;
+	size_t size;
 	int ret;
 
 	DPRINTK(3, "\n");
@@ -452,12 +453,15 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 		}
 		DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
 
-		memcpy(skb_put(skb, 12), priv->rxp, 12);	/* 8802/FDDI MAC copy */
+		size = ETH_ALEN * 2;
+		memcpy(skb_put(skb, size), priv->rxp, size);
+
 		/* (SNAP+UI..) skip */
-		memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18,
-		       rx_ind_size - 12);	/* copy after Type */
 
-		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
+		size = rx_ind_size - (ETH_ALEN * 2);
+		memcpy(skb_put(skb, size), &eth_hdr->h_proto, size);
+
+		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
 		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
 		    priv->wpa.rsn_enabled)
 			atomic_set(&priv->psstatus.snooze_guard, 1);
@@ -1113,6 +1117,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	struct ieee802_1x_hdr *aa1x_hdr;
 	struct wpa_eapol_key *eap_key;
 	struct ethhdr *eth;
+	size_t size;
 	int ret;
 
 	skb_len = skb->len;
@@ -1164,11 +1169,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 		goto err_kfree;
 	}
 
-	/* MAC address copy */
-	memcpy(p, buffer, 12);	/* DST/SRC MAC address */
-	p += 12;
-	buffer += 12;
-	length -= 12;
+	/* dest and src MAC address copy */
+	size = ETH_ALEN * 2;
+	memcpy(p, buffer, size);
+	p += size;
+	buffer += size;
+	length -= size;
+
 	/* EtherType/Length check */
 	if (*(buffer + 1) + (*buffer << 8) > 1500) {
 		/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/19] staging: ks7010: remove duplicate code
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (4 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 05/19] staging: ks7010: remove magic numbers Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 07/19] staging: ks7010: clean memory allocation Tobin C. Harding
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Current switch statement has duplicate code in branches. This code can
be put after the switch statement so as to remove the duplication.

Move code to after switch statement, remove duplicate code. Make error
branch return so as not to execute the moved code block. Do not change
the program logic.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 6f90e23..d5ec487 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -462,17 +462,6 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 		memcpy(skb_put(skb, size), &eth_hdr->h_proto, size);
 
 		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
-		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-		    priv->wpa.rsn_enabled)
-			atomic_set(&priv->psstatus.snooze_guard, 1);
-
-		/* rx indication */
-		skb->dev = priv->net_dev;
-		skb->protocol = eth_type_trans(skb, skb->dev);
-		priv->nstats.rx_packets++;
-		priv->nstats.rx_bytes += rx_ind_size;
-		netif_rx(skb);
-
 		break;
 	case 0xF0:	/* NETBEUI/NetBIOS */
 		rx_ind_size = (priv->rx_size + 2);
@@ -493,22 +482,23 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 		       rx_ind_size - 14);	/* copy after Type */
 
 		aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
-		if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
-		    priv->wpa.rsn_enabled)
-			atomic_set(&priv->psstatus.snooze_guard, 1);
-
-		/* rx indication */
-		skb->dev = priv->net_dev;
-		skb->protocol = eth_type_trans(skb, skb->dev);
-		priv->nstats.rx_packets++;
-		priv->nstats.rx_bytes += rx_ind_size;
-		netif_rx(skb);
-
 		break;
 	default:	/* other rx data */
 		DPRINTK(2, "invalid data format\n");
 		priv->nstats.rx_errors++;
+		return;
 	}
+
+	if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
+	    priv->wpa.rsn_enabled)
+		atomic_set(&priv->psstatus.snooze_guard, 1);
+
+	/* rx indication */
+	skb->dev = priv->net_dev;
+	skb->protocol = eth_type_trans(skb, skb->dev);
+	priv->nstats.rx_packets++;
+	priv->nstats.rx_bytes += rx_ind_size;
+	netif_rx(skb);
 }
 
 static
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/19] staging: ks7010: clean memory allocation
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (5 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 06/19] staging: ks7010: remove duplicate code Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 08/19] staging: ks7010: add hostif_generic_request() Tobin C. Harding
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Memory allocation code contains unneeded debug statements, failed
kmalloc() calls typically do not require a debug message. Introduction
of a local 'size' variable allows kmalloc() call to be marginally
cleaner, still uses magic numbers but these require a more substantial
fix. Moving the magic numbers onto a single line opens the way for
further refactoring.

Clean memory allocation code, remove debug statements.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index d5ec487..2fefb92 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1135,12 +1135,9 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 			netif_stop_queue(priv->net_dev);
 	}
 
-	DPRINTK(4, "skb_buff length=%d\n", skb_len);
-	pp = kmalloc(hif_align_size(sizeof(*pp) + 6 + skb_len + 8),
-		     KS_WLAN_MEM_FLAG);
-
+	size = sizeof(*pp) + 6 + skb_len + 8;
+	pp = kmalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
 	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
 		ret = -ENOMEM;
 		goto err_kfree_skb;
 	}
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/19] staging: ks7010: add hostif_generic_request()
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (6 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 07/19] staging: ks7010: clean memory allocation Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 09/19] staging: ks7010: abstract connection status Tobin C. Harding
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver contains duplicate code. Host interface has numerous request
functions which allocate memory for a request header. Each request
header is different but all contain, as the first member, a hostif_hdr
structure. This structure has size and event members which need to be
set. By defining a helper function to allocate the memory and set the
initial hostif_hdr members code duplication is reduced.

Add function to allocate  memory for a host interface request. Set
'size' and 'event' members. Remove duplicate code using newly defined
function.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 173 ++++++++++++-------------------------
 1 file changed, 57 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 2fefb92..0a2566c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1091,6 +1091,21 @@ void hostif_event_check(struct ks_wlan_private *priv)
 	priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE;
 }
 
+/* allocate size bytes, set header size and event */
+static void *hostif_generic_request(size_t size, int event)
+{
+	struct hostif_hdr *p;
+
+	p = kzalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+	if (!p)
+		return NULL;
+
+	p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
+	p->event = cpu_to_le16(event);
+
+	return p;
+}
+
 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 {
 	unsigned int skb_len = 0;
@@ -1283,15 +1298,10 @@ void hostif_mib_get_request(struct ks_wlan_private *priv,
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ);
+
 	pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
 
 	/* send to device request */
@@ -1313,17 +1323,10 @@ void hostif_mib_set_request(struct ks_wlan_private *priv,
 		return;
 	}
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_MIB_SET_REQ);
+	if (!pp)
 		return;
-	}
 
-	pp->header.size =
-	    cpu_to_le16((uint16_t)
-			(sizeof(*pp) - sizeof(pp->header.size) + size));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ);
 	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);
@@ -1341,15 +1344,10 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ);
+
 	pp->mode = cpu_to_le16((uint16_t)mode);
 
 	/* send to device request */
@@ -1368,16 +1366,10 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ);
+	if (!pp)
 		return;
-	}
-	memset(pp, 0, sizeof(*pp));
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ);
+
 	pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
 	pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
 	pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
@@ -1411,15 +1403,10 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ);
+
 	pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
 	pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
 	pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
@@ -1477,15 +1464,10 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv)
 
 	DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET2_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ);
+
 	pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
 	pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
 	pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
@@ -1546,16 +1528,10 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
+	if (!pp)
 		return;
-	}
-	memset(pp, 0, sizeof(*pp));
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
+
 	pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
 	pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
 	pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
@@ -1591,16 +1567,10 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
+	if (!pp)
 		return;
-	}
-	memset(pp, 0, sizeof(*pp));
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
+
 	pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
 	pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
 	pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
@@ -1638,15 +1608,9 @@ void hostif_stop_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
 
 	/* send to device request */
 	ps_confirm_wait_inc(priv);
@@ -1660,15 +1624,10 @@ void hostif_phy_information_request(struct ks_wlan_private *priv)
 
 	DPRINTK(3, "\n");
 
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+	pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ);
+
 	if (priv->reg.phy_info_timer) {
 		pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
 		pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
@@ -1691,15 +1650,11 @@ void hostif_power_mngmt_request(struct ks_wlan_private *priv,
 
 	DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up,
 		receiveDTIMs);
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+
+	pp = hostif_generic_request(sizeof(*pp), HIF_POWERMGT_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ);
+
 	pp->mode = cpu_to_le32((uint32_t)mode);
 	pp->wake_up = cpu_to_le32((uint32_t)wake_up);
 	pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs);
@@ -1717,15 +1672,9 @@ void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
 	DPRINTK(3, "mode=%lu\n", mode);
 
 	if (mode == SLP_ASLEEP) {
-		/* make primitive */
-		pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-		if (!pp) {
-			DPRINTK(3, "allocate memory failed..\n");
+		pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
+		if (!pp)
 			return;
-		}
-		pp->header.size =
-		    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-		pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ);
 
 		/* send to device request */
 		ps_confirm_wait_inc(priv);
@@ -1748,15 +1697,11 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
 	struct hostif_bss_scan_request_t *pp;
 
 	DPRINTK(2, "\n");
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+
+	pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ);
+
 	pp->scan_type = scan_type;
 
 	pp->ch_time_min = cpu_to_le32((uint32_t)110);	/* default value */
@@ -1804,15 +1749,11 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv,
 	struct hostif_mic_failure_request_t *pp;
 
 	DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer);
-	/* make primitive */
-	pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
-	if (!pp) {
-		DPRINTK(3, "allocate memory failed..\n");
+
+	pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ);
+	if (!pp)
 		return;
-	}
-	pp->header.size =
-	    cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
-	pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ);
+
 	pp->failure_count = cpu_to_le16((uint16_t)failure_count);
 	pp->timer = cpu_to_le16((uint16_t)timer);
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/19] staging: ks7010: abstract connection status
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (7 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 08/19] staging: ks7010: add hostif_generic_request() Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 10/19] staging: ks7010: add enum sleep_mode_type Tobin C. Harding
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Host interface connection status is handled using a 32 bit type. Top
byte is used as for FORCE_DISCONNECT status, low bits are used for
connect/disconnect status. Driver masks and checks integers to
ascertain status. If functions are defined to do the masking and
equality check then the details of how the status integer is used are
abstracted away. This makes the code easier to read. Also future
updates to the status handling will be easier because the code is in
one place.

Driver currently uses the CONNECT_STATUS and DISCONNECT_STATUS as
values, as apposed to opaque values. Because of this driver code
checks for equality with CONNECT_STATUS and DISCONNECT_STATUS as
apposed to negating a single check (ie 'foo != CONNECT_STATUS). In
order to maintain the current functionality we define two separate
functions is_connect_status() and is_disconnect_status().

Add functions to abstract the status integer check. Update all sites
that do the check manually to use the newly defined functions.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks7010_sdio.c |  2 +-
 drivers/staging/ks7010/ks_hostif.c   | 24 ++++++++++++------------
 drivers/staging/ks7010/ks_wlan.h     |  2 ++
 drivers/staging/ks7010/ks_wlan_net.c | 27 ++++++++++++++++++++++++---
 4 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 5f6a022..0e50b1f 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -172,7 +172,7 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 	if (priv->reg.operation_mode != MODE_INFRASTRUCTURE)
 		return;
 
-	if ((priv->connect_status & CONNECT_STATUS_MASK) != CONNECT_STATUS)
+	if (!is_connect_status(priv->connect_status))
 		return;
 
 	if (priv->dev_state != DEVICE_STATE_SLEEP)
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 0a2566c..0f6b507 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -99,7 +99,7 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv)
 {
 	DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status));
 
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
+	if (is_connect_status(priv->connect_status))
 		hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
 	else
 		priv->dev_state = DEVICE_STATE_READY;
@@ -116,7 +116,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
 	DPRINTK(3, "\n");
 	ap = &priv->current_ap;
 
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
+	if (is_disconnect_status(priv->connect_status)) {
 		memset(ap, 0, sizeof(struct local_ap_t));
 		return -EPERM;
 	}
@@ -183,7 +183,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
 	wrqu.data.length = 0;
 	wrqu.data.flags = 0;
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
+	if (is_connect_status(priv->connect_status)) {
 		memcpy(wrqu.ap_addr.sa_data,
 		       priv->current_ap.bssid, ETH_ALEN);
 		DPRINTK(3,
@@ -744,7 +744,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
 	wrqu.data.length = 0;
 	wrqu.data.flags = 0;
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
+	if (is_connect_status(priv->connect_status)) {
 		eth_zero_addr(wrqu.ap_addr.sa_data);
 		DPRINTK(3, "IWEVENT: disconnect\n");
 		wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
@@ -791,8 +791,8 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
 	}
 
 	get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS &&
-	    (old_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
+	if (is_connect_status(priv->connect_status) &&
+	    is_disconnect_status(old_status)) {
 		/* for power save */
 		atomic_set(&priv->psstatus.snooze_guard, 0);
 		atomic_set(&priv->psstatus.confirm_wait, 0);
@@ -802,8 +802,8 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
 	wrqu0.data.length = 0;
 	wrqu0.data.flags = 0;
 	wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS &&
-	    (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
+	if (is_disconnect_status(priv->connect_status) &&
+	    is_connect_status(old_status)) {
 		eth_zero_addr(wrqu0.ap_addr.sa_data);
 		DPRINTK(3, "IWEVENT: disconnect\n");
 		DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
@@ -860,7 +860,7 @@ void hostif_stop_confirm(struct ks_wlan_private *priv)
 		priv->dev_state = DEVICE_STATE_READY;
 
 	/* disconnect indication */
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
+	if (is_connect_status(priv->connect_status)) {
 		netif_carrier_off(netdev);
 		tmp = FORCE_DISCONNECT & priv->connect_status;
 		priv->connect_status = tmp | DISCONNECT_STATUS;
@@ -869,8 +869,8 @@ void hostif_stop_confirm(struct ks_wlan_private *priv)
 		wrqu0.data.length = 0;
 		wrqu0.data.flags = 0;
 		wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
-		if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS &&
-		    (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
+		if (is_disconnect_status(priv->connect_status) &&
+		    is_connect_status(old_status)) {
 			eth_zero_addr(wrqu0.ap_addr.sa_data);
 			DPRINTK(3, "IWEVENT: disconnect\n");
 			netdev_info(netdev, "IWEVENT: disconnect\n");
@@ -1132,7 +1132,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 		goto err_kfree_skb;
 	}
 
-	if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) ||
+	if (is_disconnect_status(priv->connect_status) ||
 	    (priv->connect_status & FORCE_DISCONNECT) ||
 	    priv->wpa.mic_failure.stop) {
 		DPRINTK(3, " DISCONNECT\n");
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index eb15db9..a246539 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -508,5 +508,7 @@ struct ks_wlan_private {
 
 int ks_wlan_net_start(struct net_device *dev);
 int ks_wlan_net_stop(struct net_device *dev);
+bool is_connect_status(u32 status);
+bool is_disconnect_status(u32 status);
 
 #endif /* _KS_WLAN_H */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 0c36290..905e302 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -253,10 +253,11 @@ static int ks_wlan_get_freq(struct net_device *dev,
 		return -EPERM;
 
 	/* for SLEEP MODE */
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
+	if (is_connect_status(priv->connect_status))
 		f = (int)priv->current_ap.channel;
-		else
+	else
 		f = (int)priv->reg.channel;
+
 	fwrq->m = frequency_list[f - 1] * 100000;
 	fwrq->e = 1;
 
@@ -395,7 +396,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
 		return -EPERM;
 
 	/* for SLEEP MODE */
-	if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
+	if (is_connect_status(priv->connect_status))
 		memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN);
 	else
 		eth_zero_addr(awrq->sa_data);
@@ -3032,3 +3033,23 @@ int ks_wlan_net_stop(struct net_device *dev)
 
 	return 0;
 }
+
+/**
+ * is_connect_status() - return true if status is 'connected'
+ * @status: high bit is used as FORCE_DISCONNECT, low bits used for
+ * 	connect status.
+ */
+bool is_connect_status(u32 status)
+{
+	return (status & CONNECT_STATUS_MASK) == CONNECT_STATUS;
+}
+
+/**
+ * is_disconnect_status() - return true if status is 'disconnected'
+ * @status: high bit is used as FORCE_DISCONNECT, low bits used for
+ * 	disconnect status.
+ */
+bool is_disconnect_status(u32 status)
+{
+	return (status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS;
+}
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/19] staging: ks7010: add enum sleep_mode_type
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (8 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 09/19] staging: ks7010: abstract connection status Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 11/19] staging: ks7010: fix checkpatch LINE_SPACING Tobin C. Harding
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver uses preprocessor directives to define SLP_ASLEEP and
SLP_ACTIVE. These can be defined using an enumeration type. Doing so
adds to the readability and gives the usual compiler benefits of
having an enum. Functions that currently accept integer types can now
use the new enumeration type, further aiding readability.

Add enumeration type sleep_mode_type. Update code that handles sleep
mode to use the new enumeration type.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c   |  7 ++++---
 drivers/staging/ks7010/ks_hostif.h   |  8 +++++---
 drivers/staging/ks7010/ks_wlan_net.c | 21 +++++++++------------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 0f6b507..3ad2dc2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1665,11 +1665,12 @@ void hostif_power_mngmt_request(struct ks_wlan_private *priv,
 }
 
 static
-void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
+void hostif_sleep_request(struct ks_wlan_private *priv,
+			  enum sleep_mode_type mode)
 {
 	struct hostif_sleep_request_t *pp;
 
-	DPRINTK(3, "mode=%lu\n", mode);
+	DPRINTK(3, "mode=%lu\n", (long)mode);
 
 	if (mode == SLP_ASLEEP) {
 		pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
@@ -1684,7 +1685,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
 		atomic_set(&priv->sleepstatus.wakeup_request, 1);
 		queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
 	} else {
-		DPRINTK(3, "invalid mode %ld\n", mode);
+		DPRINTK(3, "invalid mode %ld\n", (long)mode);
 		return;
 	}
 }
diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index 2d9a342..98944e1 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -542,9 +542,11 @@ struct hostif_phy_information_confirm_t {
 	u32 rx_error;
 } __packed;
 
-/* sleep mode */
-#define SLP_ACTIVE  0
-#define SLP_ASLEEP  1
+enum sleep_mode_type {
+	SLP_ACTIVE,
+	SLP_ASLEEP
+};
+
 struct hostif_sleep_request_t {
 	struct hostif_hdr header;
 } __packed;
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 905e302..a50d86d 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2309,22 +2309,19 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
 
 	DPRINTK(2, "\n");
 
-	if (*uwrq == SLP_ASLEEP) {
-		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_ASLEEP && *uwrq != SLP_ACTIVE) {
 		netdev_err(dev, "SET_SLEEP_MODE %d errror\n", *uwrq);
 		return -EINVAL;
 	}
 
+	priv->sleep_mode = *uwrq;
+	netdev_info(dev, "SET_SLEEP_MODE %d\n", *uwrq);
+
+	if (*uwrq == SLP_ASLEEP)
+		hostif_sme_enqueue(priv, SME_STOP_REQUEST);
+
+	hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
+
 	return 0;
 }
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 11/19] staging: ks7010: fix checkpatch LINE_SPACING
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (9 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 10/19] staging: ks7010: add enum sleep_mode_type Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 12/19] staging: ks7010: make abbreviation mgmt uniform Tobin C. Harding
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Checkpatch emits CHECK: Please don't use multiple blank lines.

Remove multiple blank lines.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 3ad2dc2..0f806b7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1217,7 +1217,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 		}
 	}
 
-
 	if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) {
 		if (eth_proto == ETHER_PROTOCOL_TYPE_EAP &&
 		    priv->wpa.key[1].key_len == 0 &&
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 12/19] staging: ks7010: make abbreviation mgmt uniform
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (10 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 11/19] staging: ks7010: fix checkpatch LINE_SPACING Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 13/19] staging: ks7010: remove cast from netdev_priv() Tobin C. Harding
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver currently uses abbreviations 'mgt' and 'mngmt' for
'management'. Also 'power' is sometimes abbreviated to 'pow' and other
times not. It makes the code easier to read and easier to modify if
one abbreviation is used throughout the driver. 'mgmt' is widely
accepted as an abbreviation of 'management'. 'power' can be spelled
out in full, the extra two characters aids readability without an
excessive cost.

Make abbreviation of 'management' uniform across the driver, function
names, preprocessor defined constants, and enumeration types.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks7010_sdio.c |  4 ++--
 drivers/staging/ks7010/ks_hostif.c   | 32 +++++++++++++-------------
 drivers/staging/ks7010/ks_hostif.h   | 17 +++++++-------
 drivers/staging/ks7010/ks_wlan.h     |  2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 44 ++++++++++++++++++------------------
 5 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 0e50b1f..9aff93d 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -166,7 +166,7 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 	unsigned char byte;
 	int ret;
 
-	if (priv->reg.powermgt == POWMGT_ACTIVE_MODE)
+	if (priv->reg.power_mgmt == POWER_MGMT_ACTIVE)
 		return;
 
 	if (priv->reg.operation_mode != MODE_INFRASTRUCTURE)
@@ -800,7 +800,7 @@ static void ks7010_init_defaults(struct ks_wlan_private *priv)
 {
 	priv->reg.tx_rate = TX_RATE_AUTO;
 	priv->reg.preamble = LONG_PREAMBLE;
-	priv->reg.powermgt = POWMGT_ACTIVE_MODE;
+	priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
 	priv->reg.scan_type = ACTIVE_SCAN;
 	priv->reg.beacon_lost_count = 20;
 	priv->reg.rts = 2347UL;
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 0f806b7..d1bfac0 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -712,11 +712,11 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
 }
 
 static
-void hostif_power_mngmt_confirm(struct ks_wlan_private *priv)
+void hostif_power_mgmt_confirm(struct ks_wlan_private *priv)
 {
 	DPRINTK(3, "\n");
 
-	if (priv->reg.powermgt > POWMGT_ACTIVE_MODE &&
+	if (priv->reg.power_mgmt > POWER_MGMT_ACTIVE &&
 	    priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
 		atomic_set(&priv->psstatus.confirm_wait, 0);
 		priv->dev_state = DEVICE_STATE_SLEEP;
@@ -1035,8 +1035,8 @@ void hostif_event_check(struct ks_wlan_private *priv)
 	case HIF_MIB_SET_CONF:
 		hostif_mib_set_confirm(priv);
 		break;
-	case HIF_POWERMGT_CONF:
-		hostif_power_mngmt_confirm(priv);
+	case HIF_POWER_MGMT_CONF:
+		hostif_power_mgmt_confirm(priv);
 		break;
 	case HIF_SLEEP_CONF:
 		hostif_sleep_confirm(priv);
@@ -1641,16 +1641,16 @@ void hostif_phy_information_request(struct ks_wlan_private *priv)
 }
 
 static
-void hostif_power_mngmt_request(struct ks_wlan_private *priv,
-				unsigned long mode, unsigned long wake_up,
-				unsigned long receiveDTIMs)
+void hostif_power_mgmt_request(struct ks_wlan_private *priv,
+			       unsigned long mode, unsigned long wake_up,
+			       unsigned long receiveDTIMs)
 {
-	struct hostif_power_mngmt_request_t *pp;
+	struct hostif_power_mgmt_request_t *pp;
 
 	DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up,
 		receiveDTIMs);
 
-	pp = hostif_generic_request(sizeof(*pp), HIF_POWERMGT_REQ);
+	pp = hostif_generic_request(sizeof(*pp), HIF_POWER_MGMT_REQ);
 	if (!pp)
 		return;
 
@@ -2198,18 +2198,18 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 }
 
 static
-void hostif_sme_powermgt_set(struct ks_wlan_private *priv)
+void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
 {
 	unsigned long mode, wake_up, receiveDTIMs;
 
 	DPRINTK(3, "\n");
-	switch (priv->reg.powermgt) {
-	case POWMGT_ACTIVE_MODE:
+	switch (priv->reg.power_mgmt) {
+	case POWER_MGMT_ACTIVE:
 		mode = POWER_ACTIVE;
 		wake_up = 0;
 		receiveDTIMs = 0;
 		break;
-	case POWMGT_SAVE1_MODE:
+	case POWER_MGMT_SAVE1:
 		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
 			mode = POWER_SAVE;
 			wake_up = 0;
@@ -2220,7 +2220,7 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv)
 			receiveDTIMs = 0;
 		}
 		break;
-	case POWMGT_SAVE2_MODE:
+	case POWER_MGMT_SAVE2:
 		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
 			mode = POWER_SAVE;
 			wake_up = 0;
@@ -2237,7 +2237,7 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv)
 		receiveDTIMs = 0;
 		break;
 	}
-	hostif_power_mngmt_request(priv, mode, wake_up, receiveDTIMs);
+	hostif_power_mgmt_request(priv, mode, wake_up, receiveDTIMs);
 }
 
 static
@@ -2370,7 +2370,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 					priv->scan_ssid, priv->scan_ssid_len);
 		break;
 	case SME_POW_MNGMT_REQUEST:
-		hostif_sme_powermgt_set(priv);
+		hostif_sme_power_mgmt_set(priv);
 		break;
 	case SME_PHY_INFO_REQUEST:
 		hostif_phy_information_request(priv);
diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index 98944e1..384d876 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -23,8 +23,8 @@
 #define HIF_MIB_GET_CONF	0xE802
 #define HIF_MIB_SET_REQ		0xE003
 #define HIF_MIB_SET_CONF	0xE803
-#define HIF_POWERMGT_REQ	0xE004
-#define HIF_POWERMGT_CONF	0xE804
+#define HIF_POWER_MGMT_REQ	0xE004
+#define HIF_POWER_MGMT_CONF	0xE804
 #define HIF_START_REQ		0xE005
 #define HIF_START_CONF		0xE805
 #define HIF_CONNECT_IND		0xE806
@@ -180,7 +180,7 @@ struct hostif_mib_set_confirm_t {
 	u32 mib_attribute;
 } __packed;
 
-struct hostif_power_mngmt_request_t {
+struct hostif_power_mgmt_request_t {
 	struct hostif_hdr header;
 	u32 mode;
 #define POWER_ACTIVE  1
@@ -193,11 +193,10 @@ struct hostif_power_mngmt_request_t {
 #define DTIM_TRUE  1
 } __packed;
 
-/* power management mode */
-enum {
-	POWMGT_ACTIVE_MODE = 0,
-	POWMGT_SAVE1_MODE,
-	POWMGT_SAVE2_MODE
+enum power_mgmt_mode_type {
+	POWER_MGMT_ACTIVE,
+	POWER_MGMT_SAVE1,
+	POWER_MGMT_SAVE2
 };
 
 #define	RESULT_SUCCESS            0
@@ -206,7 +205,7 @@ enum {
 /* #define	RESULT_ALREADY_RUNNING    3 */
 #define	RESULT_ALREADY_RUNNING    7
 
-struct hostif_power_mngmt_confirm_t {
+struct hostif_power_mgmt_confirm_t {
 	struct hostif_hdr header;
 	u16 result_code;
 } __packed;
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index a246539..cd4f56d 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -58,7 +58,7 @@ struct ks_wlan_parameter {
 		u8 body[32 + 1];
 	} ssid;	/*  SSID */
 	u8 preamble;	/*  Preamble */
-	u8 powermgt;	/*  PowerManagementMode */
+	u8 power_mgmt;
 	u32 scan_type;	/*  AP List Scan Type */
 #define BEACON_LOST_COUNT_MIN 0
 #define BEACON_LOST_COUNT_MAX 65535
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index a50d86d..8ecf34b 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1204,10 +1204,10 @@ static int ks_wlan_set_power(struct net_device *dev,
 		return -EPERM;
 
 	if (vwrq->disabled) {
-		priv->reg.powermgt = POWMGT_ACTIVE_MODE;
+		priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
 	} else {
 		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-			priv->reg.powermgt = POWMGT_SAVE1_MODE;
+			priv->reg.power_mgmt = POWER_MGMT_SAVE1;
 		else
 			return -EINVAL;
 	}
@@ -1227,7 +1227,7 @@ static int ks_wlan_get_power(struct net_device *dev,
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
 	/* for SLEEP MODE */
-	if (priv->reg.powermgt > 0)
+	if (priv->reg.power_mgmt > 0)
 		vwrq->disabled = 0;
 	else
 		vwrq->disabled = 1;
@@ -2102,9 +2102,9 @@ static int ks_wlan_get_preamble(struct net_device *dev,
 	return 0;
 }
 
-static int ks_wlan_set_powermgt(struct net_device *dev,
-				struct iw_request_info *info, __u32 *uwrq,
-				char *extra)
+static int ks_wlan_set_power_mgmt(struct net_device *dev,
+				  struct iw_request_info *info, __u32 *uwrq,
+				  char *extra)
 {
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
@@ -2113,16 +2113,16 @@ static int ks_wlan_set_powermgt(struct net_device *dev,
 		return -EPERM;
 
 	/* for SLEEP MODE */
-	if (*uwrq == POWMGT_ACTIVE_MODE) {	/* 0 */
-		priv->reg.powermgt = POWMGT_ACTIVE_MODE;
-	} else if (*uwrq == POWMGT_SAVE1_MODE) {	/* 1 */
+	if (*uwrq == POWER_MGMT_ACTIVE) {	/* 0 */
+		priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
+	} else if (*uwrq == POWER_MGMT_SAVE1) {	/* 1 */
 		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-			priv->reg.powermgt = POWMGT_SAVE1_MODE;
+			priv->reg.power_mgmt = POWER_MGMT_SAVE1;
 		else
 			return -EINVAL;
-	} else if (*uwrq == POWMGT_SAVE2_MODE) {	/* 2 */
+	} else if (*uwrq == POWER_MGMT_SAVE2) {	/* 2 */
 		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-			priv->reg.powermgt = POWMGT_SAVE2_MODE;
+			priv->reg.power_mgmt = POWER_MGMT_SAVE2;
 		else
 			return -EINVAL;
 	} else {
@@ -2134,9 +2134,9 @@ static int ks_wlan_set_powermgt(struct net_device *dev,
 	return 0;
 }
 
-static int ks_wlan_get_powermgt(struct net_device *dev,
-				struct iw_request_info *info, __u32 *uwrq,
-				char *extra)
+static int ks_wlan_get_power_mgmt(struct net_device *dev,
+				  struct iw_request_info *info, __u32 *uwrq,
+				  char *extra)
 {
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
@@ -2145,7 +2145,7 @@ static int ks_wlan_get_powermgt(struct net_device *dev,
 		return -EPERM;
 
 	/* for SLEEP MODE */
-	*uwrq = priv->reg.powermgt;
+	*uwrq = priv->reg.power_mgmt;
 	return 0;
 }
 
@@ -2525,11 +2525,11 @@ static void print_hif_event(struct net_device *dev, int event)
 	case HIF_MIB_SET_CONF:
 		netdev_info(dev, "HIF_MIB_SET_CONF\n");
 		break;
-	case HIF_POWERMGT_REQ:
-		netdev_info(dev, "HIF_POWERMGT_REQ\n");
+	case HIF_POWER_MGMT_REQ:
+		netdev_info(dev, "HIF_POWER_MGMT_REQ\n");
 		break;
-	case HIF_POWERMGT_CONF:
-		netdev_info(dev, "HIF_POWERMGT_CONF\n");
+	case HIF_POWER_MGMT_CONF:
+		netdev_info(dev, "HIF_POWER_MGMT_CONF\n");
 		break;
 	case HIF_START_REQ:
 		netdev_info(dev, "HIF_START_REQ\n");
@@ -2782,8 +2782,8 @@ static const iw_handler ks_wlan_private_handler[] = {
 	(iw_handler)ks_wlan_get_eeprom_cksum,	/*  7 KS_WLAN_GET_CONNECT */
 	(iw_handler)ks_wlan_set_preamble,	/*  8 KS_WLAN_SET_PREAMBLE */
 	(iw_handler)ks_wlan_get_preamble,	/*  9 KS_WLAN_GET_PREAMBLE */
-	(iw_handler)ks_wlan_set_powermgt,	/* 10 KS_WLAN_SET_POWER_SAVE */
-	(iw_handler)ks_wlan_get_powermgt,	/* 11 KS_WLAN_GET_POWER_SAVE */
+	(iw_handler)ks_wlan_set_power_mgmt,	/* 10 KS_WLAN_SET_POWER_SAVE */
+	(iw_handler)ks_wlan_get_power_mgmt,	/* 11 KS_WLAN_GET_POWER_SAVE */
 	(iw_handler)ks_wlan_set_scan_type,	/* 12 KS_WLAN_SET_SCAN_TYPE */
 	(iw_handler)ks_wlan_get_scan_type,	/* 13 KS_WLAN_GET_SCAN_TYPE */
 	(iw_handler)ks_wlan_set_rx_gain,	/* 14 KS_WLAN_SET_RX_GAIN */
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 13/19] staging: ks7010: remove cast from netdev_priv()
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (11 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 12/19] staging: ks7010: make abbreviation mgmt uniform Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 14/19] staging: ks7010: continue from loop on unmatched mac Tobin C. Harding
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

The returned pointer from netdev_priv() (void *) does not need to be
cast.

Remove unnecessary cast of void * returned by netdev_priv().

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_wlan_net.c | 184 ++++++++++++-----------------------
 1 file changed, 64 insertions(+), 120 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 8ecf34b..dfcef6f 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -177,8 +177,7 @@ static int ks_wlan_get_name(struct net_device *dev,
 			    struct iw_request_info *info, char *cwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -200,8 +199,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_freq *fwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int channel;
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -245,8 +243,7 @@ static int ks_wlan_get_freq(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_freq *fwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int f;
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -268,8 +265,7 @@ static int ks_wlan_set_essid(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	size_t len;
 
 	DPRINTK(2, " %d\n", dwrq->flags);
@@ -325,8 +321,7 @@ static int ks_wlan_get_essid(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -355,8 +350,7 @@ static int ks_wlan_get_essid(struct net_device *dev,
 static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
 			   struct sockaddr *ap_addr, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "\n");
 
@@ -389,8 +383,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
 static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
 			   struct sockaddr *awrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -410,8 +403,7 @@ static int ks_wlan_set_nick(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_point *dwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -431,8 +423,7 @@ static int ks_wlan_get_nick(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_point *dwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -449,8 +440,7 @@ static int ks_wlan_set_rate(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_param *vwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int i = 0;
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -682,8 +672,7 @@ static int ks_wlan_get_rate(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_param *vwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n",
 		in_interrupt(), atomic_read(&update_phyinfo));
@@ -707,8 +696,7 @@ static int ks_wlan_get_rate(struct net_device *dev,
 static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
 			   struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int rthr = vwrq->value;
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -729,8 +717,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
 static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
 			   struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -747,8 +734,7 @@ static int ks_wlan_set_frag(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_param *vwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int fthr = vwrq->value;
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -771,8 +757,7 @@ static int ks_wlan_get_frag(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_param *vwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -789,8 +774,7 @@ static int ks_wlan_set_mode(struct net_device *dev,
 			    struct iw_request_info *info, __u32 *uwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "mode=%d\n", *uwrq);
 
@@ -823,8 +807,7 @@ static int ks_wlan_get_mode(struct net_device *dev,
 			    struct iw_request_info *info, __u32 *uwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -849,8 +832,7 @@ static int ks_wlan_set_encode(struct net_device *dev,
 			      struct iw_request_info *info,
 			      struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	struct wep_key key;
 	int index = (dwrq->flags & IW_ENCODE_INDEX);
@@ -965,8 +947,7 @@ static int ks_wlan_get_encode(struct net_device *dev,
 			      struct iw_request_info *info,
 			      struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	char zeros[16];
 	int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
 
@@ -1064,8 +1045,7 @@ static int ks_wlan_get_range(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_range *range = (struct iw_range *)extra;
 	int i, k;
 
@@ -1197,8 +1177,7 @@ static int ks_wlan_set_power(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -1221,8 +1200,7 @@ static int ks_wlan_get_power(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -1239,8 +1217,7 @@ static int ks_wlan_get_iwstats(struct net_device *dev,
 			       struct iw_request_info *info,
 			       struct iw_quality *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -1279,8 +1256,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
 			      struct iw_request_info *info,
 			      struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct sockaddr *address = (struct sockaddr *)extra;
 	struct iw_quality qual[LOCAL_APLIST_MAX];
 
@@ -1312,8 +1288,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
 			    struct iw_request_info *info,
 			    union iwreq_data *wrqu, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_scan_req *req = NULL;
 
 	DPRINTK(2, "\n");
@@ -1506,8 +1481,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_point *dwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int i;
 	char *current_ev = extra;
 
@@ -1552,8 +1526,7 @@ static int ks_wlan_config_commit(struct net_device *dev,
 				 struct iw_request_info *info, void *zwrq,
 				 char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (!priv->need_commit)
 		return 0;
@@ -1568,8 +1541,7 @@ static int ks_wlan_set_genie(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "\n");
 
@@ -1584,8 +1556,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
 				 struct iw_request_info *info,
 				 struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int index = (vwrq->flags & IW_AUTH_INDEX);
 	int value = vwrq->value;
 
@@ -1719,8 +1690,7 @@ static int ks_wlan_get_auth_mode(struct net_device *dev,
 				 struct iw_request_info *info,
 				 struct iw_param *vwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	int index = (vwrq->flags & IW_AUTH_INDEX);
 
 	DPRINTK(2, "index=%d\n", index);
@@ -1764,8 +1734,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
 				  struct iw_request_info *info,
 				  struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_encode_ext *enc;
 	int index = dwrq->flags & IW_ENCODE_INDEX;
 	unsigned int commit = 0;
@@ -1861,8 +1830,7 @@ static int ks_wlan_get_encode_ext(struct net_device *dev,
 				  struct iw_request_info *info,
 				  struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -1882,8 +1850,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
 			     struct iw_request_info *info,
 			     struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_pmksa *pmksa;
 	int i;
 	struct pmk_t *pmk;
@@ -1982,8 +1949,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
 
 static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_statistics *wstats = &priv->wstats;
 
 	if (!atomic_read(&update_phyinfo)) {
@@ -2010,8 +1976,8 @@ static int ks_wlan_set_stop_request(struct net_device *dev,
 				    struct iw_request_info *info, __u32 *uwrq,
 				    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
+
 	DPRINTK(2, "\n");
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -2030,8 +1996,7 @@ static int ks_wlan_set_mlme(struct net_device *dev,
 			    struct iw_request_info *info, struct iw_point *dwrq,
 			    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 	struct iw_mlme *mlme = (struct iw_mlme *)extra;
 	__u32 mode;
 
@@ -2057,8 +2022,8 @@ static int ks_wlan_get_firmware_version(struct net_device *dev,
 					struct iw_request_info *info,
 					struct iw_point *dwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
+
 	strcpy(extra, priv->firmware_version);
 	dwrq->length = priv->version_size + 1;
 	return 0;
@@ -2068,8 +2033,7 @@ static int ks_wlan_set_preamble(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2091,8 +2055,7 @@ static int ks_wlan_get_preamble(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2106,8 +2069,7 @@ static int ks_wlan_set_power_mgmt(struct net_device *dev,
 				  struct iw_request_info *info, __u32 *uwrq,
 				  char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2138,8 +2100,7 @@ static int ks_wlan_get_power_mgmt(struct net_device *dev,
 				  struct iw_request_info *info, __u32 *uwrq,
 				  char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2153,8 +2114,7 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
 				 struct iw_request_info *info, __u32 *uwrq,
 				 char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2174,8 +2134,7 @@ static int ks_wlan_get_scan_type(struct net_device *dev,
 				 struct iw_request_info *info, __u32 *uwrq,
 				 char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2188,8 +2147,7 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
 				   struct iw_request_info *info, __u32 *uwrq,
 				   char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2211,8 +2169,7 @@ static int ks_wlan_get_beacon_lost(struct net_device *dev,
 				   struct iw_request_info *info, __u32 *uwrq,
 				   char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2225,8 +2182,7 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2249,8 +2205,7 @@ static int ks_wlan_get_phy_type(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2263,8 +2218,7 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2290,8 +2244,7 @@ static int ks_wlan_get_cts_mode(struct net_device *dev,
 				struct iw_request_info *info, __u32 *uwrq,
 				char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2304,8 +2257,7 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
 				  struct iw_request_info *info,
 				  __u32 *uwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "\n");
 
@@ -2329,8 +2281,7 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev,
 				  struct iw_request_info *info,
 				  __u32 *uwrq, char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode);
 	*uwrq = priv->sleep_mode;
@@ -2344,8 +2295,8 @@ static int ks_wlan_set_wps_enable(struct net_device *dev,
 				  struct iw_request_info *info, __u32 *uwrq,
 				  char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
+
 	DPRINTK(2, "\n");
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -2365,8 +2316,8 @@ static int ks_wlan_get_wps_enable(struct net_device *dev,
 				  struct iw_request_info *info, __u32 *uwrq,
 				  char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
+
 	DPRINTK(2, "\n");
 
 	if (priv->sleep_mode == SLP_ASLEEP)
@@ -2384,8 +2335,7 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev,
 {
 	u8 *p = extra;
 	unsigned char len;
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	DPRINTK(2, "\n");
 
@@ -2419,8 +2369,7 @@ static int ks_wlan_set_tx_gain(struct net_device *dev,
 			       struct iw_request_info *info, __u32 *uwrq,
 			       char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2443,8 +2392,7 @@ static int ks_wlan_get_tx_gain(struct net_device *dev,
 			       struct iw_request_info *info, __u32 *uwrq,
 			       char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2458,8 +2406,7 @@ static int ks_wlan_set_rx_gain(struct net_device *dev,
 			       struct iw_request_info *info, __u32 *uwrq,
 			       char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2482,8 +2429,7 @@ static int ks_wlan_get_rx_gain(struct net_device *dev,
 			       struct iw_request_info *info, __u32 *uwrq,
 			       char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	if (priv->sleep_mode == SLP_ASLEEP)
 		return -EPERM;
@@ -2497,8 +2443,7 @@ static int ks_wlan_get_eeprom_cksum(struct net_device *dev,
 				    struct iw_request_info *info, __u32 *uwrq,
 				    char *extra)
 {
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	*uwrq = priv->eeprom_checksum;
 	return 0;
@@ -2622,8 +2567,7 @@ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info,
 			 __u32 *uwrq, char *extra)
 {
 	int i, event;
-	struct ks_wlan_private *priv =
-	    (struct ks_wlan_private *)netdev_priv(dev);
+	struct ks_wlan_private *priv = netdev_priv(dev);
 
 	for (i = 63; i >= 0; i--) {
 		event =
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 14/19] staging: ks7010: continue from loop on unmatched mac
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (12 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 13/19] staging: ks7010: remove cast from netdev_priv() Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 15/19] staging: ks7010: clean up macro ps_confirm_wait_inc Tobin C. Harding
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Inside loop, code block is guarded with an 'if' statement. Instead of
guarding the block we can invert the 'if' statement conditional and
continue the loop. Doing so allows subsequent code indentation to be
reduced and aids the readability of the code.

Invert 'if' statement conditional, continue loop if new conditional
evaluates to true. Reduce subsequent code indentation level. Do not
change program logic.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index d1bfac0..4d6bc4f 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -825,13 +825,13 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
 	if (priv->scan_ind_count) {
 		for (i = 0; i < priv->aplist.size; i++) {	/* bssid check */
 			if (memcmp(ap_info->bssid,
-				   priv->aplist.ap[i].bssid, ETH_ALEN) == 0) {
-				if (ap_info->frame_type ==
-				    FRAME_TYPE_PROBE_RESP)
-					get_ap_information(priv, ap_info,
-							   &priv->aplist.ap[i]);
-				return;
-			}
+				   priv->aplist.ap[i].bssid, ETH_ALEN) != 0)
+				continue;
+
+			if (ap_info->frame_type == FRAME_TYPE_PROBE_RESP)
+				get_ap_information(priv, ap_info,
+						   &priv->aplist.ap[i]);
+			return;
 		}
 	}
 	priv->scan_ind_count++;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 15/19] staging: ks7010: clean up macro ps_confirm_wait_inc
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (13 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 14/19] staging: ks7010: continue from loop on unmatched mac Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 16/19] staging: ks7010: add enum multicast_filter_type Tobin C. Harding
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Macro includes commented out code. Removing dead code line enables
braces to be removed. Macro is easier to read if the code is clean.

Clean up macro ps_confirm_wait_inc.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 4d6bc4f..4561687 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1283,11 +1283,11 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	return ret;
 }
 
-#define ps_confirm_wait_inc(priv) do { \
-	if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) { \
-		atomic_inc(&priv->psstatus.confirm_wait); \
-		/* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \
-	} } while (0)
+#define ps_confirm_wait_inc(priv)					 \
+	do {								 \
+		if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) \
+			atomic_inc(&priv->psstatus.confirm_wait);	 \
+	} while (0)
 
 static
 void hostif_mib_get_request(struct ks_wlan_private *priv,
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 16/19] staging: ks7010: add enum multicast_filter_type
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (14 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 15/19] staging: ks7010: clean up macro ps_confirm_wait_inc Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 17/19] staging: ks7010: fix enumeration tags Tobin C. Harding
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver uses preprocessor directives to define multicast filter
constants. These can be defined using an enumeration type. Doing so
adds to the readability and gives the assists the compiler.

Add enumeration type multicast_filter_type to replace preprocessor
defined constants.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index 384d876..e679765 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -624,10 +624,11 @@ enum {
 	SHORT_PREAMBLE
 };
 
-/* multicast filter */
-#define MCAST_FILTER_MCAST    0
-#define MCAST_FILTER_MCASTALL 1
-#define MCAST_FILTER_PROMISC  2
+enum multicast_filter_type {
+	MCAST_FILTER_MCAST,
+	MCAST_FILTER_MCASTALL,
+	MCAST_FILTER_PROMISC,
+};
 
 #define NIC_MAX_MCAST_LIST 32
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 17/19] staging: ks7010: fix enumeration tags
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (15 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 16/19] staging: ks7010: add enum multicast_filter_type Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif Tobin C. Harding
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver header declares enumeration types without tags. Using
informative tags makes the code easier to understand and
eliminates the need to comment the enum.

Add tags to enumeration types.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/ks_hostif.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h
index e679765..c31177d 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -613,14 +613,13 @@ struct hostif_mic_failure_confirm_t {
 			     ((A & RATE_MASK) == TX_RATE_36M) || ((A & RATE_MASK) == TX_RATE_48M) || \
 			     ((A & RATE_MASK) == TX_RATE_54M))
 
-enum {
-	CONNECT_STATUS = 0,
+enum connect_status_type {
+	CONNECT_STATUS,
 	DISCONNECT_STATUS
 };
 
-/* preamble type */
-enum {
-	LONG_PREAMBLE = 0,
+enum preamble_type {
+	LONG_PREAMBLE,
 	SHORT_PREAMBLE
 };
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (16 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 17/19] staging: ks7010: fix enumeration tags Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-27  0:21   ` Tobin C. Harding
  2017-04-26  0:55 ` [PATCH 19/19] " Tobin C. Harding
  2017-04-27  0:28 ` [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
  19 siblings, 1 reply; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver uses non-uniform file names. Both in respect to itself and in
respect to other SDIO drivers. If we name files in a similar fashion
to in-tree SDIO drivers then we are following the principle of least
surprise.

Looking at in-tree SDIO drivers, hif.c would be the file name of
choice for the host interface code, however, the driver uses the
abbreviation 'hostif' for host interface. Best to be uniform within
the driver.

Rename ks_hostif.c to hostif.c
Rename ks_hostif.h to hostif.h

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/Makefile                  | 2 +-
 drivers/staging/ks7010/{ks_hostif.c => hostif.c} | 2 +-
 drivers/staging/ks7010/{ks_hostif.h => hostif.h} | 0
 drivers/staging/ks7010/ks7010_sdio.c             | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c             | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename drivers/staging/ks7010/{ks_hostif.c => hostif.c} (99%)
 rename drivers/staging/ks7010/{ks_hostif.h => hostif.h} (100%)

diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile
index 69fcf8d..23cf95a 100644
--- a/drivers/staging/ks7010/Makefile
+++ b/drivers/staging/ks7010/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_KS7010) += ks7010.o
 
 ccflags-y 	     += -DKS_WLAN_DEBUG=0
-ks7010-y	     := michael_mic.o ks_hostif.o ks_wlan_net.o ks7010_sdio.o
+ks7010-y	     := michael_mic.o hostif.o ks_wlan_net.o ks7010_sdio.o
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/hostif.c
similarity index 99%
rename from drivers/staging/ks7010/ks_hostif.c
rename to drivers/staging/ks7010/hostif.c
index 4561687..7d2ad52 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/hostif.c
@@ -10,7 +10,7 @@
  */
 
 #include "ks_wlan.h"
-#include "ks_hostif.h"
+#include "hostif.h"
 #include "eap_packet.h"
 #include "michael_mic.h"
 
diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/hostif.h
similarity index 100%
rename from drivers/staging/ks7010/ks_hostif.h
rename to drivers/staging/ks7010/hostif.h
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 9aff93d..6c10e3d 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -18,7 +18,7 @@
 
 #include "ks_wlan.h"
 #include "ks_wlan_ioctl.h"
-#include "ks_hostif.h"
+#include "hostif.h"
 #include "ks7010_sdio.h"
 
 #define KS7010_FUNC_NUM 1
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index dfcef6f..b5609c1 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -34,7 +34,7 @@ static int wep_on_off;
 #define	WEP_ON_128BIT	2
 
 #include "ks_wlan.h"
-#include "ks_hostif.h"
+#include "hostif.h"
 #include "ks_wlan_ioctl.h"
 
 /* Include Wireless Extension definition and check version */
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 19/19] staging: ks7010: rename ks_hostif to hostif
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (17 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif Tobin C. Harding
@ 2017-04-26  0:55 ` Tobin C. Harding
  2017-04-27  0:22   ` Tobin C. Harding
  2017-04-27  0:28 ` [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
  19 siblings, 1 reply; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-26  0:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Wolfram Sang, driverdev-devel

Driver uses non-uniform file names. Both in respect to itself and in
respect to other SDIO drivers. If we name files in a similar fashion
to in-tree SDIO drivers then we are following the principle of least
surprise.

Looking at in-tree SDIO drivers, 'sdio' is the name of choice for SDIO
code.

Rename ks7010_sdio.c to sdio.c
Rename ks7010_sdio.h to sdio.h

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 drivers/staging/ks7010/Makefile                  | 2 +-
 drivers/staging/ks7010/ks_wlan.h                 | 2 +-
 drivers/staging/ks7010/{ks7010_sdio.c => sdio.c} | 2 +-
 drivers/staging/ks7010/{ks7010_sdio.h => sdio.h} | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename drivers/staging/ks7010/{ks7010_sdio.c => sdio.c} (99%)
 rename drivers/staging/ks7010/{ks7010_sdio.h => sdio.h} (100%)

diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile
index 23cf95a..cb89a62 100644
--- a/drivers/staging/ks7010/Makefile
+++ b/drivers/staging/ks7010/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_KS7010) += ks7010.o
 
 ccflags-y 	     += -DKS_WLAN_DEBUG=0
-ks7010-y	     := michael_mic.o hostif.o ks_wlan_net.o ks7010_sdio.o
+ks7010-y	     := michael_mic.o hostif.o ks_wlan_net.o sdio.o
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index cd4f56d..6881dd0 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -32,7 +32,7 @@
 
 #include <linux/io.h>
 
-#include "ks7010_sdio.h"
+#include "sdio.h"
 
 #ifdef KS_WLAN_DEBUG
 #define DPRINTK(n, fmt, args...) \
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/sdio.c
similarity index 99%
rename from drivers/staging/ks7010/ks7010_sdio.c
rename to drivers/staging/ks7010/sdio.c
index 6c10e3d..2f21c93 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/sdio.c
@@ -19,7 +19,7 @@
 #include "ks_wlan.h"
 #include "ks_wlan_ioctl.h"
 #include "hostif.h"
-#include "ks7010_sdio.h"
+#include "sdio.h"
 
 #define KS7010_FUNC_NUM 1
 #define KS7010_IO_BLOCK_SIZE 512
diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/sdio.h
similarity index 100%
rename from drivers/staging/ks7010/ks7010_sdio.h
rename to drivers/staging/ks7010/sdio.h
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif
  2017-04-26  0:55 ` [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif Tobin C. Harding
@ 2017-04-27  0:21   ` Tobin C. Harding
  0 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-27  0:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: driverdev-devel, Wolfram Sang

On Wed, Apr 26, 2017 at 10:55:23AM +1000, Tobin C. Harding wrote:
[snip]

Please drop from the series this patch on wards (patch 18 and patch 19).

Is it easier for you if I resubmit the whole series?

Reason :

I just found the original GPL driver source released in 2009 by
Renesas and file naming makes sense when viewed amongst the original
files. This patch does not aid in the future conversion of this driver
to cfg80211 nor does it improve the clarity of the driver. It is
therefore unnecessary.

Sorry for the noise.

thanks,
Tobin.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 19/19] staging: ks7010: rename ks_hostif to hostif
  2017-04-26  0:55 ` [PATCH 19/19] " Tobin C. Harding
@ 2017-04-27  0:22   ` Tobin C. Harding
  0 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-27  0:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: driverdev-devel, Wolfram Sang

On Wed, Apr 26, 2017 at 10:55:24AM +1000, Tobin C. Harding wrote:
[snip]

Please drop this patch.

thanks,
Tobin.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/19] staging: ks7010: refactor host interface
  2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
                   ` (18 preceding siblings ...)
  2017-04-26  0:55 ` [PATCH 19/19] " Tobin C. Harding
@ 2017-04-27  0:28 ` Tobin C. Harding
  19 siblings, 0 replies; 23+ messages in thread
From: Tobin C. Harding @ 2017-04-27  0:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: driverdev-devel, Wolfram Sang

On Wed, Apr 26, 2017 at 10:55:05AM +1000, Tobin C. Harding wrote:
[snip]

Please drop this series. Will re-submit. Apologies for the noise, bad
newbie - no biscuit.

thanks,
Tobin.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-04-27  0:28 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  0:55 [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding
2017-04-26  0:55 ` [PATCH 01/19] staging: ks7010: rename constant SLP_SLEEP to SLP_ASLEEP Tobin C. Harding
2017-04-26  0:55 ` [PATCH 02/19] staging: ks7010: remove unnecessary address check Tobin C. Harding
2017-04-26  0:55 ` [PATCH 03/19] staging: ks7010: remove unused local variable eap_key Tobin C. Harding
2017-04-26  0:55 ` [PATCH 04/19] staging: ks7010: move skb null check near allocation Tobin C. Harding
2017-04-26  0:55 ` [PATCH 05/19] staging: ks7010: remove magic numbers Tobin C. Harding
2017-04-26  0:55 ` [PATCH 06/19] staging: ks7010: remove duplicate code Tobin C. Harding
2017-04-26  0:55 ` [PATCH 07/19] staging: ks7010: clean memory allocation Tobin C. Harding
2017-04-26  0:55 ` [PATCH 08/19] staging: ks7010: add hostif_generic_request() Tobin C. Harding
2017-04-26  0:55 ` [PATCH 09/19] staging: ks7010: abstract connection status Tobin C. Harding
2017-04-26  0:55 ` [PATCH 10/19] staging: ks7010: add enum sleep_mode_type Tobin C. Harding
2017-04-26  0:55 ` [PATCH 11/19] staging: ks7010: fix checkpatch LINE_SPACING Tobin C. Harding
2017-04-26  0:55 ` [PATCH 12/19] staging: ks7010: make abbreviation mgmt uniform Tobin C. Harding
2017-04-26  0:55 ` [PATCH 13/19] staging: ks7010: remove cast from netdev_priv() Tobin C. Harding
2017-04-26  0:55 ` [PATCH 14/19] staging: ks7010: continue from loop on unmatched mac Tobin C. Harding
2017-04-26  0:55 ` [PATCH 15/19] staging: ks7010: clean up macro ps_confirm_wait_inc Tobin C. Harding
2017-04-26  0:55 ` [PATCH 16/19] staging: ks7010: add enum multicast_filter_type Tobin C. Harding
2017-04-26  0:55 ` [PATCH 17/19] staging: ks7010: fix enumeration tags Tobin C. Harding
2017-04-26  0:55 ` [PATCH 18/19] staging: ks7010: rename ks_hostif to hostif Tobin C. Harding
2017-04-27  0:21   ` Tobin C. Harding
2017-04-26  0:55 ` [PATCH 19/19] " Tobin C. Harding
2017-04-27  0:22   ` Tobin C. Harding
2017-04-27  0:28 ` [PATCH 00/19] staging: ks7010: refactor host interface Tobin C. Harding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.