2016-09-12 09:42:20

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 0/9] rsi: code clean-up

*** BLURB HERE ***

Prameela Rani Garnepudi (9):
rsi: cleanup and added debug prints in file rsi_91x_core.c
rsi: Spelling and code format corrections in rsi_91x_debugfs.c
rsi: Added freeing of allocated buffers (sbands and dfsentry)
Cleanup (spelling mistakes, code format corrections,
empty lines after declaration)
rsi: code clean up in file rsi_91x_main.c
rsi: code cleanup in file rsi_91x_mgmt.c
rsi: code cleanup (spelling mistakes and new line after declaration)
in file rsi_91x_sdio.c Added developer name
rsi: zone changed for debug message and cleanup in file
rsi_91x_sdio_ops.c
rsi: code clean up and replaced ctrl message timeouts with macros in
file rsi_91x_usb.c
rsi: code cleanup in file rsi_91x_usb_ops.c

drivers/net/wireless/rsi/rsi_91x_core.c | 24 +++++++++++++----
drivers/net/wireless/rsi/rsi_91x_debugfs.c | 13 ++++-----
drivers/net/wireless/rsi/rsi_91x_mac80211.c | 24 ++++++++++++-----
drivers/net/wireless/rsi/rsi_91x_main.c | 16 +++++------
drivers/net/wireless/rsi/rsi_91x_mgmt.c | 30 +++++++++++----------
drivers/net/wireless/rsi/rsi_91x_sdio.c | 16 +++++------
drivers/net/wireless/rsi/rsi_91x_sdio_ops.c | 6 ++---
drivers/net/wireless/rsi/rsi_91x_usb.c | 42 ++++++++++++++++-------------
drivers/net/wireless/rsi/rsi_91x_usb_ops.c | 9 +++----
9 files changed, 104 insertions(+), 76 deletions(-)

--
2.4.11


2016-09-12 09:43:01

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 1/9] rsi: cleanup and added debug prints in file rsi_91x_core.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_core.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_core.c b/drivers/net/wireless/rsi/rsi_91x_core.c
index f3d3995..b989ec5 100644
--- a/drivers/net/wireless/rsi/rsi_91x_core.c
+++ b/drivers/net/wireless/rsi/rsi_91x_core.c
@@ -142,8 +142,10 @@ static u8 rsi_core_determine_hal_queue(struct rsi_common *common)
return q_num;
}

- if (common->hw_data_qs_blocked)
+ if (common->hw_data_qs_blocked) {
+ rsi_dbg(INFO_ZONE, "%s: data queue blocked\n", __func__);
return q_num;
+ }

