linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8188eu: Removed a function and coded inline
@ 2018-08-18 19:06 Bhaskar Singh
  2018-08-20  9:35 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Bhaskar Singh @ 2018-08-18 19:06 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, gregkh, bhaskar.kernel

This patch removed function named rtw_malloc2d.

I removed this function because this function is used exactly once and
function call have some overhead also.

Maybe this will improve code runtime slightly.

Signed-off-by: Bhaskar Singh <bhaskar.kernel@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c        | 10 +++++++++-
 drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
 drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 14 --------------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 0fd306a808c4..befc99c197b1 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -86,12 +86,20 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	u16	**eFuseWord = NULL;
 	u16	efuse_utilized = 0;
 	u8 u1temp = 0;
+	int z;
+	void **a = NULL;
 
 	efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
 	if (!efuseTbl)
 		return;
 
-	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
+	a = kzalloc(EFUSE_MAX_SECTION_88E * sizeof(void *) + EFUSE_MAX_SECTION_88E * EFUSE_MAX_WORD_UNIT * sizeof(u16), GFP_KERNEL);
+	if (!a)
+		goto out;
+	for (z = 0; z < EFUSE_MAX_SECTION_88E; z++)
+		a[z] = ((char *)(a + EFUSE_MAX_SECTION_88E)) + z * EFUSE_MAX_WORD_UNIT * sizeof(u16);
+out:
+	eFuseWord = (u16 **)a;
 	if (!eFuseWord) {
 		DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
 		goto eFuseWord_failed;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index fbcba79a0927..cfe5698fbbb1 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -64,8 +64,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
 u8 *_rtw_malloc(u32 sz);
 #define rtw_malloc(sz)			_rtw_malloc((sz))
 
-void *rtw_malloc2d(int h, int w, int size);
-
 void _rtw_init_queue(struct __queue *pqueue);
 
 struct rtw_netdev_priv_indicator {
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 78daef6704ac..105f3f21bdea 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -18,20 +18,6 @@ u8 *_rtw_malloc(u32 sz)
 	return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
 }
 
-void *rtw_malloc2d(int h, int w, int size)
-{
-	int j;
-	void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
-
-	if (!a)
-		goto out;
-
-	for (j = 0; j < h; j++)
-		a[j] = ((char *)(a + h)) + j * w * size;
-out:
-	return a;
-}
-
 void _rtw_init_queue(struct __queue *pqueue)
 {
 	INIT_LIST_HEAD(&pqueue->queue);
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: rtl8188eu: Removed a function and coded inline
  2018-08-18 19:06 [PATCH] staging: rtl8188eu: Removed a function and coded inline Bhaskar Singh
@ 2018-08-20  9:35 ` Dan Carpenter
  2018-08-20 16:03   ` Bhaskar Singh
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-08-20  9:35 UTC (permalink / raw)
  To: Bhaskar Singh; +Cc: devel, gregkh, linux-kernel

On Sun, Aug 19, 2018 at 12:36:40AM +0530, Bhaskar Singh wrote:
> This patch removed function named rtw_malloc2d.
> 
> I removed this function because this function is used exactly once and
> function call have some overhead also.
> 
> Maybe this will improve code runtime slightly.
> 
> Signed-off-by: Bhaskar Singh <bhaskar.kernel@gmail.com>
> ---
>  drivers/staging/rtl8188eu/core/rtw_efuse.c        | 10 +++++++++-
>  drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
>  drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 14 --------------
>  3 files changed, 9 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> index 0fd306a808c4..befc99c197b1 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> @@ -86,12 +86,20 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
>  	u16	**eFuseWord = NULL;
>  	u16	efuse_utilized = 0;
>  	u8 u1temp = 0;
> +	int z;

z is unusual name for an iterator.  Does it stand for something?  Just
use "int i;".

> +	void **a = NULL;

What does "a" mean in this context?  Maybe just say "void **tmp;"

>  
>  	efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
>  	if (!efuseTbl)
>  		return;
>  
> -	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
> +	a = kzalloc(EFUSE_MAX_SECTION_88E * sizeof(void *) + EFUSE_MAX_SECTION_88E * EFUSE_MAX_WORD_UNIT * sizeof(u16), GFP_KERNEL);
> +	if (!a)
> +		goto out;


You can simplify the math a bit:

	tmp = kzalloc(EFUSE_MAX_SECTION_88E * (sizeof(void *) + EFUSE_MAX_WORD_UNIT * sizeof(u16)), GFP_KERNEL);

Then if it fails:

	if (!tmp)
		goto eFuseWord_failed;


regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: rtl8188eu: Removed a function and coded inline
  2018-08-20  9:35 ` Dan Carpenter
@ 2018-08-20 16:03   ` Bhaskar Singh
  0 siblings, 0 replies; 3+ messages in thread
From: Bhaskar Singh @ 2018-08-20 16:03 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-kernel

On Mon, Aug 20, 2018 at 12:35:46PM +0300, Dan Carpenter wrote:
> On Sun, Aug 19, 2018 at 12:36:40AM +0530, Bhaskar Singh wrote:
> > This patch removed function named rtw_malloc2d.
> > 
> > I removed this function because this function is used exactly once and
> > function call have some overhead also.
> > 
> > Maybe this will improve code runtime slightly.
> > 
> > Signed-off-by: Bhaskar Singh <bhaskar.kernel@gmail.com>
> > ---
> >  drivers/staging/rtl8188eu/core/rtw_efuse.c        | 10 +++++++++-
> >  drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
> >  drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 14 --------------
> >  3 files changed, 9 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> > index 0fd306a808c4..befc99c197b1 100644
> > --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
> > +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
> > @@ -86,12 +86,20 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
> >  	u16	**eFuseWord = NULL;
> >  	u16	efuse_utilized = 0;
> >  	u8 u1temp = 0;
> > +	int z;
> 
> z is unusual name for an iterator.  Does it stand for something?  Just
> use "int i;".
> 
> > +	void **a = NULL;
> 
> What does "a" mean in this context?  Maybe just say "void **tmp;"
> 
> >  
> >  	efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
> >  	if (!efuseTbl)
> >  		return;
> >  
> > -	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
> > +	a = kzalloc(EFUSE_MAX_SECTION_88E * sizeof(void *) + EFUSE_MAX_SECTION_88E * EFUSE_MAX_WORD_UNIT * sizeof(u16), GFP_KERNEL);
> > +	if (!a)
> > +		goto out;
> 
> 
> You can simplify the math a bit:
> 
> 	tmp = kzalloc(EFUSE_MAX_SECTION_88E * (sizeof(void *) + EFUSE_MAX_WORD_UNIT * sizeof(u16)), GFP_KERNEL);
> 
> Then if it fails:
> 
> 	if (!tmp)
> 		goto eFuseWord_failed;
> 
> 
> regards,
> dan carpenter
>

Here I have modified 3 files but after seeing comments of Dan Carpenter
I have edited one file. What to do with those 2 files which I haven't
modified while sending 2nd version of this patch because all three file
combinedly making one logical change.
I apologies, if this is not the right place for asking this type of questions

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-20 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18 19:06 [PATCH] staging: rtl8188eu: Removed a function and coded inline Bhaskar Singh
2018-08-20  9:35 ` Dan Carpenter
2018-08-20 16:03   ` Bhaskar Singh

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).