public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
@ 2021-08-26 18:43 Joe Perches
  2021-08-26 18:43 ` [PATCH 2/5] scsi: aacraid: Use vsprintf %phNX extension Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Joe Perches @ 2021-08-26 18:43 UTC (permalink / raw)
  To: Andy Shevchenko, Rasmus Villemoes, linux-scsi, storagedev
  Cc: linux-doc, linux-kernel, linux-staging

Several sysfs uses that could use %*ph are upper case hex output.
Add a flag to the short hex formatting routine in vsprintf to support them.
Add documentation too.

Joe Perches (5):
  vsprintf/Documentation: Add X to %*ph extension to output upper case hex
  scsi: aacraid: Use vsprintf %phNX extension
  scsi: hpsa: Use vsprintf %phNX extension
  scsi: smartpqi: Use vsprintf %phNX extension
  staging: r8188eu: Use vsprintf extension %phCX to format a copy_to_user string

 Documentation/core-api/printk-formats.rst    |  6 +++
 drivers/scsi/aacraid/linit.c                 |  7 +---
 drivers/scsi/hpsa.c                          |  8 +---
 drivers/scsi/smartpqi/smartpqi_init.c        |  8 +---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c |  9 ++---
 lib/vsprintf.c                               | 42 ++++++++++++--------
 6 files changed, 37 insertions(+), 43 deletions(-)

-- 
2.30.0


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

* [PATCH 2/5] scsi: aacraid: Use vsprintf %phNX extension
  2021-08-26 18:43 [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Joe Perches
@ 2021-08-26 18:43 ` Joe Perches
  2021-08-26 18:43 ` [PATCH 3/5] scsi: hpsa: " Joe Perches
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2021-08-26 18:43 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

Reduce object size by using the %phNX extension to format a sysfs output
buffer with identical output.

compiled x86-64 defconfig w/ aacraid and gcc 10.3.0

$ size drivers/scsi/aacraid/linit.o*
   text	   data	    bss	    dec	    hex	filename
  18616	   4056	      0	  22672	   5890	drivers/scsi/aacraid/linit.o.new
  18951	   4056	      0	  23007	   59df	drivers/scsi/aacraid/linit.o.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/scsi/aacraid/linit.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 3168915adaa75..165e6e10f07b9 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -587,12 +587,7 @@ static ssize_t aac_show_unique_id(struct device *dev,
 	if (sdev_channel(sdev) == CONTAINER_CHANNEL)
 		memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn));
 
-	return snprintf(buf, 16 * 2 + 2,
-		"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
-		sn[0], sn[1], sn[2], sn[3],
-		sn[4], sn[5], sn[6], sn[7],
-		sn[8], sn[9], sn[10], sn[11],
-		sn[12], sn[13], sn[14], sn[15]);
+	return snprintf(buf, 16 * 2 + 2, "%16phNX\n", sn);
 }
 
 static struct device_attribute aac_unique_id_attr = {
-- 
2.30.0


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

* [PATCH 3/5] scsi: hpsa: Use vsprintf %phNX extension
  2021-08-26 18:43 [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Joe Perches
  2021-08-26 18:43 ` [PATCH 2/5] scsi: aacraid: Use vsprintf %phNX extension Joe Perches
@ 2021-08-26 18:43 ` Joe Perches
  2021-08-26 18:43 ` [PATCH 4/5] scsi: smartpqi: " Joe Perches
  2021-08-27  7:51 ` [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Andy Shevchenko
  3 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2021-08-26 18:43 UTC (permalink / raw)
  To: Don Brace, James E.J. Bottomley, Martin K. Petersen
  Cc: storagedev, linux-scsi, linux-kernel

Reduce object size by using the %phNX extension to format a sysfs output
buffer with identical output.

compiled x86-64 defconfig w/ hpsa and gcc 10.3.0

$ size drivers/scsi/hpsa.o*
   text	   data	    bss	    dec	    hex	filename
  84041	   2181	     20	  86242	  150e2	drivers/scsi/hpsa.o.new
  84226	   2181	     20	  86427	  1519b	drivers/scsi/hpsa.o.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/scsi/hpsa.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3faa87fa296a2..c56871e8ce1b7 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -743,13 +743,7 @@ static ssize_t unique_id_show(struct device *dev,
 	}
 	memcpy(sn, hdev->device_id, sizeof(sn));
 	spin_unlock_irqrestore(&h->lock, flags);
-	return snprintf(buf, 16 * 2 + 2,
-			"%02X%02X%02X%02X%02X%02X%02X%02X"
-			"%02X%02X%02X%02X%02X%02X%02X%02X\n",
-			sn[0], sn[1], sn[2], sn[3],
-			sn[4], sn[5], sn[6], sn[7],
-			sn[8], sn[9], sn[10], sn[11],
-			sn[12], sn[13], sn[14], sn[15]);
+	return snprintf(buf, 16 * 2 + 2, "%16phNX\n", sn);
 }
 
 static ssize_t sas_address_show(struct device *dev,
-- 
2.30.0


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

* [PATCH 4/5] scsi: smartpqi: Use vsprintf %phNX extension
  2021-08-26 18:43 [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Joe Perches
  2021-08-26 18:43 ` [PATCH 2/5] scsi: aacraid: Use vsprintf %phNX extension Joe Perches
  2021-08-26 18:43 ` [PATCH 3/5] scsi: hpsa: " Joe Perches
@ 2021-08-26 18:43 ` Joe Perches
  2021-08-27  7:51 ` [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Andy Shevchenko
  3 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2021-08-26 18:43 UTC (permalink / raw)
  To: Don Brace
  Cc: James E.J. Bottomley, Martin K. Petersen, storagedev, linux-scsi,
	linux-kernel

Reduce object size by using the %phNX extension to format a sysfs output
buffer with identical output.

compiled x86-64 defconfig w/ smartpqi and gcc 10.3.0

$ size drivers/scsi/smartpqi/smartpqi_init.o*
   text	   data	    bss	    dec	    hex	filename
  69791	   2205	     48	  72044	  1196c	drivers/scsi/smartpqi/smartpqi_init.o.new
  69950	   2205	     48	  72203	  11a0b	drivers/scsi/smartpqi/smartpqi_init.o.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ecb2af3f43ca3..eb39490b196cc 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6674,13 +6674,7 @@ static ssize_t pqi_unique_id_show(struct device *dev,
 
 	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 
-	return scnprintf(buffer, PAGE_SIZE,
-		"%02X%02X%02X%02X%02X%02X%02X%02X"
-		"%02X%02X%02X%02X%02X%02X%02X%02X\n",
-		unique_id[0], unique_id[1], unique_id[2], unique_id[3],
-		unique_id[4], unique_id[5], unique_id[6], unique_id[7],
-		unique_id[8], unique_id[9], unique_id[10], unique_id[11],
-		unique_id[12], unique_id[13], unique_id[14], unique_id[15]);
+	return scnprintf(buffer, PAGE_SIZE, "%16phNX\n", unique_id);
 }
 
 static ssize_t pqi_lunid_show(struct device *dev,
-- 
2.30.0


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

* Re: [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
  2021-08-26 18:43 [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Joe Perches
                   ` (2 preceding siblings ...)
  2021-08-26 18:43 ` [PATCH 4/5] scsi: smartpqi: " Joe Perches
@ 2021-08-27  7:51 ` Andy Shevchenko
  2021-08-27  8:10   ` Joe Perches
  3 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2021-08-27  7:51 UTC (permalink / raw)
  To: Joe Perches
  Cc: Rasmus Villemoes, linux-scsi, storagedev, linux-doc, linux-kernel,
	linux-staging

On Thu, Aug 26, 2021 at 11:43:00AM -0700, Joe Perches wrote:
> Several sysfs uses that could use %*ph are upper case hex output.
> Add a flag to the short hex formatting routine in vsprintf to support them.
> Add documentation too.

Thanks!

Unfortunately I have got only first patch and this cover letter. Can you,
please, Cc entire series?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
  2021-08-27  7:51 ` [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Andy Shevchenko
@ 2021-08-27  8:10   ` Joe Perches
  2021-08-27  8:46     ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Joe Perches @ 2021-08-27  8:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rasmus Villemoes, linux-scsi, storagedev, linux-doc, linux-kernel,
	linux-staging

On Fri, 2021-08-27 at 10:51 +0300, Andy Shevchenko wrote:
> On Thu, Aug 26, 2021 at 11:43:00AM -0700, Joe Perches wrote:
> > Several sysfs uses that could use %*ph are upper case hex output.
> > Add a flag to the short hex formatting routine in vsprintf to support them.
> > Add documentation too.
> 
> Thanks!
> 
> Unfortunately I have got only first patch and this cover letter. Can you,
> please, Cc entire series?

It's on lore.

https://lore.kernel.org/lkml/cover.1630003183.git.joe@perches.com/T/#u
 



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

* Re: [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
  2021-08-27  8:10   ` Joe Perches
@ 2021-08-27  8:46     ` Andy Shevchenko
  2021-08-27 10:23       ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2021-08-27  8:46 UTC (permalink / raw)
  To: Joe Perches
  Cc: Rasmus Villemoes, linux-scsi, storagedev, linux-doc, linux-kernel,
	linux-staging

On Fri, Aug 27, 2021 at 01:10:41AM -0700, Joe Perches wrote:
> On Fri, 2021-08-27 at 10:51 +0300, Andy Shevchenko wrote:
> > On Thu, Aug 26, 2021 at 11:43:00AM -0700, Joe Perches wrote:
> > > Several sysfs uses that could use %*ph are upper case hex output.
> > > Add a flag to the short hex formatting routine in vsprintf to support them.
> > > Add documentation too.
> >
> > Thanks!
> >
> > Unfortunately I have got only first patch and this cover letter. Can you,
> > please, Cc entire series?
> 
> It's on lore.
> 
> https://lore.kernel.org/lkml/cover.1630003183.git.joe@perches.com/T/#u

Thanks. So, you won't me to review them in a regular way :-)

TBH, I think those examples may pretty much be safe to use small
letters always.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
  2021-08-27  8:46     ` Andy Shevchenko
@ 2021-08-27 10:23       ` Greg KH
  2021-08-27 16:09         ` Joe Perches
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2021-08-27 10:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Joe Perches, Rasmus Villemoes, linux-scsi, storagedev, linux-doc,
	linux-kernel, linux-staging

On Fri, Aug 27, 2021 at 11:46:20AM +0300, Andy Shevchenko wrote:
> On Fri, Aug 27, 2021 at 01:10:41AM -0700, Joe Perches wrote:
> > On Fri, 2021-08-27 at 10:51 +0300, Andy Shevchenko wrote:
> > > On Thu, Aug 26, 2021 at 11:43:00AM -0700, Joe Perches wrote:
> > > > Several sysfs uses that could use %*ph are upper case hex output.
> > > > Add a flag to the short hex formatting routine in vsprintf to support them.
> > > > Add documentation too.
> > >
> > > Thanks!
> > >
> > > Unfortunately I have got only first patch and this cover letter. Can you,
> > > please, Cc entire series?
> > 
> > It's on lore.
> > 
> > https://lore.kernel.org/lkml/cover.1630003183.git.joe@perches.com/T/#u
> 
> Thanks. So, you won't me to review them in a regular way :-)
> 
> TBH, I think those examples may pretty much be safe to use small
> letters always.

I agree, let's just fix the users here to use small letters instead of
adding another modifier to the kernel.

thanks,

greg k-h

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

* Re: [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension
  2021-08-27 10:23       ` Greg KH
@ 2021-08-27 16:09         ` Joe Perches
  0 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2021-08-27 16:09 UTC (permalink / raw)
  To: Greg KH, Andy Shevchenko
  Cc: Rasmus Villemoes, linux-scsi, storagedev, linux-doc, linux-kernel,
	linux-staging

On Fri, 2021-08-27 at 12:23 +0200, Greg KH wrote:
> On Fri, Aug 27, 2021 at 11:46:20AM +0300, Andy Shevchenko wrote:
> > On Fri, Aug 27, 2021 at 01:10:41AM -0700, Joe Perches wrote:
> > > On Fri, 2021-08-27 at 10:51 +0300, Andy Shevchenko wrote:
> > > > On Thu, Aug 26, 2021 at 11:43:00AM -0700, Joe Perches wrote:
> > > > > Several sysfs uses that could use %*ph are upper case hex output.
> > > > > Add a flag to the short hex formatting routine in vsprintf to support them.
> > > > > Add documentation too.
> > > > 
> > > > Thanks!
> > > > 
> > > > Unfortunately I have got only first patch and this cover letter. Can you,
> > > > please, Cc entire series?
> > > 
> > > It's on lore.
> > > 
> > > https://lore.kernel.org/lkml/cover.1630003183.git.joe@perches.com/T/#u
> > 
> > Thanks. So, you won't me to review them in a regular way :-)
> > 
> > TBH, I think those examples may pretty much be safe to use small
> > letters always.
> 
> I agree, let's just fix the users here to use small letters instead of
> adding another modifier to the kernel.

ABI _should_ mean stability for random parsers.

I don't use these so I don't care that much.


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

end of thread, other threads:[~2021-08-27 16:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-26 18:43 [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Joe Perches
2021-08-26 18:43 ` [PATCH 2/5] scsi: aacraid: Use vsprintf %phNX extension Joe Perches
2021-08-26 18:43 ` [PATCH 3/5] scsi: hpsa: " Joe Perches
2021-08-26 18:43 ` [PATCH 4/5] scsi: smartpqi: " Joe Perches
2021-08-27  7:51 ` [PATCH 0/5] vsprintf and uses: Add upper case output to %*ph extension Andy Shevchenko
2021-08-27  8:10   ` Joe Perches
2021-08-27  8:46     ` Andy Shevchenko
2021-08-27 10:23       ` Greg KH
2021-08-27 16:09         ` Joe Perches

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