Search Linux Wireless

[RFC/RFT 4/9] iwlegacy: use CMD_COPY_PKT on il_send_add_sta

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Stanislaw Gruszka <sgruszka@xxxxxxxxxx>
---
 drivers/net/wireless/iwlegacy/common.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 0661a5b..2778bdf 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -1847,8 +1847,8 @@ il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd,
 int
 il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
 {
-	struct il_rx_pkt *pkt = NULL;
-	int ret = 0;
+	struct il_rx_pkt *pkt;
+	int ret;
 	u8 data[sizeof(*sta)];
 	struct il_host_cmd cmd = {
 		.id = C_ADD_STA,
@@ -1860,25 +1860,26 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
 	D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr,
 	       flags & CMD_ASYNC ? "a" : "");
 
-	if (flags & CMD_ASYNC)
+	if (flags & CMD_ASYNC) {
 		cmd.callback = il_add_sta_callback;
-	else {
-		cmd.flags |= CMD_WANT_SKB;
-		might_sleep();
+	} else {
+		/* SYNC command mean we allow to sleep */
+		pkt = kmalloc(sizeof(*pkt), GFP_KERNEL);
+		if (!pkt)
+			return -ENOMEM;
+		cmd.pkt_ptr = pkt;
+		cmd.flags |= CMD_COPY_PKT;
 	}
 
 	cmd.len = il->ops->build_addsta_hcmd(sta, data);
 	ret = il_send_cmd(il, &cmd);
 
-	if (ret || (flags & CMD_ASYNC))
+	if (flags & CMD_ASYNC)
 		return ret;
 
-	if (ret == 0) {
-		pkt = (struct il_rx_pkt *)cmd.reply_page;
+	if (ret == 0)
 		ret = il_process_add_sta_resp(il, sta, pkt, true);
-	}
-	il_free_pages(il, cmd.reply_page);
-
+	kfree(pkt);
 	return ret;
 }
 EXPORT_SYMBOL(il_send_add_sta);
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux