[PATCH v2] staging: vt6655: Rename two dimensional array declaration

2021-03-14 Thread Madhumitha Prabakaran
Rename two dimensional array declaration to fix checkpatch warning: Avoid
Camelcase and make the declaration more readable and understandable

Signed-off-by: Madhumitha Prabakaran 
---
Changes in v2: Improve commit message
---
 drivers/staging/vt6655/baseband.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6655/baseband.c 
b/drivers/staging/vt6655/baseband.c
index 1aa675241599..d89163299172 100644
--- a/drivers/staging/vt6655/baseband.c
+++ b/drivers/staging/vt6655/baseband.c
@@ -52,7 +52,7 @@
 /*-  Static Variables  --*/
 
 #define CB_VT3253_INIT_FOR_RFMD 446
-static const unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+static const unsigned char by_vt3253_init_tab_rfmd[CB_VT3253_INIT_FOR_RFMD][2] 
= {
{0x00, 0x30},
{0x01, 0x00},
{0x02, 0x00},
@@ -2002,8 +2002,8 @@ bool bb_vt3253_init(struct vnt_private *priv)
if (by_local_id <= REV_ID_VT3253_A1) {
for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
result &= bb_write_embedded(priv,
-   byVT3253InitTab_RFMD[ii][0],
-   byVT3253InitTab_RFMD[ii][1]);
+   by_vt3253_init_tab_rfmd[ii][0],
+   by_vt3253_init_tab_rfmd[ii][1]);
 
} else {
for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
-- 
2.25.1



[PATCH] staging: vt6655: Fix camelcase

2021-03-13 Thread Madhumitha Prabakaran
Fix checkpatch.pl - Avoid CamelCase: 

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/vt6655/baseband.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vt6655/baseband.c 
b/drivers/staging/vt6655/baseband.c
index 1aa675241599..d89163299172 100644
--- a/drivers/staging/vt6655/baseband.c
+++ b/drivers/staging/vt6655/baseband.c
@@ -52,7 +52,7 @@
 /*-  Static Variables  --*/
 
 #define CB_VT3253_INIT_FOR_RFMD 446
-static const unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+static const unsigned char by_vt3253_init_tab_rfmd[CB_VT3253_INIT_FOR_RFMD][2] 
= {
{0x00, 0x30},
{0x01, 0x00},
{0x02, 0x00},
@@ -2002,8 +2002,8 @@ bool bb_vt3253_init(struct vnt_private *priv)
if (by_local_id <= REV_ID_VT3253_A1) {
for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
result &= bb_write_embedded(priv,
-   byVT3253InitTab_RFMD[ii][0],
-   byVT3253InitTab_RFMD[ii][1]);
+   by_vt3253_init_tab_rfmd[ii][0],
+   by_vt3253_init_tab_rfmd[ii][1]);
 
} else {
for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
-- 
2.25.1



[PATCH v2] Staging: bcm2835-camera: Prefer kernel types

2019-05-16 Thread Madhumitha Prabakaran
Fix the warning issued by checkpatch
Prefer kernel type 'u32' over 'uint32_t'.
Along with that include a blank line after a declaration
to maintain Linux kernel coding style.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2:
- Modified subject line
- Included one more change in control.c
---
 drivers/staging/vc04_services/bcm2835-camera/controls.c | 3 ++-
 drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index 74410fedffad..5ad957e23895 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -52,7 +52,8 @@ static const s64 ev_bias_qmenu[] = {
 static const s64 iso_qmenu[] = {
0, 10, 20, 40, 80,
 };
-static const uint32_t iso_values[] = {
+
+static const u32 iso_values[] = {
0, 100, 200, 400, 800,
 };
 
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h 
b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
index d1c57edbe2b8..90793c9f9a0f 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
@@ -309,7 +309,7 @@ struct mmal_msg_port_parameter_set {
u32 port_handle;  /* port */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 struct mmal_msg_port_parameter_set_reply {
@@ -331,7 +331,7 @@ struct mmal_msg_port_parameter_get_reply {
u32 status;   /* Status of mmal_port_parameter_get call */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 /* event messages */
-- 
2.17.1



[PATCH] Staging: vc04_services: Fix kernel type 'u32' over 'uint32_t'

2019-05-14 Thread Madhumitha Prabakaran
Fix the warning issued by checkpatch
Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h 
b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
index d1c57edbe2b8..90793c9f9a0f 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
@@ -309,7 +309,7 @@ struct mmal_msg_port_parameter_set {
u32 port_handle;  /* port */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 struct mmal_msg_port_parameter_set_reply {
@@ -331,7 +331,7 @@ struct mmal_msg_port_parameter_get_reply {
u32 status;   /* Status of mmal_port_parameter_get call */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 /* event messages */
-- 
2.17.1



[PATCH] Staging: kpc2000: Cleanup in kpc_dma_transfer()

2019-05-05 Thread Madhumitha Prabakaran
Remove unnecessary typecast in kzalloc function. In addition to that
replace kzalloc(sizeof(*acd)) over kzalloc(sizeof(struct aio_cb_data))
to maintain Linux kernel style.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c 
b/drivers/staging/kpc2000/kpc_dma/fileops.c
index 5741d2b49a7d..c24329affd3a 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -57,7 +57,7 @@ int  kpc_dma_transfer(struct dev_private_data *priv, struct 
kiocb *kcb, unsigned

dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = 
[%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, 
(void*)iov_base, iov_len, ldev);

-   acd = (struct aio_cb_data *) kzalloc(sizeof(struct aio_cb_data), 
GFP_KERNEL);
+   acd = kzalloc(sizeof(*acd), GFP_KERNEL);
if (!acd){
dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for 
for the aio data\n");
return -ENOMEM;
-- 
2.17.1



[PATCH] Staging: speakup: Replace return type

2019-05-05 Thread Madhumitha Prabakaran
Replace return type and remove the respective assignment.

Issue found by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/speakup/i18n.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
index ee240d36f947..a748eb8052d1 100644
--- a/drivers/staging/speakup/i18n.c
+++ b/drivers/staging/speakup/i18n.c
@@ -470,8 +470,7 @@ static char *find_specifier_end(char *input)
input++;/* Advance over %. */
input = skip_flags(input);
input = skip_width(input);
-   input = skip_conversion(input);
-   return input;
+   return skip_conversion(input);
 }
 
 /*
-- 
2.17.1



[PATCH v3] Staging: vc04_services: Cleanup in ctrl_set_bitrate()

2019-04-23 Thread Madhumitha Prabakaran
Remove unnecessary variable from the function and make a corresponding
change w.r.t the variable. In addition to that align the parameters in
the parentheses to maintain Linux kernel coding style

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2 -
1) Fix my own error of removing function call from the variable.
2) Align the function parameters with parentheses.

Changes in v3 -
1) Since there was no real purpose of returning true value, replace it with
return value of the function vchiq_mmal_port_parameter_set().
---
 drivers/staging/vc04_services/bcm2835-camera/controls.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index e39ab5fae724..2e0a422cdf3e 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -607,18 +607,15 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev,
struct v4l2_ctrl *ctrl,
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
 {
-   int ret;
struct vchiq_mmal_port *encoder_out;
 
dev->capture.encode_bitrate = ctrl->val;
 
encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
 
-   ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
-   mmal_ctrl->mmal_id,
-   &ctrl->val, sizeof(ctrl->val));
-   ret = 0;
-   return ret;
+   return vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
+mmal_ctrl->mmal_id, &ctrl->val,
+sizeof(ctrl->val));
 }
 
 static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev,
-- 
2.17.1



Re: [PATCH v2] Staging: vc04_services: Cleanup in ctrl_set_bitrate()

2019-04-23 Thread Madhumitha Prabakaran
On 04/20  :51, Greg KH wrote:
> On Sat, Apr 20, 2019 at 11:56:44AM -0500, Madhumitha Prabakaran wrote:
> > Remove unnecessary variable and replace return type.
> > In addition to that align the function parameters with parentheses to
> > maintain Linux coding style.
> > 
> > Issue suggested by Coccinelle.
> > 
> > Signed-off-by: Madhumitha Prabakaran 
> > 
> > ---
> > Changes in v2
> > 
> > 1) Fix my own error of removing function call from the variable.
> > 2) Align the function parameters with parentheses.
> > 
> > ---
> > ---
> >  .../staging/vc04_services/bcm2835-camera/controls.c| 10 --
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
> > b/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > index e39ab5fae724..71eb349c3138 100644
> > --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > @@ -607,18 +607,16 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev 
> > *dev,
> > struct v4l2_ctrl *ctrl,
> > const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
> >  {
> > -   int ret;
> > struct vchiq_mmal_port *encoder_out;
> >  
> > dev->capture.encode_bitrate = ctrl->val;
> >  
> > encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
> >  
> > -   ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
> > -   mmal_ctrl->mmal_id,
> > -   &ctrl->val, sizeof(ctrl->val));
> > -   ret = 0;
> > -   return ret;
> > +   vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
> > + mmal_ctrl->mmal_id, &ctrl->val,
> > + sizeof(ctrl->val));
> > +   return 0;
> >  }
> 
> Why does this function even return anything at all if it can not fail?

I looked at the function vchiq_mmal_port_parameter_set, which calls
another function for setting the port parameters, which inturns sends an
synchronous message. If it is able to send the message successfully, it
returns 0. It can also fail and can return any other value. Also the
function ctrl_set_bitrate is not evaluated anywhere for true or false,
so it is safe to return the value we get from
vchiq_mmal_port_parameter_set instead of returning 0 always.


> 
> Why not return the value that vchiq_mmal_port_parameter_set() returned?
> 

I will change the code to return the value from
vchiq_mmal_port_parameter_set directly.

> thanks,
> 
> greg k-h


[PATCH v2] Staging: vc04_services: Cleanup in ctrl_set_bitrate()

2019-04-20 Thread Madhumitha Prabakaran
Remove unnecessary variable and replace return type.
In addition to that align the function parameters with parentheses to
maintain Linux coding style.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2

1) Fix my own error of removing function call from the variable.
2) Align the function parameters with parentheses.

---
---
 .../staging/vc04_services/bcm2835-camera/controls.c| 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index e39ab5fae724..71eb349c3138 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -607,18 +607,16 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev,
struct v4l2_ctrl *ctrl,
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
 {
-   int ret;
struct vchiq_mmal_port *encoder_out;
 
dev->capture.encode_bitrate = ctrl->val;
 
encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
 
-   ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
-   mmal_ctrl->mmal_id,
-   &ctrl->val, sizeof(ctrl->val));
-   ret = 0;
-   return ret;
+   vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
+ mmal_ctrl->mmal_id, &ctrl->val,
+ sizeof(ctrl->val));
+   return 0;
 }
 
 static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev,
-- 
2.17.1



Re: [PATCH] Staging: vc04_services: Cleanup in ctrl_set_bitrate()

2019-04-19 Thread Madhumitha Prabakaran
On 04/19  :49, Stefan Wahren wrote:
> Hi Madhumitha,
> 
> Am 19.04.19 um 23:23 schrieb Madhumitha Prabakaran:
> > Remove unnecessary variable and replace return type.
> >
> > Issue suggested by Coccinelle.
> >
> > Signed-off-by: Madhumitha Prabakaran 
> > ---
> >  drivers/staging/vc04_services/bcm2835-camera/controls.c | 7 +--
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
> > b/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > index e39ab5fae724..f87fa7f61db3 100644
> > --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
> > @@ -607,18 +607,13 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev 
> > *dev,
> > struct v4l2_ctrl *ctrl,
> > const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
> >  {
> > -   int ret;
> > struct vchiq_mmal_port *encoder_out;
> >  
> > dev->capture.encode_bitrate = ctrl->val;
> >  
> > encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
> >  
> > -   ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
> > -   mmal_ctrl->mmal_id,
> > -   &ctrl->val, sizeof(ctrl->val));
> > -   ret = 0;
> > -   return ret;
> > +   return 0;
> 
> i don't understand why we can remove here the function call.

I overlooked the function call. I will fix it.

> 
> Stefan
> 
> >  }
> >  
> >  static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev,


[PATCH] Staging: rtlwifi: Replace return type

2019-04-19 Thread Madhumitha Prabakaran
Replace return type and remove the respective assignment.

Issue found by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtlwifi/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index 2cce65368f92..1e4e858f7517 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -377,9 +377,7 @@ static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
for (i = 0; i < len; i++)
crc = crc16_ccitt(pattern[i], crc);
 
-   crc = ~crc;
-
-   return crc;
+   return ~crc;
 }
 
 static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
-- 
2.17.1



[PATCH] Staging: vc04_services: Cleanup in ctrl_set_bitrate()

2019-04-19 Thread Madhumitha Prabakaran
Remove unnecessary variable and replace return type.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/vc04_services/bcm2835-camera/controls.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index e39ab5fae724..f87fa7f61db3 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -607,18 +607,13 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev,
struct v4l2_ctrl *ctrl,
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
 {
-   int ret;
struct vchiq_mmal_port *encoder_out;
 
dev->capture.encode_bitrate = ctrl->val;
 
encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0];
 
-   ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out,
-   mmal_ctrl->mmal_id,
-   &ctrl->val, sizeof(ctrl->val));
-   ret = 0;
-   return ret;
+   return 0;
 }
 
 static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev,
-- 
2.17.1



[PATCH] Staging: mt7621-mmc: Cleanup in msdc_app_cmd()

2019-04-19 Thread Madhumitha Prabakaran
Remove unwanted variable and replace the respective return type.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/mt7621-mmc/sd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index b12ed2c988fd..2b327fde7145 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -752,7 +752,6 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct 
msdc_host *host)
 {
struct mmc_command cmd;
struct mmc_request mrq;
-   u32 err;
 
memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_APP_CMD;
@@ -763,8 +762,7 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct 
msdc_host *host)
mrq.cmd = &cmd; cmd.mrq = &mrq;
cmd.data = NULL;
 
-   err = msdc_do_command(host, &cmd, 0, CMD_TIMEOUT);
-   return err;
+   return msdc_do_command(host, &cmd, 0, CMD_TIMEOUT);
 }
 
 static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd)
-- 
2.17.1



[PATCH] Staging: rtl8723bs: core: Replace return types

2019-04-19 Thread Madhumitha Prabakaran
Remove unwanted assignments and replace return types.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index b9d36db762a9..2474fa6fb49b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -204,8 +204,7 @@ struct  sta_info *rtw_alloc_stainfo(struct  
sta_priv *pstapriv, u8 *hwaddr)
if (list_empty(&pfree_sta_queue->queue)) {
/* spin_unlock_bh(&(pfree_sta_queue->lock)); */
spin_unlock_bh(&(pstapriv->sta_hash_lock));
-   psta = NULL;
-   return psta;
+   return NULL;
} else {
psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct 
sta_info, list);
 
@@ -586,12 +585,10 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
 
 struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter)
 {
-   struct sta_info *psta;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
-   psta = rtw_get_stainfo(pstapriv, bc_addr);
-   return psta;
+   return rtw_get_stainfo(pstapriv, bc_addr);
 }
 
 u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
-- 
2.17.1



Re: [greybus-dev] [PATCH v2] Staging: greybus: Cleanup in greybus driver

2019-04-17 Thread Madhumitha Prabakaran
On 04/17  :41, Alex Elder wrote:
> On 4/16/19 5:13 PM, Madhumitha Prabakaran wrote:
> > Fix a blank line after structure declarations. Also, convert
> > macros into inline functions in order to maintain Linux kernel
> > coding style based on which the inline function is
> > preferable over the macro.
> 
> Madhumitha, here is my explanation for why *not* to convert these
> container_of() macros to inline functions.  It's not just because
> "we do this all over the kernel."  The reason is that it actually
> does not improve the code.
> 
> Inline functions are often better than macros because they are
> explicit about types, allowing the compiler to tell you if you
> are passing parameters of the right type, and possibly assigning
> results to objects of the right type.


This makes more sense now.

> 
> Here is the definition of the container_of() macro in :
> 
> #define container_of(ptr, type, member) ({  \
> const typeof(((type *)0)->member) * __mptr = (ptr); \
> (type *)((char *)__mptr - offsetof(type, member)); })
> 
> You see that ptr is explicitly assigned to a local variable
> of the type of the member field, so the compiler is able to
> check that assignment.  And the return value is similarly
> cast to the type of the containing structure, so the type
> compatibility of the assignment can also be checked.  It is
> assumed that where this macro is used, the caller knows it
> is passing an appropriate address.
> 
> There is another thing about this particular definition make
> it just as good as an inline function.  A macro expansion can
> result in one of its parameters being used more than once, and
> that allows those parameters to be *evaluated* more than once
> in a single statement, which can produce incorrect code.
> 
> This macro is defined using the "statement expression"
> extension to C--where a compound statement is enclosed in
> parentheses--({ ... }).  This allows a local variable to be
> used in the macro expansion, which avoids any reuse of the
> macro parameters which might cause side-effects.
> 
> So anyway, I don't think there is any benefit to replacing
> macros like this that do container_of() with inline functions.
> 
>       -Alex

Thanks for taking time to explain it in detailed way.

> 
> > Blank line fixes are suggested by checkpatch.pl
> > 
> > Signed-off-by: Madhumitha Prabakaran 
> > 
> > Changes in v2:
> > - To maintain consistency in driver greybus, all the instances of macro
> > with container_of are fixed in a single patch.
> > ---
> >  drivers/staging/greybus/bundle.h|  6 +-
> >  drivers/staging/greybus/control.h   |  6 +-
> >  drivers/staging/greybus/gbphy.h | 12 ++--
> >  drivers/staging/greybus/greybus.h   |  6 +-
> >  drivers/staging/greybus/hd.h|  6 +-
> >  drivers/staging/greybus/interface.h |  6 +-
> >  drivers/staging/greybus/module.h|  6 +-
> >  drivers/staging/greybus/svc.h   |  6 +-
> >  8 files changed, 45 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/staging/greybus/bundle.h 
> > b/drivers/staging/greybus/bundle.h
> > index 8734d2055657..84956eedb1c4 100644
> > --- a/drivers/staging/greybus/bundle.h
> > +++ b/drivers/staging/greybus/bundle.h
> > @@ -31,7 +31,11 @@ struct gb_bundle {
> >  
> > struct list_headlinks;  /* interface->bundles */
> >  };
> > -#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
> > +
> > +static inline struct gb_bundle *to_gb_bundle(struct device *d)
> > +{
> > +   return container_of(d, struct gb_bundle, dev);
> > +}
> >  
> >  /* Greybus "private" definitions" */
> >  struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
> > diff --git a/drivers/staging/greybus/control.h 
> > b/drivers/staging/greybus/control.h
> > index 3a29ec05f631..a681ef74e7fe 100644
> > --- a/drivers/staging/greybus/control.h
> > +++ b/drivers/staging/greybus/control.h
> > @@ -24,7 +24,11 @@ struct gb_control {
> > char *vendor_string;
> > char *product_string;
> >  };
> > -#define to_gb_control(d) container_of(d, struct gb_control, dev)
> > +
> > +static inline struct gb_control *to_gb_control(struct device *d)
> > +{
> > +   return container_of(d, struct gb_control, dev);
> > +}
> >  
> >  struct gb_control *gb_control_create(struct gb_interface *intf);
> >  int gb_control_enable(struct gb_control *control);
> >

Re: [PATCH v2] Staging: greybus: Cleanup in greybus driver

2019-04-17 Thread Madhumitha Prabakaran
On 04/17  :25, Greg KH wrote:
> On Tue, Apr 16, 2019 at 05:13:18PM -0500, Madhumitha Prabakaran wrote:
> > Fix a blank line after structure declarations. Also, convert
> > macros into inline functions in order to maintain Linux kernel
> > coding style based on which the inline function is
> > preferable over the macro.
> > 
> > Blank line fixes are suggested by checkpatch.pl
> > 
> > Signed-off-by: Madhumitha Prabakaran 
> > 
> > Changes in v2:
> > - To maintain consistency in driver greybus, all the instances of macro
> > with container_of are fixed in a single patch.
> > ---
> >  drivers/staging/greybus/bundle.h|  6 +-
> >  drivers/staging/greybus/control.h   |  6 +-
> >  drivers/staging/greybus/gbphy.h | 12 ++--
> >  drivers/staging/greybus/greybus.h   |  6 +-
> >  drivers/staging/greybus/hd.h|  6 +-
> >  drivers/staging/greybus/interface.h |  6 +-
> >  drivers/staging/greybus/module.h|  6 +-
> >  drivers/staging/greybus/svc.h   |  6 +-
> >  8 files changed, 45 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/staging/greybus/bundle.h 
> > b/drivers/staging/greybus/bundle.h
> > index 8734d2055657..84956eedb1c4 100644
> > --- a/drivers/staging/greybus/bundle.h
> > +++ b/drivers/staging/greybus/bundle.h
> > @@ -31,7 +31,11 @@ struct gb_bundle {
> >  
> > struct list_headlinks;  /* interface->bundles */
> >  };
> > -#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
> > +
> > +static inline struct gb_bundle *to_gb_bundle(struct device *d)
> > +{
> > +   return container_of(d, struct gb_bundle, dev);
> > +}
> 
> Why are we changing this to an inline function?  The #define is fine,
> and how we "normally" do this type of container_of conversion.
> 
> I understand the objection of the "no blank line", but this was the
> "original" style that we used to create these #defines from the very
> beginning of the driver model work a decade ago.  Changing that
> muscle-memory is going to be hard for some of us.  Look at
> drivers/base/base.h for other examples of this.

Thanks for explaining it.

> 
> thanks,
> 
> greg k-h


[PATCH v2] Staging: greybus: Cleanup in greybus driver

2019-04-16 Thread Madhumitha Prabakaran
Fix a blank line after structure declarations. Also, convert
macros into inline functions in order to maintain Linux kernel
coding style based on which the inline function is
preferable over the macro.

Blank line fixes are suggested by checkpatch.pl

Signed-off-by: Madhumitha Prabakaran 

Changes in v2:
- To maintain consistency in driver greybus, all the instances of macro
with container_of are fixed in a single patch.
---
 drivers/staging/greybus/bundle.h|  6 +-
 drivers/staging/greybus/control.h   |  6 +-
 drivers/staging/greybus/gbphy.h | 12 ++--
 drivers/staging/greybus/greybus.h   |  6 +-
 drivers/staging/greybus/hd.h|  6 +-
 drivers/staging/greybus/interface.h |  6 +-
 drivers/staging/greybus/module.h|  6 +-
 drivers/staging/greybus/svc.h   |  6 +-
 8 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 8734d2055657..84956eedb1c4 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -31,7 +31,11 @@ struct gb_bundle {
 
struct list_headlinks;  /* interface->bundles */
 };
-#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
+
+static inline struct gb_bundle *to_gb_bundle(struct device *d)
+{
+   return container_of(d, struct gb_bundle, dev);
+}
 
 /* Greybus "private" definitions" */
 struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
diff --git a/drivers/staging/greybus/control.h 
b/drivers/staging/greybus/control.h
index 3a29ec05f631..a681ef74e7fe 100644
--- a/drivers/staging/greybus/control.h
+++ b/drivers/staging/greybus/control.h
@@ -24,7 +24,11 @@ struct gb_control {
char *vendor_string;
char *product_string;
 };
-#define to_gb_control(d) container_of(d, struct gb_control, dev)
+
+static inline struct gb_control *to_gb_control(struct device *d)
+{
+   return container_of(d, struct gb_control, dev);
+}
 
 struct gb_control *gb_control_create(struct gb_interface *intf);
 int gb_control_enable(struct gb_control *control);
diff --git a/drivers/staging/greybus/gbphy.h b/drivers/staging/greybus/gbphy.h
index 99463489d7d6..20307f6dfcb9 100644
--- a/drivers/staging/greybus/gbphy.h
+++ b/drivers/staging/greybus/gbphy.h
@@ -15,7 +15,11 @@ struct gbphy_device {
struct list_head list;
struct device dev;
 };
-#define to_gbphy_dev(d) container_of(d, struct gbphy_device, dev)
+
+static inline struct gbphy_device *to_gbphy_dev(struct device *d)
+{
+   return container_of(d, struct gbphy_device, dev);
+}
 
 static inline void *gb_gbphy_get_data(struct gbphy_device *gdev)
 {
@@ -43,7 +47,11 @@ struct gbphy_driver {
 
struct device_driver driver;
 };
-#define to_gbphy_driver(d) container_of(d, struct gbphy_driver, driver)
+
+static inline struct gbphy_driver *to_gbphy_driver(struct device_driver *d)
+{
+   return container_of(d, struct gbphy_driver, driver);
+}
 
 int gb_gbphy_register_driver(struct gbphy_driver *driver,
 struct module *owner, const char *mod_name);
diff --git a/drivers/staging/greybus/greybus.h 
b/drivers/staging/greybus/greybus.h
index d03ddb7c9df0..a82d5002b4d5 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -64,7 +64,11 @@ struct greybus_driver {
 
struct device_driver driver;
 };
-#define to_greybus_driver(d) container_of(d, struct greybus_driver, driver)
+
+static inline struct greybus_driver *to_greybus_driver(struct device_driver *d)
+{
+   return container_of(d, struct greybus_driver, driver);
+}
 
 static inline void greybus_set_drvdata(struct gb_bundle *bundle, void *data)
 {
diff --git a/drivers/staging/greybus/hd.h b/drivers/staging/greybus/hd.h
index 6cf024a20a58..de7c49d05266 100644
--- a/drivers/staging/greybus/hd.h
+++ b/drivers/staging/greybus/hd.h
@@ -57,7 +57,11 @@ struct gb_host_device {
/* Private data for the host driver */
unsigned long hd_priv[0] __aligned(sizeof(s64));
 };
-#define to_gb_host_device(d) container_of(d, struct gb_host_device, dev)
+
+static inline struct gb_host_device *to_gb_host_device(struct device *d)
+{
+   return container_of(d, struct gb_host_device, dev);
+}
 
 int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id);
 void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id);
diff --git a/drivers/staging/greybus/interface.h 
b/drivers/staging/greybus/interface.h
index 1c00c5bb3ec9..f86c0d596dbe 100644
--- a/drivers/staging/greybus/interface.h
+++ b/drivers/staging/greybus/interface.h
@@ -63,7 +63,11 @@ struct gb_interface {
struct work_struct mode_switch_work;
struct completion mode_switch_completion;
 };
-#define to_gb_interface(d) container_of(d, struct gb_interface, dev)
+
+static inline struct gb_interface *to_gb_interface(struct device *d)
+{
+   return container_of(d, struct gb_interface, 

[PATCH 3/3] Staging: rtl8723bs: Remove an unused struct tx_pending_t

2019-04-15 Thread Madhumitha Prabakaran
Remove an unused struct tx_pending_t, as it is never used in
kernel tree.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 1327728e6dff..74c028fbe8f7 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -870,13 +870,6 @@ static inline int is_zero_mac_addr(const u8 *addr)
 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
 
-typedef struct tx_pending_t{
-   int frag;
-   struct ieee80211_txb *txb;
-}tx_pending_t;
-
-
-
 #define MAXTID 16
 
 #define IEEE_A(1<<0)
-- 
2.17.1



[PATCH 1/3] Staging: rtl8723bs: Remove typedef in struct ieee_param_ex

2019-04-15 Thread Madhumitha Prabakaran
Remove typedef in struct ieee_param_ex, as the struct that
has elements that can reasonably be directly accessed should
never be a typedef.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 9efb4dcb9d3a..8077465402c6 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -242,11 +242,11 @@ typedef struct ieee_param {
} u;
 }ieee_param;
 
-typedef struct ieee_param_ex {
+struct ieee_param_ex {
u32 cmd;
u8 sta_addr[ETH_ALEN];
u8 data[0];
-}ieee_param_ex;
+};
 
 struct sta_data{
u16 aid;
-- 
2.17.1



[PATCH 2/3] Staging: rtl8723bs: Remove typedef in struct ieee_param

2019-04-15 Thread Madhumitha Prabakaran
Remove typedef in struct ieee_param, as the struct that
has elements that can reasonably be directly accessed
should never be a typedef.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 8077465402c6..1327728e6dff 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -202,7 +202,7 @@ enum NETWORK_TYPE
 #define IsSupportedVHT(NetType) (((NetType) & (WIRELESS_11AC)) ? true : false)
 
 
-typedef struct ieee_param {
+struct ieee_param {
u32 cmd;
u8 sta_addr[ETH_ALEN];
union {
@@ -240,7 +240,7 @@ typedef struct ieee_param {
u8 buf[0];
} bcn_ie;
} u;
-}ieee_param;
+};
 
 struct ieee_param_ex {
u32 cmd;
-- 
2.17.1



[PATCH 0/3] Cleanups in rtl8723bs

2019-04-15 Thread Madhumitha Prabakaran
Patch 1 and 2 remove typedef in structures. Patch 3 remove unused
structure.

Madhumitha Prabakaran (3):
  Staging: rtl8723bs: Remove typedef in struct ieee_param_ex
  Staging: rtl8723bs: Remove typedef in struct ieee_param
  Staging: rtl8723bs: Remove an unused struct tx_pending_t

 drivers/staging/rtl8723bs/include/ieee80211.h | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

-- 
2.17.1



[PATCH v2] Staging: rtl8723bs: Remove typedef in struct sdio_data

2019-04-11 Thread Madhumitha Prabakaran
Remove typedef in struct sdio_data and make the respective changes in
associated files, as the struct that has elements that can reasonably
be directly accessed should never be a typedef.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2:
- Removed INTF_DATA data
- Removed ifdef around it
---
 drivers/staging/rtl8723bs/hal/sdio_ops.c  |  6 ++--
 drivers/staging/rtl8723bs/include/drv_types.h |  6 ++--
 .../rtl8723bs/include/drv_types_sdio.h|  4 +--
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  | 10 +++
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c | 30 +--
 5 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 92191e9789bb..acb94aa272ca 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -425,7 +425,7 @@ static u32 sdio_read_port(
 )
 {
struct adapter *adapter;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
struct hal_com_data *hal;
u32 oldcnt;
s32 err;
@@ -473,7 +473,7 @@ static u32 sdio_write_port(
 )
 {
struct adapter *adapter;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
s32 err;
struct xmit_buf *xmitbuf = (struct xmit_buf *)mem;
 
@@ -1207,7 +1207,7 @@ u8 RecvOnePkt(struct adapter *adapter, u32 size)
 {
struct recv_buf *recvbuf;
struct dvobj_priv *sddev;
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio;
struct sdio_func *func;
 
u8 res = false;
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h 
b/drivers/staging/rtl8723bs/include/drv_types.h
index bafb2c30e7fb..29cff7a64e3f 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -220,7 +220,6 @@ struct registry_priv
 #define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *) 0)->field)
 
 #include 
-#define INTF_DATA SDIO_DATA
 
 #define is_primary_adapter(adapter) (1)
 #define get_iface_type(adapter) (IFACE_PORT0)
@@ -476,9 +475,8 @@ struct dvobj_priv
 
 /* below is for SDIO INTERFACE */
 
-#ifdef INTF_DATA
-   INTF_DATA intf_data;
-#endif
+struct sdio_data intf_data;
+
 };
 
 #define dvobj_to_pwrctl(dvobj) (&(dvobj->pwrctl_priv))
diff --git a/drivers/staging/rtl8723bs/include/drv_types_sdio.h 
b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
index 23bf30ece2df..09263ad27ce9 100644
--- a/drivers/staging/rtl8723bs/include/drv_types_sdio.h
+++ b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
@@ -16,7 +16,7 @@
#include 
 #endif
 
-typedef struct sdio_data
+struct sdio_data
 {
u8  func_number;
 
@@ -26,6 +26,6 @@ typedef struct sdio_data
 
struct sdio_func *func;
void *sys_sdio_irq_thd;
-} SDIO_DATA, *PSDIO_DATA;
+};
 
 #endif
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 6d02904de63f..052482554f74 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -74,7 +74,7 @@ static void sd_sync_int_hdl(struct sdio_func *func)
 
 static int sdio_alloc_irq(struct dvobj_priv *dvobj)
 {
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio_data;
struct sdio_func *func;
int err;
 
@@ -102,7 +102,7 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj)
 
 static void sdio_free_irq(struct dvobj_priv *dvobj)
 {
-PSDIO_DATA psdio_data;
+struct sdio_data *psdio_data;
 struct sdio_func *func;
 int err;
 
@@ -176,7 +176,7 @@ static void gpio_hostwakeup_free_irq(struct adapter 
*padapter)
 
 static u32 sdio_init(struct dvobj_priv *dvobj)
 {
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio_data;
struct sdio_func *func;
int err;
 
@@ -248,7 +248,7 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func 
*func)
 {
int status = _FAIL;
struct dvobj_priv *dvobj = NULL;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
 
dvobj = devobj_init();
if (dvobj == NULL) {
@@ -327,7 +327,7 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv 
*dvobj, const struct
int status = _FAIL;
struct net_device *pnetdev;
struct adapter *padapter = NULL;
-   PSDIO_DATA psdio = &dvobj->intf_data;
+   struct sdio_data *psdio = &dvobj->intf_data;
 
padapter = vzalloc(sizeof(*padapter));
if (padapter == NULL) {
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 43a9d922e3aa..1787534487b4 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -12,7 +12,7 @@
 static bool rtw_sdio_claim_host_needed(struct sdio_func *func)
 {
struct dvobj_priv *dvobj = sdio_get_drvdata(func);
-   PSDIO_DATA sdio_

[PATCH] Staging: rtl8723bs: Remove typedef in struct sdio_data

2019-04-09 Thread Madhumitha Prabakaran
Remove typedef in struct sdio_data and make the respective changes in
associated files, as the struct that has elements that can reasonably
be directly accessed should never be a typedef.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtl8723bs/hal/sdio_ops.c  |  6 ++--
 drivers/staging/rtl8723bs/include/drv_types.h |  2 +-
 .../rtl8723bs/include/drv_types_sdio.h|  4 +--
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  | 10 +++
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c | 30 +--
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 92191e9789bb..97b82b9e2b43 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -425,7 +425,7 @@ static u32 sdio_read_port(
 )
 {
struct adapter *adapter;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
struct hal_com_data *hal;
u32 oldcnt;
s32 err;
@@ -473,7 +473,7 @@ static u32 sdio_write_port(
 )
 {
struct adapter *adapter;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
s32 err;
struct xmit_buf *xmitbuf = (struct xmit_buf *)mem;
 
@@ -1207,7 +1207,7 @@ u8 RecvOnePkt(struct adapter *adapter, u32 size)
 {
struct recv_buf *recvbuf;
struct dvobj_priv *sddev;
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio_data;
struct sdio_func *func;
 
u8 res = false;
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h 
b/drivers/staging/rtl8723bs/include/drv_types.h
index bafb2c30e7fb..b0623c936940 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -220,7 +220,7 @@ struct registry_priv
 #define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *) 0)->field)
 
 #include 
-#define INTF_DATA SDIO_DATA
+#define INTF_DATA struct sdio_data
 
 #define is_primary_adapter(adapter) (1)
 #define get_iface_type(adapter) (IFACE_PORT0)
diff --git a/drivers/staging/rtl8723bs/include/drv_types_sdio.h 
b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
index 23bf30ece2df..09263ad27ce9 100644
--- a/drivers/staging/rtl8723bs/include/drv_types_sdio.h
+++ b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
@@ -16,7 +16,7 @@
#include 
 #endif
 
-typedef struct sdio_data
+struct sdio_data
 {
u8  func_number;
 
@@ -26,6 +26,6 @@ typedef struct sdio_data
 
struct sdio_func *func;
void *sys_sdio_irq_thd;
-} SDIO_DATA, *PSDIO_DATA;
+};
 
 #endif
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 6d02904de63f..052482554f74 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -74,7 +74,7 @@ static void sd_sync_int_hdl(struct sdio_func *func)
 
 static int sdio_alloc_irq(struct dvobj_priv *dvobj)
 {
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio_data;
struct sdio_func *func;
int err;
 
@@ -102,7 +102,7 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj)
 
 static void sdio_free_irq(struct dvobj_priv *dvobj)
 {
-PSDIO_DATA psdio_data;
+struct sdio_data *psdio_data;
 struct sdio_func *func;
 int err;
 
@@ -176,7 +176,7 @@ static void gpio_hostwakeup_free_irq(struct adapter 
*padapter)
 
 static u32 sdio_init(struct dvobj_priv *dvobj)
 {
-   PSDIO_DATA psdio_data;
+   struct sdio_data *psdio_data;
struct sdio_func *func;
int err;
 
@@ -248,7 +248,7 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func 
*func)
 {
int status = _FAIL;
struct dvobj_priv *dvobj = NULL;
-   PSDIO_DATA psdio;
+   struct sdio_data *psdio;
 
dvobj = devobj_init();
if (dvobj == NULL) {
@@ -327,7 +327,7 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv 
*dvobj, const struct
int status = _FAIL;
struct net_device *pnetdev;
struct adapter *padapter = NULL;
-   PSDIO_DATA psdio = &dvobj->intf_data;
+   struct sdio_data *psdio = &dvobj->intf_data;
 
padapter = vzalloc(sizeof(*padapter));
if (padapter == NULL) {
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 43a9d922e3aa..1787534487b4 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -12,7 +12,7 @@
 static bool rtw_sdio_claim_host_needed(struct sdio_func *func)
 {
struct dvobj_priv *dvobj = sdio_get_drvdata(func);
-   PSDIO_DATA sdio_data = &dvobj->intf_data;
+   struct sdio_data *sdio_data = &dvobj->intf_data;
 
if (sdio_data->sys_sdio_irq_thd && sdio_data->sys_sdio_irq_thd == 
current)
return false;
@@ -21,7 +21,7 @@ static bool rtw_sdio_claim_host_

[PATCH] Staging: greybus: Cleanup in header file control.h

2019-04-05 Thread Madhumitha Prabakaran
Fix a blank line after function/struct/union/enum
declarations. Also, convert to_gb_control()  macro into an inline
function in order to maintain Linux kernel coding style based
on which the inline function is preferable over the macro.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/greybus/control.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/control.h 
b/drivers/staging/greybus/control.h
index 3a29ec05f631..a681ef74e7fe 100644
--- a/drivers/staging/greybus/control.h
+++ b/drivers/staging/greybus/control.h
@@ -24,7 +24,11 @@ struct gb_control {
char *vendor_string;
char *product_string;
 };
-#define to_gb_control(d) container_of(d, struct gb_control, dev)
+
+static inline struct gb_control *to_gb_control(struct device *d)
+{
+   return container_of(d, struct gb_control, dev);
+}
 
 struct gb_control *gb_control_create(struct gb_interface *intf);
 int gb_control_enable(struct gb_control *control);
-- 
2.17.1



[PATCH] Staging: greybus: Fix spinlock_t definition without comment

2019-04-05 Thread Madhumitha Prabakaran
Fix spinlock_t definition without comment.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/greybus/connection.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/connection.h 
b/drivers/staging/greybus/connection.h
index 5ca3befc0636..0aedd246e94a 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -47,7 +47,7 @@ struct gb_connection {
unsigned long   flags;
 
struct mutexmutex;
-   spinlock_t  lock;
+   spinlock_t  lock; /* Protect structure fields */
enum gb_connection_statestate;
struct list_headoperations;
 
-- 
2.17.1



[PATCH] Staging: olpc_dcon: Use WARN_ON() instead of BUG_ON()

2019-04-05 Thread Madhumitha Prabakaran
Use WARN_ON() instead of BUG_ON(), as the WARN_ON() produces a backtrace
without crashing the kernel.

Issue found by checkpatch.pl.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index 6b714f740ac3..900baab70691 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -138,7 +138,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int 
is_powered_down)
}
if (x < 0) {
pr_err("unable to stabilize dcon's smbus, reasserting power and 
praying.\n");
-   BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
+   WARN_ON(olpc_board_at_least(olpc_board(0xc2)));
pm = 0;
olpc_ec_cmd(EC_DCON_POWER_MODE, &pm, 1, NULL, 0);
msleep(100);
-- 
2.17.1



linux-kernel@vger.kernel.org

2019-04-04 Thread Madhumitha Prabakaran
Remove an exceptional & on function names, otherwise they are used as
pointers without &.

Issue suggested using Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 .../vc04_services/bcm2835-camera/controls.c   | 58 +--
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index a2c55cb2192a..e39ab5fae724 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -930,49 +930,49 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
V4L2_CID_SATURATION, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
MMAL_PARAMETER_SATURATION,
-   &ctrl_set_rational,
+   ctrl_set_rational,
false
},
{
V4L2_CID_SHARPNESS, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
MMAL_PARAMETER_SHARPNESS,
-   &ctrl_set_rational,
+   ctrl_set_rational,
false
},
{
V4L2_CID_CONTRAST, MMAL_CONTROL_TYPE_STD,
-100, 100, 0, 1, NULL,
MMAL_PARAMETER_CONTRAST,
-   &ctrl_set_rational,
+   ctrl_set_rational,
false
},
{
V4L2_CID_BRIGHTNESS, MMAL_CONTROL_TYPE_STD,
0, 100, 50, 1, NULL,
MMAL_PARAMETER_BRIGHTNESS,
-   &ctrl_set_rational,
+   ctrl_set_rational,
false
},
{
V4L2_CID_ISO_SENSITIVITY, MMAL_CONTROL_TYPE_INT_MENU,
0, ARRAY_SIZE(iso_qmenu) - 1, 0, 1, iso_qmenu,
MMAL_PARAMETER_ISO,
-   &ctrl_set_iso,
+   ctrl_set_iso,
false
},
{
V4L2_CID_ISO_SENSITIVITY_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
0, 1, V4L2_ISO_SENSITIVITY_AUTO, 1, NULL,
MMAL_PARAMETER_ISO,
-   &ctrl_set_iso,
+   ctrl_set_iso,
false
},
{
V4L2_CID_IMAGE_STABILIZATION, MMAL_CONTROL_TYPE_STD,
0, 1, 0, 1, NULL,
MMAL_PARAMETER_VIDEO_STABILISATION,
-   &ctrl_set_value,
+   ctrl_set_value,
false
},
 /* {
@@ -983,7 +983,7 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
V4L2_CID_EXPOSURE_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
~0x03, 3, V4L2_EXPOSURE_AUTO, 0, NULL,
MMAL_PARAMETER_EXPOSURE_MODE,
-   &ctrl_set_exposure,
+   ctrl_set_exposure,
false
},
 /* todo this needs mixing in with set exposure
@@ -996,7 +996,7 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
/* Units of 100usecs */
1, 1 * 1000 * 10, 100 * 10, 1, NULL,
MMAL_PARAMETER_SHUTTER_SPEED,
-   &ctrl_set_exposure,
+   ctrl_set_exposure,
false
},
{
@@ -1004,7 +1004,7 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
0, ARRAY_SIZE(ev_bias_qmenu) - 1,
(ARRAY_SIZE(ev_bias_qmenu) + 1) / 2 - 1, 0, ev_bias_qmenu,
MMAL_PARAMETER_EXPOSURE_COMP,
-   &ctrl_set_value_ev,
+   ctrl_set_value_ev,
false
},
{
@@ -1012,7 +1012,7 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
0, 1,
0, 1, NULL,
0,  /* Dummy MMAL ID as it gets mapped into FPS range*/
-   &ctrl_set_exposure,
+   ctrl_set_exposure,
false
},
{
@@ -1020,7 +1020,7 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
MMAL_CONTROL_TYPE_STD_MENU,
~0x7, 2, V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL,
MMAL_PARAMETER_EXP_METERING_MODE,
-   &ctrl_set_metering_mode,
+   ctrl_set_metering_mode,
false
},
{
@@ -1028,56 +1028,56 @@ static const struct bm2835_mmal_v4l2_ctrl 
v4l2_ctrls[V4L2_CTRL_COUNT] = {
MMAL_CONTROL_TYPE_STD_MENU,
~0x3ff, 9, V4L2_WHITE_BALANCE_AUTO, 0, NULL,
MMAL_PARAMETER_AWB_MODE,
-   &ctrl_set_awb_mode,
+   ctrl_set_awb_mode,
false
},
{
V4L2_CID_RED_BALANCE, MMAL_CONTROL_TYPE_STD,
1, 7999, 1000, 1, NULL,
MMAL_PARAMETER_CUSTOM_AWB_GAINS,
-   &ctrl_set_awb_

[PATCH] Staging: rtlwifi: Remove & on function name

2019-04-04 Thread Madhumitha Prabakaran
Function name is otherwise used as pointers without &.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtlwifi/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/pci.c b/drivers/staging/rtlwifi/pci.c
index 4bb5703bd715..b97c76ec22ea 100644
--- a/drivers/staging/rtlwifi/pci.c
+++ b/drivers/staging/rtlwifi/pci.c
@@ -2134,7 +2134,7 @@ static int rtl_pci_intr_mode_msi(struct ieee80211_hw *hw)
if (ret < 0)
return ret;
 
-   ret = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt,
+   ret = request_irq(rtlpci->pdev->irq, _rtl_pci_interrupt,
  IRQF_SHARED, KBUILD_MODNAME, hw);
if (ret < 0) {
pci_disable_msi(rtlpci->pdev);
@@ -2155,7 +2155,7 @@ static int rtl_pci_intr_mode_legacy(struct ieee80211_hw 
*hw)
struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
int ret;
 
-   ret = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt,
+   ret = request_irq(rtlpci->pdev->irq, _rtl_pci_interrupt,
  IRQF_SHARED, KBUILD_MODNAME, hw);
if (ret < 0)
return ret;
-- 
2.17.1



[PATCH v3] Staging: rtlwifi: Cleanup crc16_ccitt()

2019-04-04 Thread Madhumitha Prabakaran
crc16_ccitt() function does "BIT(0) << i" instead of "BIT(i)".
Using !! is slightly shorter than "foo ? 1: 0" and remove unnecessary
parentheses to make the code simple.

Issue suggested by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v3:
- Changed subject line and commit log
- Removed unnecessary parentheses in the function

Changes in v2:
- Changed commit log
- Replaced ternary operator with !! idiom
- Modified a BIT operator
---
 drivers/staging/rtlwifi/core.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index a9902818ae7e..2cce65368f92 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -341,25 +341,25 @@ static u16 crc16_ccitt(u8 data, u16 crc)
u16 result;
 
for (i = 0; i < 8; i++) {
-   crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
-   data_bit  = (data & (BIT(0) << i) ? 1 : 0);
+   crc_bit15 = !!(crc & BIT(15));
+   data_bit  = !!(data & BIT(i));
shift_in = crc_bit15 ^ data_bit;
 
result = crc << 1;
if (shift_in == 0)
-   result &= (~BIT(0));
+   result &= ~BIT(0);
else
result |= BIT(0);
 
-   crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
+   crc_bit11 = !!(crc & BIT(11)) ^ shift_in;
if (crc_bit11 == 0)
-   result &= (~BIT(12));
+   result &= ~BIT(12);
else
result |= BIT(12);
 
-   crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
+   crc_bit4 = !!(crc & BIT(4)) ^ shift_in;
if (crc_bit4 == 0)
-   result &= (~BIT(5));
+   result &= ~BIT(5);
else
result |= BIT(5);
 
-- 
2.17.1



[PATCH v2] Staging: rtlwifi: Remove unwanted parentheses

2019-04-03 Thread Madhumitha Prabakaran
Remove unwanted parentheses and use !! idiom in place of ternary
operator to make code simple and more understandable.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2:
- Changed commit log
- Replaced ternary operator with !! idiom
- Modified a BIT operator
---
 drivers/staging/rtlwifi/core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index a9902818ae7e..c70f062cf4b9 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -341,8 +341,8 @@ static u16 crc16_ccitt(u8 data, u16 crc)
u16 result;
 
for (i = 0; i < 8; i++) {
-   crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
-   data_bit  = (data & (BIT(0) << i) ? 1 : 0);
+   crc_bit15 = !!(crc & BIT(15));
+   data_bit  = !!(data & BIT(i));
shift_in = crc_bit15 ^ data_bit;
 
result = crc << 1;
@@ -351,13 +351,13 @@ static u16 crc16_ccitt(u8 data, u16 crc)
else
result |= BIT(0);
 
-   crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
+   crc_bit11 = !!(crc & BIT(11)) ^ shift_in;
if (crc_bit11 == 0)
result &= (~BIT(12));
else
result |= BIT(12);
 
-   crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
+   crc_bit4 = !!(crc & BIT(4)) ^ shift_in;
if (crc_bit4 == 0)
result &= (~BIT(5));
else
-- 
2.17.1



[PATCH] Staging: rtlwifi: Remove unwanted parentheses

2019-04-03 Thread Madhumitha Prabakaran
Remove unwanted parentheses around right hand side of an assignment to
make code better and more understandable.

Issue found by Coccinelle.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/rtlwifi/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
index a9902818ae7e..970343048b69 100644
--- a/drivers/staging/rtlwifi/core.c
+++ b/drivers/staging/rtlwifi/core.c
@@ -341,8 +341,8 @@ static u16 crc16_ccitt(u8 data, u16 crc)
u16 result;
 
for (i = 0; i < 8; i++) {
-   crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
-   data_bit  = (data & (BIT(0) << i) ? 1 : 0);
+   crc_bit15 = (crc & BIT(15)) ? 1 : 0;
+   data_bit  = data & (BIT(0) << i) ? 1 : 0;
shift_in = crc_bit15 ^ data_bit;
 
result = crc << 1;
-- 
2.17.1



[PATCH] Staging: mt7621-mmc: Use DIV_ROUND_UP in function msdc_set_mclk

2019-04-03 Thread Madhumitha Prabakaran
Use DIV_ROUND_UP to make code simple and more understandable.

Signed-off-by: Madhumitha Prabakaran 
---
 drivers/staging/mt7621-mmc/sd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 4b26ec896a96..b12ed2c988fd 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -240,7 +240,7 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, 
unsigned int hz)
div  = 1; /* mean div = 1/4 */
sclk = hclk >> 2; /* sclk = clk / 4 */
} else {
-   div  = (hclk + ((hz << 2) - 1)) / (hz << 2);
+   div  = DIV_ROUND_UP(hclk, (hz << 2));
sclk = (hclk >> 2) / div;
}
} else if (hz >= hclk) { /* bug fix */
@@ -253,7 +253,7 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, 
unsigned int hz)
div  = 0; /* mean div = 1/2 */
sclk = hclk >> 1; /* sclk = clk / 2 */
} else {
-   div  = (hclk + ((hz << 2) - 1)) / (hz << 2);
+   div  = DIV_ROUND_UP(hclk, (hz << 2));
sclk = (hclk >> 2) / div;
}
}
-- 
2.17.1



[PATCH v3] Staging: gasket: Use DIV_ROUND_UP

2019-04-03 Thread Madhumitha Prabakaran
Use DIV_ROUND_UP in-kernel function to make code simple and more
understandable.

Issue found using Coccinelle.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v3:
- Included version no in patch

Changes in v2:
- Commit log modified
---
 drivers/staging/gasket/gasket_page_table.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index 26755d9ca41d..600928f63577 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -768,8 +768,7 @@ static bool gasket_is_extended_dev_addr_bad(struct 
gasket_page_table *pg_tbl,
page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
 
/* Get the count of affected level 0 pages. */
-   num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) /
-   GASKET_PAGES_PER_SUBTABLE;
+   num_lvl0_pages = DIV_ROUND_UP(num_pages, GASKET_PAGES_PER_SUBTABLE);
 
if (gasket_components_to_dev_address(pg_tbl, 0, page_global_idx,
 page_offset) != dev_addr) {
@@ -1258,7 +1257,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev 
*gasket_dev, u64 size,
dma_addr_t handle;
void *mem;
int j;
-   unsigned int num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+   unsigned int num_pages = DIV_ROUND_UP(size, PAGE_SIZE);
const struct gasket_driver_desc *driver_desc =
gasket_get_driver_desc(gasket_dev);
 
-- 
2.17.1



[PATCH] Staging: gasket: Use DIV_ROUND_UP

2019-04-03 Thread Madhumitha Prabakaran
Use DIV_ROUND_UP in-kernel function to make code simple and more
understandable.

Issue found using Coccinelle.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2:
- Commit log modified
---
 drivers/staging/gasket/gasket_page_table.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index 26755d9ca41d..600928f63577 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -768,8 +768,7 @@ static bool gasket_is_extended_dev_addr_bad(struct 
gasket_page_table *pg_tbl,
page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
 
/* Get the count of affected level 0 pages. */
-   num_lvl0_pages = (num_pages + GASKET_PAGES_PER_SUBTABLE - 1) /
-   GASKET_PAGES_PER_SUBTABLE;
+   num_lvl0_pages = DIV_ROUND_UP(num_pages, GASKET_PAGES_PER_SUBTABLE);
 
if (gasket_components_to_dev_address(pg_tbl, 0, page_global_idx,
 page_offset) != dev_addr) {
@@ -1258,7 +1257,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev 
*gasket_dev, u64 size,
dma_addr_t handle;
void *mem;
int j;
-   unsigned int num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+   unsigned int num_pages = DIV_ROUND_UP(size, PAGE_SIZE);
const struct gasket_driver_desc *driver_desc =
gasket_get_driver_desc(gasket_dev);
 
-- 
2.17.1