All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] cleanupas continue
@ 2018-04-28 10:34 Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 01/10] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, wsa

The following patch series continue with driver cleanups. This series
starts focusing in ks_hostif.c file which really needs refactors.
Some functions have been refactor as well as some style stuff
has been fixed.

Sergio Paracuellos (10):
  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

 drivers/staging/ks7010/ks_hostif.c   | 307 +++++++++++++----------------------
 drivers/staging/ks7010/ks_wlan.h     |   2 +-
 drivers/staging/ks7010/ks_wlan_net.c |   4 +-
 3 files changed, 113 insertions(+), 200 deletions(-)

-- 
2.7.4

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

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

* [PATCH 01/10] staging: ks7010: change type for rsn_enabled in wpa_status struct
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 02/10] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 02/10] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 01/10] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 03/10] staging: use ether_addr_copy in get_ap_information function Sergio Paracuellos
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 03/10] staging: use ether_addr_copy in get_ap_information function
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 01/10] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 02/10] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 04/10] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 04/10] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (2 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 03/10] staging: use ether_addr_copy in get_ap_information function Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 05/10] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 05/10] staging: ks7010: factor out send_request_to_device function
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (3 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 04/10] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 06/10] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 06/10] staging: ks7010: fix some style issues in ks_hostif.c
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (4 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 05/10] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 07/10] staging: ks7010: add blank line between after definitions Sergio Paracuellos
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 07/10] staging: ks7010: add blank line between after definitions
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (5 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 06/10] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 08/10] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 08/10] staging: ks7010: refactor hostif_sme_set_rsn function
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (6 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 07/10] staging: ks7010: add blank line between after definitions Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 09/10] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 09/10] staging: ks7010: change parameter types in hostif_power_mgmt_request
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (7 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 08/10] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-28 10:34 ` [PATCH 10/10] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
  2018-04-29 13:16 ` [PATCH 00/10] cleanupas continue Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* [PATCH 10/10] staging: ks7010: refactor hostif_sme_power_mgmt_set function
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (8 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 09/10] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
@ 2018-04-28 10:34 ` Sergio Paracuellos
  2018-04-29 13:16 ` [PATCH 00/10] cleanupas continue Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Sergio Paracuellos @ 2018-04-28 10:34 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] 12+ messages in thread

* Re: [PATCH 00/10] cleanupas continue
  2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
                   ` (9 preceding siblings ...)
  2018-04-28 10:34 ` [PATCH 10/10] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
@ 2018-04-29 13:16 ` Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2018-04-29 13:16 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: driverdev-devel, wsa

On Sat, Apr 28, 2018 at 12:34:36PM +0200, Sergio Paracuellos wrote:
> The following patch series continue with driver cleanups. This series
> starts focusing in ks_hostif.c file which really needs refactors.
> Some functions have been refactor as well as some style stuff
> has been fixed.

Please put the subsystem: driver: in your 00/XX email subject line,
otherwise it sometimes gets lost in my filters...

And on it's own, it really doesn't make any sense, right?

thanks,

greg k-h

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28 10:34 [PATCH 00/10] cleanupas continue Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 01/10] staging: ks7010: change type for rsn_enabled in wpa_status struct Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 02/10] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 03/10] staging: use ether_addr_copy in get_ap_information function Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 04/10] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 05/10] staging: ks7010: factor out send_request_to_device function Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 06/10] staging: ks7010: fix some style issues in ks_hostif.c Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 07/10] staging: ks7010: add blank line between after definitions Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 08/10] staging: ks7010: refactor hostif_sme_set_rsn function Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 09/10] staging: ks7010: change parameter types in hostif_power_mgmt_request Sergio Paracuellos
2018-04-28 10:34 ` [PATCH 10/10] staging: ks7010: refactor hostif_sme_power_mgmt_set function Sergio Paracuellos
2018-04-29 13:16 ` [PATCH 00/10] cleanupas continue Greg KH

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.