public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: make dump_chip_info() static
@ 2022-07-24 18:25 Michael Straube
  2022-07-24 18:39 ` Philipp Hortmann
  2022-07-27  6:30 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Straube @ 2022-07-24 18:25 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The function dump_chip_info() is only used in rtl8188e_hal_init.c.
Make it static to reduce the driver object file size by 281 bytes.

before:
  text    data     bss     dec     hex filename
530606   43897    7072  581575   8dfc7 drivers/staging/r8188eu/r8188eu.o

after:
  text    data     bss     dec     hex filename
530405   43817    7072  581294   8deae drivers/staging/r8188eu/r8188eu.o

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/hal_com.c         | 39 -------------------
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 39 +++++++++++++++++++
 drivers/staging/r8188eu/include/hal_com.h     |  3 --
 3 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
index e9a32dd84a8e..6a1cdc67335b 100644
--- a/drivers/staging/r8188eu/hal/hal_com.c
+++ b/drivers/staging/r8188eu/hal/hal_com.c
@@ -10,45 +10,6 @@
 
 #define _HAL_INIT_C_
 
-void dump_chip_info(struct HAL_VERSION	chip_vers)
-{
-	uint cnt = 0;
-	char buf[128];
-
-	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
-	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
-		       "Normal_Chip" : "Test_Chip");
-	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
-		       "TSMC" : "UMC");
-
-	switch (chip_vers.CUTVersion) {
-	case A_CUT_VERSION:
-		cnt += sprintf((buf + cnt), "A_CUT_");
-		break;
-	case B_CUT_VERSION:
-		cnt += sprintf((buf + cnt), "B_CUT_");
-		break;
-	case C_CUT_VERSION:
-		cnt += sprintf((buf + cnt), "C_CUT_");
-		break;
-	case D_CUT_VERSION:
-		cnt += sprintf((buf + cnt), "D_CUT_");
-		break;
-	case E_CUT_VERSION:
-		cnt += sprintf((buf + cnt), "E_CUT_");
-		break;
-	default:
-		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
-		break;
-	}
-
-	cnt += sprintf((buf + cnt), "1T1R_");
-
-	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
-
-	pr_info("%s", buf);
-}
-
 #define	CHAN_PLAN_HW	0x80
 
 u8 /* return the final channel plan decision */
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index fe477438899e..5b8f1a912bbb 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -526,6 +526,45 @@ void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf)
 	Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf);
 }
 
+static void dump_chip_info(struct HAL_VERSION chip_vers)
+{
+	uint cnt = 0;
+	char buf[128];
+
+	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
+	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
+		       "Normal_Chip" : "Test_Chip");
+	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
+		       "TSMC" : "UMC");
+
+	switch (chip_vers.CUTVersion) {
+	case A_CUT_VERSION:
+		cnt += sprintf((buf + cnt), "A_CUT_");
+		break;
+	case B_CUT_VERSION:
+		cnt += sprintf((buf + cnt), "B_CUT_");
+		break;
+	case C_CUT_VERSION:
+		cnt += sprintf((buf + cnt), "C_CUT_");
+		break;
+	case D_CUT_VERSION:
+		cnt += sprintf((buf + cnt), "D_CUT_");
+		break;
+	case E_CUT_VERSION:
+		cnt += sprintf((buf + cnt), "E_CUT_");
+		break;
+	default:
+		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
+		break;
+	}
+
+	cnt += sprintf((buf + cnt), "1T1R_");
+
+	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
+
+	pr_info("%s", buf);
+}
+
 void rtl8188e_read_chip_version(struct adapter *padapter)
 {
 	u32				value32;
diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
index 56ba356b5371..d7e333f6ce39 100644
--- a/drivers/staging/r8188eu/include/hal_com.h
+++ b/drivers/staging/r8188eu/include/hal_com.h
@@ -131,9 +131,6 @@
 #define REG_NOA_DESC_START			0x05E8
 #define REG_NOA_DESC_COUNT			0x05EC
 
-#include "HalVerDef.h"
-void dump_chip_info(struct HAL_VERSION	ChipVersion);
-
 /* return the final channel plan decision */
 u8 hal_com_get_channel_plan(struct adapter *padapter,
 			    u8 hw_channel_plan,
-- 
2.37.1


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

* Re: [PATCH] staging: r8188eu: make dump_chip_info() static
  2022-07-24 18:25 [PATCH] staging: r8188eu: make dump_chip_info() static Michael Straube
@ 2022-07-24 18:39 ` Philipp Hortmann
  2022-07-24 20:53   ` Joe Perches
  2022-07-27  6:30 ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Philipp Hortmann @ 2022-07-24 18:39 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On 7/24/22 20:25, Michael Straube wrote:
> The function dump_chip_info() is only used in rtl8188e_hal_init.c.
> Make it static to reduce the driver object file size by 281 bytes.
> 
> before:
>    text    data     bss     dec     hex filename
> 530606   43897    7072  581575   8dfc7 drivers/staging/r8188eu/r8188eu.o
> 
> after:
>    text    data     bss     dec     hex filename
> 530405   43817    7072  581294   8deae drivers/staging/r8188eu/r8188eu.o
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>   drivers/staging/r8188eu/hal/hal_com.c         | 39 -------------------
>   .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 39 +++++++++++++++++++
>   drivers/staging/r8188eu/include/hal_com.h     |  3 --
>   3 files changed, 39 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
> index e9a32dd84a8e..6a1cdc67335b 100644
> --- a/drivers/staging/r8188eu/hal/hal_com.c
> +++ b/drivers/staging/r8188eu/hal/hal_com.c
> @@ -10,45 +10,6 @@
>   
>   #define _HAL_INIT_C_
>   
> -void dump_chip_info(struct HAL_VERSION	chip_vers)
> -{
> -	uint cnt = 0;
> -	char buf[128];
> -
> -	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
> -	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
> -		       "Normal_Chip" : "Test_Chip");
> -	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
> -		       "TSMC" : "UMC");
> -
> -	switch (chip_vers.CUTVersion) {
> -	case A_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "A_CUT_");
> -		break;
> -	case B_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "B_CUT_");
> -		break;
> -	case C_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "C_CUT_");
> -		break;
> -	case D_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "D_CUT_");
> -		break;
> -	case E_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "E_CUT_");
> -		break;
> -	default:
> -		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
> -		break;
> -	}
> -
> -	cnt += sprintf((buf + cnt), "1T1R_");
> -
> -	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
> -
> -	pr_info("%s", buf);
> -}
> -
>   #define	CHAN_PLAN_HW	0x80
>   
>   u8 /* return the final channel plan decision */
> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> index fe477438899e..5b8f1a912bbb 100644
> --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> @@ -526,6 +526,45 @@ void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf)
>   	Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf);
>   }
>   
> +static void dump_chip_info(struct HAL_VERSION chip_vers)
> +{
> +	uint cnt = 0;
> +	char buf[128];
> +
> +	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
> +	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
> +		       "Normal_Chip" : "Test_Chip");
> +	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
> +		       "TSMC" : "UMC");
> +
> +	switch (chip_vers.CUTVersion) {
> +	case A_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "A_CUT_");
> +		break;
> +	case B_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "B_CUT_");
> +		break;
> +	case C_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "C_CUT_");
> +		break;
> +	case D_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "D_CUT_");
> +		break;
> +	case E_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "E_CUT_");
> +		break;
> +	default:
> +		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
> +		break;
> +	}
> +
> +	cnt += sprintf((buf + cnt), "1T1R_");
> +
> +	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
> +
> +	pr_info("%s", buf);
> +}
> +
>   void rtl8188e_read_chip_version(struct adapter *padapter)
>   {
>   	u32				value32;
> diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
> index 56ba356b5371..d7e333f6ce39 100644
> --- a/drivers/staging/r8188eu/include/hal_com.h
> +++ b/drivers/staging/r8188eu/include/hal_com.h
> @@ -131,9 +131,6 @@
>   #define REG_NOA_DESC_START			0x05E8
>   #define REG_NOA_DESC_COUNT			0x05EC
>   
> -#include "HalVerDef.h"
> -void dump_chip_info(struct HAL_VERSION	ChipVersion);
> -
>   /* return the final channel plan decision */
>   u8 hal_com_get_channel_plan(struct adapter *padapter,
>   			    u8 hw_channel_plan,

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

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

* Re: [PATCH] staging: r8188eu: make dump_chip_info() static
  2022-07-24 18:39 ` Philipp Hortmann
