All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/47] staging: ks7010: next cleanups
@ 2018-04-30 13:43 Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 01/47] staging: ks7010: add SPDX identifiers to all files Sergio Paracuellos
                   ` (46 more replies)
  0 siblings, 47 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This patch series are all of my patches that haven't been
applied yet. Most of them are from previous series and 
there are also a few new patches included.

Sergio Paracuellos (47):
  staging: ks7010: add SPDX identifiers to all files
  staging: ks7010: move tx and rx queues definitions into ks_wlan.h
    header
  staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header
  staging: ks7010: change netdev_dbg msg to avoid a long line
  staging: ks7010: remove missing WPS preprocessor conditional code
  staging: ks7010: use u8 instead of unsigned char in write_to_device
    function
  staging: ks7010: change local variable type in _ks_wlan_hw_power_save
  staging: ks7010: change local variable type in ks7010_rw_function
  staging: ks7010: change some local variables type in ks_sdio_interrupt
  staging: ks7010: change local variable type in ks7010_sdio_init_irqs
  staging: ks7010: use the same parameter for 'event' in
    hostif_sme_enqueue
  staging: ks7010: refactor ks7010_sme_enqueue_events function
  staging: ks7010: change local variable type in ks_wlan_hw_rx
  staging: ks7010: remove nonsense comment in ks_wlan.h file
  staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in
    hostif_sme_execute
  staging: ks7010: convert MIB preprocessor defs into an enum
  staging: ks7010: conver MIB attributes preprocessor defs into an enum
  staging: ks7010: change some casts from uint8_t to u8 in ks_hostif
    header
  staging: ks7010: change parameter types and reorder them in
    hostif_mib_set_request
  staging: ks7010: add new helpers to achieve mib set request and
    simplify code
  staging: ks7010: use ether_addr_copy in get_current_ap
  staging: ks7010: move two preprocessor definitions to ks_wlan.h
  staging: ks7010: avoid two long lines in hostif_sme_mode_setup
  staging: ks7010: remove non sense comments in ks_hostif.c source file
  staging: ks7010: change type for rsn_enabled in wpa_status struct
  staging: ks7010: use ether_addr_copy to copy ethernet address sa_data
  staging: use ether_addr_copy in get_ap_information function
  staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside
    switch
  staging: ks7010: factor out send_request_to_device function
  staging: ks7010: fix some style issues in ks_hostif.c
  staging: ks7010: add blank line between after definitions
  staging: ks7010: refactor hostif_sme_set_rsn function
  staging: ks7010: change parameter types in hostif_power_mgmt_request
  staging: ks7010: refactor hostif_sme_power_mgmt_set function
  staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address
  staging: ks7010: use ether_addr_copy in ks_wlan_net_start
  staging: ks7010: refactor ks_wlan_set_sleep_mode function
  staging: ks7010: refactor ks_wlan_set_phy_type function
  staging: ks7010: refactor ks_wlan_set_mlme function
  staging: ks7010: refactor ks_get_wireless_stats function
  staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody
  staging: ks7010: refactor LOCAL_EEPROM_SUM case in
    hostif_mib_get_confirm
  staging: ks7010: use u16 instead of unsigned short in
    hostif_event_check
  staging: ks7010: use u16 instead of unsigned short in
    hostif_data_indication
  staging: ks7010: use u16 instead of unsigned short in
    hostif_connect_indication
  staging: ks7010: use u32 instead of unsigned int in
    hostif_bss_scan_confirm
  staging: ks7010: review local variable types in
    hostif_phy_information_confirm

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

-- 
2.7.4

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

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

* [PATCH 01/47] staging: ks7010: add SPDX identifiers to all files
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header Sergio Paracuellos
                   ` (45 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

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

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

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

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

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

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

* [PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 01/47] staging: ks7010: add SPDX identifiers to all files Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 03/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header Sergio Paracuellos
                   ` (44 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 6a5565d..9c22a76 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -8,7 +8,6 @@
  */
 
 #include <linux/atomic.h>
-#include <linux/circ_buf.h>
 #include <linux/firmware.h>
 #include <linux/jiffies.h>
 #include <linux/mmc/card.h>
@@ -98,50 +97,6 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
-static inline void inc_txqhead(struct ks_wlan_private *priv)
-{
-	priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_txqtail(struct ks_wlan_private *priv)
-{
-	priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool txq_has_space(struct ks_wlan_private *priv)
-{
-	return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
-			   TX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline void inc_rxqhead(struct ks_wlan_private *priv)
-{
-	priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_rxqtail(struct ks_wlan_private *priv)
-{
-	priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool rxq_has_space(struct ks_wlan_private *priv)
-{
-	return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
-			   RX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline unsigned int txq_count(struct ks_wlan_private *priv)
-{
-	return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
-			       TX_DEVICE_BUFF_SIZE);
-}
-
-static inline unsigned int rxq_count(struct ks_wlan_private *priv)
-{
-	return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
-			       RX_DEVICE_BUFF_SIZE);
-}
-
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 			     u32 address, u8 *byte)
diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h
index 831b2f1..891a09f 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -8,6 +8,8 @@
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
 
+struct ks_wlan_private;
+
 /**
  * struct ks_sdio_card - SDIO device data.
  *
@@ -21,65 +23,4 @@ struct ks_sdio_card {
 	struct ks_wlan_private *priv;
 };
 
-/* Tx Device struct */
-#define	TX_DEVICE_BUFF_SIZE	1024
-
-/**
- * struct tx_device_buffer - Queue item for the tx queue.
- * @sendp: Pointer to the send request data.
- * @size: Size of @sendp data.
- * @complete_handler: Function called once data write to device is complete.
- * @arg1: First argument to @complete_handler.
- * @arg2: Second argument to @complete_handler.
- */
-struct tx_device_buffer {
-	unsigned char *sendp;
-	unsigned int size;
-	void (*complete_handler)(struct ks_wlan_private *priv,
-				 struct sk_buff *skb);
-	struct sk_buff *skb;
-};
-
-/**
- * struct tx_device - Tx buffer queue.
- * @tx_device_buffer: Queue buffer.
- * @qhead: Head of tx queue.
- * @qtail: Tail of tx queue.
- * @tx_dev_lock: Queue lock.
- */
-struct tx_device {
-	struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
-	unsigned int qhead;
-	unsigned int qtail;
-	spinlock_t tx_dev_lock;	/* protect access to the queue */
-};
-
-/* Rx Device struct */
-#define	RX_DATA_SIZE	(2 + 2 + 2347 + 1)
-#define	RX_DEVICE_BUFF_SIZE	32
-
-/**
- * struct rx_device_buffer - Queue item for the rx queue.
- * @data: rx data.
- * @size: Size of @data.
- */
-struct rx_device_buffer {
-	unsigned char data[RX_DATA_SIZE];
-	unsigned int size;
-};
-
-/**
- * struct rx_device - Rx buffer queue.
- * @rx_device_buffer: Queue buffer.
- * @qhead: Head of rx queue.
- * @qtail: Tail of rx queue.
- * @rx_dev_lock: Queue lock.
- */
-struct rx_device {
-	struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
-	unsigned int qhead;
-	unsigned int qtail;
-	spinlock_t rx_dev_lock;	/* protect access to the queue */
-};
-
 #endif /* _KS7010_SDIO_H */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 5070af8..d73f622 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -10,14 +10,13 @@
 #define _KS_WLAN_H
 
 #include <linux/atomic.h>	/* struct atomic_t */
+#include <linux/circ_buf.h>
 #include <linux/completion.h>	/* struct completion */
 #include <linux/netdevice.h>	/* struct net_device_stats,  struct sk_buff */
 #include <linux/sched.h>	/* wait_queue_head_t */
 #include <linux/spinlock.h>	/* spinlock_t */
 #include <linux/wireless.h>
 
-#include "ks7010_sdio.h"
-
 struct ks_wlan_parameter {
 	u8 operation_mode;	/* Operation Mode */
 	u8 channel;	/*  Channel */
@@ -366,6 +365,71 @@ struct wps_status {
 	u8 ie[255];
 };
 
+/* Tx Device struct */
+#define	TX_DEVICE_BUFF_SIZE	1024
+
+struct ks_wlan_private;
+
+/**
+ * struct tx_device_buffer - Queue item for the tx queue.
+ * @sendp: Pointer to the send request data.
+ * @size: Size of @sendp data.
+ * @complete_handler: Function called once data write to device is complete.
+ * @arg1: First argument to @complete_handler.
+ * @arg2: Second argument to @complete_handler.
+ */
+struct tx_device_buffer {
+	unsigned char *sendp;
+	unsigned int size;
+	void (*complete_handler)(struct ks_wlan_private *priv,
+				 struct sk_buff *skb);
+	struct sk_buff *skb;
+};
+
+/**
+ * struct tx_device - Tx buffer queue.
+ * @tx_device_buffer: Queue buffer.
+ * @qhead: Head of tx queue.
+ * @qtail: Tail of tx queue.
+ * @tx_dev_lock: Queue lock.
+ */
+struct tx_device {
+	struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
+	unsigned int qhead;
+	unsigned int qtail;
+	spinlock_t tx_dev_lock;	/* protect access to the queue */
+};
+
+/* Rx Device struct */
+#define	RX_DATA_SIZE	(2 + 2 + 2347 + 1)
+#define	RX_DEVICE_BUFF_SIZE	32
+
+/**
+ * struct rx_device_buffer - Queue item for the rx queue.
+ * @data: rx data.
+ * @size: Size of @data.
+ */
+struct rx_device_buffer {
+	unsigned char data[RX_DATA_SIZE];
+	unsigned int size;
+};
+
+/**
+ * struct rx_device - Rx buffer queue.
+ * @rx_device_buffer: Queue buffer.
+ * @qhead: Head of rx queue.
+ * @qtail: Tail of rx queue.
+ * @rx_dev_lock: Queue lock.
+ */
+struct rx_device {
+	struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
+	unsigned int qhead;
+	unsigned int qtail;
+	spinlock_t rx_dev_lock;	/* protect access to the queue */
+};
+
+struct ks_sdio_card;
+
 struct ks_wlan_private {
 	/* hardware information */
 	struct ks_sdio_card *ks_sdio_card;
@@ -452,6 +516,50 @@ struct ks_wlan_private {
 	uint wakeup_count;	/* for detect wakeup loop */
 };
 
+static inline void inc_txqhead(struct ks_wlan_private *priv)
+{
+	priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
+}
+
+static inline void inc_txqtail(struct ks_wlan_private *priv)
+{
+	priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
+}
+
+static inline bool txq_has_space(struct ks_wlan_private *priv)
+{
+	return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
+			   TX_DEVICE_BUFF_SIZE) > 0);
+}
+
+static inline void inc_rxqhead(struct ks_wlan_private *priv)
+{
+	priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
+}
+
+static inline void inc_rxqtail(struct ks_wlan_private *priv)
+{
+	priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
+}
+
+static inline bool rxq_has_space(struct ks_wlan_private *priv)
+{
+	return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
+			   RX_DEVICE_BUFF_SIZE) > 0);
+}
+
+static inline unsigned int txq_count(struct ks_wlan_private *priv)
+{
+	return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
+			       TX_DEVICE_BUFF_SIZE);
+}
+
+static inline unsigned int rxq_count(struct ks_wlan_private *priv)
+{
+	return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
+			       RX_DEVICE_BUFF_SIZE);
+}
+
 int ks_wlan_net_start(struct net_device *dev);
 int ks_wlan_net_stop(struct net_device *dev);
 bool is_connect_status(u32 status);
-- 
2.7.4

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

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

* [PATCH 03/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 01/47] staging: ks7010: add SPDX identifiers to all files Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line Sergio Paracuellos
                   ` (43 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 9c22a76..d71c826 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -16,7 +16,6 @@
 #include <linux/workqueue.h>
 #include "ks_wlan.h"
 #include "ks_hostif.h"
-#include "ks7010_sdio.h"
 
 #define ROM_FILE "ks7010sd.rom"
 
@@ -97,11 +96,31 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
+/**
+ * struct ks_sdio_card - SDIO device data.
+ *
+ * Structure is used as the &struct sdio_func private data.
+ *
+ * @func: Pointer to the SDIO function device.
+ * @priv: Pointer to the &struct net_device private data.
+ */
+struct ks_sdio_card {
+	struct sdio_func *func;
+	struct ks_wlan_private *priv;
+};
+
+static struct sdio_func *ks7010_to_func(struct ks_wlan_private *priv)
+{
+	struct ks_sdio_card *ks_sdio = priv->if_hw;
+
+	return ks_sdio->func;
+}
+
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 			     u32 address, u8 *byte)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 	int ret;
 
 	*byte = sdio_readb(func, address, &ret);
@@ -113,7 +132,7 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
 			    u8 *buffer, unsigned int length)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 
 	return sdio_memcpy_fromio(func, buffer, address, length);
 }
@@ -122,7 +141,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
 static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
 			      u32 address, u8 byte)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 	int ret;
 
 	sdio_writeb(func, byte, address, &ret);
@@ -134,7 +153,7 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
 static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address,
 			     u8 *buffer, unsigned int length)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 
 	return sdio_memcpy_toio(func, address, buffer, length);
 }
@@ -449,12 +468,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
 
 static void ks7010_rw_function(struct work_struct *work)
 {
-	struct ks_wlan_private *priv;
+	struct ks_wlan_private *priv = container_of(work,
+						    struct ks_wlan_private,
+						    rw_dwork.work);
+	struct sdio_func *func = ks7010_to_func(priv);
 	unsigned char byte;
 	int ret;
 
-	priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
-
 	/* wait after DOZE */
 	if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
 		netdev_dbg(priv->net_dev, "wait after DOZE\n");
@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work)
 	/* wait after WAKEUP */
 	while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
 		netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
-		dev_info(&priv->ks_sdio_card->func->dev,
-			 "wake: %lu %lu\n",
+		dev_info(&func->dev, "wake: %lu %lu\n",
 			 priv->last_wakeup + msecs_to_jiffies(30), jiffies);
 		msleep(30);
 	}
 
-	sdio_claim_host(priv->ks_sdio_card->func);
+	sdio_claim_host(func);
 
 	/* power save wakeup */
 	if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work)
 	_ks_wlan_hw_power_save(priv);
 
 release_host:
-	sdio_release_host(priv->ks_sdio_card->func);
+	sdio_release_host(func);
 }
 
 static void ks_sdio_interrupt(struct sdio_func *func)
@@ -726,13 +745,14 @@ static int ks7010_copy_firmware(struct ks_wlan_private *priv,
 static int ks7010_upload_firmware(struct ks_sdio_card *card)
 {
 	struct ks_wlan_private *priv = card->priv;
+	struct sdio_func *func = ks7010_to_func(priv);
 	unsigned int n;
 	unsigned char byte = 0;
 	int ret;
 	const struct firmware *fw_entry = NULL;
 
 
-	sdio_claim_host(card->func);
+	sdio_claim_host(func);
 
 	/* Firmware running ? */
 	ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte);
@@ -745,7 +765,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 	}
 
 	ret = request_firmware(&fw_entry, ROM_FILE,
-			       &priv->ks_sdio_card->func->dev);
+			       &func->dev);
 	if (ret)
 		goto release_host;
 
@@ -774,7 +794,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
  release_firmware:
 	release_firmware(fw_entry);
  release_host:
-	sdio_release_host(card->func);
+	sdio_release_host(func);
 
 	return ret;
 }
