Re: [v2] rsi: sdio suspend and resume support

2017-09-21 Thread Souptick Joarder
On Thu, Sep 21, 2017 at 6:21 PM, Amitkumar Karwar  wrote:
> From: Karun Eagalapati 
>
> SDIO suspend and resume handlers are implemented and verified
> that device works after suspend/resume cycle.
>
> Signed-off-by: Karun Eagalapati 
> Signed-off-by: Amitkumar Karwar 
> ---
> v2: Replaced never ending while loop with 20msecs loop(Kalle Valo)
> ---
>  drivers/net/wireless/rsi/rsi_91x_sdio.c | 128 
> +++-
>  drivers/net/wireless/rsi/rsi_sdio.h |   2 +
>  2 files changed, 126 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c 
> b/drivers/net/wireless/rsi/rsi_91x_sdio.c
> index 8d3a483..b3f8006 100644
> --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
> +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
> @@ -1059,16 +1059,136 @@ static void rsi_disconnect(struct sdio_func 
> *pfunction)
>  }
>
>  #ifdef CONFIG_PM
> +static int rsi_set_sdio_pm_caps(struct rsi_hw *adapter)
> +{
> +   struct rsi_91x_sdiodev *dev =
> +   (struct rsi_91x_sdiodev *)adapter->rsi_dev;
> +   struct sdio_func *func = dev->pfunction;
> +   int ret;
> +
> +   ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
> +   if (ret)
> +   rsi_dbg(ERR_ZONE, "Set sdio keep pwr flag failed: %d\n", ret);
> +
> +   return ret;
> +}
> +
> +static int rsi_sdio_disable_interrupts(struct sdio_func *pfunc)
> +{
> +   struct rsi_hw *adapter = sdio_get_drvdata(pfunc);
> +   u8 isr_status = 0, data = 0;
> +   int ret;
> +   unsigned long t1;
> +
> +   rsi_dbg(INFO_ZONE, "Waiting for interrupts to be cleared..");
> +   t1 = jiffies;
> +   do {
> +   rsi_sdio_read_register(adapter, RSI_FN1_INT_REGISTER,
> +  &isr_status);
> +   rsi_dbg(INFO_ZONE, ".");
> +   } while ((isr_status) && (jiffies_to_msecs(jiffies - t1) < 20));
> +   rsi_dbg(INFO_ZONE, "Interrupts cleared\n");
> +
> +   sdio_claim_host(pfunc);
> +   ret = rsi_cmd52readbyte(pfunc->card, RSI_INT_ENABLE_REGISTER, &data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to read int enable register\n",
> +   __func__);
> +   goto done;
> +   }
> +
> +   data &= RSI_INT_ENABLE_MASK;
> +   ret = rsi_cmd52writebyte(pfunc->card, RSI_INT_ENABLE_REGISTER, data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to write to int enable register\n",
> +   __func__);
> +   goto done;
> +   }
> +   ret = rsi_cmd52readbyte(pfunc->card, RSI_INT_ENABLE_REGISTER, &data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to read int enable register\n",
> +   __func__);
> +   goto done;
> +   }
> +   rsi_dbg(INFO_ZONE, "int enable reg content = %x\n", data);
> +
> +done:
> +   sdio_release_host(pfunc);
> +   return ret;
> +}
> +
> +static int rsi_sdio_enable_interrupts(struct sdio_func *pfunc)
> +{
> +   u8 data;
> +   int ret;
> +
> +   sdio_claim_host(pfunc);
> +   ret = rsi_cmd52readbyte(pfunc->card, RSI_INT_ENABLE_REGISTER, &data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to read int enable register\n", __func__);
> +   goto done;
> +   }
> +
> +   data |= ~RSI_INT_ENABLE_MASK & 0xff;
> +
> +   ret = rsi_cmd52writebyte(pfunc->card, RSI_INT_ENABLE_REGISTER, data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to write to int enable register\n",
> +   __func__);
> +   goto done;
> +   }
> +
> +   ret = rsi_cmd52readbyte(pfunc->card, RSI_INT_ENABLE_REGISTER, &data);
> +   if (ret < 0) {
> +   rsi_dbg(ERR_ZONE,
> +   "%s: Failed to read int enable register\n", __func__);
> +   goto done;
> +   }
> +   rsi_dbg(INFO_ZONE, "int enable reg content = %x\n", data);
> +
> +done:
> +   sdio_release_host(pfunc);
> +   return ret;
> +}
> +
>  static int rsi_suspend(struct device *dev)
>  {
> -   /* Not yet implemented */
> -   return -ENOSYS;
> +   int ret;
> +   struct sdio_func *pfunction = dev_to_sdio_func(dev);
> +   struct rsi_hw *adapter = sdio_get_drvdata(pfunction);
> +   struct rsi_common *common;
> +
> +   if (!adapter) {
> +   rsi_dbg(ERR_ZONE, "Device is not ready\n");
> +   return -ENODEV;
> +   }
> +   common = adapter->priv;
> +   rsi_sdio_disable_interrupts(pfunction);
> +
> +   ret = rsi_set_sdio_pm_caps(adapter);
> +   if (ret)
> +   rsi_dbg(INFO_ZONE,
> +   "Setting power management caps failed\n");
> +   common->fsm_state = FSM_CARD_NOT_READY;
> +
> +   return 0;

Re: [PATCH] mwifiex: add device specific ioctl handler

2017-09-20 Thread Souptick Joarder
On Wed, Sep 20, 2017 at 12:14 PM, Xinming Hu  wrote:
> From: Xinming Hu 
>
> Add net_dev ndo_do_ioctl handler, which could be used for
> downloading host command by utility in manufactory test
>
> Signed-off-by: Xinming Hu 
> Signed-off-by: Cathy Luo 
> Signed-off-by: Ganapathi Bhat 
> ---
>  drivers/net/wireless/marvell/mwifiex/cmdevt.c | 59 
> +++
>  drivers/net/wireless/marvell/mwifiex/main.c   | 23 +++
>  drivers/net/wireless/marvell/mwifiex/main.h   |  7 +++-
>  3 files changed, 88 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c 
> b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
> index 0edc5d6..86ee399 100644
> --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c
> +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
> @@ -839,6 +839,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter 
> *adapter)
> hostcmd = adapter->curr_cmd->data_buf;
> hostcmd->len = size;
> memcpy(hostcmd->cmd, resp, size);
> +   adapter->hostcmd_resp_data.len = size;
> +   memcpy(adapter->hostcmd_resp_data.cmd, resp, size);
> }
> }
> orig_cmdresp_no = le16_to_cpu(resp->command);
> @@ -1221,6 +1223,63 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private 
> *priv,
>  }
>  EXPORT_SYMBOL_GPL(mwifiex_process_hs_config);
>
> +/* This function get hostcmd data from userspace and construct a cmd
> + * to be download to FW.
> + */
> +int mwifiex_process_host_command(struct mwifiex_private *priv,
> +struct ifreq *req)
> +{
> +   struct mwifiex_ds_misc_cmd *hostcmd_buf;
> +   struct host_cmd_ds_command *cmd;
> +   struct mwifiex_adapter *adapter = priv->adapter;
> +   int ret;
> +
> +   hostcmd_buf = kzalloc(sizeof(*hostcmd_buf), GFP_KERNEL);

will it be sizeof(*hostcmd_buf) or sizeof( struct mwifiex_ds_misc_cmd *) ?

> +   if (!hostcmd_buf)
> +   return -ENOMEM;
> +
> +   cmd = (void *)hostcmd_buf->cmd;
> +
> +   if (copy_from_user(cmd, req->ifr_data,
> +  sizeof(cmd->command) + sizeof(cmd->size))) {
> +   ret = -EFAULT;
> +   goto done;
> +   }
> +
> +   hostcmd_buf->len = le16_to_cpu(cmd->size);
> +   if (hostcmd_buf->len > MWIFIEX_SIZE_OF_CMD_BUFFER) {
> +   ret = -EINVAL;
> +   goto done;
> +   }
> +
> +   if (copy_from_user(cmd, req->ifr_data, hostcmd_buf->len)) {
> +   ret = -EFAULT;
> +   goto done;
> +   }
> +
> +   if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd_buf, true)) {
> +   dev_err(priv->adapter->dev, "Failed to process hostcmd\n");
> +   ret = -EFAULT;
> +   goto done;
> +   }
> +
> +   if (adapter->hostcmd_resp_data.len > hostcmd_buf->len) {
> +   ret = -EFBIG;
> +   goto done;
> +   }
> +
> +   if (copy_to_user(req->ifr_data, adapter->hostcmd_resp_data.cmd,
> +adapter->hostcmd_resp_data.len)) {
> +   ret = -EFAULT;
> +   goto done;
> +   }
> +
> +   ret = 0;
> +done:
> +   kfree(hostcmd_buf);
> +   return ret;
> +}
> +
>  /*
>   * This function handles the command response of a sleep confirm command.
>   *
> diff --git a/drivers/net/wireless/marvell/mwifiex/main.c 
> b/drivers/net/wireless/marvell/mwifiex/main.c
> index ee40b73..3e7700f 100644
> --- a/drivers/net/wireless/marvell/mwifiex/main.c
> +++ b/drivers/net/wireless/marvell/mwifiex/main.c
> @@ -1265,12 +1265,35 @@ static struct net_device_stats 
> *mwifiex_get_stats(struct net_device *dev)
> return mwifiex_1d_to_wmm_queue[skb->priority];
>  }
>
> +static int mwifiex_do_ioctl(struct net_device *dev, struct ifreq *req, int 
> cmd)
> +{
> +   struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
> +   int ret;
> +
> +   if (!priv->adapter->mfg_mode)
> +   return -EINVAL;

ret can be used instead of returning -EINVAL.

> +
> +   mwifiex_dbg(priv->adapter, "ioctl cmd = 0x%x\n", cmd);
> +
> +   switch (cmd) {
> +   case MWIFIEX_HOSTCMD_IOCTL:
> +   ret = mwifiex_process_host_command(priv, req);
> +   break;
> +   default:
> +   ret = -EINVAL;
> +   break;
> +   }
> +
> +   return ret;
> +}
> +
>  /* Network device handlers */
>  static const struct net_device_ops mwifiex_netdev_ops = {
> .ndo_open = mwifiex_open,
> .ndo_stop = mwifiex_close,
> .ndo_start_xmit = mwifiex_hard_start_xmit,
> .ndo_set_mac_address = mwifiex_ndo_set_mac_address,
> +   .ndo_do_ioctl = mwifiex_do_ioctl,
> .ndo_validate_addr = eth_validate_addr,
> .ndo_tx_timeout = mwifiex_tx_timeout,
> .ndo_get_stats = mwifiex_get_stats,
> diff --git a/drivers/net/wireless/marvell/mwifiex/ma

Re: [PATCH v5] rtlwifi: Replace hardcode value with macro

2017-08-03 Thread Souptick Joarder
On Thu, Aug 3, 2017 at 3:48 PM, Kalle Valo  wrote:
> Larry Finger  writes:
>
>> On 08/02/2017 07:29 AM, Souptick Joarder wrote:
>>> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
>>> and hw->max_rate_tries are replaced by macro and removed the comment.
>>>
>>> Signed-off-by: Souptick Joarder 
>>
>> Finally!
>>
>> Acked-by: Larry Finger 
>>
>> @Kalle: I'm sure you can work around this, but patchwork shows two
>> different "v5" versions and a "v4" entry for this same patch. That may
>> be due to no one formally rejecting the patch.
>
> It's because Souptick submitted two v5 patches, but yeah I can that sort
> it out.
>
> Souptick, the idea with patch versions is that maintainers and reviewers
> can easily find the latest version and drop the rest so ALWAYS increase
> the version number. Submitting duplicate version numbers defeats the
> purpose and creates extra work for others.

Noted. Thanks for the feedback.

>
> --
> Kalle Valo


[PATCH v5] rtlwifi: Replace hardcode value with macro

2017-08-02 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro and removed the comment.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 5 ++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 8b833e2..ea18aa7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -426,9 +426,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
 
/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index ab7d819..b56d1b7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL10
+#define MAX_RATE_TRIES 4
 
 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
-- 
1.9.1



Re: [PATCH v5] rtlwifi: Replace hardcode value with macro

2017-08-02 Thread Souptick Joarder
Please ignore this patch.

On Wed, Aug 2, 2017 at 5:50 PM, Souptick Joarder  wrote:
> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
> and hw->max_rate_tries are replaced by macro and removed the comment.
>
> Signed-off-by: Souptick Joarder 
> ---
>  drivers/net/wireless/realtek/rtlwifi/base.c | 5 ++---
>  drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
> b/drivers/net/wireless/realtek/rtlwifi/base.c
> index 8b833e2..ea18aa7 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
> @@ -426,9 +426,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
> hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
>
> /* TODO: Correct this value for our hw */
> -   /* TODO: define these hard code value */
> -   hw->max_listen_interval = 10;
> -   hw->max_rate_tries = 4;
> +   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
> +   hw->max_rate_tries = MAX_RATE_TRIES;
> /* hw->max_rates = 1; */
> hw->sta_data_size = sizeof(struct rtl_sta_info);
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
> b/drivers/net/wireless/realtek/rtlwifi/base.h
> index ab7d819..b56d1b7 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/base.h
> +++ b/drivers/net/wireless/realtek/rtlwifi/base.h
> @@ -65,6 +65,8 @@ enum ap_peer {
>  #define FRAME_OFFSET_ADDRESS3  16
>  #define FRAME_OFFSET_SEQUENCE  22
>  #define FRAME_OFFSET_ADDRESS4  24
> +#define MAX_LISTEN_INTERVAL10
> +#define MAX_RATE_TRIES 4
>
>  #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
> WRITEEF2BYTE(_hdr, _val)
> --
> 1.9.1
>


[PATCH v5] rtlwifi: Replace hardcode value with macro

2017-08-02 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro and removed the comment.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 5 ++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 8b833e2..ea18aa7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -426,9 +426,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index ab7d819..b56d1b7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL10
+#define MAX_RATE_TRIES 4

 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
--
1.9.1



[PATCH v4] rtlwifi: Replace hardcode value with macro

2017-08-02 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro and removed the comment.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 5 ++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 8b833e2..ea18aa7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -426,9 +426,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index ab7d819..c591d75 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL 10
+#define MAX_RATE_TRIES  4

 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
--
1.9.1



Re: [PATCH v4] rtlwifi: Replace hardcode value with macro

2017-08-02 Thread Souptick Joarder
Hi Kalle,

On Wed, Aug 2, 2017 at 2:51 PM, Kalle Valo  wrote:
> Larry Finger  writes:
>
>> On 07/31/2017 06:14 AM, Souptick Joarder wrote:
>>> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
>>> and hw->max_rate_tries are replaced by macro.
>>
>> That is NOT what your patch does. It only removes a comment! Granted,
>> that comment is useless and should come out, but your commit message
>> must be a little more accurate.
>
> Actually the patch does not even apply, I suspect that Souptick
> incorrectly used v3 of his patch as the baseline for v4. Instead this v4
> should be folded with v3.

Do you mean I should address your comment in v3 and send v3 again
instead of v4 ?

>
> --
> Kalle Valo

-Souptick


[PATCH v4] rtlwifi: Replace hardcode value with macro

2017-07-31 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index f45d093..52f2d0b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,7 +422,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* defined these hard code values */
hw->max_listen_interval = MAX_LISTEN_INTERVAL;
hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
--
1.9.1



[PATCH v2] rtlwifi: Fix memory leak when firmware request fails

2017-07-05 Thread Souptick Joarder
This patch will fix memory leak when firmware request fails

Signed-off-by: Souptick Joarder 
---
v2:
   - Modified patch title

 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 4 
 drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 6 ++
 9 files changed, 24 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 7661cfa..37489b4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -175,6 +175,8 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_info("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index bcbb0c6..38f85bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -176,6 +176,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
index 62d9214..dfbbd35 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
@@ -85,6 +85,10 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
err = request_firmware_nowait(THIS_MODULE, 1,
  fw_name, rtlpriv->io.dev,
  GFP_KERNEL, hw, rtl_fw_cb);
+   if (err) {
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
+   }
return err;
 }

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
index 16132c6..e38d6f7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
@@ -183,6 +183,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index 48820bc..6f2d1f0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -177,6 +177,8 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
index 2006b09..1ec20ef 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
@@ -216,6 +216,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
  rtl92se_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index 7bf9f25..aab8666 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -184,6 +184,8 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtl

Re: [PATCH] rtlwifi: Handle memory free

2017-07-05 Thread Souptick Joarder
On Wed, Jul 5, 2017 at 1:53 AM, Larry Finger  wrote:
> On 07/04/2017 02:21 AM, Souptick Joarder wrote:
>>
>> This patch will fix memory leak when firmware load fails
>>
>> Signed-off-by: Souptick Joarder 
>
>
> The patch title needs to be improved. "Handle memory free" tells us nothing

Ok, I will change the patch title and send a new patch.
>
> NACK.
>
> Larry


[PATCH] rtlwifi: Fix memory leak when firmware request fails

2017-07-04 Thread Souptick Joarder
This patch will fix memory leak when firmware request fails

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 4 
 drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 6 ++
 9 files changed, 24 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 7661cfa..37489b4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -175,6 +175,8 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_info("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index bcbb0c6..38f85bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -176,6 +176,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
index 62d9214..dfbbd35 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
@@ -85,6 +85,10 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
err = request_firmware_nowait(THIS_MODULE, 1,
  fw_name, rtlpriv->io.dev,
  GFP_KERNEL, hw, rtl_fw_cb);
+   if (err) {
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
+   }
return err;
 }

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
index 16132c6..e38d6f7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
@@ -183,6 +183,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index 48820bc..6f2d1f0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -177,6 +177,8 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
index 2006b09..1ec20ef 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
@@ -216,6 +216,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
  rtl92se_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index 7bf9f25..aab8666 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -184,6 +184,8 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+ 

Re: [PATCH] rtlwifi: Remove unused dummy function

2017-07-04 Thread Souptick Joarder
Any Comment for this patch ?

On Wed, Jun 28, 2017 at 6:02 PM, Souptick Joarder  wrote:
> Removing unused dummy function
>
> Signed-off-by: Souptick Joarder 
> ---
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c  |  2 +-
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 12 
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h |  3 ---
>  3 files changed, 1 insertion(+), 16 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c 
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
> index 96c923b..62d9214 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
> @@ -173,7 +173,7 @@ static bool rtl92cu_get_btc_status(void)
> .rx_urb_num = RTL92C_NUM_RX_URBS,
> .rx_max_size = RTL92C_SIZE_MAX_RX_BUFFER,
> .usb_rx_hdl = rtl8192cu_rx_hdl,
> -   .usb_rx_segregate_hdl = NULL, /* rtl8192c_rx_segregate_hdl; */
> +   .usb_rx_segregate_hdl = NULL,
> /* tx */
> .usb_tx_cleanup = rtl8192c_tx_cleanup,
> .usb_tx_post_hdl = rtl8192c_tx_post_hdl,
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c 
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index 41422e4..25a081c 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -436,13 +436,6 @@ void  rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct 
> sk_buff * skb)
> _rtl_rx_process(hw, skb);
>  }
>
> -void rtl8192c_rx_segregate_hdl(
> -   struct ieee80211_hw *hw,
> -   struct sk_buff *skb,
> -   struct sk_buff_head *skb_list)
> -{
> -}
> -
>  /*--
>   *
>   * Tx handler
> @@ -675,8 +668,3 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
> RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content",
>   pdesc, RTL_TX_DESC_SIZE);
>  }
> -
> -bool rtl92cu_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
> -{
> -   return true;
> -}
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h 
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
> index 487eec8..15a66c5 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
> @@ -385,8 +385,6 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
>struct ieee80211_rx_status *rx_status,
>u8 *p_desc, struct sk_buff *skb);
>  void  rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct sk_buff * skb);
> -void rtl8192c_rx_segregate_hdl(struct ieee80211_hw *, struct sk_buff *,
> -  struct sk_buff_head *);
>  void rtl8192c_tx_cleanup(struct ieee80211_hw *hw, struct sk_buff  *skb);
>  int rtl8192c_tx_post_hdl(struct ieee80211_hw *hw, struct urb *urb,
>  struct sk_buff *skb);
> @@ -404,6 +402,5 @@ void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 
> * pDesc,
>  void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
>  u8 *pdesc, bool b_firstseg,
>  bool b_lastseg, struct sk_buff *skb);
> -bool rtl92cu_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
>
>  #endif
> --
> 1.9.1
>


Re: [PATCH] rtlwifi: remove dummy function call

2017-07-04 Thread Souptick Joarder
Hi Larry,

On Wed, Jun 28, 2017 at 1:27 PM, Souptick Joarder  wrote:
> _rtl92cu_init_usb_aggregation() can be removed as it is dummy one
>
> Signed-off-by: Souptick Joarder 
> ---
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 5 -
>  1 file changed, 5 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c 
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
> index 107c34e..ef8bd71 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
> @@ -777,10 +777,6 @@ static void _rtl92cu_init_queue_priority(struct 
> ieee80211_hw *hw,
>queue_sel);
>  }
>
> -static void _rtl92cu_init_usb_aggregation(struct ieee80211_hw *hw)
> -{
> -}
> -
>  static void _rtl92cu_init_wmac_setting(struct ieee80211_hw *hw)
>  {
> u16 value16;
> @@ -863,7 +859,6 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
> rtl92c_init_edca(hw);
> rtl92c_init_rate_fallback(hw);
> rtl92c_init_retry_function(hw);
> -   _rtl92cu_init_usb_aggregation(hw);
> rtlpriv->cfg->ops->set_bw_mode(hw, NL80211_CHAN_HT20);
> rtl92c_set_min_space(hw, IS_92C_SERIAL(rtlhal->version));
> _rtl92cu_init_beacon_parameters(hw);
> --
> 1.9.1

Any comment for this patch ?
>

-Souptick


[PATCH] rtlwifi: Handle memory free

2017-07-04 Thread Souptick Joarder
This patch will fix memory leak when firmware load fails

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 4 
 drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 2 ++
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 6 ++
 9 files changed, 24 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 7661cfa..37489b4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -175,6 +175,8 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_info("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index bcbb0c6..38f85bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -176,6 +176,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
index 62d9214..dfbbd35 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
@@ -85,6 +85,10 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
err = request_firmware_nowait(THIS_MODULE, 1,
  fw_name, rtlpriv->io.dev,
  GFP_KERNEL, hw, rtl_fw_cb);
+   if (err) {
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
+   }
return err;
 }
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
index 16132c6..e38d6f7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
@@ -183,6 +183,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index 48820bc..6f2d1f0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -177,6 +177,8 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
index 2006b09..1ec20ef 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
@@ -216,6 +216,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
  rtl92se_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+   rtlpriv->rtlhal.pfirmware = NULL;
return 1;
}
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index 7bf9f25..aab8666 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -184,6 +184,8 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
  rtl_fw_cb);
if (err) {
pr_err("Failed to request firmware!\n");
+   vfree(rtlpriv->rtlhal.pfirmware);
+ 

[PATCH v3] rtlwifi: Replace hardcode value with macro

2017-06-30 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 6 +++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index bdc3791..f45d093 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,9 +422,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   /* defined these hard code values */
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index 02ff0c5..d03e198 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL 10
+#define MAX_RATE_TRIES  4

 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
