All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: gregkh@linuxfoundation.org
Cc: driverdev-devel@linuxdriverproject.org, wsa@the-dreams.de
Subject: [PATCH 05/10] staging: ks7010: factor out send_request_to_device function
Date: Sat, 28 Apr 2018 12:34:41 +0200	[thread overview]
Message-ID: <1524911686-27191-6-git-send-email-sergio.paracuellos@gmail.com> (raw)
In-Reply-To: <1524911686-27191-1-git-send-email-sergio.paracuellos@gmail.com>

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

  parent reply	other threads:[~2018-04-28 10:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Sergio Paracuellos [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524911686-27191-6-git-send-email-sergio.paracuellos@gmail.com \
    --to=sergio.paracuellos@gmail.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.