@@ -907,7 +927,7 @@ static void ks7010_private_init(struct ks_wlan_private *priv,
 				struct net_device *netdev)
 {
 	/* private memory initialize */
-	priv->ks_sdio_card = card;
+	priv->if_hw = card;
 
 	priv->dev_state = DEVICE_STATE_PREBOOT;
 	priv->net_dev = netdev;
diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h
deleted file mode 100644
index 891a09f..0000000
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- *   Driver for KeyStream, KS7010 based SDIO cards.
- *
- *   Copyright (C) 2006-2008 KeyStream Corp.
- *   Copyright (C) 2009 Renesas Technology Corp.
- */
-#ifndef _KS7010_SDIO_H
-#define _KS7010_SDIO_H
-
-struct ks_wlan_private;
-
-/**
- * struct ks_sdio_card - SDIO device data.
- *
- * Structure is used as the &struct sdio_func private data.
- *
- * @func: Pointer to the SDIO function device.
- * @priv: Pointer to the &struct net_device private data.
- */
-struct ks_sdio_card {
-	struct sdio_func *func;
-	struct ks_wlan_private *priv;
-};
-
-#endif /* _KS7010_SDIO_H */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index d73f622..ad349ef 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -428,11 +428,9 @@ struct rx_device {
 	spinlock_t rx_dev_lock;	/* protect access to the queue */
 };
 
-struct ks_sdio_card;
-
 struct ks_wlan_private {
 	/* hardware information */
-	struct ks_sdio_card *ks_sdio_card;
+	void *if_hw;
 	struct workqueue_struct *wq;
 	struct delayed_work rw_dwork;
 	struct tasklet_struct rx_bh_task;
-- 
2.7.4

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

* [PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (2 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 03/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code Sergio Paracuellos
                   ` (42 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit avoids a long line changing a bit message in
_ks_wlan_hw_power_save function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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

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

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

* [PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (3 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function Sergio Paracuellos
                   ` (41 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Commit 92c1552caef3661f049c4e967550e933599e2663 removes WPS hardcoded
definition and its related conditional preprocessor code. There
was some missing stuff already in this files. Remove it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 6 ------
 drivers/staging/ks7010/ks_hostif.h | 2 --
 2 files changed, 8 deletions(-)

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

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

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

* [PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (4 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save Sergio Paracuellos
                   ` (40 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

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

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

* [PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (5 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function Sergio Paracuellos
                   ` (39 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Local variable 'byte' in _ks_wlan_hw_power_save function is declared
as unsigned char and can be declared as u8 which is preferred. It
is being using with ks7010_sdio_readb which expects u8 already.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (6 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt Sergio Paracuellos
                   ` (38 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Local variable 'byte' in ks7010_rw_function is declared as unsigned
char and can be declared as u8 which is preferred. It is being used
in ks7010_sdio_readb which is already expecting an u8.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (7 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs Sergio Paracuellos
                   ` (37 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (8 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue Sergio Paracuellos
                   ` (36 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Local variable 'byte' in ks7010_sdio_init_irqs is declared as
unsigned char and can be declared as u8 which is preferred.
It is being used in calls to ks7010_sdio_writeb which is already
expected an u8.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (9 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function Sergio Paracuellos
                   ` (35 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Declaration of second parameter 'event' in ks_hostif .h and .c
file is different using uint16_t and unsigned short respectively.
Just unify both using 'u16' which is preferred instead.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 drivers/staging/ks7010/ks_hostif.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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

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

* [PATCH 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (10 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx Sergio Paracuellos
                   ` (34 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

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

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

* [PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (11 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:43 ` [PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file Sergio Paracuellos
                   ` (33 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Local variable event in ks_wlan_hw_rx function is declared
as unsigned short and can be declared as u16 which is preferred
style.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (12 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx Sergio Paracuellos
@ 2018-04-30 13:43 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute Sergio Paracuellos
                   ` (32 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:43 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan.h | 49 ++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

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

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

* [PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (13 preceding siblings ...)
  2018-04-30 13:43 ` [PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum Sergio Paracuellos
                   ` (31 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

This commit cleans code for the event SME_MIC_FAILURE_REQUEST
changing if logic to handle invalid value first and using a
local variable.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

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

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

* [PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (14 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 17/47] staging: ks7010: conver MIB attributes " Sergio Paracuellos
                   ` (30 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

This commit just change some preprocessor definitions related
with MIB data types into an enumeration which is much cleaner
for this here.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.h | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

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

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

* [PATCH 17/47] staging: ks7010: conver MIB attributes preprocessor defs into an enum
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (15 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 18/47] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header Sergio Paracuellos
                   ` (29 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.h | 130 ++++++++++++++++++++++++-------------
 1 file changed, 85 insertions(+), 45 deletions(-)

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

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

* [PATCH 18/47] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (16 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 17/47] staging: ks7010: conver MIB attributes " Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request Sergio Paracuellos
                   ` (28 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

This commit changes some type cast in rate related preprocessor
definitions included in ks_hostif header file to use preferred
u8 type.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

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

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

* [PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (17 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 18/47] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 20/47] staging: ks7010: add new helpers to achieve mib set request and simplify code Sergio Paracuellos
                   ` (27 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 144 +++++++++++++++++++------------------
 1 file changed, 74 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 5dceadc..9b25221 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1192,10 +1192,10 @@ void hostif_mib_get_request(struct ks_wlan_private *priv,
 	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
 }
 
-static
-void hostif_mib_set_request(struct ks_wlan_private *priv,
-			    unsigned long mib_attribute, unsigned short size,
-			    unsigned short type, void *vp)
+static void hostif_mib_set_request(struct ks_wlan_private *priv,
+				   enum mib_attribute attr,
+				   enum mib_data_type type,
+				   void *data, size_t size)
 {
 	struct hostif_mib_set_request_t *pp;
 
@@ -1206,10 +1206,10 @@ void hostif_mib_set_request(struct ks_wlan_private *priv,
 	if (!pp)
 		return;
 
-	pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
-	pp->mib_value.size = cpu_to_le16((uint16_t)size);
-	pp->mib_value.type = cpu_to_le16((uint16_t)type);
-	memcpy(&pp->mib_value.body, vp, size);
+	pp->mib_attribute = cpu_to_le32(attr);
+	pp->mib_value.size = cpu_to_le16((u16)size);
+	pp->mib_value.type = cpu_to_le16(type);
+	memcpy(&pp->mib_value.body, data, size);
 
 	/* send to device request */
 	ps_confirm_wait_inc(priv);
@@ -1557,44 +1557,44 @@ void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
 	case SME_WEP_INDEX_REQUEST:
 		val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-				       sizeof(val), MIB_VALUE_TYPE_INT, &val);
+				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
 		break;
 	case SME_WEP_KEY1_REQUEST:
 		if (!priv->wpa.wpa_enabled)
 			hostif_mib_set_request(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE1,
-					       priv->reg.wep_key[0].size,
 					       MIB_VALUE_TYPE_OSTRING,
-					       &priv->reg.wep_key[0].val[0]);
+					       &priv->reg.wep_key[0].val[0],
+					       priv->reg.wep_key[0].size);
 		break;
 	case SME_WEP_KEY2_REQUEST:
 		if (!priv->wpa.wpa_enabled)
 			hostif_mib_set_request(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE2,
-					       priv->reg.wep_key[1].size,
 					       MIB_VALUE_TYPE_OSTRING,
-					       &priv->reg.wep_key[1].val[0]);
+					       &priv->reg.wep_key[1].val[0],
+					       priv->reg.wep_key[1].size);
 		break;
 	case SME_WEP_KEY3_REQUEST:
 		if (!priv->wpa.wpa_enabled)
 			hostif_mib_set_request(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE3,
-					       priv->reg.wep_key[2].size,
 					       MIB_VALUE_TYPE_OSTRING,
-					       &priv->reg.wep_key[2].val[0]);
+					       &priv->reg.wep_key[2].val[0],
+					       priv->reg.wep_key[2].size);
 		break;
 	case SME_WEP_KEY4_REQUEST:
 		if (!priv->wpa.wpa_enabled)
 			hostif_mib_set_request(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE4,
-					       priv->reg.wep_key[3].size,
 					       MIB_VALUE_TYPE_OSTRING,
-					       &priv->reg.wep_key[3].val[0]);
+					       &priv->reg.wep_key[3].val[0],
+					       priv->reg.wep_key[3].size);
 		break;
 	case SME_WEP_FLAG_REQUEST:
 		val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
 		hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
-				       sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
 		break;
 	}
 }
@@ -1615,6 +1615,7 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 	struct wpa_suite wpa_suite;
 	struct rsn_mode rsn_mode;
 	__le32 val;
+	size_t size;
 
 	memset(&wpa_suite, 0, sizeof(wpa_suite));
 
@@ -1664,11 +1665,11 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 			break;
 		}
 
+		size = sizeof(wpa_suite.size) +
+		       (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
 		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
-				       sizeof(wpa_suite.size) +
-				       CIPHER_ID_LEN *
-				       le16_to_cpu(wpa_suite.size),
-				       MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+				       MIB_VALUE_TYPE_OSTRING,
+				       &wpa_suite, size);
 		break;
 	case SME_RSN_MCAST_REQUEST:
 		switch (priv->wpa.group_suite) {
@@ -1715,8 +1716,8 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 		}
 
 		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
-				       CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
-				       &wpa_suite.suite[0][0]);
+				       MIB_VALUE_TYPE_OSTRING,
+				       &wpa_suite.suite[0][0], CIPHER_ID_LEN);
 		break;
 	case SME_RSN_AUTH_REQUEST:
 		wpa_suite.size = cpu_to_le16((uint16_t)1);
@@ -1757,16 +1758,16 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 			break;
 		}
 
+		size = sizeof(wpa_suite.size) +
+		       (KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size));
 		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
-				       sizeof(wpa_suite.size) +
-				       KEY_MGMT_ID_LEN *
-				       le16_to_cpu(wpa_suite.size),
-				       MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+				       MIB_VALUE_TYPE_OSTRING, &wpa_suite,
+				       size);
 		break;
 	case SME_RSN_ENABLED_REQUEST:
 		val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
 		hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
-				       sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
 		break;
 	case SME_RSN_MODE_REQUEST:
 		if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
@@ -1782,8 +1783,9 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 			    cpu_to_le32((uint32_t)RSN_MODE_NONE);
 			rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
 		}
-		hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
-				       MIB_VALUE_TYPE_OSTRING, &rsn_mode);
+		hostif_mib_set_request(priv, LOCAL_RSN_MODE,
+				       MIB_VALUE_TYPE_OSTRING, &rsn_mode,
+				       sizeof(rsn_mode));
 		break;
 	}
 }
@@ -1904,8 +1906,8 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 	if (dev->flags & IFF_PROMISC) {
 		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
 		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
-				       &filter_type);
+				       MIB_VALUE_TYPE_BOOL,
+				       &filter_type, sizeof(filter_type));
 		goto spin_unlock;
 	}
 
@@ -1913,8 +1915,8 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 	    (dev->flags & IFF_ALLMULTI)) {
 		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
 		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
-				       &filter_type);
+				       MIB_VALUE_TYPE_BOOL,
+				       &filter_type, sizeof(filter_type));
 		goto spin_unlock;
 	}
 