--
1.9.1



Re: [PATCH v2] rtlwifi: Replace hardcode value with macro

2017-06-28 Thread Souptick Joarder
Hi Kalle,

On Wed, Jun 28, 2017 at 9:47 PM, Kalle Valo  wrote:
> Souptick Joarder  writes:
>
>> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
>> and hw->max_rate_tries are replaced by macro.
>>
>> Signed-off-by: Souptick Joarder 
>> ---
>> Changes in v2:
>>- Signed-off was missing in previous one.

As Signed-off was missing in first patch, so I send v2 with change
logs mentioned the same.
Just for clarification, shall I replace the comment mentioned in
change log with "no change"?

>>
>>  drivers/net/wireless/realtek/rtlwifi/base.c | 6 +++---
>>  drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
>>  2 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
>> b/drivers/net/wireless/realtek/rtlwifi/base.c
>> index bdc3791..f45d093 100644
>> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
>> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
>> @@ -422,9 +422,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
>>   hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
>>
>>   /* TODO: Correct this value for our hw */
>> - /* TODO: define these hard code value */
>> - hw->max_listen_interval = 10;
>> - hw->max_rate_tries = 4;
>> + /* defined these hard code values */
>> + hw->max_listen_interval = MAX_LISTEN_INTERVAL;
>> + hw->max_rate_tries = MAX_RATE_TRIES;
>
> Like Larry said, the comment does not make any sense. Please remove it
> and send v3.
>
> --
> Kalle Valo

