public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: altera-stapl: Replace sprintf with hex_asc_lo for hex conversion
@ 2026-03-26 17:32 aravindanilraj0702
  2026-04-02 14:23 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: aravindanilraj0702 @ 2026-03-26 17:32 UTC (permalink / raw)
  To: gregkh, arnd; +Cc: linux-kernel, Aravind Anilraj

From: Aravind Anilraj <aravindanilraj0702@gmail.com>

Replace sprintf() calls used to format single hex digits with direct
assignment using hex_asc_lo().This avoids unnecessary overhead
from using sprintf for single character output.

No functional changes.

Signed-off-by: Aravind Anilraj <aravindanilraj0702@gmail.com>
---
 drivers/misc/altera-stapl/altera.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c
index 4fa6c90624e5..4352bfb80043 100644
--- a/drivers/misc/altera-stapl/altera.c
+++ b/drivers/misc/altera-stapl/altera.c
@@ -8,7 +8,7 @@
  * Copyright (C) 2010,2011 NetUP Inc.
  * Copyright (C) 2010,2011 Igor M. Liplianin <liplianin@netup.ru>
  */
-
+#include <linux/hex.h>
 #include <linux/unaligned.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
@@ -167,13 +167,13 @@ static void altera_export_bool_array(char *key, u8 *data, s32 count)
 				if (data[i >> 3] & (1 << (i & 7)))
 					value |= (1 << (i & 3));
 				if ((i & 3) == 3) {
-					sprintf(&string[j], "%1x", value);
+					string[j] = hex_asc_lo(value);
 					value = 0;
 					--j;
 				}
 			}
 			if ((k & 3) > 0)
-				sprintf(&string[j], "%1x", value);
+				string[j] = hex_asc_lo(value);
 
 			dprintk("%s\n", string);
 		}
@@ -188,13 +188,13 @@ static void altera_export_bool_array(char *key, u8 *data, s32 count)
 			if (data[i >> 3] & (1 << (i & 7)))
 				value |= (1 << (i & 3));
 			if ((i & 3) == 3) {
-				sprintf(&string[j], "%1x", value);
+				string[j] = hex_asc_lo(value);
 				value = 0;
 				--j;
 			}
 		}
 		if ((i & 3) > 0)
-			sprintf(&string[j], "%1x", value);
+			string[j] = hex_asc_lo(value);
 
 		dprintk("Export: key = \"%s\", %d bits, value = HEX %s\n",
 			key, count, string);
-- 
2.47.3


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

* Re: [PATCH] misc: altera-stapl: Replace sprintf with hex_asc_lo for hex conversion
  2026-03-26 17:32 [PATCH] misc: altera-stapl: Replace sprintf with hex_asc_lo for hex conversion aravindanilraj0702
@ 2026-04-02 14:23 ` Greg KH
  2026-04-02 15:42   ` Aravind
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2026-04-02 14:23 UTC (permalink / raw)
  To: aravindanilraj0702; +Cc: arnd, linux-kernel

On Thu, Mar 26, 2026 at 01:32:57PM -0400, aravindanilraj0702@gmail.com wrote:
> From: Aravind Anilraj <aravindanilraj0702@gmail.com>
> 
> Replace sprintf() calls used to format single hex digits with direct
> assignment using hex_asc_lo().This avoids unnecessary overhead
> from using sprintf for single character output.
> 
> No functional changes.

Nah, this driver is so old, let's just leave it alone wherever possible,
unless you have the hardware to actually test your changes?

thanks,

greg k-h

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

* Re: [PATCH] misc: altera-stapl: Replace sprintf with hex_asc_lo for hex conversion
  2026-04-02 14:23 ` Greg KH
@ 2026-04-02 15:42   ` Aravind
  0 siblings, 0 replies; 3+ messages in thread
From: Aravind @ 2026-04-02 15:42 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel

Heya greg,

Thanks for the feedback.

I thought I had the hardware to test the change but it ain't the one.
So I am dropping the patch for now.

Appreciate the guidance.

Thanks,
Aravind


On Thu, Apr 2, 2026 at 7:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Thu, Mar 26, 2026 at 01:32:57PM -0400, aravindanilraj0702@gmail.com wrote:
> > From: Aravind Anilraj <aravindanilraj0702@gmail.com>
> >
> > Replace sprintf() calls used to format single hex digits with direct
> > assignment using hex_asc_lo().This avoids unnecessary overhead
> > from using sprintf for single character output.
> >
> > No functional changes.
>
> Nah, this driver is so old, let's just leave it alone wherever possible,
> unless you have the hardware to actually test your changes?
>
> thanks,
>
> greg k-h

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

end of thread, other threads:[~2026-04-02 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 17:32 [PATCH] misc: altera-stapl: Replace sprintf with hex_asc_lo for hex conversion aravindanilraj0702
2026-04-02 14:23 ` Greg KH
2026-04-02 15:42   ` Aravind

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