@@ -1926,15 +1928,14 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 		}
 		priv->sme_i.sme_flag &= ~SME_MULTICAST;
 		hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
-				       ETH_ALEN * mc_count,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &set_address[0]);
+				       &set_address[0], ETH_ALEN * mc_count);
 	} else {
 		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
 		priv->sme_i.sme_flag |= SME_MULTICAST;
 		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
-				       &filter_type);
+				       MIB_VALUE_TYPE_BOOL,
+				       &filter_type, sizeof(filter_type));
 	}
 
 spin_unlock:
@@ -1992,51 +1993,54 @@ void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
 	case SME_SET_FLAG:
 		val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
 		hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
-				       sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
 		break;
 	case SME_SET_TXKEY:
 		val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-				       sizeof(val), MIB_VALUE_TYPE_INT, &val);
+				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
 		break;
 	case SME_SET_KEY1:
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
-				       priv->wpa.key[0].key_len,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[0].key_val[0]);
+				       &priv->wpa.key[0].key_val[0],
+				       priv->wpa.key[0].key_len);
 		break;
 	case SME_SET_KEY2:
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
-				       priv->wpa.key[1].key_len,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[1].key_val[0]);
+				       &priv->wpa.key[1].key_val[0],
+				       priv->wpa.key[1].key_len);
 		break;
 	case SME_SET_KEY3:
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
-				       priv->wpa.key[2].key_len,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[2].key_val[0]);
+				       &priv->wpa.key[2].key_val[0],
+				       priv->wpa.key[2].key_len);
 		break;
 	case SME_SET_KEY4:
 		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
-				       priv->wpa.key[3].key_len,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[3].key_val[0]);
+				       &priv->wpa.key[3].key_val[0],
+				       priv->wpa.key[3].key_len);
 		break;
 	case SME_SET_PMK_TSC:
 		hostif_mib_set_request(priv, DOT11_PMK_TSC,
-				       WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[0].rx_seq[0]);
+				       MIB_VALUE_TYPE_OSTRING,
+				       &priv->wpa.key[0].rx_seq[0],
+				       WPA_RX_SEQ_LEN);
 		break;
 	case SME_SET_GMK1_TSC:
 		hostif_mib_set_request(priv, DOT11_GMK1_TSC,
-				       WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[1].rx_seq[0]);
+				       MIB_VALUE_TYPE_OSTRING,
+				       &priv->wpa.key[1].rx_seq[0],
+				       WPA_RX_SEQ_LEN);
 		break;
 	case SME_SET_GMK2_TSC:
 		hostif_mib_set_request(priv, DOT11_GMK2_TSC,
-				       WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[2].rx_seq[0]);
+				       MIB_VALUE_TYPE_OSTRING,
+				       &priv->wpa.key[2].rx_seq[0],
+				       WPA_RX_SEQ_LEN);
 		break;
 	}
 }
@@ -2052,6 +2056,7 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 		} __packed list[PMK_LIST_MAX];
 	} __packed pmkcache;
 	struct pmk *pmk;
+	size_t size;
 	int i = 0;
 
 	list_for_each_entry(pmk, &priv->pmklist.head, list) {
@@ -2062,11 +2067,10 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 		i++;
 	}
 	pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
+	size = sizeof(priv->pmklist.size) +
+	       ((ETH_ALEN + IW_PMKID_LEN) * priv->pmklist.size);
 	hostif_mib_set_request(priv, LOCAL_PMK,
-			       sizeof(priv->pmklist.size) + (ETH_ALEN +
-							     IW_PMKID_LEN) *
-			       (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
-			       &pmkcache);
+			       MIB_VALUE_TYPE_OSTRING, &pmkcache, size);
 }
 
 /* execute sme */
@@ -2084,9 +2088,9 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		hostif_sme_multicast_set(priv);
 		break;
 	case SME_MACADDRESS_SET_REQUEST:
-		hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
+		hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS,
 				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->eth_addr[0]);
+				       &priv->eth_addr[0], ETH_ALEN);
 		break;
 	case SME_BSS_SCAN_REQUEST:
 		hostif_bss_scan_request(priv, priv->reg.scan_type,
@@ -2131,12 +2135,12 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 	case SME_RTS_THRESHOLD_REQUEST:
 		val = cpu_to_le32((uint32_t)(priv->reg.rts));
 		hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
-				       sizeof(val), MIB_VALUE_TYPE_INT, &val);
+				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
 		break;
 	case SME_FRAGMENTATION_THRESHOLD_REQUEST:
 		val = cpu_to_le32((uint32_t)(priv->reg.fragment));
 		hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
-				       sizeof(val), MIB_VALUE_TYPE_INT, &val);
+				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
 		break;
 	case SME_WEP_INDEX_REQUEST:
 	case SME_WEP_KEY1_REQUEST:
@@ -2169,22 +2173,22 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		break;
 	case SME_WPS_ENABLE_REQUEST:
 		hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
-				       sizeof(priv->wps.wps_enabled),
 				       MIB_VALUE_TYPE_INT,
-				       &priv->wps.wps_enabled);
+				       &priv->wps.wps_enabled,
+				       sizeof(priv->wps.wps_enabled));
 		break;
 	case SME_WPS_PROBE_REQUEST:
 		hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
-				       priv->wps.ielen,
-				       MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
+				       MIB_VALUE_TYPE_OSTRING, priv->wps.ie,
+				       priv->wps.ielen);
 		break;
 	case SME_MODE_SET_REQUEST:
 		hostif_sme_mode_setup(priv);
 		break;
 	case SME_SET_GAIN:
 		hostif_mib_set_request(priv, LOCAL_GAIN,
-				       sizeof(priv->gain),
-				       MIB_VALUE_TYPE_OSTRING, &priv->gain);
+				       MIB_VALUE_TYPE_OSTRING, &priv->gain,
+				       sizeof(priv->gain));
 		break;
 	case SME_GET_GAIN:
 		hostif_mib_get_request(priv, LOCAL_GAIN);
@@ -2211,7 +2215,7 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 	case SME_SET_REGION:
 		val = cpu_to_le32((uint32_t)(priv->region));
 		hostif_mib_set_request(priv, LOCAL_REGION,
-				       sizeof(val), MIB_VALUE_TYPE_INT, &val);
+				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
 		break;
 	case SME_MULTICAST_CONFIRM:
 	case SME_BSS_SCAN_CONFIRM:
-- 
2.7.4

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

* [PATCH 20/47] staging: ks7010: add new helpers to achieve mib set request and simplify code
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (18 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 21/47] staging: ks7010: use ether_addr_copy in get_current_ap Sergio Paracuellos
                   ` (26 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

New three functions have been created to centralice and simplify
calls related with set MIB requests:

    - hostif_mib_set_request_int
    - hostif_mib_set_request_bool
    - hostif_mib_set_request_ostring

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 225 ++++++++++++++++++-------------------
 1 file changed, 109 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 9b25221..b22dc0c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1216,6 +1216,32 @@ static void hostif_mib_set_request(struct ks_wlan_private *priv,
 	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
 }
 
+static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
+					      enum mib_attribute attr, int val)
+{
+	__le32 v = cpu_to_le32((u32)val);
+	size_t size = sizeof(v);
+
+	hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, &v, size);
+}
+
+static inline void hostif_mib_set_request_bool(struct ks_wlan_private *priv,
+					       enum mib_attribute attr,
+					       bool val)
+{
+	__le32 v = cpu_to_le32((u32)val);
+	size_t size = sizeof(v);
+
+	hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, &v, size);
+}
+
+static inline void hostif_mib_set_request_ostring(struct ks_wlan_private *priv,
+						  enum mib_attribute attr,
+						  void *data, size_t size)
+{
+	hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_OSTRING, data, size);
+}
+
 static
 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
 {
@@ -1548,53 +1574,48 @@ void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
 		hostif_event_check(priv);
 }
 
-static
-void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
 {
-	__le32 val;
-
 	switch (type) {
 	case SME_WEP_INDEX_REQUEST:
-		val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
+		hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+					   priv->reg.wep_index);
 		break;
 	case SME_WEP_KEY1_REQUEST:
-		if (!priv->wpa.wpa_enabled)
-			hostif_mib_set_request(priv,
+		if (priv->wpa.wpa_enabled)
+			return;
+		hostif_mib_set_request_ostring(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE1,
-					       MIB_VALUE_TYPE_OSTRING,
 					       &priv->reg.wep_key[0].val[0],
 					       priv->reg.wep_key[0].size);
 		break;
 	case SME_WEP_KEY2_REQUEST:
-		if (!priv->wpa.wpa_enabled)
-			hostif_mib_set_request(priv,
+		if (priv->wpa.wpa_enabled)
+			return;
+		hostif_mib_set_request_ostring(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE2,
-					       MIB_VALUE_TYPE_OSTRING,
 					       &priv->reg.wep_key[1].val[0],
 					       priv->reg.wep_key[1].size);
 		break;
 	case SME_WEP_KEY3_REQUEST:
-		if (!priv->wpa.wpa_enabled)
-			hostif_mib_set_request(priv,
+		if (priv->wpa.wpa_enabled)
+			return;
+		hostif_mib_set_request_ostring(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE3,
-					       MIB_VALUE_TYPE_OSTRING,
 					       &priv->reg.wep_key[2].val[0],
 					       priv->reg.wep_key[2].size);
 		break;
 	case SME_WEP_KEY4_REQUEST:
-		if (!priv->wpa.wpa_enabled)
-			hostif_mib_set_request(priv,
+		if (priv->wpa.wpa_enabled)
+			return;
+		hostif_mib_set_request_ostring(priv,
 					       DOT11_WEP_DEFAULT_KEY_VALUE4,
-					       MIB_VALUE_TYPE_OSTRING,
 					       &priv->reg.wep_key[3].val[0],
 					       priv->reg.wep_key[3].size);
 		break;
 	case SME_WEP_FLAG_REQUEST:
-		val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
-		hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
-				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
+		hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+				            priv->reg.privacy_invoked);
 		break;
 	}
 }
@@ -1614,7 +1635,6 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 {
 	struct wpa_suite wpa_suite;
 	struct rsn_mode rsn_mode;
-	__le32 val;
 	size_t size;
 
 	memset(&wpa_suite, 0, sizeof(wpa_suite));
@@ -1667,9 +1687,9 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 
 		size = sizeof(wpa_suite.size) +
 		       (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
-		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &wpa_suite, size);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_RSN_CONFIG_UNICAST_CIPHER,
+					       &wpa_suite, size);
 		break;
 	case SME_RSN_MCAST_REQUEST:
 		switch (priv->wpa.group_suite) {
@@ -1714,10 +1734,10 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 				       CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
 			break;
 		}
-
-		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &wpa_suite.suite[0][0], CIPHER_ID_LEN);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_RSN_CONFIG_MULTICAST_CIPHER,
+					       &wpa_suite.suite[0][0],
+					       CIPHER_ID_LEN);
 		break;
 	case SME_RSN_AUTH_REQUEST:
 		wpa_suite.size = cpu_to_le16((uint16_t)1);
@@ -1760,14 +1780,13 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 
 		size = sizeof(wpa_suite.size) +
 		       (KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size));
-		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
-				       MIB_VALUE_TYPE_OSTRING, &wpa_suite,
-				       size);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_RSN_CONFIG_AUTH_SUITE,
+					       &wpa_suite, size);
 		break;
 	case SME_RSN_ENABLED_REQUEST:
-		val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
-		hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
-				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
+		hostif_mib_set_request_bool(priv, DOT11_RSN_ENABLED,
+					    priv->wpa.rsn_enabled);
 		break;
 	case SME_RSN_MODE_REQUEST:
 		if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
@@ -1783,9 +1802,8 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 			    cpu_to_le32((uint32_t)RSN_MODE_NONE);
 			rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
 		}
-		hostif_mib_set_request(priv, LOCAL_RSN_MODE,
-				       MIB_VALUE_TYPE_OSTRING, &rsn_mode,
-				       sizeof(rsn_mode));
+		hostif_mib_set_request_ostring(priv, LOCAL_RSN_MODE,
+					       &rsn_mode, sizeof(rsn_mode));
 		break;
 	}
 }
@@ -1896,7 +1914,6 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 	int mc_count;
 	struct netdev_hw_addr *ha;
 	char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
-	__le32 filter_type;
 	int i = 0;
 
 	spin_lock(&priv->multicast_spin);
@@ -1904,19 +1921,15 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 	memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
 
 	if (dev->flags & IFF_PROMISC) {
-		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
-		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       MIB_VALUE_TYPE_BOOL,
-				       &filter_type, sizeof(filter_type));
+		hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+					    MCAST_FILTER_PROMISC);
 		goto spin_unlock;
 	}
 
 	if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) ||
 	    (dev->flags & IFF_ALLMULTI)) {
-		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
-		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       MIB_VALUE_TYPE_BOOL,
-				       &filter_type, sizeof(filter_type));
+		hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+					    MCAST_FILTER_MCASTALL);
 		goto spin_unlock;
 	}
 
@@ -1927,15 +1940,13 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 			i++;
 		}
 		priv->sme_i.sme_flag &= ~SME_MULTICAST;
-		hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &set_address[0], ETH_ALEN * mc_count);
+		hostif_mib_set_request_ostring(priv, LOCAL_MULTICAST_ADDRESS,
+					       &set_address[0],
+					       ETH_ALEN * mc_count);
 	} else {
-		filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
 		priv->sme_i.sme_flag |= SME_MULTICAST;
-		hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
-				       MIB_VALUE_TYPE_BOOL,
-				       &filter_type, sizeof(filter_type));
+		hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+					    MCAST_FILTER_MCAST);
 	}
 
 spin_unlock:
@@ -1987,60 +1998,53 @@ static void hostif_sme_sleep_set(struct ks_wlan_private *priv)
 static
 void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
 {
-	__le32 val;
-
 	switch (type) {
 	case SME_SET_FLAG:
-		val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
-		hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
-				       MIB_VALUE_TYPE_BOOL, &val, sizeof(val));
+		hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+					    priv->reg.privacy_invoked);
 		break;
 	case SME_SET_TXKEY:
-		val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
+		hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+					   priv->wpa.txkey);
 		break;
 	case SME_SET_KEY1:
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[0].key_val[0],
-				       priv->wpa.key[0].key_len);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_WEP_DEFAULT_KEY_VALUE1,
+					       &priv->wpa.key[0].key_val[0],
+					       priv->wpa.key[0].key_len);
 		break;
 	case SME_SET_KEY2:
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[1].key_val[0],
-				       priv->wpa.key[1].key_len);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_WEP_DEFAULT_KEY_VALUE2,
+				               &priv->wpa.key[1].key_val[0],
+				               priv->wpa.key[1].key_len);
 		break;
 	case SME_SET_KEY3:
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[2].key_val[0],
-				       priv->wpa.key[2].key_len);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_WEP_DEFAULT_KEY_VALUE3,
+					       &priv->wpa.key[2].key_val[0],
+				               priv->wpa.key[2].key_len);
 		break;
 	case SME_SET_KEY4:
-		hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[3].key_val[0],
-				       priv->wpa.key[3].key_len);
+		hostif_mib_set_request_ostring(priv,
+					       DOT11_WEP_DEFAULT_KEY_VALUE4,
+					       &priv->wpa.key[3].key_val[0],
+				               priv->wpa.key[3].key_len);
 		break;
 	case SME_SET_PMK_TSC:
-		hostif_mib_set_request(priv, DOT11_PMK_TSC,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[0].rx_seq[0],
-				       WPA_RX_SEQ_LEN);
+		hostif_mib_set_request_ostring(priv, DOT11_PMK_TSC,
+				               &priv->wpa.key[0].rx_seq[0],
+				               WPA_RX_SEQ_LEN);
 		break;
 	case SME_SET_GMK1_TSC:
-		hostif_mib_set_request(priv, DOT11_GMK1_TSC,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[1].rx_seq[0],
-				       WPA_RX_SEQ_LEN);
+		hostif_mib_set_request_ostring(priv, DOT11_GMK1_TSC,
+				               &priv->wpa.key[1].rx_seq[0],
+					       WPA_RX_SEQ_LEN);
 		break;
 	case SME_SET_GMK2_TSC:
-		hostif_mib_set_request(priv, DOT11_GMK2_TSC,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->wpa.key[2].rx_seq[0],
-				       WPA_RX_SEQ_LEN);
+		hostif_mib_set_request_ostring(priv, DOT11_GMK2_TSC,
+					       &priv->wpa.key[2].rx_seq[0],
+					       WPA_RX_SEQ_LEN);
 		break;
 	}
 }
@@ -2069,14 +2073,12 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 	pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
 	size = sizeof(priv->pmklist.size) +
 	       ((ETH_ALEN + IW_PMKID_LEN) * priv->pmklist.size);
-	hostif_mib_set_request(priv, LOCAL_PMK,
-			       MIB_VALUE_TYPE_OSTRING, &pmkcache, size);
+	hostif_mib_set_request_ostring(priv, LOCAL_PMK, &pmkcache, size);
 }
 
 /* execute sme */
 static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 {
-	__le32 val;
 	u16 failure;
 
 	switch (event) {
@@ -2088,9 +2090,8 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		hostif_sme_multicast_set(priv);
 		break;
 	case SME_MACADDRESS_SET_REQUEST:
-		hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS,
-				       MIB_VALUE_TYPE_OSTRING,
-				       &priv->eth_addr[0], ETH_ALEN);
+		hostif_mib_set_request_ostring(priv, LOCAL_CURRENTADDRESS,
+					       &priv->eth_addr[0], ETH_ALEN);
 		break;
 	case SME_BSS_SCAN_REQUEST:
 		hostif_bss_scan_request(priv, priv->reg.scan_type,
@@ -2133,14 +2134,12 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		hostif_stop_request(priv);
 		break;
 	case SME_RTS_THRESHOLD_REQUEST:
-		val = cpu_to_le32((uint32_t)(priv->reg.rts));
-		hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
-				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
+		hostif_mib_set_request_int(priv, DOT11_RTS_THRESHOLD,
+					   priv->reg.rts);
 		break;
 	case SME_FRAGMENTATION_THRESHOLD_REQUEST:
-		val = cpu_to_le32((uint32_t)(priv->reg.fragment));
-		hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
-				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
+		hostif_mib_set_request_int(priv, DOT11_FRAGMENTATION_THRESHOLD,
+					   priv->reg.fragment);
 		break;
 	case SME_WEP_INDEX_REQUEST:
 	case SME_WEP_KEY1_REQUEST:
@@ -2172,23 +2171,19 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		hostif_sme_set_pmksa(priv);
 		break;
 	case SME_WPS_ENABLE_REQUEST:
-		hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
-				       MIB_VALUE_TYPE_INT,
-				       &priv->wps.wps_enabled,
-				       sizeof(priv->wps.wps_enabled));
+		hostif_mib_set_request_int(priv, LOCAL_WPS_ENABLE,
+				           priv->wps.wps_enabled);
 		break;
 	case SME_WPS_PROBE_REQUEST:
-		hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
-				       MIB_VALUE_TYPE_OSTRING, priv->wps.ie,
-				       priv->wps.ielen);
+		hostif_mib_set_request_ostring(priv, LOCAL_WPS_PROBE_REQ,
+					       priv->wps.ie, priv->wps.ielen);
 		break;
 	case SME_MODE_SET_REQUEST:
 		hostif_sme_mode_setup(priv);
 		break;
 	case SME_SET_GAIN:
-		hostif_mib_set_request(priv, LOCAL_GAIN,
-				       MIB_VALUE_TYPE_OSTRING, &priv->gain,
-				       sizeof(priv->gain));
+		hostif_mib_set_request_ostring(priv, LOCAL_GAIN,
+					       &priv->gain, sizeof(priv->gain));
 		break;
 	case SME_GET_GAIN:
 		hostif_mib_get_request(priv, LOCAL_GAIN);
@@ -2213,9 +2208,7 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 		hostif_sme_sleep_set(priv);
 		break;
 	case SME_SET_REGION:
-		val = cpu_to_le32((uint32_t)(priv->region));
-		hostif_mib_set_request(priv, LOCAL_REGION,
-				       MIB_VALUE_TYPE_INT, &val, sizeof(val));
+		hostif_mib_set_request_int(priv, LOCAL_REGION, priv->region);
 		break;
 	case SME_MULTICAST_CONFIRM:
 	case SME_BSS_SCAN_CONFIRM:
-- 
2.7.4

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

* [PATCH 21/47] staging: ks7010: use ether_addr_copy in get_current_ap
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (19 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 20/47] staging: ks7010: add new helpers to achieve mib set request and simplify code Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 22/47] staging: ks7010: move two preprocessor definitions to ks_wlan.h Sergio Paracuellos
                   ` (25 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

Instead of use memcpy to copy ethernet addresses use
ether_addr_copy created for that.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [PATCH 22/47] staging: ks7010: move two preprocessor definitions to ks_wlan.h
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (20 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 21/47] staging: ks7010: use ether_addr_copy in get_current_ap Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup Sergio Paracuellos
                   ` (24 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: wsa, driverdev-devel

In ks_wlan_translate_scan function there are two preprocessor
definitions:

    - RSN_INFO_ELEM_ID
    - GENERIC_INFO_ELEM_ID

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

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

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

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

* [PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (21 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 22/47] staging: ks7010: move two preprocessor definitions to ks_wlan.h Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 24/47] staging: ks7010: remove non sense comments in ks_hostif.c source file Sergio Paracuellos
                   ` (23 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit avoid two checkpatch script complains about
two long lines.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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

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

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

* [PATCH 24/47] staging: ks7010: remove non sense comments in ks_hostif.c source file
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (22 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
                   ` (22 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Comments which say the same as the code are not useful at all
so just remove them.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

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

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

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

* [PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (23 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 24/47] staging: ks7010: remove non sense comments in ks_hostif.c source file Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
                   ` (21 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

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

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

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

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

* [PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (24 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 27/47] staging: ks7010: use ether_addr_copy in get_ap_information function Sergio Paracuellos
                   ` (20 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Use ether_addr_copy kernel function to copy an ethernet address
instead of a simple memcpy with ETH_ALEN size.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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

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

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

* [PATCH 27/47] staging: ks7010: use ether_addr_copy in get_ap_information function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (25 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
                   ` (19 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit make use of ether_addr_copy to copy ethernet
address instead of copy it using memcpy.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (26 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 27/47] staging: ks7010: use ether_addr_copy in get_ap_information function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 29/47] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
                   ` (18 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

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

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

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

* [PATCH 29/47] staging: ks7010: factor out send_request_to_device function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (27 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
                   ` (17 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 60 +++++++++++++-------------------------
 1 file changed, 20 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 8bd2797..1a59218 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1172,6 +1172,13 @@ static inline void ps_confirm_wait_inc(struct ks_wlan_private *priv)
 		atomic_inc(&priv->psstatus.confirm_wait);
 }
 
+static inline void send_request_to_device(struct ks_wlan_private *priv,
+					  void *data, size_t size)
+{
+	ps_confirm_wait_inc(priv);
+	ks_wlan_hw_tx(priv, data, size, NULL, NULL);
+}
+
 static
 void hostif_mib_get_request(struct ks_wlan_private *priv,
 			    unsigned long mib_attribute)
@@ -1184,9 +1191,7 @@ void hostif_mib_get_request(struct ks_wlan_private *priv,
 
 	pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static void hostif_mib_set_request(struct ks_wlan_private *priv,
@@ -1208,9 +1213,7 @@ static void hostif_mib_set_request(struct ks_wlan_private *priv,
 	pp->mib_value.type = cpu_to_le16(type);
 	memcpy(&pp->mib_value.body, data, size);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp) + size));
 }
 
 static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
@@ -1250,9 +1253,7 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
 
 	pp->mode = cpu_to_le16((uint16_t)mode);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 
 	priv->aplist.size = 0;
 	priv->scan_ind_count = 0;
@@ -1299,9 +1300,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
 	init_request(priv, &pp->request);
 	pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1340,9 +1339,7 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
 		pp->channel_list.size = 14;
 	}
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1359,9 +1356,7 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv)
 	pp->ssid.size = priv->reg.ssid.size;
 	memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1381,9 +1376,7 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
 	pp->channel_list.size = 1;
 	memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1395,9 +1388,7 @@ void hostif_stop_request(struct ks_wlan_private *priv)
 	if (!pp)
 		return;
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1417,9 +1408,7 @@ void hostif_phy_information_request(struct ks_wlan_private *priv)
 		pp->time = cpu_to_le16((uint16_t)0);
 	}
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1437,9 +1426,7 @@ void hostif_power_mgmt_request(struct ks_wlan_private *priv,
 	pp->wake_up = cpu_to_le32((uint32_t)wake_up);
 	pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1453,10 +1440,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv,
 		if (!pp)
 			return;
 
-		/* send to device request */
-		ps_confirm_wait_inc(priv);
-		ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL,
-			      NULL);
+		send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 	} else if (mode == SLP_ACTIVE) {
 		atomic_set(&priv->sleepstatus.wakeup_request, 1);
 		queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
@@ -1508,9 +1492,7 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
 		memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
 	}
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 
 	priv->aplist.size = 0;
 	priv->scan_ind_count = 0;