Souptick


[PATCH] rtlwifi: Remove unused dummy function

2017-06-28 Thread Souptick Joarder
Removing unused dummy function

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c  |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 12 
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h |  3 ---
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
index 96c923b..62d9214 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c
@@ -173,7 +173,7 @@ static bool rtl92cu_get_btc_status(void)
.rx_urb_num = RTL92C_NUM_RX_URBS,
.rx_max_size = RTL92C_SIZE_MAX_RX_BUFFER,
.usb_rx_hdl = rtl8192cu_rx_hdl,
-   .usb_rx_segregate_hdl = NULL, /* rtl8192c_rx_segregate_hdl; */
+   .usb_rx_segregate_hdl = NULL,
/* tx */
.usb_tx_cleanup = rtl8192c_tx_cleanup,
.usb_tx_post_hdl = rtl8192c_tx_post_hdl,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
index 41422e4..25a081c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
@@ -436,13 +436,6 @@ void  rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct 
sk_buff * skb)
_rtl_rx_process(hw, skb);
 }

-void rtl8192c_rx_segregate_hdl(
-   struct ieee80211_hw *hw,
-   struct sk_buff *skb,
-   struct sk_buff_head *skb_list)
-{
-}
-
 /*--
  *
  * Tx handler
@@ -675,8 +668,3 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content",
  pdesc, RTL_TX_DESC_SIZE);
 }
-
-bool rtl92cu_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
-{
-   return true;
-}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
index 487eec8..15a66c5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.h
@@ -385,8 +385,6 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
   struct ieee80211_rx_status *rx_status,
   u8 *p_desc, struct sk_buff *skb);
 void  rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct sk_buff * skb);
-void rtl8192c_rx_segregate_hdl(struct ieee80211_hw *, struct sk_buff *,
-  struct sk_buff_head *);
 void rtl8192c_tx_cleanup(struct ieee80211_hw *hw, struct sk_buff  *skb);
 int rtl8192c_tx_post_hdl(struct ieee80211_hw *hw, struct urb *urb,
 struct sk_buff *skb);
@@ -404,6 +402,5 @@ void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * 
pDesc,
 void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
 u8 *pdesc, bool b_firstseg,
 bool b_lastseg, struct sk_buff *skb);
-bool rtl92cu_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);

 #endif
--
1.9.1



[PATCH] rtlwifi: remove dummy function call

2017-06-28 Thread Souptick Joarder
_rtl92cu_init_usb_aggregation() can be removed as it is dummy one

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index 107c34e..ef8bd71 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -777,10 +777,6 @@ static void _rtl92cu_init_queue_priority(struct 
ieee80211_hw *hw,
   queue_sel);
 }

-static void _rtl92cu_init_usb_aggregation(struct ieee80211_hw *hw)
-{
-}
-
 static void _rtl92cu_init_wmac_setting(struct ieee80211_hw *hw)
 {
u16 value16;
@@ -863,7 +859,6 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
rtl92c_init_edca(hw);
rtl92c_init_rate_fallback(hw);
rtl92c_init_retry_function(hw);
-   _rtl92cu_init_usb_aggregation(hw);
rtlpriv->cfg->ops->set_bw_mode(hw, NL80211_CHAN_HT20);
rtl92c_set_min_space(hw, IS_92C_SERIAL(rtlhal->version));
_rtl92cu_init_beacon_parameters(hw);
--
1.9.1



Re: [PATCH v2] rtlwifi: Replace hardcode value with macro

2017-06-27 Thread Souptick Joarder
Hi Larry,

On Thu, Jun 22, 2017 at 7:05 PM, Larry Finger  wrote:
> On 06/22/2017 07:00 AM, Souptick Joarder wrote:
>>
>> In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
>> and hw->max_rate_tries are replaced by macro.
>>
>> Signed-off-by: Souptick Joarder 
>> ---
>> Changes in v2:
>> - Signed-off was missing in previous one.
>
>
> This patch includes a comment that is not needed, but it is OK.
>
> Acked-by: Larry Finger 
>
> Larry

Any further review is required for this patch or it will be merged to
maintainer tree ?

>
>
>>
>>   drivers/net/wireless/realtek/rtlwifi/base.c | 6 +++---
>>   drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
>>   2 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c
>> b/drivers/net/wireless/realtek/rtlwifi/base.c
>> index bdc3791..f45d093 100644
>> --- a/drivers/net/wireless/realtek/rtlwifi/base.c
>> +++ b/drivers/net/wireless/realtek/rtlwifi/base.c
>> @@ -422,9 +422,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw
>> *hw)
>> hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
>>
>> /* TODO: Correct this value for our hw */
>> -   /* TODO: define these hard code value */
>> -   hw->max_listen_interval = 10;
>> -   hw->max_rate_tries = 4;
>> +   /* defined these hard code values */
>> +   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
>> +   hw->max_rate_tries = MAX_RATE_TRIES;
>> /* hw->max_rates = 1; */
>> hw->sta_data_size = sizeof(struct rtl_sta_info);
>>
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h
>> b/drivers/net/wireless/realtek/rtlwifi/base.h
>> index 02ff0c5..d03e198 100644
>> --- a/drivers/net/wireless/realtek/rtlwifi/base.h
>> +++ b/drivers/net/wireless/realtek/rtlwifi/base.h
>> @@ -65,6 +65,8 @@ enum ap_peer {
>>   #define FRAME_OFFSET_ADDRESS3 16
>>   #define FRAME_OFFSET_SEQUENCE 22
>>   #define FRAME_OFFSET_ADDRESS4 24
>> +#define MAX_LISTEN_INTERVAL 10
>> +#define MAX_RATE_TRIES  4
>>
>>   #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)   \
>> WRITEEF2BYTE(_hdr, _val)
>> --
>> 1.9.1
>>
>>
>

-Souptick


Re: [PATCH v2] rtlwifi: Remove unnecessary conditions

2017-06-27 Thread Souptick Joarder
Hi Larry,


On Tue, Jun 27, 2017 at 7:21 PM, Larry Finger  wrote:
> On 06/26/2017 09:41 PM, Souptick Joarder wrote:
>>
>> Any further comment on this patch ?
>>
>> On 22-Jun-2017 6:53 PM, "Souptick Joarder" > <mailto:jrdr.li...@gmail.com>> wrote:
>>  >
>>  > As wmm_enable is initialized to false, hence the else condition never
>>  > execute and boundary is assigned with TX_PAGE_BOUNDARY. So the if-else
>>  > condition can be removed and boundary will be assigned with
>>  > TX_PAGE_BOUNDARY.
>>  >
>>  > Signed-off-by: Souptick Joarder > <mailto:jrdr.li...@gmail.com>>
>>
>>  > ---
>>  > Changes in v2:
>>  >   - Correcting the indent and moving up the change where
>>  > boundary is defined.
>>  >
>>  >  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 9 +
>>  >  1 file changed, 1 insertion(+), 8 deletions(-)
>>  >
>>  > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>>  > index f95a645..107c34e 100644
>>  > --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>>  > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>>  > @@ -835,7 +835,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw
>> *hw)
>>  > struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
>>  > struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
>>  > int err = 0;
>>  > -   u32 boundary = 0;
>>  > +   u32 boundary = TX_PAGE_BOUNDARY;
>>  > u8 wmm_enable = false; /* TODO */
>>  > u8 out_ep_nums = rtlusb->out_ep_nums;
>>  > u8 queue_sel = rtlusb->out_queue_sel;
>>  > @@ -845,13 +845,6 @@ static int _rtl92cu_init_mac(struct ieee80211_hw
>> *hw)
>>  > pr_err("Failed to init power on!\n");
>>  > return err;
>>  > }
>>  > -   if (!wmm_enable) {
>>  > -   boundary = TX_PAGE_BOUNDARY;
>>  > -   } else { /* for WMM */
>>  > -   boundary = (IS_NORMAL_CHIP(rtlhal->version))
>>  > -   ? WMM_CHIP_B_TX_PAGE_BOUNDARY
>>  > -   : WMM_CHIP_A_TX_PAGE_BOUNDARY;
>>  > -   }
>>  > if (false == rtl92c_init_llt_table(hw, boundary)) {
>>  > pr_err("Failed to init LLT Table!\n");
>>  > return -EINVAL;
>
>
> This patch troubles me. I have no idea why the original author placed a TODO
> on the assignent of wmm_enable. You, however, have left the TODO in place
> but removed the actual place where it would make a difference. As a result,
> it would become impossible to reconstruct that author's intentions. For that
> reason
>
> NACK.
>
> Note that these changes make no difference in the object code and the
> optimizer will remove that code anyway.

Thanks for your feedback.
>
> Larry
>

Souptick


[PATCH v2] rtlwifi: Remove unnecessary conditions

2017-06-22 Thread Souptick Joarder
As wmm_enable is initialized to false, hence the else condition never
execute and boundary is assigned with TX_PAGE_BOUNDARY. So the if-else
condition can be removed and boundary will be assigned with
TX_PAGE_BOUNDARY.

Signed-off-by: Souptick Joarder 
---
Changes in v2:
  - Correcting the indent and moving up the change where
boundary is defined.

 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index f95a645..107c34e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -835,7 +835,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
int err = 0;
-   u32 boundary = 0;
+   u32 boundary = TX_PAGE_BOUNDARY;
u8 wmm_enable = false; /* TODO */
u8 out_ep_nums = rtlusb->out_ep_nums;
u8 queue_sel = rtlusb->out_queue_sel;
@@ -845,13 +845,6 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
pr_err("Failed to init power on!\n");
return err;
}
-   if (!wmm_enable) {
-   boundary = TX_PAGE_BOUNDARY;
-   } else { /* for WMM */
-   boundary = (IS_NORMAL_CHIP(rtlhal->version))
-   ? WMM_CHIP_B_TX_PAGE_BOUNDARY
-   : WMM_CHIP_A_TX_PAGE_BOUNDARY;
-   }
if (false == rtl92c_init_llt_table(hw, boundary)) {
pr_err("Failed to init LLT Table!\n");
return -EINVAL;
--
1.9.1



Re: [PATCH] rtlwifi: Remove unnecessary conditions

2017-06-22 Thread Souptick Joarder
Hi Julian,

On Thu, Jun 22, 2017 at 6:03 PM, Julian Calaby  wrote:
> Hi Souptick,
>
> On Thu, Jun 22, 2017 at 9:16 PM, Souptick Joarder  
> wrote:
>> As wmm_enable is initialized to false, hence the else condition never
>> execute and boundary is assigned with TX_PAGE_BOUNDARY. So the if-else
>> condition can be removed and boundary will be assigned with TX_PAGE_BOUNDARY.
>>
>> Signed-off-by: Souptick Joarder 
>> ---
>>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 6 --
>>  1 file changed, 6 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c 
>> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>> index f95a645..e9c5f6a 100644
>> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
>> @@ -845,13 +845,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
>> pr_err("Failed to init power on!\n");
>> return err;
>> }
>> -   if (!wmm_enable) {
>> boundary = TX_PAGE_BOUNDARY;
>
> Firstly this isn't indented properly.
>
> Secondly, can this be moved up to where boundary is defined?

Sure. I will modify it and send in v2.

>
> Thanks,
>
> --
> Julian Calaby
>
> Email: julian.cal...@gmail.com
> Profile: http://www.google.com/profiles/julian.calaby/

-Souptick


[PATCH v2] rtlwifi: Replace hardcode value with macro

2017-06-22 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.

Signed-off-by: Souptick Joarder 
---
Changes in v2:
   - Signed-off was missing in previous one.

 drivers/net/wireless/realtek/rtlwifi/base.c | 6 +++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index bdc3791..f45d093 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,9 +422,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   /* defined these hard code values */
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index 02ff0c5..d03e198 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL 10
+#define MAX_RATE_TRIES  4

 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
--
1.9.1



[PATCH] rtlwifi: Remove unnecessary conditions

2017-06-22 Thread Souptick Joarder
As wmm_enable is initialized to false, hence the else condition never
execute and boundary is assigned with TX_PAGE_BOUNDARY. So the if-else
condition can be removed and boundary will be assigned with TX_PAGE_BOUNDARY.

Signed-off-by: Souptick Joarder 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index f95a645..e9c5f6a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -845,13 +845,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
pr_err("Failed to init power on!\n");
return err;
}
-   if (!wmm_enable) {
boundary = TX_PAGE_BOUNDARY;
-   } else { /* for WMM */
-   boundary = (IS_NORMAL_CHIP(rtlhal->version))
-   ? WMM_CHIP_B_TX_PAGE_BOUNDARY
-   : WMM_CHIP_A_TX_PAGE_BOUNDARY;
-   }
if (false == rtl92c_init_llt_table(hw, boundary)) {
pr_err("Failed to init LLT Table!\n");
return -EINVAL;
--
1.9.1



[PATCH] rtlwifi: Replace hardcode value with macro

2017-06-21 Thread Souptick Joarder
In _rtl_init_mac80211(), hardcoded value for hw->max_listen_interval
and hw->max_rate_tries are replaced by macro.
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 6 +++---
 drivers/net/wireless/realtek/rtlwifi/base.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index bdc3791..f45d093 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -422,9 +422,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;

/* TODO: Correct this value for our hw */
-   /* TODO: define these hard code value */
-   hw->max_listen_interval = 10;
-   hw->max_rate_tries = 4;
+   /* defined these hard code values */
+   hw->max_listen_interval = MAX_LISTEN_INTERVAL;
+   hw->max_rate_tries = MAX_RATE_TRIES;
/* hw->max_rates = 1; */
hw->sta_data_size = sizeof(struct rtl_sta_info);

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h 
b/drivers/net/wireless/realtek/rtlwifi/base.h
index 02ff0c5..d03e198 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -65,6 +65,8 @@ enum ap_peer {
 #define FRAME_OFFSET_ADDRESS3  16
 #define FRAME_OFFSET_SEQUENCE  22
 #define FRAME_OFFSET_ADDRESS4  24
+#define MAX_LISTEN_INTERVAL 10
+#define MAX_RATE_TRIES  4

 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)\
WRITEEF2BYTE(_hdr, _val)
--
1.9.1



[PATCH] staging: rtl8712: Free memory and return failure when kmalloc fails

2016-10-20 Thread Souptick Joarder
This patch is added to free memory and return failure when kmalloc fails

Signed-off-by: Souptick joarder 
---
 drivers/staging/rtl8712/os_intfs.c | 3 ++-
 drivers/staging/rtl8712/rtl871x_cmd.c  | 5 -
 drivers/staging/rtl8712/rtl871x_xmit.c | 5 -
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8712/os_intfs.c 
b/drivers/staging/rtl8712/os_intfs.c
index cbe4de0..aab3141 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -313,7 +313,8 @@ u8 r8712_init_drv_sw(struct _adapter *padapter)
return _FAIL;
if (r8712_init_mlme_priv(padapter) == _FAIL)
return _FAIL;
-   _r8712_init_xmit_priv(&padapter->xmitpriv, padapter);
+   if ((_r8712_init_xmit_priv(&padapter->xmitpriv, padapter)) != _SUCCESS)
+   return _FAIL;
_r8712_init_recv_priv(&padapter->recvpriv, padapter);
memset((unsigned char *)&padapter->securitypriv, 0,
   sizeof(struct security_priv));
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index b7ee5e6..04638f1 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -72,8 +72,11 @@ static sint _init_cmd_priv(struct cmd_priv *pcmdpriv)
((addr_t)(pcmdpriv->cmd_allocated_buf) &
(CMDBUFF_ALIGN_SZ - 1));
pcmdpriv->rsp_allocated_buf = kmalloc(MAX_RSPSZ + 4, GFP_ATOMIC);
-   if (!pcmdpriv->rsp_allocated_buf)
+   if (!pcmdpriv->rsp_allocated_buf) {
+   kfree(pcmdpriv->cmd_allocated_buf);
+   pcmdpriv->cmd_allocated_buf = NULL;
return _FAIL;
+   }
pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf  +  4 -
((addr_t)(pcmdpriv->rsp_allocated_buf) & 3);
pcmdpriv->cmd_issued_cnt = 0;
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c 
b/drivers/staging/rtl8712/rtl871x_xmit.c
index be38364..484d2f2 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.c
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -128,8 +128,11 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
_init_queue(&pxmitpriv->pending_xmitbuf_queue);
pxmitpriv->pallocated_xmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct 
xmit_buf) + 4,
GFP_ATOMIC);
-   if (!pxmitpriv->pallocated_xmitbuf)
+   if (!pxmitpriv->pallocated_xmitbuf) {
+   kfree(pxmitpriv->pallocated_frame_buf);
+   pxmitpriv->pallocated_frame_buf = NULL;
return _FAIL;
+   }
pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 -
  ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3);
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
-- 
1.9.1