if (common->pkt_cnt != 0) {
--common->pkt_cnt;
@@ -210,6 +212,7 @@ static void rsi_core_queue_pkt(struct rsi_common *common,
struct sk_buff *skb)
{
u8 q_num = skb->priority;
+
if (q_num >= NUM_SOFT_QUEUES) {
rsi_dbg(ERR_ZONE, "%s: Invalid Queue Number: q_num = %d\n",
__func__, q_num);
@@ -285,7 +288,7 @@ void rsi_core_qos_processor(struct rsi_common *common)
}

skb = rsi_core_dequeue_pkt(common, q_num);
- if (skb == NULL) {
+ if (!skb) {
rsi_dbg(ERR_ZONE, "skb null\n");
mutex_unlock(&common->tx_rxlock);
break;
@@ -331,21 +334,32 @@ void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb)
__func__);
goto xmit_fail;
}
- info = IEEE80211_SKB_CB(skb);
- tx_params = (struct skb_info *)info->driver_data;
- tmp_hdr = (struct ieee80211_hdr *)&skb->data[0];

if (common->fsm_state != FSM_MAC_INIT_DONE) {
rsi_dbg(ERR_ZONE, "%s: FSM state not open\n", __func__);
goto xmit_fail;
}

+ info = IEEE80211_SKB_CB(skb);
+ tx_params = (struct skb_info *)info->driver_data;
+ tmp_hdr = (struct ieee80211_hdr *)&skb->data[0];
+
if ((ieee80211_is_mgmt(tmp_hdr->frame_control)) ||
(ieee80211_is_ctl(tmp_hdr->frame_control)) ||
(ieee80211_is_qos_nullfunc(tmp_hdr->frame_control))) {
q_num = MGMT_SOFT_Q;
skb->priority = q_num;
+ if (ieee80211_is_probe_req(tmp_hdr->frame_control))
+ rsi_dbg(MGMT_TX_ZONE, "%s: Probe Request\n", __func__);
+ else if (ieee80211_is_auth(tmp_hdr->frame_control))
+ rsi_dbg(MGMT_TX_ZONE, "%s: Auth Request\n", __func__);
+ else if (ieee80211_is_assoc_req(tmp_hdr->frame_control))
+ rsi_dbg(MGMT_TX_ZONE, "%s: Assoc Request\n", __func__);
+ else
+ rsi_dbg(MGMT_TX_ZONE, "%s: pkt_type=%04x\n",
+ __func__, tmp_hdr->frame_control);
} else {
+ rsi_dbg(DATA_TX_ZONE, "%s: Data Packet\n", __func__);
if (ieee80211_is_data_qos(tmp_hdr->frame_control)) {
tid = (skb->data[24] & IEEE80211_QOS_TID);
skb->priority = TID_TO_WME_AC(tid);
--
2.4.11

2016-09-12 09:43:27

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 3/9] rsi: Added freeing of allocated buffers (sbands and dfsentry) Cleanup (spelling mistakes, code format corrections, empty lines after declaration)

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_mac80211.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index dbb2389..29abedc 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -194,6 +194,7 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
void rsi_mac80211_detach(struct rsi_hw *adapter)
{
struct ieee80211_hw *hw = adapter->hw;
+ int i;

if (hw) {
ieee80211_stop_queues(hw);
@@ -201,7 +202,17 @@ void rsi_mac80211_detach(struct rsi_hw *adapter)
ieee80211_free_hw(hw);
}

+ for(i = 0; i < 2; i++) {
+ struct ieee80211_supported_band *sbands = &adapter->sbands[i];
+
+ if (sbands->channels)
+ kfree(sbands->channels);
+ }
+
+#ifdef CONFIG_RSI_DEBUGFS
rsi_remove_dbgfs(adapter);
+ kfree(adapter->dfsentry);
+#endif
}
EXPORT_SYMBOL_GPL(rsi_mac80211_detach);

@@ -304,7 +315,8 @@ static int rsi_mac80211_add_interface(struct ieee80211_hw *hw,
if (!adapter->sc_nvifs) {
++adapter->sc_nvifs;
adapter->vifs[0] = vif;
- ret = rsi_set_vap_capabilities(common, STA_OPMODE);
+ ret = rsi_set_vap_capabilities(common,
+ STA_OPMODE);
}
break;
default:
@@ -429,9 +441,11 @@ static int rsi_mac80211_config(struct ieee80211_hw *hw,
u16 rsi_get_connected_channel(struct rsi_hw *adapter)
{
struct ieee80211_vif *vif = adapter->vifs[0];
+
if (vif) {
struct ieee80211_bss_conf *bss = &vif->bss_conf;
struct ieee80211_channel *channel = bss->chandef.chan;
+
return channel->hw_value;
}

@@ -819,8 +833,6 @@ static void rsi_perform_cqm(struct rsi_common *common,
common->cqm_info.last_cqm_event_rssi = rssi;
rsi_dbg(INFO_ZONE, "CQM: Notifying event: %d\n", event);
ieee80211_cqm_rssi_notify(adapter->vifs[0], event, GFP_KERNEL);
-
- return;
}

/**
@@ -875,16 +887,14 @@ static void rsi_fill_rx_status(struct ieee80211_hw *hw,
}

/* CQM only for connected AP beacons, the RSSI is a weighted avg */
- if (bss->assoc && !(memcmp(bss->bssid, hdr->addr2, ETH_ALEN))) {
+ if (bss->assoc && ether_addr_equal(bss->bssid, hdr->addr2)) {
if (ieee80211_is_beacon(hdr->frame_control))
rsi_perform_cqm(common, hdr->addr2, rxs->signal);
}
-
- return;
}

/**
- * rsi_indicate_pkt_to_os() - This function sends recieved packet to mac80211.
+ * rsi_indicate_pkt_to_os() - This function sends received packet to mac80211.
* @common: Pointer to the driver private structure.
* @skb: Pointer to the socket buffer structure.
*
--
2.4.11

2016-09-12 09:43:54

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 8/9] rsi: code clean up and replaced ctrl message timeouts with macros in file rsi_91x_usb.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_usb.c | 42 +++++++++++++++++++---------------
1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index ef5d394..21957dd 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -1,6 +1,9 @@
/**
* Copyright (c) 2014 Redpine Signals Inc.
*
+ * Developers:
+ * Prameela Rani Garnepudi 2016 <[email protected]>
+ *
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
@@ -19,7 +22,7 @@
#include "rsi_usb.h"

/**
- * rsi_usb_card_write() - This function writes to the USB Card.
+ * rsi_usb_card_write() - This function writes data to the USB Card.
* @adapter: Pointer to the adapter structure.
* @buf: Pointer to the buffer from where the data has to be taken.
* @len: Length to be written.
@@ -34,7 +37,7 @@ static int rsi_usb_card_write(struct rsi_hw *adapter,
{
struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
int status;
- s32 transfer;
+ int transfer;

status = usb_bulk_msg(dev->usbdev,
usb_sndbulkpipe(dev->usbdev,
@@ -46,7 +49,7 @@ static int rsi_usb_card_write(struct rsi_hw *adapter,

if (status < 0) {
rsi_dbg(ERR_ZONE,
- "Card write failed with error code :%10d\n", status);
+ "Card write failed with error code :%d\n", status);
dev->write_fail = 1;
}
return status;
@@ -155,11 +158,11 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
u16 len)
{
u8 *buf;
- int status = -ENOMEM;
+ int status = 0;

buf = kmalloc(0x04, GFP_KERNEL);
if (!buf)
- return status;
+ return -ENOMEM;

status = usb_control_msg(usbdev,
usb_rcvctrlpipe(usbdev, 0),
@@ -168,7 +171,7 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
((reg & 0xffff0000) >> 16), (reg & 0xffff),
(void *)buf,
len,
- HZ * 5);
+ USB_CTRL_GET_TIMEOUT);

*value = (buf[0] | (buf[1] << 8));
if (status < 0) {
@@ -197,11 +200,11 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
u16 len)
{
u8 *usb_reg_buf;
- int status = -ENOMEM;
+ int status = 0;

usb_reg_buf = kmalloc(0x04, GFP_KERNEL);
if (!usb_reg_buf)
- return status;
+ return -ENOMEM;

usb_reg_buf[0] = (value & 0x00ff);
usb_reg_buf[1] = (value & 0xff00) >> 8;
@@ -216,7 +219,7 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
(reg & 0xffff),
(void *)usb_reg_buf,
len,
- HZ * 5);
+ USB_CTRL_SET_TIMEOUT);
if (status < 0) {
rsi_dbg(ERR_ZONE,
"%s: Reg write failed with error code :%d\n",
@@ -275,11 +278,11 @@ static int rsi_rx_urb_submit(struct rsi_hw *adapter)

/**
* rsi_usb_write_register_multiple() - This function writes multiple bytes of
- * information to multiple registers.
- * @adapter: Pointer to the adapter structure.
- * @addr: Address of the register.
- * @data: Pointer to the data that has to be written.
- * @count: Number of multiple bytes to be written on to the registers.
+ * information to the given address.
+ * @adapter: Pointer to the adapter structure.
+ * @addr: Address of the register.
+ * @data: Pointer to the data that has to be written.
+ * @count: Number of multiple bytes to be written on to the registers.
*
* Return: status: 0 on success, a negative error code on failure.
*/
@@ -308,16 +311,17 @@ int rsi_usb_write_register_multiple(struct rsi_hw *adapter,
(addr & 0xffff),
(void *)buf,
transfer,
- HZ * 5);
+ USB_CTRL_SET_TIMEOUT);
if (status < 0) {
rsi_dbg(ERR_ZONE,
"Reg write failed with error code :%d\n",
status);
- } else {
- count -= transfer;
- data += transfer;
- addr += transfer;
+ kfree(buf);
+ return status;
}
+ count -= transfer;
+ data += transfer;
+ addr += transfer;
}

kfree(buf);
--
2.4.11

2016-09-12 18:50:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 0/9] rsi: code clean-up

On Mon, 2016-09-12 at 15:53 +0300, Kalle Valo wrote:
> Also try to get more familiar how development is done, here are few
> links:
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> https://www.kernel.org/doc/Documentation/SubmittingPatches
> https://kernelnewbies.org/FirstKernelPatch
>
> Also mailing list archives and git logs are a great way to learn from
> how others do it.

And only working on drivers/staging files is a good way to start.

2016-09-12 12:05:50

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 3/9] rsi: Added freeing of allocated buffers (sbands and dfsentry) Cleanup (spelling mistakes, code format corrections, empty lines after declaration)

Hi Prameela,

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.8-rc6 next-20160912]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Prameela-Rani-Garnepudi/rsi-cleanup-and-added-debug-prints-in-file-rsi_91x_core-c/20160912-184326
base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master


coccinelle warnings: (new ones prefixed by >>)

>> drivers/net/wireless/rsi/rsi_91x_mac80211.c:209:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

2016-09-12 09:43:44

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 7/9] rsi: zone changed for debug message and cleanup in file rsi_91x_sdio_ops.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_sdio_ops.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
index 40d7231..4287360 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
@@ -36,7 +36,7 @@ static int rsi_sdio_master_access_msword(struct rsi_hw *adapter,

byte = (u8)(ms_word & 0x00FF);

- rsi_dbg(INIT_ZONE,
+ rsi_dbg(INFO_ZONE,
"%s: MASTER_ACCESS_MSBYTE:0x%x\n", __func__, byte);

status = rsi_sdio_write_register(adapter,
@@ -52,7 +52,7 @@ static int rsi_sdio_master_access_msword(struct rsi_hw *adapter,

byte = (u8)(ms_word >> 8);

- rsi_dbg(INIT_ZONE, "%s:MASTER_ACCESS_LSBYTE:0x%x\n", __func__, byte);
+ rsi_dbg(INFO_ZONE, "%s:MASTER_ACCESS_LSBYTE:0x%x\n", __func__, byte);
status = rsi_sdio_write_register(adapter,
function,
SDIO_MASTER_ACCESS_LSBYTE,
@@ -435,7 +435,7 @@ void rsi_interrupt_handler(struct rsi_hw *adapter)
} else {
rsi_dbg(ERR_ZONE,
"%s: Firmware Status is 0x%x\n",
- __func__ , fw_status);
+ __func__, fw_status);
rsi_sdio_ack_intr(common->priv,
(1 << FW_ASSERT_IND));
}
--
2.4.11

2016-09-12 12:05:51

by kernel test robot

[permalink] [raw]
Subject: [PATCH] rsi: fix ifnullfree.cocci warnings

drivers/net/wireless/rsi/rsi_91x_mac80211.c:209:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

NULL check before some freeing functions is not needed.

Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: Prameela Rani Garnepudi <[email protected]>
Signed-off-by: Fengguang Wu <[email protected]>
---

rsi_91x_mac80211.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -205,8 +205,7 @@ void rsi_mac80211_detach(struct rsi_hw *
for(i = 0; i < 2; i++) {
struct ieee80211_supported_band *sbands = &adapter->sbands[i];

- if (sbands->channels)
- kfree(sbands->channels);
+ kfree(sbands->channels);
}

#ifdef CONFIG_RSI_DEBUGFS

2016-09-12 09:43:58

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 9/9] rsi: code cleanup in file rsi_91x_usb_ops.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_usb_ops.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb_ops.c b/drivers/net/wireless/rsi/rsi_91x_usb_ops.c
index de49008..5ab2ce3 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb_ops.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb_ops.c
@@ -96,26 +96,25 @@ void rsi_usb_rx_thread(struct rsi_common *common)
rsi_wait_event(&dev->rx_thread.event, EVENT_WAIT_FOREVER);

if (atomic_read(&dev->rx_thread.thread_done))
- goto out;
+ break;

mutex_lock(&common->tx_rxlock);
status = rsi_read_pkt(common, 0);
if (status) {
rsi_dbg(ERR_ZONE, "%s: Failed To read data", __func__);
mutex_unlock(&common->tx_rxlock);
- return;
+ break;
}
mutex_unlock(&common->tx_rxlock);
rsi_reset_event(&dev->rx_thread.event);
if (adapter->rx_urb_submit(adapter)) {
rsi_dbg(ERR_ZONE,
"%s: Failed in urb submission", __func__);
- return;
+ break;
}
} while (1);

-out:
- rsi_dbg(INFO_ZONE, "%s: Terminated thread\n", __func__);
+ rsi_dbg(INFO_ZONE, "%s: Terminated USB RX thread\n", __func__);
complete_and_exit(&dev->rx_thread.completion, 0);
}

--
2.4.11

2016-09-12 09:43:30

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 4/9] rsi: code clean up in file rsi_91x_main.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_main.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_main.c b/drivers/net/wireless/rsi/rsi_91x_main.c
index 8810862..f82e457 100644
--- a/drivers/net/wireless/rsi/rsi_91x_main.c
+++ b/drivers/net/wireless/rsi/rsi_91x_main.c
@@ -86,7 +86,7 @@ static struct sk_buff *rsi_prepare_skb(struct rsi_common *common,

pkt_len -= extended_desc;
skb = dev_alloc_skb(pkt_len + FRAME_DESC_SZ);
- if (skb == NULL)
+ if (!skb)
return NULL;

payload_offset = (extended_desc + FRAME_DESC_SZ);
@@ -111,11 +111,10 @@ static struct sk_buff *rsi_prepare_skb(struct rsi_common *common,
int rsi_read_pkt(struct rsi_common *common, s32 rcv_pkt_len)
{
u8 *frame_desc = NULL, extended_desc = 0;
- u32 index, length = 0, queueno = 0;
+ u32 index = 0, length = 0, queueno = 0;
u16 actual_length = 0, offset;
struct sk_buff *skb = NULL;

- index = 0;
do {
frame_desc = &common->rx_data_pkt[index];
actual_length = *(u16 *)&frame_desc[0];
@@ -131,7 +130,7 @@ int rsi_read_pkt(struct rsi_common *common, s32 rcv_pkt_len)
(frame_desc + offset),
length,
extended_desc);
- if (skb == NULL)
+ if (!skb)
goto fail;

rsi_indicate_pkt_to_os(common, skb);
@@ -198,15 +197,14 @@ struct rsi_hw *rsi_91x_init(void)
return NULL;

adapter->priv = kzalloc(sizeof(*common), GFP_KERNEL);
- if (adapter->priv == NULL) {
- rsi_dbg(ERR_ZONE, "%s: Failed in allocation of memory\n",
+ if (!adapter->priv) {
+ rsi_dbg(ERR_ZONE, "%s: Failed in allocation of common cb\n",
__func__);
kfree(adapter);
return NULL;
- } else {
- common = adapter->priv;
- common->priv = adapter;
}
+ common = adapter->priv;
+ common->priv = adapter;

for (ii = 0; ii < NUM_SOFT_QUEUES; ii++)
skb_queue_head_init(&common->tx_queue[ii]);
--
2.4.11

2016-09-12 09:43:34

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 5/9] rsi: code cleanup in file rsi_91x_mgmt.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_mgmt.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 35c14cc..e505600 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -255,7 +255,7 @@ static int rsi_send_internal_mgmt_frame(struct rsi_common *common,
{
struct skb_info *tx_params;

- if (skb == NULL) {
+ if (!skb) {
rsi_dbg(ERR_ZONE, "%s: Unable to allocate skb\n", __func__);
return -ENOMEM;
}
@@ -290,7 +290,6 @@ static int rsi_load_radio_caps(struct rsi_common *common)
rsi_dbg(INFO_ZONE, "%s: Sending rate symbol req frame\n", __func__);

skb = dev_alloc_skb(sizeof(struct rsi_radio_caps));
-
if (!skb) {
rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n",
__func__);
@@ -310,6 +309,7 @@ static int rsi_load_radio_caps(struct rsi_common *common)
if (common->fsm_state == FSM_MAC_INIT_DONE) {
struct ieee80211_hw *hw = adapter->hw;
struct ieee80211_conf *conf = &hw->conf;
+
if (conf_is_ht40_plus(conf)) {
radio_caps->desc_word[5] =
cpu_to_le16(LOWER_20_ENABLE);
@@ -375,8 +375,8 @@ static int rsi_load_radio_caps(struct rsi_common *common)
* rsi_mgmt_pkt_to_core() - This function is the entry point for Mgmt module.
* @common: Pointer to the driver private structure.
* @msg: Pointer to received packet.
- * @msg_len: Length of the recieved packet.
- * @type: Type of recieved packet.
+ * @msg_len: Length of the received packet.
+ * @type: Type of received packet.
*
* Return: 0 on success, -1 on failure.
*/
@@ -425,9 +425,8 @@ static int rsi_mgmt_pkt_to_core(struct rsi_common *common,
rx_params->rssi = rsi_get_rssi(msg);
rx_params->channel = rsi_get_channel(msg);
rsi_indicate_pkt_to_os(common, skb);
- } else {
+ } else
rsi_dbg(MGMT_TX_ZONE, "%s: Internal Packet\n", __func__);
- }

return 0;
}
@@ -545,7 +544,9 @@ int rsi_send_aggregation_params_frame(struct rsi_common *common,
mgmt_frame->desc_word[4] = cpu_to_le16(ssn);
mgmt_frame->desc_word[5] = cpu_to_le16(buf_size);
mgmt_frame->desc_word[7] =
- cpu_to_le16((tid | (START_AMPDU_AGGR << 4) | (peer_id << 8)));
+ cpu_to_le16((tid |
+ (START_AMPDU_AGGR << 4) |
+ (peer_id << 8)));
} else if (event == STA_RX_ADDBA_DONE) {
mgmt_frame->desc_word[4] = cpu_to_le16(ssn);
mgmt_frame->desc_word[7] = cpu_to_le16(tid |
@@ -980,6 +981,7 @@ static int rsi_compare(const void *a, const void *b)
static bool rsi_map_rates(u16 rate, int *offset)
{
int kk;
+
for (kk = 0; kk < ARRAY_SIZE(rsi_mcsrates); kk++) {
if (rate == mcs[kk]) {
*offset = kk;
@@ -1013,7 +1015,6 @@ static int rsi_send_auto_rate_request(struct rsi_common *common)
u8 num_supported_rates = 0;
u8 rate_table_offset, rate_offset = 0;
u32 rate_bitmap = common->bitrate_mask[band];
-
u16 *selected_rates, min_rate;

skb = dev_alloc_skb(sizeof(struct rsi_auto_rate));
@@ -1261,9 +1262,8 @@ static int rsi_handle_ta_confirm_type(struct rsi_common *common,
if (rsi_eeprom_read(common)) {
common->fsm_state = FSM_CARD_NOT_READY;
goto out;
- } else {
+ } else
common->fsm_state = FSM_EEPROM_READ_MAC_ADDR;
- }
} else {
rsi_dbg(INFO_ZONE,
"%s: Received bootup params cfm in %d state\n",
@@ -1275,8 +1275,10 @@ static int rsi_handle_ta_confirm_type(struct rsi_common *common,
case EEPROM_READ_TYPE:
if (common->fsm_state == FSM_EEPROM_READ_MAC_ADDR) {
if (msg[16] == MAGIC_WORD) {
- u8 offset = (FRAME_DESC_SZ + WLAN_HOST_MODE_LEN
- + WLAN_MAC_MAGIC_WORD_LEN);
+ u8 offset = (FRAME_DESC_SZ +
+ WLAN_HOST_MODE_LEN +
+ WLAN_MAC_MAGIC_WORD_LEN);
+
memcpy(common->mac_addr,
&msg[offset],
ETH_ALEN);
@@ -1347,7 +1349,7 @@ static int rsi_handle_ta_confirm_type(struct rsi_common *common,
}
} else {
rsi_dbg(INFO_ZONE,
- "%s: Received bbb_rf cfm in %d state\n",
+ "%s: Received bb_rf cfm in %d state\n",
__func__, common->fsm_state);
return 0;
}
@@ -1367,7 +1369,7 @@ out:

/**
* rsi_mgmt_pkt_recv() - This function processes the management packets
- * recieved from the hardware.
+ * received from the hardware.
* @common: Pointer to the driver private structure.
* @msg: Pointer to the received packet.
*
--
2.4.11

2016-09-12 09:43:39

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 6/9] rsi: code cleanup (spelling mistakes and new line after declaration) in file rsi_91x_sdio.c Added developer name

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_sdio.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
index 8428858..d958f90 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
@@ -1,6 +1,8 @@
/**
* Copyright (c) 2014 Redpine Signals Inc.
*
+ * Developers:
+ * Fariya Fathima 2014 <[email protected]>
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
@@ -128,7 +130,7 @@ static int rsi_issue_sdiocommand(struct sdio_func *func,
}

/**
- * rsi_handle_interrupt() - This function is called upon the occurence
+ * rsi_handle_interrupt() - This function is called upon the occurrence
* of an interrupt.
* @function: Pointer to the sdio_func structure.
*
@@ -183,8 +185,7 @@ static void rsi_reset_card(struct sdio_func *pfunction)
host->ios.timing = MMC_TIMING_LEGACY;
host->ops->set_ios(host, &host->ios);

- /*
- * This delay should be sufficient to allow the power supply
+ /* This delay should be sufficient to allow the power supply
* to reach the minimum voltage.
*/
msleep(20);
@@ -193,8 +194,7 @@ static void rsi_reset_card(struct sdio_func *pfunction)
host->ios.power_mode = MMC_POWER_ON;
host->ops->set_ios(host, &host->ios);

- /*
- * This delay must be at least 74 clock sizes, or 1 ms, or the
+ /* This delay must be at least 74 clock sizes, or 1 ms, or the
* time required to reach a stable voltage.
*/
msleep(20);
@@ -361,6 +361,7 @@ static int rsi_setblocklength(struct rsi_hw *adapter, u32 length)
struct rsi_91x_sdiodev *dev =
(struct rsi_91x_sdiodev *)adapter->rsi_dev;
int status;
+
rsi_dbg(INIT_ZONE, "%s: Setting the block length\n", __func__);

status = sdio_set_block_size(dev->pfunction, length);
@@ -464,6 +465,7 @@ int rsi_sdio_write_register(struct rsi_hw *adapter,
void rsi_sdio_ack_intr(struct rsi_hw *adapter, u8 int_bit)
{
int status;
+
status = rsi_sdio_write_register(adapter,
1,
(SDIO_FUN1_INTR_CLR_REG |
@@ -473,8 +475,6 @@ void rsi_sdio_ack_intr(struct rsi_hw *adapter, u8 int_bit)
rsi_dbg(ERR_ZONE, "%s: unable to send ack\n", __func__);
}

-
-
/**
* rsi_sdio_read_register_multiple() - This function read multiple bytes of
* information from the SD card.
@@ -667,7 +667,7 @@ static int rsi_init_sdio_interface(struct rsi_hw *adapter,
goto fail;
}

- rsi_dbg(INIT_ZONE, "%s: Setup card succesfully\n", __func__);
+ rsi_dbg(INIT_ZONE, "%s: Setup card successfully\n", __func__);

status = rsi_init_sdio_slave_regs(adapter);
if (status) {
--
2.4.11

2016-09-12 12:53:52

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 0/9] rsi: code clean-up

Prameela Rani Garnepudi <[email protected]> writes:

> *** BLURB HERE ***

This has a meaning :)

> Prameela Rani Garnepudi (9):
> rsi: cleanup and added debug prints in file rsi_91x_core.c
> rsi: Spelling and code format corrections in rsi_91x_debugfs.c
> rsi: Added freeing of allocated buffers (sbands and dfsentry)
> Cleanup (spelling mistakes, code format corrections,
> empty lines after declaration)
> rsi: code clean up in file rsi_91x_main.c
> rsi: code cleanup in file rsi_91x_mgmt.c
> rsi: code cleanup (spelling mistakes and new line after declaration)
> in file rsi_91x_sdio.c Added developer name
> rsi: zone changed for debug message and cleanup in file
> rsi_91x_sdio_ops.c
> rsi: code clean up and replaced ctrl message timeouts with macros in
> file rsi_91x_usb.c
> rsi: code cleanup in file rsi_91x_usb_ops.c

Usually patches are split based on type of changes, not by files
affected. So one patch does one type of logical change to all files in
the driver and another patch does again something else. Also the commit
logs are not correctly formatted, for example the title is too long.

I recommend to start with something small, for example one small patch a
time. And once you get more familiar with the process you can submit
more, and bigger, patches at a time. Also code cleanup is not really the
best way to start as it's a very subjective matter.

Also try to get more familiar how development is done, here are few
links:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

https://www.kernel.org/doc/Documentation/SubmittingPatches

https://kernelnewbies.org/FirstKernelPatch

Also mailing list archives and git logs are a great way to learn from
how others do it.

--
Kalle Valo

2016-09-12 09:43:17

by Prameela Rani Garnepudi

[permalink] [raw]
Subject: [PATCH 2/9] rsi: Spelling and code format corrections in rsi_91x_debugfs.c

Signed-off-by: Prameela Rani Garnepudi <[email protected]>
---
drivers/net/wireless/rsi/rsi_91x_debugfs.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
index 828a042..5ec7bce 100644
--- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c
+++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
@@ -59,7 +59,7 @@ static int rsi_sdio_stats_read(struct seq_file *seq, void *data)
}

/**
- * rsi_sdio_stats_open() - This funtion calls single open function of seq_file
+ * rsi_sdio_stats_open() - This function calls single open function of seq_file
* to open file and read contents from it.
* @inode: Pointer to the inode structure.
* @file: Pointer to the file structure.
@@ -100,7 +100,7 @@ static int rsi_version_read(struct seq_file *seq, void *data)
}

/**
- * rsi_version_open() - This funtion calls single open function of seq_file to
+ * rsi_version_open() - This function calls single open function of seq_file to
* open file and read contents from it.
* @inode: Pointer to the inode structure.
* @file: Pointer to the file structure.
@@ -108,7 +108,7 @@ static int rsi_version_read(struct seq_file *seq, void *data)
* Return: Pointer to the opened file status: 0 on success, ENOMEM on failure.
*/
static int rsi_version_open(struct inode *inode,
- struct file *file)
+ struct file *file)
{
return single_open(file, rsi_version_read, inode->i_private);
}
@@ -180,7 +180,7 @@ static int rsi_stats_read(struct seq_file *seq, void *data)
}

/**
- * rsi_stats_open() - This funtion calls single open function of seq_file to
+ * rsi_stats_open() - This function calls single open function of seq_file to
* open file and read contents from it.
* @inode: Pointer to the inode structure.
* @file: Pointer to the file structure.
@@ -194,7 +194,8 @@ static int rsi_stats_open(struct inode *inode,
}

/**
- * rsi_debug_zone_read() - This function display the currently enabled debug zones.
+ * rsi_debug_zone_read() - This function display the currently
+ * enabled debug zones.
* @seq: Pointer to the sequence file structure.
* @data: Pointer to the data.
*
@@ -209,7 +210,7 @@ static int rsi_debug_zone_read(struct seq_file *seq, void *data)
}

/**
- * rsi_debug_read() - This funtion calls single open function of seq_file to
+ * rsi_debug_read() - This function calls single open function of seq_file to
* open file and read contents from it.
* @inode: Pointer to the inode structure.
* @file: Pointer to the file structure.
--
2.4.11