@@ -1530,9 +1512,7 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv,
 	pp->failure_count = cpu_to_le16((uint16_t)failure_count);
 	pp->timer = cpu_to_le16((uint16_t)timer);
 
-	/* send to device request */
-	ps_confirm_wait_inc(priv);
-	ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+	send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 /* Device I/O Receive indicate */
-- 
2.7.4

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

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

* [PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (28 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 29/47] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 31/47] staging: ks7010: add blank line between after definitions Sergio Paracuellos
                   ` (16 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Fix some checkpatch complains about long lines in some
parts of the code. It also fix some lines where spaces
instead of tabs were inserted.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 46 +++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 20 deletions(-)

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

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

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

* [PATCH 31/47] staging: ks7010: add blank line between after definitions
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (29 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
                   ` (15 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Add blank line after definitions in hostif_aplist_init function
to fix a checkpatch script complain about that.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 1 +
 1 file changed, 1 insertion(+)

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

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

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

* [PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (30 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 31/47] staging: ks7010: add blank line between after definitions Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
                   ` (14 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 145 +++++++++++--------------------------
 1 file changed, 44 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 30c2d3a..08f95f7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1613,12 +1613,13 @@ struct rsn_mode {
 	__le16 rsn_capability;
 } __packed;
 
-static
-void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 {
 	struct wpa_suite wpa_suite;
 	struct rsn_mode rsn_mode;
 	size_t size;
+	u32 mode;
+	const u8 *buf = NULL;
 
 	memset(&wpa_suite, 0, sizeof(wpa_suite));
 
@@ -1627,47 +1628,29 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 		wpa_suite.size = cpu_to_le16((uint16_t)1);
 		switch (priv->wpa.pairwise_suite) {
 		case IW_AUTH_CIPHER_NONE:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
 			break;
 		case IW_AUTH_CIPHER_WEP40:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
 			break;
 		case IW_AUTH_CIPHER_TKIP:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
 			break;
 		case IW_AUTH_CIPHER_CCMP:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
 			break;
 		case IW_AUTH_CIPHER_WEP104:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
 			break;
 		}
 
+		if (buf)
+			memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
 		size = sizeof(wpa_suite.size) +
 		       (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
 		hostif_mib_set_request_ostring(priv,
@@ -1677,46 +1660,28 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 	case SME_RSN_MCAST_REQUEST:
 		switch (priv->wpa.group_suite) {
 		case IW_AUTH_CIPHER_NONE:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
 			break;
 		case IW_AUTH_CIPHER_WEP40:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
 			break;
 		case IW_AUTH_CIPHER_TKIP:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
 			break;
 		case IW_AUTH_CIPHER_CCMP:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
 			break;
 		case IW_AUTH_CIPHER_WEP104:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
 			break;
 		}
+		if (buf)
+			memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
 		hostif_mib_set_request_ostring(priv,
 					       DOT11_RSN_CONFIG_MULTICAST_CIPHER,
 					       &wpa_suite.suite[0][0],
@@ -1726,41 +1691,26 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 		wpa_suite.size = cpu_to_le16((uint16_t)1);
 		switch (priv->wpa.key_mgmt_suite) {
 		case IW_AUTH_KEY_MGMT_802_1X:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				KEY_MGMT_ID_WPA2_1X : KEY_MGMT_ID_WPA_1X;
 			break;
 		case IW_AUTH_KEY_MGMT_PSK:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				KEY_MGMT_ID_WPA2_PSK : KEY_MGMT_ID_WPA_PSK;
 			break;
 		case 0:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				KEY_MGMT_ID_WPA2_NONE : KEY_MGMT_ID_WPA_NONE;
 			break;
 		case 4:
-			if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA2_WPANONE,
-				       KEY_MGMT_ID_LEN);
-			else
-				memcpy(&wpa_suite.suite[0][0],
-				       KEY_MGMT_ID_WPA_WPANONE,
-				       KEY_MGMT_ID_LEN);
+			buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+				KEY_MGMT_ID_WPA2_WPANONE :
+				KEY_MGMT_ID_WPA_WPANONE;
 			break;
 		}
 
+		if (buf)
+			memcpy(&wpa_suite.suite[0][0], buf, KEY_MGMT_ID_LEN);
 		size = sizeof(wpa_suite.size) +
 		       (KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size));
 		hostif_mib_set_request_ostring(priv,
@@ -1772,19 +1722,12 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 					    priv->wpa.rsn_enabled);
 		break;
 	case SME_RSN_MODE_REQUEST:
-		if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
-			rsn_mode.rsn_mode =
-			    cpu_to_le32((uint32_t)RSN_MODE_WPA2);
-			rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
-		} else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
-			rsn_mode.rsn_mode =
-			    cpu_to_le32((uint32_t)RSN_MODE_WPA);
-			rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
-		} else {
-			rsn_mode.rsn_mode =
-			    cpu_to_le32((uint32_t)RSN_MODE_NONE);
-			rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
-		}
+		mode = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+			RSN_MODE_WPA2 :
+			(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) ?
+			 RSN_MODE_WPA : RSN_MODE_NONE;
+		rsn_mode.rsn_mode = cpu_to_le32(mode);
+		rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
 		hostif_mib_set_request_ostring(priv, LOCAL_RSN_MODE,
 					       &rsn_mode, sizeof(rsn_mode));
 		break;
-- 
2.7.4

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

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

* [PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (31 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 34/47] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
                   ` (13 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

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

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

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

* [PATCH 34/47] staging: ks7010: refactor hostif_sme_power_mgmt_set function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (32 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address Sergio Paracuellos
                   ` (12 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit refactor hostif_sme_power_mgmt_set avoiding to
use switch-case statement and simplifying data paths. This
improves readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 3a6385c..359187e 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1880,36 +1880,23 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
 	spin_unlock(&priv->multicast_spin);
 }
 
-static
-void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
+static void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
 {
 	u32 mode, wake_up, receive_dtims;
 
-	switch (priv->reg.power_mgmt) {
-	case POWER_MGMT_SAVE1:
-		mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
-			POWER_SAVE : POWER_ACTIVE;
-		wake_up = 0;
-		receive_dtims = 0;
-		break;
-	case POWER_MGMT_SAVE2:
-		if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
-			mode = POWER_SAVE;
-			wake_up = 0;
-			receive_dtims = 1;
-		} else {
-			mode = POWER_ACTIVE;
-			wake_up = 0;
-			receive_dtims = 0;
-		}
-		break;
-	case POWER_MGMT_ACTIVE:
-	default:
+	if (priv->reg.power_mgmt != POWER_MGMT_SAVE1 &&
+	    priv->reg.power_mgmt != POWER_MGMT_SAVE2) {
 		mode = POWER_ACTIVE;
 		wake_up = 0;
 		receive_dtims = 0;
-		break;
+	} else {
+		mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
+			POWER_SAVE : POWER_ACTIVE;
+		wake_up = 0;
+		receive_dtims = (priv->reg.operation_mode == MODE_INFRASTRUCTURE &&
+				 priv->reg.power_mgmt == POWER_MGMT_SAVE2);
 	}
+
 	hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
 }
 
-- 
2.7.4

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

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

* [PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (33 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 34/47] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start Sergio Paracuellos
                   ` (11 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Use ether_addr_copy to copy ethernet address instad of using
memcpy in ks_wlan_set_mac_address function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (34 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function Sergio Paracuellos
                   ` (10 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Instead of use memcpy for copying ethernet addresses, use
ether_addr_copy that do the same.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (35 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function Sergio Paracuellos
                   ` (9 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

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

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

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

* [PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (36 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function Sergio Paracuellos
                   ` (8 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

Handle invalid values first and assign good ones at the
end if it is the case. This makes code simplier.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

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

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

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

* [PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (37 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function Sergio Paracuellos
                   ` (7 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit refactors ks_wlan_set_mlme function changing
switch-case block for more simple if paths improving
readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

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

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

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

* [PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (38 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody Sergio Paracuellos
                   ` (6 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit refactor a bit ks_get_wireless_stats using
ternary operator for return code. It also change a comment
to use preferred style.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

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

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

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

* [PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (39 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm Sergio Paracuellos
                   ` (5 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

This commit changes custom implementation of CIRC_CNT_TO_END.
Just use the linux kernel header one to simplify code.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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

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

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

* [PATCH 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (40 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check Sergio Paracuellos
                   ` (4 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

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

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

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

* [PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (41 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication Sergio Paracuellos
                   ` (3 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (42 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication Sergio Paracuellos
                   ` (2 subsequent siblings)
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (43 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm Sergio Paracuellos
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (44 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  2018-04-30 13:44 ` [PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm Sergio Paracuellos
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

* [PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm
  2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
                   ` (45 preceding siblings ...)
  2018-04-30 13:44 ` [PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm Sergio Paracuellos
@ 2018-04-30 13:44 ` Sergio Paracuellos
  46 siblings, 0 replies; 48+ messages in thread
From: Sergio Paracuellos @ 2018-04-30 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

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

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks_hostif.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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

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

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

end of thread, other threads:[~2018-04-30 13:45 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 13:43 [PATCH 00/47] staging: ks7010: next cleanups Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 01/47] staging: ks7010: add SPDX identifiers to all files Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 03/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx Sergio Paracuellos
2018-04-30 13:43 ` [PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 17/47] staging: ks7010: conver MIB attributes " Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 18/47] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 20/47] staging: ks7010: add new helpers to achieve mib set request and simplify code Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 21/47] staging: ks7010: use ether_addr_copy in get_current_ap Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 22/47] staging: ks7010: move two preprocessor definitions to ks_wlan.h Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 24/47] staging: ks7010: remove non sense comments in ks_hostif.c source file Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 27/47] staging: ks7010: use ether_addr_copy in get_ap_information function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 29/47] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 31/47] staging: ks7010: add blank line between after definitions Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 34/47] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm Sergio Paracuellos
2018-04-30 13:44 ` [PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm Sergio Paracuellos

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.