linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf()
       [not found] <20220923063448.239259-1-ye.xingchen@zte.com.cn>
@ 2022-09-23 21:04 ` Han Jingoo
  2022-09-26 13:26 ` Daniel Thompson
  1 sibling, 0 replies; 5+ messages in thread
From: Han Jingoo @ 2022-09-23 21:04 UTC (permalink / raw)
  To: cgel.zte
  Cc: lee, daniel.thompson, deller, dri-devel, linux-fbdev,
	linux-kernel, ye xingchen

On Thu, Sep 22, 2022 <cgel.zte@gmail.com> wrote:
>
> 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>

Acked-by: Jingoo Han <jingoohan1@gmail.com>

Best regards,
Jingoo Han

> ---
>  drivers/video/backlight/lm3533_bl.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> index 1df1b6643c0b..5e2ce9285245 100644
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
> @@ -66,7 +66,7 @@ static ssize_t show_id(struct device *dev,
>  {
>         struct lm3533_bl *bl = dev_get_drvdata(dev);
>
> -       return scnprintf(buf, PAGE_SIZE, "%d\n", bl->id);
> +       return sysfs_emit(buf, "%d\n", bl->id);
>  }
>
>  static ssize_t show_als_channel(struct device *dev,
> @@ -75,7 +75,7 @@ static ssize_t show_als_channel(struct device *dev,
>         struct lm3533_bl *bl = dev_get_drvdata(dev);
>         unsigned channel = lm3533_bl_get_ctrlbank_id(bl);
>
> -       return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
> +       return sysfs_emit(buf, "%u\n", channel);
>  }
>
>  static ssize_t show_als_en(struct device *dev,
> @@ -95,7 +95,7 @@ static ssize_t show_als_en(struct device *dev,
>         mask = 1 << (2 * ctrlbank);
>         enable = val & mask;
>
> -       return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
> +       return sysfs_emit(buf, "%d\n", enable);
>  }
>
>  static ssize_t store_als_en(struct device *dev,
> @@ -147,7 +147,7 @@ static ssize_t show_linear(struct device *dev,
>         else
>                 linear = 0;
>
> -       return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
> +       return sysfs_emit(buf, "%x\n", linear);
>  }
>
>  static ssize_t store_linear(struct device *dev,
> @@ -190,7 +190,7 @@ static ssize_t show_pwm(struct device *dev,
>         if (ret)
>                 return ret;
>
> -       return scnprintf(buf, PAGE_SIZE, "%u\n", val);
> +       return sysfs_emit(buf, "%u\n", val);
>  }
>
>  static ssize_t store_pwm(struct device *dev,
> --
> 2.25.1

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

* Re: [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf()
       [not found] <20220923063448.239259-1-ye.xingchen@zte.com.cn>
  2022-09-23 21:04 ` [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf() Han Jingoo
@ 2022-09-26 13:26 ` Daniel Thompson
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Thompson @ 2022-09-26 13:26 UTC (permalink / raw)
  To: cgel.zte
  Cc: lee, jingoohan1, deller, dri-devel, linux-fbdev, linux-kernel,
	ye xingchen

On Fri, Sep 23, 2022 at 06:34:48AM +0000, cgel.zte@gmail.com wrote:
> Subject: [PATCH linux-next] backlight: use sysfs_emit() to instead of
> scnprintf()
> 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/video/backlight/lm3533_bl.c | 10 +++++-----

Looks like a good change but the topic tag ('backlight:') looks a bit
generic for something that only impacts the lm3533_bl.c driver.

Also it would be good if this patchset included the same fix
for *all* drivers that a grep shows contain this code pattern
(e.g. git grep 'return scnprintf.*PAGE_SIZE').


Daniel.

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

* Re: [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf()
  2022-12-05  7:56 ye.xingchen
  2022-12-09 12:51 ` Daniel Thompson
@ 2023-01-04 16:21 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Jones @ 2023-01-04 16:21 UTC (permalink / raw)
  To: ye.xingchen
  Cc: daniel.thompson, jingoohan1, deller, dri-devel, linux-fbdev,
	linux-kernel

On Mon, 05 Dec 2022, ye.xingchen@zte.com.cn wrote:

> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/video/backlight/lm3533_bl.c | 10 +++++-----
>  drivers/video/backlight/lp855x_bl.c |  4 ++--
>  drivers/video/backlight/lp8788_bl.c |  2 +-
>  3 files changed, 8 insertions(+), 8 deletions(-)

Is this v3?

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf()
  2022-12-05  7:56 ye.xingchen
@ 2022-12-09 12:51 ` Daniel Thompson
  2023-01-04 16:21 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Thompson @ 2022-12-09 12:51 UTC (permalink / raw)
  To: ye.xingchen; +Cc: lee, jingoohan1, deller, dri-devel, linux-fbdev, linux-kernel

On Mon, Dec 05, 2022 at 03:56:47PM +0800, ye.xingchen@zte.com.cn wrote:
> Subject: [PATCH linux-next] backlight: use sysfs_emit() to instead of
> scnprintf()

Isn't this a v2?

(this isn't just a "nice to have"... I ended up delaying review for
several days until I had time to look up where I had seen these changes
before)


> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.

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

* [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf()
@ 2022-12-05  7:56 ye.xingchen
  2022-12-09 12:51 ` Daniel Thompson
  2023-01-04 16:21 ` Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: ye.xingchen @ 2022-12-05  7:56 UTC (permalink / raw)
  To: lee, daniel.thompson
  Cc: jingoohan1, deller, dri-devel, linux-fbdev, linux-kernel

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

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/video/backlight/lm3533_bl.c | 10 +++++-----
 drivers/video/backlight/lp855x_bl.c |  4 ++--
 drivers/video/backlight/lp8788_bl.c |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index 1df1b6643c0b..5e2ce9285245 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -66,7 +66,7 @@ static ssize_t show_id(struct device *dev,
 {
 	struct lm3533_bl *bl = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%d\n", bl->id);
+	return sysfs_emit(buf, "%d\n", bl->id);
 }

 static ssize_t show_als_channel(struct device *dev,
@@ -75,7 +75,7 @@ static ssize_t show_als_channel(struct device *dev,
 	struct lm3533_bl *bl = dev_get_drvdata(dev);
 	unsigned channel = lm3533_bl_get_ctrlbank_id(bl);

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

 static ssize_t show_als_en(struct device *dev,
@@ -95,7 +95,7 @@ static ssize_t show_als_en(struct device *dev,
 	mask = 1 << (2 * ctrlbank);
 	enable = val & mask;

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

 static ssize_t store_als_en(struct device *dev,
@@ -147,7 +147,7 @@ static ssize_t show_linear(struct device *dev,
 	else
 		linear = 0;

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

 static ssize_t store_linear(struct device *dev,
@@ -190,7 +190,7 @@ static ssize_t show_pwm(struct device *dev,
 	if (ret)
 		return ret;

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

 static ssize_t store_pwm(struct device *dev,
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index bd0bdeae23a4..fafc1a9e76ef 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -293,7 +293,7 @@ static ssize_t lp855x_get_chip_id(struct device *dev,
 {
 	struct lp855x *lp = dev_get_drvdata(dev);

-	return scnprintf(buf, PAGE_SIZE, "%s\n", lp->chipname);
+	return sysfs_emit(buf, "%s\n", lp->chipname);
 }

 static ssize_t lp855x_get_bl_ctl_mode(struct device *dev,
@@ -307,7 +307,7 @@ static ssize_t lp855x_get_bl_ctl_mode(struct device *dev,
 	else if (lp->mode == REGISTER_BASED)
 		strmode = "register based";

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

 static DEVICE_ATTR(chip_id, S_IRUGO, lp855x_get_chip_id, NULL);
diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c
index ba42f3fe0c73..00d79c0cfee9 100644
--- a/drivers/video/backlight/lp8788_bl.c
+++ b/drivers/video/backlight/lp8788_bl.c
@@ -240,7 +240,7 @@ static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
 	else
 		strmode = "Invalid mode";

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

 static DEVICE_ATTR(bl_ctl_mode, S_IRUGO, lp8788_get_bl_ctl_mode, NULL);
-- 
2.25.1

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

end of thread, other threads:[~2023-01-04 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220923063448.239259-1-ye.xingchen@zte.com.cn>
2022-09-23 21:04 ` [PATCH linux-next] backlight: use sysfs_emit() to instead of scnprintf() Han Jingoo
2022-09-26 13:26 ` Daniel Thompson
2022-12-05  7:56 ye.xingchen
2022-12-09 12:51 ` Daniel Thompson
2023-01-04 16:21 ` Lee Jones

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