mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bus: use sysfs_emit() to instead of scnprintf()
@ 2022-12-01  1:38 ye.xingchen
  2022-12-05  0:53 ` Serge Semin
  0 siblings, 1 reply; 2+ messages in thread
From: ye.xingchen @ 2022-12-01  1:38 UTC (permalink / raw)
  To: sergey.semin; +Cc: arnd, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

Replace the open-code with sysfs_emit() to simplify the code.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/bus/bt1-apb.c | 6 +++---
 drivers/bus/bt1-axi.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
index 63b1b4a76671..bcf10f1d6dc1 100644
--- a/drivers/bus/bt1-apb.c
+++ b/drivers/bus/bt1-apb.c
@@ -265,7 +265,7 @@ static ssize_t count_show(struct device *dev, struct device_attribute *attr,
 {
 	struct bt1_apb *apb = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&apb->count));
+	return sysfs_emit(buf, "%d\n", atomic_read(&apb->count));
 }
 static DEVICE_ATTR_RO(count);

@@ -283,7 +283,7 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,

 	timeout = bt1_apb_n_to_timeout_us(apb, n);

-	return scnprintf(buf, PAGE_SIZE, "%lu\n", timeout);
+	return sysfs_emit(buf, "%lu\n", timeout);
 }

 static ssize_t timeout_store(struct device *dev,
@@ -310,7 +310,7 @@ static DEVICE_ATTR_RW(timeout);
 static ssize_t inject_error_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "Error injection: nodev irq\n");
+	return sysfs_emit(buf, "Error injection: nodev irq\n");
 }

 static ssize_t inject_error_store(struct device *dev,
diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
index 70e49a6e5374..04c14821bb3c 100644
--- a/drivers/bus/bt1-axi.c
+++ b/drivers/bus/bt1-axi.c
@@ -197,14 +197,14 @@ static ssize_t count_show(struct device *dev,
 {
 	struct bt1_axi *axi = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&axi->count));
+	return sysfs_emit(buf, "%d\n", atomic_read(&axi->count));
 }
 static DEVICE_ATTR_RO(count);

 static ssize_t inject_error_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "Error injection: bus unaligned\n");
+	return sysfs_emit(buf, "Error injection: bus unaligned\n");
 }

 static ssize_t inject_error_store(struct device *dev,
-- 
2.25.1

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

* Re: [PATCH] bus: use sysfs_emit() to instead of scnprintf()
  2022-12-01  1:38 [PATCH] bus: use sysfs_emit() to instead of scnprintf() ye.xingchen
@ 2022-12-05  0:53 ` Serge Semin
  0 siblings, 0 replies; 2+ messages in thread
From: Serge Semin @ 2022-12-05  0:53 UTC (permalink / raw)
  To: ye.xingchen; +Cc: arnd, linux-kernel, Serge Semin

On Thu, Dec 01, 2022 at 09:38:14AM +0800, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Replace the open-code with sysfs_emit() to simplify the code.

Nice cleanup. Thanks.
Acked-by: Serge Semin <fancer.lancer@gmail.com>

* One note. Next time please use the scripts/get_maintainer.pl script
to get the driver maintainers list and their actual email addresses.

-Sergey

> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/bus/bt1-apb.c | 6 +++---
>  drivers/bus/bt1-axi.c | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/bt1-apb.c b/drivers/bus/bt1-apb.c
> index 63b1b4a76671..bcf10f1d6dc1 100644
> --- a/drivers/bus/bt1-apb.c
> +++ b/drivers/bus/bt1-apb.c
> @@ -265,7 +265,7 @@ static ssize_t count_show(struct device *dev, struct device_attribute *attr,
>  {
>  	struct bt1_apb *apb = dev_get_drvdata(dev);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&apb->count));
> +	return sysfs_emit(buf, "%d\n", atomic_read(&apb->count));
>  }
>  static DEVICE_ATTR_RO(count);
> 
> @@ -283,7 +283,7 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
> 
>  	timeout = bt1_apb_n_to_timeout_us(apb, n);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%lu\n", timeout);
> +	return sysfs_emit(buf, "%lu\n", timeout);
>  }
> 
>  static ssize_t timeout_store(struct device *dev,
> @@ -310,7 +310,7 @@ static DEVICE_ATTR_RW(timeout);
>  static ssize_t inject_error_show(struct device *dev,
>  				 struct device_attribute *attr, char *buf)
>  {
> -	return scnprintf(buf, PAGE_SIZE, "Error injection: nodev irq\n");
> +	return sysfs_emit(buf, "Error injection: nodev irq\n");
>  }
> 
>  static ssize_t inject_error_store(struct device *dev,
> diff --git a/drivers/bus/bt1-axi.c b/drivers/bus/bt1-axi.c
> index 70e49a6e5374..04c14821bb3c 100644
> --- a/drivers/bus/bt1-axi.c
> +++ b/drivers/bus/bt1-axi.c
> @@ -197,14 +197,14 @@ static ssize_t count_show(struct device *dev,
>  {
>  	struct bt1_axi *axi = dev_get_drvdata(dev);
> 
> -	return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&axi->count));
> +	return sysfs_emit(buf, "%d\n", atomic_read(&axi->count));
>  }
>  static DEVICE_ATTR_RO(count);
> 
>  static ssize_t inject_error_show(struct device *dev,
>  				 struct device_attribute *attr, char *buf)
>  {
> -	return scnprintf(buf, PAGE_SIZE, "Error injection: bus unaligned\n");
> +	return sysfs_emit(buf, "Error injection: bus unaligned\n");
>  }
> 
>  static ssize_t inject_error_store(struct device *dev,
> -- 
> 2.25.1
> 


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

end of thread, other threads:[~2022-12-05  0:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01  1:38 [PATCH] bus: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-05  0:53 ` Serge Semin

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

all inboxes | Powered by JetHome®