LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: rtl8712: Move similar execution in to a function.
@ 2021-09-05 18:45 Saurav Girepunje
2021-09-06 9:45 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Saurav Girepunje @ 2021-09-05 18:45 UTC (permalink / raw)
To: Larry.Finger, florian.c.schilhabel, gregkh, fmdefrancesco,
saurav.girepunje, linux-staging, linux-kernel
Cc: saurav.girepunje
Move the common execution for read_macreg_hdl, write_macreg_hdl,
write_bbreg_hdl and write_rfreg_hdl in to a new function
common_read_write_hdl.
Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
---
drivers/staging/rtl8712/rtl8712_cmd.c | 41 +++++++--------------------
1 file changed, 11 insertions(+), 30 deletions(-)
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c
index e9294e1ed06e..9bc0588be04b 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -117,9 +117,9 @@ static void r871x_internal_cmd_hdl(struct _adapter *padapter, u8 *pbuf)
kfree(pdrvcmd->pbuf);
}
-static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
+static u8 common_read_write_hdl(struct _adapter *padapter, u8 *pbuf)
{
- void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
/* invoke cmd->callback function */
@@ -129,20 +129,17 @@ static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
+
}
-static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
+static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
- void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
- struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+ return common_read_write_hdl(padapter, pbuf);
+}
- /* invoke cmd->callback function */
- pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
- if (!pcmd_callback)
- r8712_free_cmd_obj(pcmd);
- else
- pcmd_callback(padapter, pcmd);
- return H2C_SUCCESS;
+static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ return common_read_write_hdl(padapter, pbuf);
}
static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
@@ -155,15 +152,7 @@ static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
static u8 write_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
- void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
- struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
-
- pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
- if (!pcmd_callback)
- r8712_free_cmd_obj(pcmd);
- else
- pcmd_callback(padapter, pcmd);
- return H2C_SUCCESS;
+ return common_read_write_hdl(padapter, pbuf);
}
static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
@@ -184,15 +173,7 @@ static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
- void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
- struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
-
- pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
- if (!pcmd_callback)
- r8712_free_cmd_obj(pcmd);
- else
- pcmd_callback(padapter, pcmd);
- return H2C_SUCCESS;
+ return common_read_write_hdl(padapter, pbuf);
}
static u8 sys_suspend_hdl(struct _adapter *padapter, u8 *pbuf)
--
2.32.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8712: Move similar execution in to a function.
2021-09-05 18:45 [PATCH] staging: rtl8712: Move similar execution in to a function Saurav Girepunje
@ 2021-09-06 9:45 ` Greg KH
2021-09-06 16:50 ` Saurav Girepunje
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-09-06 9:45 UTC (permalink / raw)
To: Saurav Girepunje
Cc: Larry.Finger, florian.c.schilhabel, fmdefrancesco, linux-staging,
linux-kernel, saurav.girepunje
On Mon, Sep 06, 2021 at 12:15:57AM +0530, Saurav Girepunje wrote:
> Move the common execution for read_macreg_hdl, write_macreg_hdl,
> write_bbreg_hdl and write_rfreg_hdl in to a new function
> common_read_write_hdl.
You said _what_ you did here, but not _why_ you did this.
I can't easily see why you did this, please explain it better in the
next version of this patch.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8712: Move similar execution in to a function.
2021-09-06 9:45 ` Greg KH
@ 2021-09-06 16:50 ` Saurav Girepunje
0 siblings, 0 replies; 3+ messages in thread
From: Saurav Girepunje @ 2021-09-06 16:50 UTC (permalink / raw)
To: Greg KH
Cc: saurav.girepunje, Larry.Finger, florian.c.schilhabel,
fmdefrancesco, linux-staging, linux-kernel
On 06/09/21 3:15 pm, Greg KH wrote:
> On Mon, Sep 06, 2021 at 12:15:57AM +0530, Saurav Girepunje wrote:
>> Move the common execution for read_macreg_hdl, write_macreg_hdl,
>> write_bbreg_hdl and write_rfreg_hdl in to a new function
>> common_read_write_hdl.
>
> You said _what_ you did here, but not _why_ you did this.
>
> I can't easily see why you did this, please explain it better in the
> next version of this patch.
>
> thanks,
>
> greg k-h
>
Ok, I will add explanation and send next version.
Thanks for review greg.
Regards,
Saurav Girepunje
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-06 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-05 18:45 [PATCH] staging: rtl8712: Move similar execution in to a function Saurav Girepunje
2021-09-06 9:45 ` Greg KH
2021-09-06 16:50 ` Saurav Girepunje
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).