* [PATCH] ACPI: fan: Convert to use sysfs_emit_at() API
@ 2022-12-06 7:19 ye.xingchen
2022-12-06 11:46 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: ye.xingchen @ 2022-12-06 7:19 UTC (permalink / raw)
To: rafael; +Cc: lenb, linux-acpi, 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/acpi/fan_attr.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/acpi/fan_attr.c b/drivers/acpi/fan_attr.c
index f15157d40713..f4f6e2381f1d 100644
--- a/drivers/acpi/fan_attr.c
+++ b/drivers/acpi/fan_attr.c
@@ -27,24 +27,24 @@ static ssize_t show_state(struct device *dev, struct device_attribute *attr, cha
count = scnprintf(buf, PAGE_SIZE, "%lld:", fps->control);
if (fps->trip_point == 0xFFFFFFFF || fps->trip_point > 9)
- count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
+ count += sysfs_emit_at(buf, count, "not-defined:");
else
- count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->trip_point);
+ count += sysfs_emit_at(buf, count, "%lld:", fps->trip_point);
if (fps->speed == 0xFFFFFFFF)
- count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
+ count += sysfs_emit_at(buf, count, "not-defined:");
else
- count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->speed);
+ count += sysfs_emit_at(buf, count, "%lld:", fps->speed);
if (fps->noise_level == 0xFFFFFFFF)
- count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
+ count += sysfs_emit_at(buf, count, "not-defined:");
else
- count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->noise_level * 100);
+ count += sysfs_emit_at(buf, count, "%lld:", fps->noise_level * 100);
if (fps->power == 0xFFFFFFFF)
- count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined\n");
+ count += sysfs_emit_at(buf, count, "not-defined\n");
else
- count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld\n", fps->power);
+ count += sysfs_emit_at(buf, count, "%lld\n", fps->power);
return count;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ACPI: fan: Convert to use sysfs_emit_at() API
2022-12-06 7:19 [PATCH] ACPI: fan: Convert to use sysfs_emit_at() API ye.xingchen
@ 2022-12-06 11:46 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-12-06 11:46 UTC (permalink / raw)
To: ye.xingchen; +Cc: rafael, lenb, linux-acpi, linux-kernel
On Tue, Dec 6, 2022 at 8:19 AM <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/acpi/fan_attr.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/acpi/fan_attr.c b/drivers/acpi/fan_attr.c
> index f15157d40713..f4f6e2381f1d 100644
> --- a/drivers/acpi/fan_attr.c
> +++ b/drivers/acpi/fan_attr.c
> @@ -27,24 +27,24 @@ static ssize_t show_state(struct device *dev, struct device_attribute *attr, cha
> count = scnprintf(buf, PAGE_SIZE, "%lld:", fps->control);
>
> if (fps->trip_point == 0xFFFFFFFF || fps->trip_point > 9)
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
> + count += sysfs_emit_at(buf, count, "not-defined:");
> else
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->trip_point);
> + count += sysfs_emit_at(buf, count, "%lld:", fps->trip_point);
>
> if (fps->speed == 0xFFFFFFFF)
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
> + count += sysfs_emit_at(buf, count, "not-defined:");
> else
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->speed);
> + count += sysfs_emit_at(buf, count, "%lld:", fps->speed);
>
> if (fps->noise_level == 0xFFFFFFFF)
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined:");
> + count += sysfs_emit_at(buf, count, "not-defined:");
> else
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld:", fps->noise_level * 100);
> + count += sysfs_emit_at(buf, count, "%lld:", fps->noise_level * 100);
>
> if (fps->power == 0xFFFFFFFF)
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "not-defined\n");
> + count += sysfs_emit_at(buf, count, "not-defined\n");
> else
> - count += scnprintf(&buf[count], PAGE_SIZE - count, "%lld\n", fps->power);
> + count += sysfs_emit_at(buf, count, "%lld\n", fps->power);
>
> return count;
> }
> --
Applied as 6.2 material, thanks!
However, if you are about to send any analogous material to me, please
defer it until 6.2-rc1 is out, because it will be unlikely to get into
6.2 anyway.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-06 11:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-06 7:19 [PATCH] ACPI: fan: Convert to use sysfs_emit_at() API ye.xingchen
2022-12-06 11:46 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox