linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] counter/counter-sysfs: use sysfs_emit everywhere
@ 2021-10-17 19:01 David Lechner
  2021-10-17 23:33 ` William Breathitt Gray
  0 siblings, 1 reply; 5+ messages in thread
From: David Lechner @ 2021-10-17 19:01 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, William Breathitt Gray, linux-kernel, Greg KH

In the counter subsystem, we are already using sysfs_emit(), but there
were a few places where we were still using sprintf() in *_show()
functions. For consistency and added protections, use sysfs_emit()
everywhere.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/counter/counter-sysfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index 7bf8882ff54d..8c2d7c29ea59 100644
--- a/drivers/counter/counter-sysfs.c
+++ b/drivers/counter/counter-sysfs.c
@@ -113,7 +113,7 @@ static ssize_t counter_comp_u8_show(struct device *dev,
 		/* data should already be boolean but ensure just to be safe */
 		data = !!data;
 
-	return sprintf(buf, "%u\n", (unsigned int)data);
+	return sysfs_emit(buf, "%u\n", (unsigned int)data);
 }
 
 static ssize_t counter_comp_u8_store(struct device *dev,
@@ -196,7 +196,7 @@ static ssize_t counter_comp_u32_show(struct device *dev,
 	case COUNTER_COMP_COUNT_MODE:
 		return sysfs_emit(buf, "%s\n", counter_count_mode_str[data]);
 	default:
-		return sprintf(buf, "%u\n", (unsigned int)data);
+		return sysfs_emit(buf, "%u\n", (unsigned int)data);
 	}
 }
 
@@ -300,7 +300,7 @@ static ssize_t counter_comp_u64_show(struct device *dev,
 	if (err < 0)
 		return err;
 
-	return sprintf(buf, "%llu\n", (unsigned long long)data);
+	return sysfs_emit(buf, "%llu\n", (unsigned long long)data);
 }
 
 static ssize_t counter_comp_u64_store(struct device *dev,
@@ -539,7 +539,7 @@ static ssize_t counter_comp_id_show(struct device *dev,
 {
 	const size_t id = (size_t)to_counter_attribute(attr)->comp.priv;
 
-	return sprintf(buf, "%zu\n", id);
+	return sysfs_emit(buf, "%zu\n", id);
 }
 
 static int counter_comp_id_attr_create(struct device *const dev,
-- 
2.25.1


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

* Re: [PATCH] counter/counter-sysfs: use sysfs_emit everywhere
  2021-10-17 19:01 [PATCH] counter/counter-sysfs: use sysfs_emit everywhere David Lechner
@ 2021-10-17 23:33 ` William Breathitt Gray
  2021-10-18  6:06   ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: William Breathitt Gray @ 2021-10-17 23:33 UTC (permalink / raw)
  To: David Lechner, jic23; +Cc: linux-iio, linux-kernel, Greg KH

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

On Sun, Oct 17, 2021 at 02:01:06PM -0500, David Lechner wrote:
> In the counter subsystem, we are already using sysfs_emit(), but there
> were a few places where we were still using sprintf() in *_show()
> functions. For consistency and added protections, use sysfs_emit()
> everywhere.
> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Signed-off-by: David Lechner <david@lechnology.com>

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