Re: [PATCH] wl18xx: Handle kfree() in better way when kzalloc fails

2016-10-07 Thread souptick joarder
On Fri, Oct 7, 2016 at 12:36 PM, Johannes Berg
 wrote:
>
> On Fri, 2016-10-07 at 12:19 +0530, Souptick Joarder wrote:
> > This patch is added to handle kfree and return error in a better way
>
> What's "better" about this?
>
> kfree(NULL) is perfectly valid, adding another label makes the code
> harder to read,

I agree with you.

when kzalloc(sizeof(*cmd), GFP_KERNEL) fails, try to avoid extra
kfree(cmd_channel) function call,
cause anyway it will call kfree with NULL.

I thought from that point of view.

>
> > - struct wl18xx_cmd_scan_params *cmd;
> > + struct wl18xx_cmd_scan_params *cmd = NULL;
>
> that new initialization is actually *completely* pointless since it's
> overwritten immediately here:
>
> >   struct wlcore_scan_channels *cmd_channels = NULL;
> >   int ret;
> >
> >   cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
> >   if (!cmd) {
> > - ret = -ENOMEM;
> > - goto out;
> > + return -ENOMEM;
> >   }
> >
> ...
>
> what gives?
>

> johannes

Ok, I will drop this patch.

-Souptick


[PATCH] wl18xx: Handle kfree() in better way when kzalloc fails

2016-10-06 Thread Souptick Joarder
This patch is added to handle kfree and return error in a better way
if kzalloc fails in wl18xx_scan_send() and wl18xx_scan_sched_scan_config().

Signed-off-by: Souptick joarder 
---
 drivers/net/wireless/ti/wl18xx/scan.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ti/wl18xx/scan.c 
b/drivers/net/wireless/ti/wl18xx/scan.c
index 4e522154..aed22e1 100644
--- a/drivers/net/wireless/ti/wl18xx/scan.c
+++ b/drivers/net/wireless/ti/wl18xx/scan.c
@@ -41,14 +41,13 @@ static void wl18xx_adjust_channels(struct 
wl18xx_cmd_scan_params *cmd,
 static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
struct cfg80211_scan_request *req)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
int ret;
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
/* scan on the dev role if the regular one is not started */
@@ -59,7 +58,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_SEARCH;
@@ -84,7 +83,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
wlcore_set_scan_chan_params(wl, cmd_channels, req->channels,
@@ -153,6 +152,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
@@ -171,7 +171,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
  struct cfg80211_sched_scan_request *req,
  struct ieee80211_scan_ies *ies)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
int ret;
@@ -185,15 +185,14 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
cmd->role_id = wlvif->role_id;
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_PERIODIC;
@@ -218,7 +217,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
/* configure channels */
@@ -296,6 +295,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
-- 
1.9.1



Re: [PATCH] [wl18xx] Fix memory leakage if kzalloc fails

2016-10-06 Thread Souptick Joarder
Hi Julian,


On Thu, Oct 6, 2016 at 3:05 PM, Julian Calaby  wrote:
> Hi,
>
> On Wed, Oct 5, 2016 at 10:50 PM, Souptick Joarder  
> wrote:
>> This patch is added to properly handle memory leak if kzalloc fails
>> in wl18xx_scan_send() and wl18xx_scan_sched_scan_config()
>
> What memory leak?

My Apologies here. I was addressing here about freeing the invalid memories.
But I put wrong description. I will resend this patch with proper
descriptions and addressing your comments.
>
>> Signed-off-by: Souptick Joarder 
>> Signed-off-by: Rameshwar Sahu 
>
> Why two signed-off-bys?

We both were involved in addressing this.
>
>> ---
>>  drivers/net/wireless/ti/wl18xx/scan.c | 20 ++--
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ti/wl18xx/scan.c 
>> b/drivers/net/wireless/ti/wl18xx/scan.c
>> index 4e522154..aed22e1 100644
>> --- a/drivers/net/wireless/ti/wl18xx/scan.c
>> +++ b/drivers/net/wireless/ti/wl18xx/scan.c
>> @@ -41,14 +41,13 @@ static void wl18xx_adjust_channels(struct 
>> wl18xx_cmd_scan_params *cmd,
>>  static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
>> struct cfg80211_scan_request *req)
>>  {
>> -   struct wl18xx_cmd_scan_params *cmd;
>> +   struct wl18xx_cmd_scan_params *cmd = NULL;
>> struct wlcore_scan_channels *cmd_channels = NULL;
>> int ret;
>>
>> cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
>> if (!cmd) {
>> -   ret = -ENOMEM;
>> -   goto out;
>> +   return -ENOMEM;
>> }
>>
>> /* scan on the dev role if the regular one is not started */
>> @@ -59,7 +58,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
>> wl12xx_vif *wlvif,
>>
>> if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
>> ret = -EINVAL;
>> -   goto out;
>> +   goto err_cmd_free;
>> }
>>
>> cmd->scan_type = SCAN_TYPE_SEARCH;
>> @@ -84,7 +83,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
>> wl12xx_vif *wlvif,
>> cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
>> if (!cmd_channels) {
>> ret = -ENOMEM;
>> -   goto out;
>> +   goto err_cmd_free;
>> }
>>
>> wlcore_set_scan_chan_params(wl, cmd_channels, req->channels,
>> @@ -153,6 +152,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
>> wl12xx_vif *wlvif,
>>
>>  out:
>> kfree(cmd_channels);
>> +err_cmd_free:
>
> kfree(NULL) is valid,

I agree with you. As *cmd not initialized with NULL, so it can hold a
garbage address.
In case of memory allocation failure, kernel may enter in abnormal
behavior while freeing this memory.

 so therefore the out: and err_cmd_free: labels
> are equivalent from a memory freeing perspective, so where exactly are
> we leaking memory in this function?

I want to avoid kfree(cmd_channels) calls when we have not allocated the memory.

>
>> kfree(cmd);
>> return ret;
>>  }
>> @@ -171,7 +171,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
>>   struct cfg80211_sched_scan_request *req,
>>   struct ieee80211_scan_ies *ies)
>>  {
>> -   struct wl18xx_cmd_scan_params *cmd;
>> +   struct wl18xx_cmd_scan_params *cmd = NULL;
>> struct wlcore_scan_channels *cmd_channels = NULL;
>> struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
>> int ret;
>> @@ -185,15 +185,14 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
>>
>> cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
>> if (!cmd) {
>> -   ret = -ENOMEM;
>> -   goto out;
>> +   return -ENOMEM;
>> }
>>
>> cmd->role_id = wlvif->role_id;
>>
>> if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
>> ret = -EINVAL;
>> -   goto out;
>> +   goto err_cmd_free;
>> }
>>
>> cmd->scan_type = SCAN_TYPE_PERIODIC;
>> @@ -218,7 +217,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
>> cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
>> if (!cmd_channels) {
>> ret = -ENOMEM;
>> -   goto out;
>> +   goto err_cmd_free;
>> }
>>
>> /* configure channels */
>> @@ -296,6 +295,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
>>
>>  out:
>> kfree(cmd_channels);
>> +err_cmd_free:
>
> Same question here.

Please refer above comment for the same.
>
>> kfree(cmd);
>> return ret;
>>  }
>> --
>> 1.9.1
>>
>
>
>
> --
> Julian Calaby
>
> Email: julian.cal...@gmail.com
> Profile: http://www.google.com/profiles/julian.calaby/


[PATCH] [wl18xx] Fix memory leakage if kzalloc fails

2016-10-05 Thread Souptick Joarder
This patch is added to properly handle memory leak if kzalloc fails
in wl18xx_scan_send() and wl18xx_scan_sched_scan_config()

Signed-off-by: Souptick Joarder 
Signed-off-by: Rameshwar Sahu 
---
 drivers/net/wireless/ti/wl18xx/scan.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ti/wl18xx/scan.c 
b/drivers/net/wireless/ti/wl18xx/scan.c
index 4e522154..aed22e1 100644
--- a/drivers/net/wireless/ti/wl18xx/scan.c
+++ b/drivers/net/wireless/ti/wl18xx/scan.c
@@ -41,14 +41,13 @@ static void wl18xx_adjust_channels(struct 
wl18xx_cmd_scan_params *cmd,
 static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
struct cfg80211_scan_request *req)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
int ret;
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
/* scan on the dev role if the regular one is not started */
@@ -59,7 +58,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_SEARCH;
@@ -84,7 +83,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
wlcore_set_scan_chan_params(wl, cmd_channels, req->channels,
@@ -153,6 +152,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
@@ -171,7 +171,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
  struct cfg80211_sched_scan_request *req,
  struct ieee80211_scan_ies *ies)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
int ret;
@@ -185,15 +185,14 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
cmd->role_id = wlvif->role_id;
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_PERIODIC;
@@ -218,7 +217,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
/* configure channels */
@@ -296,6 +295,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
-- 
1.9.1



Test mail please ignore

2016-10-05 Thread Souptick Joarder


test mail please ignore

2016-10-05 Thread Souptick Joarder




[PATCH] [wl18xx] Fix memory leakage if kzalloc fails