@ 2022-07-24 20:53   ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2022-07-24 20:53 UTC (permalink / raw)
  To: Philipp Hortmann, Michael Straube, gregkh
  Cc: Larry.Finger, phil, linux-staging, linux-kernel

On Sun, 2022-07-24 at 20:39 +0200, Philipp Hortmann wrote:
> On 7/24/22 20:25, Michael Straube wrote:
> > The function dump_chip_info() is only used in rtl8188e_hal_init.c.
> > Make it static to reduce the driver object file size by 281 bytes.
> > 
> > before:
> >    text    data     bss     dec     hex filename
> > 530606   43897    7072  581575   8dfc7 drivers/staging/r8188eu/r8188eu.o
> > 
> > after:
> >    text    data     bss     dec     hex filename
> > 530405   43817    7072  581294   8deae drivers/staging/r8188eu/r8188eu.o
[]
> > diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
[]
> > @@ -526,6 +526,45 @@ void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf)
> >   	Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf);
> >   }
> >   
> > +static void dump_chip_info(struct HAL_VERSION chip_vers)
> > +{
> > +	uint cnt = 0;
> > +	char buf[128];
> > +
> > +	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
> > +	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
> > +		       "Normal_Chip" : "Test_Chip");
> > +	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
> > +		       "TSMC" : "UMC");
> > +
> > +	switch (chip_vers.CUTVersion) {
> > +	case A_CUT_VERSION:
> > +		cnt += sprintf((buf + cnt), "A_CUT_");
> > +		break;
> > +	case B_CUT_VERSION:
> > +		cnt += sprintf((buf + cnt), "B_CUT_");
> > +		break;
> > +	case C_CUT_VERSION:
> > +		cnt += sprintf((buf + cnt), "C_CUT_");
> > +		break;
> > +	case D_CUT_VERSION:
> > +		cnt += sprintf((buf + cnt), "D_CUT_");
> > +		break;
> > +	case E_CUT_VERSION:
> > +		cnt += sprintf((buf + cnt), "E_CUT_");
> > +		break;
> > +	default:
> > +		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
> > +		break;
> > +	}
> > +
> > +	cnt += sprintf((buf + cnt), "1T1R_");
> > +
> > +	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
> > +
> > +	pr_info("%s", buf);
> > +}