> ---
>  drivers/counter/counter-sysfs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
> index 7bf8882ff54d..8c2d7c29ea59 100644
> --- a/drivers/counter/counter-sysfs.c
> +++ b/drivers/counter/counter-sysfs.c
> @@ -113,7 +113,7 @@ static ssize_t counter_comp_u8_show(struct device *dev,
>  		/* data should already be boolean but ensure just to be safe */
>  		data = !!data;
>  
> -	return sprintf(buf, "%u\n", (unsigned int)data);
> +	return sysfs_emit(buf, "%u\n", (unsigned int)data);
>  }
>  
>  static ssize_t counter_comp_u8_store(struct device *dev,
> @@ -196,7 +196,7 @@ static ssize_t counter_comp_u32_show(struct device *dev,
>  	case COUNTER_COMP_COUNT_MODE:
>  		return sysfs_emit(buf, "%s\n", counter_count_mode_str[data]);
>  	default:
> -		return sprintf(buf, "%u\n", (unsigned int)data);
> +		return sysfs_emit(buf, "%u\n", (unsigned int)data);
>  	}
>  }
>  
> @@ -300,7 +300,7 @@ static ssize_t counter_comp_u64_show(struct device *dev,
>  	if (err < 0)
>  		return err;
>  
> -	return sprintf(buf, "%llu\n", (unsigned long long)data);
> +	return sysfs_emit(buf, "%llu\n", (unsigned long long)data);
>  }
>  
>  static ssize_t counter_comp_u64_store(struct device *dev,
> @@ -539,7 +539,7 @@ static ssize_t counter_comp_id_show(struct device *dev,
>  {
>  	const size_t id = (size_t)to_counter_attribute(attr)->comp.priv;
>  
> -	return sprintf(buf, "%zu\n", id);
> +	return sysfs_emit(buf, "%zu\n", id);
>  }
>  
>  static int counter_comp_id_attr_create(struct device *const dev,
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] counter/counter-sysfs: use sysfs_emit everywhere
  2021-10-17 23:33 ` William Breathitt Gray
@ 2021-10-18  6:06   ` Greg KH
  2021-10-18  8:19     ` William Breathitt Gray
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-10-18  6:06 UTC (permalink / raw)
  To: William Breathitt Gray; +Cc: David Lechner, jic23, linux-iio, linux-kernel

On Mon, Oct 18, 2021 at 08:33:34AM +0900, William Breathitt Gray wrote:
> On Sun, Oct 17, 2021 at 02:01:06PM -0500, David Lechner wrote:
> > In the counter subsystem, we are already using sysfs_emit(), but there
> > were a few places where we were still using sprintf() in *_show()
> > functions. For consistency and added protections, use sysfs_emit()
> > everywhere.
> > 
> > Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> > Signed-off-by: David Lechner <david@lechnology.com>
> 
> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

Thanks, want me to take this directly on top of the previous pull
request?

greg k-h

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

* Re: [PATCH] counter/counter-sysfs: use sysfs_emit everywhere
  2021-10-18  6:06   ` Greg KH
@ 2021-10-18  8:19     ` William Breathitt Gray
  2021-10-18  8:26       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: William Breathitt Gray @ 2021-10-18  8:19 UTC (permalink / raw)
  To: Greg KH; +Cc: David Lechner, jic23, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 839 bytes --]

On Mon, Oct 18, 2021 at 08:06:58AM +0200, Greg KH wrote:
> On Mon, Oct 18, 2021 at 08:33:34AM +0900, William Breathitt Gray wrote:
> > On Sun, Oct 17, 2021 at 02:01:06PM -0500, David Lechner wrote:
> > > In the counter subsystem, we are already using sysfs_emit(), but there
> > > were a few places where we were still using sprintf() in *_show()
> > > functions. For consistency and added protections, use sysfs_emit()
> > > everywhere.
> > > 
> > > Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> > > Signed-off-by: David Lechner <david@lechnology.com>
> > 
> > Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> 
> Thanks, want me to take this directly on top of the previous pull
> request?
> 
> greg k-h

Yes, that should be a fine path forward for this patch.

Thank you,

William Breathitt Gray

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] counter/counter-sysfs: use sysfs_emit everywhere
  2021-10-18  8:19     ` William Breathitt Gray
@ 2021-10-18  8:26       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2021-10-18  8:26 UTC (permalink / raw)
  To: William Breathitt Gray; +Cc: David Lechner, jic23, linux-iio, linux-kernel

On Mon, Oct 18, 2021 at 05:19:02PM +0900, William Breathitt Gray wrote:
> On Mon, Oct 18, 2021 at 08:06:58AM +0200, Greg KH wrote:
> > On Mon, Oct 18, 2021 at 08:33:34AM +0900, William Breathitt Gray wrote:
> > > On Sun, Oct 17, 2021 at 02:01:06PM -0500, David Lechner wrote:
> > > > In the counter subsystem, we are already using sysfs_emit(), but there
> > > > were a few places where we were still using sprintf() in *_show()
> > > > functions. For consistency and added protections, use sysfs_emit()
> > > > everywhere.
> > > > 
> > > > Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> > > > Signed-off-by: David Lechner <david@lechnology.com>
> > > 
> > > Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> > 
> > Thanks, want me to take this directly on top of the previous pull
> > request?
> > 
> > greg k-h
> 
> Yes, that should be a fine path forward for this patch.

Great!  Can you also ack the other patch from David as well?

thanks,

greg k-h

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

end of thread, other threads:[~2021-10-18  8:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-17 19:01 [PATCH] counter/counter-sysfs: use sysfs_emit everywhere David Lechner
2021-10-17 23:33 ` William Breathitt Gray
2021-10-18  6:06   ` Greg KH
2021-10-18  8:19     ` William Breathitt Gray
2021-10-18  8:26       ` Greg KH

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