2016-10-05 Thread Souptick Joarder
This patch is added to properly handle memory leak if kzalloc fails
in wl18xx_scan_send() and wl18xx_scan_sched_scan_config()

Signed-off-by: Souptick Joarder 
Signed-off-by: Rameshwar Sahu 
---
 drivers/net/wireless/ti/wl18xx/scan.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ti/wl18xx/scan.c 
b/drivers/net/wireless/ti/wl18xx/scan.c
index 4e522154..aed22e1 100644
--- a/drivers/net/wireless/ti/wl18xx/scan.c
+++ b/drivers/net/wireless/ti/wl18xx/scan.c
@@ -41,14 +41,13 @@ static void wl18xx_adjust_channels(struct 
wl18xx_cmd_scan_params *cmd,
 static int wl18xx_scan_send(struct wl1271 *wl, struct wl12xx_vif *wlvif,
struct cfg80211_scan_request *req)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
int ret;
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
/* scan on the dev role if the regular one is not started */
@@ -59,7 +58,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_SEARCH;
@@ -84,7 +83,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
wlcore_set_scan_chan_params(wl, cmd_channels, req->channels,
@@ -153,6 +152,7 @@ static int wl18xx_scan_send(struct wl1271 *wl, struct 
wl12xx_vif *wlvif,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
@@ -171,7 +171,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
  struct cfg80211_sched_scan_request *req,
  struct ieee80211_scan_ies *ies)
 {
-   struct wl18xx_cmd_scan_params *cmd;
+   struct wl18xx_cmd_scan_params *cmd = NULL;
struct wlcore_scan_channels *cmd_channels = NULL;
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
int ret;
@@ -185,15 +185,14 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
cmd->role_id = wlvif->role_id;
 
if (WARN_ON(cmd->role_id == WL12XX_INVALID_ROLE_ID)) {
ret = -EINVAL;
-   goto out;
+   goto err_cmd_free;
}
 
cmd->scan_type = SCAN_TYPE_PERIODIC;
@@ -218,7 +217,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
cmd_channels = kzalloc(sizeof(*cmd_channels), GFP_KERNEL);
if (!cmd_channels) {
ret = -ENOMEM;
-   goto out;
+   goto err_cmd_free;
}
 
/* configure channels */
@@ -296,6 +295,7 @@ int wl18xx_scan_sched_scan_config(struct wl1271 *wl,
 
 out:
kfree(cmd_channels);
+err_cmd_free:
kfree(cmd);
return ret;
 }
-- 
1.9.1



Re: [PATCH] rt2x00: unterminated strlen of user data

2016-02-17 Thread Souptick Joarder
On Thu, Feb 18, 2016 at 5:49 AM, Julian Calaby  wrote:
> Hi Souptick,
>
> On Thu, Feb 18, 2016 at 12:49 AM, Souptick Joarder  
> wrote:
>> Hi Julian,
>>
>> On Wed, Feb 17, 2016 at 5:38 AM, Julian Calaby  
>> wrote:
>>> Hi Souptick,
>>>
>>> On Tue, Feb 16, 2016 at 5:36 PM, Souptick Joarder  
>>> wrote:
>>>> On Tue, Feb 16, 2016 at 12:34 AM, Alan  wrote:
>>>>> The buffer needs to be zero terminated in case the user data is not.
>>>>> Otherwise we run off the end of the buffer.
>>>>>
>>>>> Signed-off-by: Alan Cox 
>>>>> ---
>>>>>  drivers/net/wireless/ralink/rt2x00/rt2x00debug.c |5 +++--
>>>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c 
>>>>> b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>>>> index 25ee3cb..72ae530 100644
>>>>> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>>>> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>>>> @@ -478,7 +478,7 @@ static ssize_t rt2x00debug_write_##__name(struct file 
>>>>> *file,\
>>>>>  {  \
>>>>> struct rt2x00debug_intf *intf = file->private_data; \
>>>>> const struct rt2x00debug *debug = intf->debug;  \
>>>>> -   char line[16];  \
>>>>> +   char line[17];  \
>>>>> size_t size;\
>>>>> unsigned int index = intf->offset_##__name; \
>>>>> __type value;   \
>>>>> @@ -494,7 +494,8 @@ static ssize_t rt2x00debug_write_##__name(struct file 
>>>>> *file,\
>>>>> \
>>>>> if (copy_from_user(line, buf, length))  \
>>>>> return -EFAULT; \
>>>>> -   \
>>>>> +   line[16] = 0;
>>>>
>>>> line[length] = '\0';
>>>> correct me if I am wrong.  \
>>>
>>> I believe that in this case the data in buf will already be null
>>> terminated, so ensuring that line is null terminated is only needed if
>>> there are exactly 16 bytes in buf. IMHO
>>>
>>> line[16] = 0;
>>
>> I think, if there are 16 bytes in buf, we end up loosing 1 byte data.
>> If there are 15 bytes in buf, buf is already be null terminated.
>> So is this really required?
>> Correct me if I am wrong.
>
> Counting in C starts at 0.
>
> We started out with line being a 16 character string, so it initially
> looked like this:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <- index
> _ _ _ _ _ _ _ _ _ _ __ __ __ __ __ __ <- data, i.e. line[index]
>
> If we are given a 4 byte null terminated string, we end up with:
>
> 0 1 2 3  4 5 6 7 8 9 10 11 12 13 14 15
> a b c d \0 _ _ _ _ _ __ __ __ __ __ __
>
> If we are given a 15 byte null terminated string, we end up with:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> a b c d e f g h i j  k  l  m  n  o \0
>
> If we are given a 16 byte null terminated string, we end up with:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> a b c d e f g h i j  k  l  m  n  o  p
>
> Note that it is not null terminated. The call to strlen() will now run
> off into memory that doesn't belong to line and potentially cause a
> crash. This is a bug.
>
> Alan fixed this by adding another character to the string, so it's now
> 17 characters long and line[16] will always be set to 0 after
> copy_from_user() is called. So now line initially looks like:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
> _ _ _ _ _ _ _ _ _ _ __ __ __ __ __ __ __
>
> If we are given a 4 byte null terminated string, we end up with:
>
> 0 1 2 3  4 5 6 7 8 9 10 11 12 13 14 15 16
> a b c d \0 _ _ _ _ _ __ __ __ __ __ __ \0
>
> If we are given a 15 byte null terminated string, we end up with:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
> a b c d e f g h i j  k  l  m  n  o \0 \0
>
> If we are given a 16 byte null terminated string, we end up with:
>
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
>

Re: [PATCH] rt2x00: unterminated strlen of user data

2016-02-17 Thread Souptick Joarder
Hi Julian,

On Wed, Feb 17, 2016 at 5:38 AM, Julian Calaby  wrote:
> Hi Souptick,
>
> On Tue, Feb 16, 2016 at 5:36 PM, Souptick Joarder  
> wrote:
>> On Tue, Feb 16, 2016 at 12:34 AM, Alan  wrote:
>>> The buffer needs to be zero terminated in case the user data is not.
>>> Otherwise we run off the end of the buffer.
>>>
>>> Signed-off-by: Alan Cox 
>>> ---
>>>  drivers/net/wireless/ralink/rt2x00/rt2x00debug.c |5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c 
>>> b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>> index 25ee3cb..72ae530 100644
>>> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
>>> @@ -478,7 +478,7 @@ static ssize_t rt2x00debug_write_##__name(struct file 
>>> *file,\
>>>  {  \
>>> struct rt2x00debug_intf *intf = file->private_data; \
>>> const struct rt2x00debug *debug = intf->debug;  \
>>> -   char line[16];  \
>>> +   char line[17];  \
>>> size_t size;\
>>> unsigned int index = intf->offset_##__name; \
>>> __type value;   \
>>> @@ -494,7 +494,8 @@ static ssize_t rt2x00debug_write_##__name(struct file 
>>> *file,\
>>> \
>>> if (copy_from_user(line, buf, length))  \
>>> return -EFAULT; \
>>> -   \
>>> +   line[16] = 0;
>>
>> line[length] = '\0';
>> correct me if I am wrong.  \
>
> I believe that in this case the data in buf will already be null
> terminated, so ensuring that line is null terminated is only needed if
> there are exactly 16 bytes in buf. IMHO
>
> line[16] = 0;

I think, if there are 16 bytes in buf, we end up loosing 1 byte data.
If there are 15 bytes in buf, buf is already be null terminated.
So is this really required?
Correct me if I am wrong.
>
> is dealing with this bug much more explicitly than
>
> line[length] = 0;
>
> however either will work. (BTW '\0' is identical to 0.)
>
> Thanks,
>
> --
> Julian Calaby
>
> Email: julian.cal...@gmail.com
> Profile: http://www.google.com/profiles/julian.calaby/

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


Re: [PATCH] rt2x00: unterminated strlen of user data

2016-02-15 Thread Souptick Joarder
On Tue, Feb 16, 2016 at 12:34 AM, Alan  wrote:
> The buffer needs to be zero terminated in case the user data is not.
> Otherwise we run off the end of the buffer.
>
> Signed-off-by: Alan Cox 
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00debug.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c 
> b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
> index 25ee3cb..72ae530 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
> @@ -478,7 +478,7 @@ static ssize_t rt2x00debug_write_##__name(struct file 
> *file,\
>  {  \
> struct rt2x00debug_intf *intf = file->private_data; \
> const struct rt2x00debug *debug = intf->debug;  \
> -   char line[16];  \
> +   char line[17];  \
> size_t size;\
> unsigned int index = intf->offset_##__name; \
> __type value;   \
> @@ -494,7 +494,8 @@ static ssize_t rt2x00debug_write_##__name(struct file 
> *file,\
> \
> if (copy_from_user(line, buf, length))  \
> return -EFAULT; \
> -   \
> +   line[16] = 0;

line[length] = '\0';
correct me if I am wrong.  \
> +   \
> size = strlen(line);\
> value = simple_strtoul(line, NULL, 0);  \
> \
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH] rtlwifi: Change long delays to sleeps

2016-02-15 Thread Souptick Joarder
On Tue, Feb 16, 2016 at 3:42 AM, Larry Finger  wrote:
> Routine rtl_addr_delay() uses delay statements in code that can
> sleep. To improve system responsiveness, the various delay statements
> are changed.
>
> In addition, routines rtl_rfreg_delay() and rtl_bb_delay() are
> rewritten to use the code in rtl_addr_delay() for most of their
> input values.
>
> Suggested-by: Byeoungwook Kim 
> Signed-off-by: Larry Finger 
> ---
>
> Kalle,
>
> This patch will interfere with a set of 3 patches submitted by Byeoungwook Kim
>  on Feb. 3, 2016 that are currently in the deferred list
> at patchwork.
>
> Larry
>
>  drivers/net/wireless/realtek/rtlwifi/core.c | 44 
> -
>  1 file changed, 12 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
> b/drivers/net/wireless/realtek/rtlwifi/core.c
> index 02eba0e..16ad0d6 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/core.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/core.c
> @@ -54,59 +54,39 @@ EXPORT_SYMBOL(channel5g_80m);
>  void rtl_addr_delay(u32 addr)
>  {
> if (addr == 0xfe)
> -   mdelay(50);
> +   msleep(50);
> else if (addr == 0xfd)
> -   mdelay(5);
> +   msleep(5);
> else if (addr == 0xfc)
> -   mdelay(1);
> +   msleep(1);
> else if (addr == 0xfb)
> -   udelay(50);
> +   usleep_range(50, 100);
> else if (addr == 0xfa)
> -   udelay(5);
> +   usleep_range(5, 10);
> else if (addr == 0xf9)
> -   udelay(1);
> +   usleep_range(1, 2);

 why udelay is replaced by usleep_range?
>  }
>  EXPORT_SYMBOL(rtl_addr_delay);
>
>  void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 
> addr,
>  u32 mask, u32 data)
>  {
> -   if (addr == 0xfe) {
> -   mdelay(50);
> -   } else if (addr == 0xfd) {
> -   mdelay(5);
> -   } else if (addr == 0xfc) {
> -   mdelay(1);
> -   } else if (addr == 0xfb) {
> -   udelay(50);
> -   } else if (addr == 0xfa) {
> -   udelay(5);
> -   } else if (addr == 0xf9) {
> -   udelay(1);
> +   if (addr >= 0xf9 && addr <= 0xfe) {
> +   rtl_addr_delay(addr);
> } else {
> rtl_set_rfreg(hw, rfpath, addr, mask, data);
> -   udelay(1);
> +   usleep_range(1, 2);
> }
>  }
>  EXPORT_SYMBOL(rtl_rfreg_delay);
>
>  void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
>  {
> -   if (addr == 0xfe) {
> -   mdelay(50);
> -   } else if (addr == 0xfd) {
> -   mdelay(5);
> -   } else if (addr == 0xfc) {
> -   mdelay(1);
> -   } else if (addr == 0xfb) {
> -   udelay(50);
> -   } else if (addr == 0xfa) {
> -   udelay(5);
> -   } else if (addr == 0xf9) {
> -   udelay(1);
> +   if (addr >= 0xf9 && addr <= 0xfe) {
> +   rtl_addr_delay(addr);
> } else {
> rtl_set_bbreg(hw, addr, MASKDWORD, data);
> -   udelay(1);
> +   usleep_range(1, 2);
> }
>  }
>  EXPORT_SYMBOL(rtl_bb_delay);
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH 3/3] mwifiex: Added missing spaces around brackets

2016-02-15 Thread Souptick Joarder
Looks fine.

On Thu, Feb 11, 2016 at 12:17 PM, Ujjal Roy  wrote:
> This patch fixes the missing spaces issue in coding style.
>
> Signed-off-by: Ujjal Roy 
> ---
>  drivers/net/wireless/marvell/mwifiex/usb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c 
> b/drivers/net/wireless/marvell/mwifiex/usb.c
> index e43aff9..0510861 100644
> --- a/drivers/net/wireless/marvell/mwifiex/usb.c
> +++ b/drivers/net/wireless/marvell/mwifiex/usb.c
> @@ -244,9 +244,9 @@ setup_for_next:
> if (card->rx_cmd_ep == context->ep) {
> mwifiex_usb_submit_rx_urb(context, size);
> } else {
> -   if (atomic_read(&adapter->rx_pending) <= HIGH_RX_PENDING){
> +   if (atomic_read(&adapter->rx_pending) <= HIGH_RX_PENDING) {
> mwifiex_usb_submit_rx_urb(context, size);
> -   }else{
> +   } else {
> context->skb = NULL;
> }
> }
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init()

2016-01-02 Thread Souptick Joarder
On Sat, Jan 2, 2016 at 2:02 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 1 Jan 2016 21:16:01 +0100
>
> Rename a jump label according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring 
> ---
>  drivers/net/wireless/intel/iwlegacy/common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.c 
> b/drivers/net/wireless/intel/iwlegacy/common.c
> index ae45fd3..660ab2b 100644
> --- a/drivers/net/wireless/intel/iwlegacy/common.c
> +++ b/drivers/net/wireless/intel/iwlegacy/common.c
> @@ -759,7 +759,7 @@ il_eeprom_init(struct il_priv *il)
>  IL_EEPROM_ACCESS_TIMEOUT);
> if (ret < 0) {
> IL_ERR("Time out reading EEPROM[%d]\n", addr);
> -   goto done;
> +   goto release_semaphore;

Current code looks good.
> }
> r = _il_rd(il, CSR_EEPROM_REG);
> e[addr / 2] = cpu_to_le16(r >> 16);
> @@ -769,7 +769,7 @@ il_eeprom_init(struct il_priv *il)
>  il_eeprom_query16(il, EEPROM_VERSION));
>
> ret = 0;
> -done:
> +release_semaphore:
> il->ops->eeprom_release_semaphore(il);
>
> if (ret) {
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH v2 1/2] staging: wilc1000: fix always return 0 error

2015-12-30 Thread Souptick Joarder
HI Glen,

On Thu, Dec 24, 2015 at 11:32 AM, Glen Lee  wrote:
> This patch fixes a bug that return always 0 so it fails every time.
>
> Fixes: c1af9db78950 ("staging: wilc1000: call linux_sdio_init instead of 
> io_init")
> Signed-off-by: Glen Lee 
> ---
> Changes in v2: separate v1 patch into two patches.
> ---
>  drivers/staging/wilc1000/wilc_sdio.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
> b/drivers/staging/wilc1000/wilc_sdio.c
> index e961b50..464d27d 100644
> --- a/drivers/staging/wilc1000/wilc_sdio.c
> +++ b/drivers/staging/wilc1000/wilc_sdio.c
> @@ -614,8 +614,6 @@ static int sdio_init(struct wilc *wilc)
> if (!wilc_sdio_init()) {
> dev_err(&func->dev, "Failed io init bus...\n");
> return 0;
> -   } else {
> -   return 0;
> }

I think it's better to handle the error case properly when
wilc_sdio_init() call fails.

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

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


Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR()

2015-12-30 Thread Souptick Joarder
On Wed, Dec 30, 2015 at 10:35 PM, Bjorn Andersson  wrote:
> On Wed, Dec 30, 2015 at 8:47 AM, Souptick Joarder  
> wrote:
>>
>> HI Bjorn,
>>
>> On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson  wrote:
>> > Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
>> > clients from having to cast away a const qualifier.
>> >
>> > Signed-off-by: Bjorn Andersson 
>> > ---
>> >  include/net/mac80211.h | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/include/net/mac80211.h b/include/net/mac80211.h
>> > index 7c30faff245f..a6f3c9c4b7c2 100644
>> > --- a/include/net/mac80211.h
>> > +++ b/include/net/mac80211.h
>> > @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct 
>> > ieee80211_hw *hw, struct device *dev
>> >   * @hw: the &struct ieee80211_hw to set the MAC address for
>> >   * @addr: the address to set
>> >   */
>> > -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 
>> > *addr)
>> > +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const 
>> > u8 *addr)
>>
>> I guess without const or with const doesn't make much difference here.
>> Correct me if I am wrong.
>
> For most cases it doesn't make any difference, but in my driver I
> acquire the mac address as a const u8 *. Therefor I need to cast away
> the const part when calling this API.
>
> There's an existing example of this in
> drivers/net/wireless/st/cw1200/main.c line 601.

Is the path correct ? I think path is
drivers/net/wireless/cw1200/main.c line 334

> I think it's safe to assume that this API won't ever modify the passed
> addr buffer, so there would be no future issues of marking the
> parameter const either.

I agree with you.

>
>>
>> >  {
>> > memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
>> >  }
>>
>
> Regards,
> Bjorn

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


Re: [PATCH] mac80211: Make addr const in SET_IEEE80211_PERM_ADDR()

2015-12-30 Thread Souptick Joarder
HI Bjorn,

On Thu, Dec 24, 2015 at 2:03 PM, Bjorn Andersson  wrote:
> Make the addr parameter const in SET_IEEE80211_PERM_ADDR() to save
> clients from having to cast away a const qualifier.
>
> Signed-off-by: Bjorn Andersson 
> ---
>  include/net/mac80211.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 7c30faff245f..a6f3c9c4b7c2 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -2167,7 +2167,7 @@ static inline void SET_IEEE80211_DEV(struct 
> ieee80211_hw *hw, struct device *dev
>   * @hw: the &struct ieee80211_hw to set the MAC address for
>   * @addr: the address to set
>   */
> -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
> +static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 
> *addr)

I guess without const or with const doesn't make much difference here.
Correct me if I am wrong.
>  {
> memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
>  }
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH 17/20] staging: wilc1000: fix return type of host_int_get_ipaddress

2015-12-30 Thread Souptick Joarder
Hi Lim,

On Wed, Dec 30, 2015 at 5:45 PM, Chaehyun Lim  wrote:
> This patch changes return type of host_int_get_ipaddress from s32 to
> int. The result variable gets return value from wilc_mq_send that has
> data type of int. It should be changed return type of this function as
> well as data type of result variable.
>
> Signed-off-by: Chaehyun Lim 
> ---
>  drivers/staging/wilc1000/host_interface.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/host_interface.c 
> b/drivers/staging/wilc1000/host_interface.c
> index 90fdbdd..a203647 100644
> --- a/drivers/staging/wilc1000/host_interface.c
> +++ b/drivers/staging/wilc1000/host_interface.c
> @@ -362,7 +362,7 @@ static s32 handle_set_operation_mode(struct wilc_vif *vif,
> return result;
>  }
>
> -static s32 host_int_get_ipaddress(struct wilc_vif *vif,
> +static int host_int_get_ipaddress(struct wilc_vif *vif,
>   struct host_if_drv *hif_drv,
>   u8 *u16ipadd, u8 idx);
>
s32 and int both are same. isn't it ?

> @@ -4664,11 +4664,11 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 
> *ip_addr, u8 idx)
> return result;
>  }
>
> -static s32 host_int_get_ipaddress(struct wilc_vif *vif,
> +static int host_int_get_ipaddress(struct wilc_vif *vif,
>   struct host_if_drv *hif_drv,
>   u8 *u16ipadd, u8 idx)
>  {
> -   s32 result = 0;
> +   int result = 0;
> struct host_if_msg msg;
>
> if (!hif_drv) {
> --
> 2.6.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-29 Thread Souptick Joarder
Brent,

On Tue, Dec 22, 2015 at 2:42 PM, Kalle Valo  wrote:
> Souptick Joarder  writes:
>
>> Hi Brent,
>>
>> On Tue, Dec 22, 2015 at 3:23 AM, Brent Taylor  wrote:
>>> On Mon, Dec 21, 2015 at 1:23 PM, Souptick Joarder  
>>> wrote:
>>>> Hi Brent,
>>>>
>>>> On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
>>>>
>>>>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>>>>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>>>>> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const 
>>>>> char *filename,
>>>>> return ret;
>>>>>
>>>>> *fw_len = fw_entry->size;
>>>>> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>>>>> +   if (&ar->fw == fw)
>>>>> +   *fw = vmalloc(fw_entry->size);
>>>>> +   else
>>>>> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL)
>>>>
>>>>   Why vmalloc and kmalloc both are required? can't use either
>>>> vmalloc or kmalloc?
>>>
>>> My original problem was that kmemdup (which uses kmalloc) could not
>>> allocate enough memory
>>
>> If kmemdump ( which uses kmalloc) could not allocate memory then
>> using kmalloc again can lead to same problem.
>> I guess it will be correct to use
>> *fw = vmalloc(fw_entry->size);
>> Correct me if i am wrong.
>
> That sounds best. But remember take into account DMA requirements, IIRC
> you cannot DMA from vmalloc memory on all platforms.

Is it possible to modify the patch as per feedback from Kalle.

>
> --
> Kalle Valo

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


Re: [PATCH] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-22 Thread Souptick Joarder
Hi Brent,

On Tue, Dec 22, 2015 at 3:23 AM, Brent Taylor  wrote:
> On Mon, Dec 21, 2015 at 1:23 PM, Souptick Joarder  
> wrote:
>> Hi Brent,
>>
>> On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
>>> Since commit 8437754c83351d6213c1a47ff029c1126d6042a7, ar->fw is expected 
>>> to be pointing to memory allocated by vmalloc.  If the api1 method (via 
>>> ath6kl_fetch_fw_api1) is used to allocate memory for ar->fw, then kmemdup 
>>> is used.  This patch checks if the firmware being loaded is the 'fw' image, 
>>> then use vmalloc, otherwise use kmalloc.
>>>
>>> Signed-off-by: Brent Taylor 
>>> ---
>>>  drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
>>> b/drivers/net/wireless/ath/ath6kl/init.c
>>> index 6ae0734..4f2b124d 100644
>>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>>> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const 
>>> char *filename,
>>> return ret;
>>>
>>> *fw_len = fw_entry->size;
>>> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>>> +   if (&ar->fw == fw)
>>> +   *fw = vmalloc(fw_entry->size);
>>> +   else
>>> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL)
>>
>>   Why vmalloc and kmalloc both are required? can't use either
>> vmalloc or kmalloc?
>
> My original problem was that kmemdup (which uses kmalloc) could not
> allocate enough memory

If kmemdump ( which uses kmalloc) could not allocate memory then
using kmalloc again can lead to same problem.
I guess it will be correct to use
*fw = vmalloc(fw_entry->size);
Correct me if i am wrong.

> to hold the firmware that is placed into "ar->fw".  In the function
> ath6kl_core_cleanup (in core.c),
> the "ar->fw" pointer is the only one that uses vfree which was changed in 
> commit
> 8437754c83351d6213c1a47ff029c1126d6042a7.
>
> I was trying to change as little as possible and I wasn't sure if
> there was a reason that any of the
> other firmware items needed to be allocated with kmalloc or if they
> could be changed to use vmalloc.

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


Re: [PATCH] wlcore: consolidate kmalloc + memset 0 into kzalloc

2015-12-21 Thread Souptick Joarder
On Mon, Dec 21, 2015 at 10:17 PM, Nicholas Mc Guire  wrote:
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kzalloc.
>
> Signed-off-by: Nicholas Mc Guire 
> ---
>
> Found by coccinelle script (relaxed version of
> scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
>
> Patch was compile tested with: x86_64_defconfig +
> CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
>
> Patch is against linux-next (localversion-next is -next-20151221)
>
>  drivers/net/wireless/ti/wlcore/main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c 
> b/drivers/net/wireless/ti/wlcore/main.c
> index ec7f6af..dfc49bf 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>
> wl1271_info("Reading FW panic log");
>
> -   block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
> +   block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
> if (!block)
> return;
>
> @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
> goto out;
> }
>
> -   memset(block, 0, wl->fw_mem_block_size);

Current code is reseting the block value to 0 in each iterations and
perform some operations.
But if you are using kzalloc as mentioned above it will memset 0 to
block pointer only once.
So both are not equivalent operations.

> ret = wlcore_read_hwaddr(wl, addr, block,
> wl->fw_mem_block_size, false);
>
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH] ath6kl: Use vmalloc to allocate ar->fw for api1 method

2015-12-21 Thread Souptick Joarder
Hi Brent,

On Tue, Dec 1, 2015 at 11:11 AM, Brent Taylor  wrote:
> Since commit 8437754c83351d6213c1a47ff029c1126d6042a7, ar->fw is expected to 
> be pointing to memory allocated by vmalloc.  If the api1 method (via 
> ath6kl_fetch_fw_api1) is used to allocate memory for ar->fw, then kmemdup is 
> used.  This patch checks if the firmware being loaded is the 'fw' image, then 
> use vmalloc, otherwise use kmalloc.
>
> Signed-off-by: Brent Taylor 
> ---
>  drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
> b/drivers/net/wireless/ath/ath6kl/init.c
> index 6ae0734..4f2b124d 100644
> --- a/drivers/net/wireless/ath/ath6kl/init.c
> +++ b/drivers/net/wireless/ath/ath6kl/init.c
> @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
> *filename,
> return ret;
>
> *fw_len = fw_entry->size;
> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
> +   if (&ar->fw == fw)
> +   *fw = vmalloc(fw_entry->size);
> +   else
> +   *fw = kmalloc(fw_entry->size, GFP_KERNEL);

  Why vmalloc and kmalloc both are required? can't use either
vmalloc or kmalloc?
>
> if (*fw == NULL)
> ret = -ENOMEM;
> +   else
> +   memcpy(*fw, fw_entry->data, fw_entry->size);
>
> release_firmware(fw_entry);
>
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [RFC/RFT 2/2] ath9k: request aligned skb

2015-12-21 Thread Souptick Joarder
On Thu, Dec 17, 2015 at 2:50 PM, Janusz Dziedzic
 wrote:
>
> Set NEEDS_ALIGNED4_SKB hw flag.
> This allow driver to save CPU and remove two memmove
> from tx path.
>
> Signed-off-by: Janusz Dziedzic 
> ---
>  drivers/net/wireless/ath/ath9k/init.c |  1 +
>  drivers/net/wireless/ath/ath9k/xmit.c | 15 ++-
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/init.c 
> b/drivers/net/wireless/ath/ath9k/init.c
> index 6abace6..d578a00 100644
> --- a/drivers/net/wireless/ath/ath9k/init.c
> +++ b/drivers/net/wireless/ath/ath9k/init.c
> @@ -831,6 +831,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, 
> struct ieee80211_hw *hw)
> ieee80211_hw_set(hw, RX_INCLUDES_FCS);
> ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
> ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
> +   ieee80211_hw_set(hw, NEEDS_ALIGNED4_SKBS);
>
> if (ath9k_ps_enable)
> ieee80211_hw_set(hw, SUPPORTS_PS);
> diff --git a/drivers/net/wireless/ath/ath9k/xmit.c 
> b/drivers/net/wireless/ath/ath9k/xmit.c
> index 82fc76f..c3bd1b1 100644
> --- a/drivers/net/wireless/ath/ath9k/xmit.c
> +++ b/drivers/net/wireless/ath/ath9k/xmit.c
> @@ -2267,11 +2267,15 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, 
> struct sk_buff *skb,
> padpos = ieee80211_hdrlen(hdr->frame_control);
> padsize = padpos & 3;
> if (padsize && skb->len > padpos) {
> -   if (skb_headroom(skb) < padsize)
> -   return -ENOMEM;
> +   if (ieee80211_hw_check(hw, NEEDS_ALIGNED4_SKBS)) {
> +   frmlen -= padsize;
> +   } else {
> +   if (skb_headroom(skb) < padsize)
> +   return -ENOMEM;
>
> -   skb_push(skb, padsize);
> -   memmove(skb->data, skb->data + padsize, padpos);

  why the same lines has been removed and added again ?
> +   skb_push(skb, padsize);
> +   memmove(skb->data, skb->data + padsize, padpos);
> +   }
> }



>
>
> setup_frame_info(hw, sta, skb, frmlen);
> @@ -2494,7 +2498,8 @@ static void ath_tx_complete(struct ath_softc *sc, 
> struct sk_buff *skb,
>
> padpos = ieee80211_hdrlen(hdr->frame_control);
> padsize = padpos & 3;
> -   if (padsize && skb->len>padpos+padsize) {
> +   if (padsize && skb->len > padpos + padsize &&
> +   !ieee80211_hw_check(sc->hw, NEEDS_ALIGNED4_SKBS)) {
> /*
>  * Remove MAC header padding before giving the frame back to
>  * mac80211.
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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