Probably better and likely smaller without the temporary buffer
and the possibility of overrun.

Something like:

{
	char cut[25];
	char *v = NULL;

	switch (chip_vers.CUTVersion) {
	case A_CUT_VERSION:
		v = "A_CUT";
		break;
	case B_CUT_VERSION:
		v = "B_CUT";
		break;
	case C_CUT_VERSION:
		v = "C_CUT";
		break;
	case D_CUT_VERSION:
		v = "D_CUT";
		break;
	case E_CUT_VERSION:
		v = "E_CUT";
		break;
	default:
		snprintf(cut, sizeof(cut), "UNKNOWN_CUT(%d)", chip_vers.CUTVersion);
		v = cut;
		break;
	}
	
	pr_info("Chip Version Info: CHIP_8188E_%s__Chip_%s_%s_1T1R_RomVer(%d)\n",
		IS_NORMAL_CHIP(chip_vers) ? "Normal" : "Test",
		IS_CHIP_VENDOR_TSMC(chip_vers) ? "TSMC" : "UMC",
		v, 0);
}


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

* Re: [PATCH] staging: r8188eu: make dump_chip_info() static
  2022-07-24 18:25 [PATCH] staging: r8188eu: make dump_chip_info() static Michael Straube
  2022-07-24 18:39 ` Philipp Hortmann
@ 2022-07-27  6:30 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-07-27  6:30 UTC (permalink / raw)
  To: Michael Straube; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On Sun, Jul 24, 2022 at 08:25:20PM +0200, Michael Straube wrote:
> The function dump_chip_info() is only used in rtl8188e_hal_init.c.
> Make it static to reduce the driver object file size by 281 bytes.
> 
> before:
>   text    data     bss     dec     hex filename
> 530606   43897    7072  581575   8dfc7 drivers/staging/r8188eu/r8188eu.o
> 
> after:
>   text    data     bss     dec     hex filename
> 530405   43817    7072  581294   8deae drivers/staging/r8188eu/r8188eu.o
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>  drivers/staging/r8188eu/hal/hal_com.c         | 39 -------------------
>  .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 39 +++++++++++++++++++
>  drivers/staging/r8188eu/include/hal_com.h     |  3 --
>  3 files changed, 39 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
> index e9a32dd84a8e..6a1cdc67335b 100644
> --- a/drivers/staging/r8188eu/hal/hal_com.c
> +++ b/drivers/staging/r8188eu/hal/hal_com.c
> @@ -10,45 +10,6 @@
>  
>  #define _HAL_INIT_C_
>  
> -void dump_chip_info(struct HAL_VERSION	chip_vers)
> -{
> -	uint cnt = 0;
> -	char buf[128];
> -
> -	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
> -	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
> -		       "Normal_Chip" : "Test_Chip");
> -	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
> -		       "TSMC" : "UMC");
> -
> -	switch (chip_vers.CUTVersion) {
> -	case A_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "A_CUT_");
> -		break;
> -	case B_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "B_CUT_");
> -		break;
> -	case C_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "C_CUT_");
> -		break;
> -	case D_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "D_CUT_");
> -		break;
> -	case E_CUT_VERSION:
> -		cnt += sprintf((buf + cnt), "E_CUT_");
> -		break;
> -	default:
> -		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
> -		break;
> -	}
> -
> -	cnt += sprintf((buf + cnt), "1T1R_");
> -
> -	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
> -
> -	pr_info("%s", buf);
> -}
> -
>  #define	CHAN_PLAN_HW	0x80
>  
>  u8 /* return the final channel plan decision */
> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> index fe477438899e..5b8f1a912bbb 100644
> --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> @@ -526,6 +526,45 @@ void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf)
>  	Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf);
>  }
>  
> +static void dump_chip_info(struct HAL_VERSION chip_vers)
> +{
> +	uint cnt = 0;
> +	char buf[128];
> +
> +	cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_");
> +	cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
> +		       "Normal_Chip" : "Test_Chip");
> +	cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
> +		       "TSMC" : "UMC");
> +
> +	switch (chip_vers.CUTVersion) {
> +	case A_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "A_CUT_");
> +		break;
> +	case B_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "B_CUT_");
> +		break;
> +	case C_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "C_CUT_");
> +		break;
> +	case D_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "D_CUT_");
> +		break;
> +	case E_CUT_VERSION:
> +		cnt += sprintf((buf + cnt), "E_CUT_");
> +		break;
> +	default:
> +		cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion);
> +		break;
> +	}
> +
> +	cnt += sprintf((buf + cnt), "1T1R_");
> +
> +	cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0);
> +
> +	pr_info("%s", buf);

Nit, none of this should be sent to the kernel log if all is good.  When
drivers are working properly, they are quiet.  This is spamming the
kernel log for when things are working properly, which just slows
booting down.

Also no driver should be calling pr_*() calls when they have a real
device at hand.

So this should be moved to be a dev_dbg() so that developers can still
enable it when they want to see this information, but it doesn't spam
the log for normal users.  But that's all for a future change, this one
is fine as-is, I'll take it now, thanks.

greg k-h

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

end of thread, other threads:[~2022-07-27  6:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-24 18:25 [PATCH] staging: r8188eu: make dump_chip_info() static Michael Straube
2022-07-24 18:39 ` Philipp Hortmann
2022-07-24 20:53   ` Joe Perches
2022-07-27  6:30 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox