* [PATCH] platform/x86: thinkpad_acpi: fix coccinelle warnings
@ 2021-10-18 9:17 Ye Guojin
2021-10-19 15:20 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Ye Guojin @ 2021-10-18 9:17 UTC (permalink / raw)
To: hmh
Cc: hdegoede, markgross, ibm-acpi-devel, platform-driver-x86,
linux-kernel, zealci, Ye Guojin
coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
---
drivers/platform/x86/thinkpad_acpi.c | 54 ++++++++++++++--------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 882e994658f1..338a848d6dd0 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1277,7 +1277,7 @@ static ssize_t tpacpi_rfk_sysfs_enable_show(const enum tpacpi_rfk_id id,
return status;
}
- return snprintf(buf, PAGE_SIZE, "%d\n",
+ return sysfs_emit(buf, "%d\n",
(status == TPACPI_RFK_RADIO_ON) ? 1 : 0);
}
@@ -1370,14 +1370,14 @@ static int tpacpi_rfk_procfs_write(const enum tpacpi_rfk_id id, char *buf)
/* interface_version --------------------------------------------------- */
static ssize_t interface_version_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", TPACPI_SYSFS_VERSION);
+ return sysfs_emit(buf, "0x%08x\n", TPACPI_SYSFS_VERSION);
}
static DRIVER_ATTR_RO(interface_version);
/* debug_level --------------------------------------------------------- */
static ssize_t debug_level_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%04x\n", dbg_level);
+ return sysfs_emit(buf, "0x%04x\n", dbg_level);
}
static ssize_t debug_level_store(struct device_driver *drv, const char *buf,
@@ -1397,7 +1397,7 @@ static DRIVER_ATTR_RW(debug_level);
/* version ------------------------------------------------------------- */
static ssize_t version_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s v%s\n",
+ return sysfs_emit(buf, "%s v%s\n",
TPACPI_DESC, TPACPI_VERSION);
}
static DRIVER_ATTR_RO(version);
@@ -1409,7 +1409,7 @@ static DRIVER_ATTR_RO(version);
/* wlsw_emulstate ------------------------------------------------------ */
static ssize_t wlsw_emulstate_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wlsw_emulstate);
+ return sysfs_emit(buf, "%d\n", !!tpacpi_wlsw_emulstate);
}
static ssize_t wlsw_emulstate_store(struct device_driver *drv, const char *buf,
@@ -1432,7 +1432,7 @@ static DRIVER_ATTR_RW(wlsw_emulstate);
/* bluetooth_emulstate ------------------------------------------------- */
static ssize_t bluetooth_emulstate_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_bluetooth_emulstate);
+ return sysfs_emit(buf, "%d\n", !!tpacpi_bluetooth_emulstate);
}
static ssize_t bluetooth_emulstate_store(struct device_driver *drv,
@@ -1452,7 +1452,7 @@ static DRIVER_ATTR_RW(bluetooth_emulstate);
/* wwan_emulstate ------------------------------------------------- */
static ssize_t wwan_emulstate_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wwan_emulstate);
+ return sysfs_emit(buf, "%d\n", !!tpacpi_wwan_emulstate);
}
static ssize_t wwan_emulstate_store(struct device_driver *drv, const char *buf,
@@ -1472,7 +1472,7 @@ static DRIVER_ATTR_RW(wwan_emulstate);
/* uwb_emulstate ------------------------------------------------- */
static ssize_t uwb_emulstate_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_uwb_emulstate);
+ return sysfs_emit(buf, "%d\n", !!tpacpi_uwb_emulstate);
}
static ssize_t uwb_emulstate_store(struct device_driver *drv, const char *buf,
@@ -2680,7 +2680,7 @@ static ssize_t hotkey_enable_show(struct device *dev,
if (res)
return res;
- return snprintf(buf, PAGE_SIZE, "%d\n", status);
+ return sysfs_emit(buf, "%d\n", status);
}
static ssize_t hotkey_enable_store(struct device *dev,
@@ -2708,7 +2708,7 @@ static ssize_t hotkey_mask_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_user_mask);
+ return sysfs_emit(buf, "0x%08x\n", hotkey_user_mask);
}
static ssize_t hotkey_mask_store(struct device *dev,
@@ -2756,7 +2756,7 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
{
printk_deprecated_attribute("hotkey_bios_mask",
"This attribute is useless.");
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
+ return sysfs_emit(buf, "0x%08x\n", hotkey_orig_mask);
}
static DEVICE_ATTR_RO(hotkey_bios_mask);
@@ -2766,7 +2766,7 @@ static ssize_t hotkey_all_mask_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+ return sysfs_emit(buf, "0x%08x\n",
hotkey_all_mask | hotkey_source_mask);
}
@@ -2777,7 +2777,7 @@ static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+ return sysfs_emit(buf, "0x%08x\n",
hotkey_adaptive_all_mask | hotkey_source_mask);
}
@@ -2788,7 +2788,7 @@ static ssize_t hotkey_recommended_mask_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+ return sysfs_emit(buf, "0x%08x\n",
(hotkey_all_mask | hotkey_source_mask)
& ~hotkey_reserved_mask);
}
@@ -2802,7 +2802,7 @@ static ssize_t hotkey_source_mask_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_source_mask);
+ return sysfs_emit(buf, "0x%08x\n", hotkey_source_mask);
}
static ssize_t hotkey_source_mask_store(struct device *dev,
@@ -2853,7 +2853,7 @@ static ssize_t hotkey_poll_freq_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_poll_freq);
+ return sysfs_emit(buf, "%d\n", hotkey_poll_freq);
}
static ssize_t hotkey_poll_freq_store(struct device *dev,
@@ -2895,7 +2895,7 @@ static ssize_t hotkey_radio_sw_show(struct device *dev,
/* Opportunistic update */
tpacpi_rfk_update_hwblock_state((res == TPACPI_RFK_RADIO_OFF));
- return snprintf(buf, PAGE_SIZE, "%d\n",
+ return sysfs_emit(buf, "%d\n",
(res == TPACPI_RFK_RADIO_OFF) ? 0 : 1);
}
@@ -2918,7 +2918,7 @@ static ssize_t hotkey_tablet_mode_show(struct device *dev,
if (res < 0)
return res;
- return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
+ return sysfs_emit(buf, "%d\n", !!s);
}
static DEVICE_ATTR_RO(hotkey_tablet_mode);
@@ -2935,7 +2935,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_wakeup_reason);
+ return sysfs_emit(buf, "%d\n", hotkey_wakeup_reason);
}
static DEVICE_ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL);
@@ -2951,7 +2951,7 @@ static ssize_t hotkey_wakeup_hotunplug_complete_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_autosleep_ack);
+ return sysfs_emit(buf, "%d\n", hotkey_autosleep_ack);
}
static DEVICE_ATTR(wakeup_hotunplug_complete, S_IRUGO,
@@ -2986,7 +2986,7 @@ static ssize_t adaptive_kbd_mode_show(struct device *dev,
if (current_mode < 0)
return current_mode;
- return snprintf(buf, PAGE_SIZE, "%d\n", current_mode);
+ return sysfs_emit(buf, "%d\n", current_mode);
}
static ssize_t adaptive_kbd_mode_store(struct device *dev,
@@ -6350,7 +6350,7 @@ static ssize_t thermal_temp_input_show(struct device *dev,
if (value == TPACPI_THERMAL_SENSOR_NA)
return -ENXIO;
- return snprintf(buf, PAGE_SIZE, "%d\n", value);
+ return sysfs_emit(buf, "%d\n", value);
}
#define THERMAL_SENSOR_ATTR_TEMP(_idxA, _idxB) \
@@ -8583,7 +8583,7 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
} else
mode = 1;
- return snprintf(buf, PAGE_SIZE, "%d\n", mode);
+ return sysfs_emit(buf, "%d\n", mode);
}
static ssize_t fan_pwm1_enable_store(struct device *dev,
@@ -8649,7 +8649,7 @@ static ssize_t fan_pwm1_show(struct device *dev,
if (status > 7)
status = 7;
- return snprintf(buf, PAGE_SIZE, "%u\n", (status * 255) / 7);
+ return sysfs_emit(buf, "%u\n", (status * 255) / 7);
}
static ssize_t fan_pwm1_store(struct device *dev,
@@ -8702,7 +8702,7 @@ static ssize_t fan_fan1_input_show(struct device *dev,
if (res < 0)
return res;
- return snprintf(buf, PAGE_SIZE, "%u\n", speed);
+ return sysfs_emit(buf, "%u\n", speed);
}
static DEVICE_ATTR(fan1_input, S_IRUGO, fan_fan1_input_show, NULL);
@@ -8719,7 +8719,7 @@ static ssize_t fan_fan2_input_show(struct device *dev,
if (res < 0)
return res;
- return snprintf(buf, PAGE_SIZE, "%u\n", speed);
+ return sysfs_emit(buf, "%u\n", speed);
}
static DEVICE_ATTR(fan2_input, S_IRUGO, fan_fan2_input_show, NULL);
@@ -8727,7 +8727,7 @@ static DEVICE_ATTR(fan2_input, S_IRUGO, fan_fan2_input_show, NULL);
/* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
static ssize_t fan_watchdog_show(struct device_driver *drv, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%u\n", fan_watchdog_maxinterval);
+ return sysfs_emit(buf, "%u\n", fan_watchdog_maxinterval);
}
static ssize_t fan_watchdog_store(struct device_driver *drv, const char *buf,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: fix coccinelle warnings
2021-10-18 9:17 [PATCH] platform/x86: thinkpad_acpi: fix coccinelle warnings Ye Guojin
@ 2021-10-19 15:20 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-10-19 15:20 UTC (permalink / raw)
To: Ye Guojin, hmh
Cc: markgross, ibm-acpi-devel, platform-driver-x86, linux-kernel,
zealci, Ye Guojin
Hi,
On 10/18/21 11:17, Ye Guojin wrote:
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
>
> WARNING use scnprintf or sprintf
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/thinkpad_acpi.c | 54 ++++++++++++++--------------
> 1 file changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 882e994658f1..338a848d6dd0 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -1277,7 +1277,7 @@ static ssize_t tpacpi_rfk_sysfs_enable_show(const enum tpacpi_rfk_id id,
> return status;
> }
>
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> + return sysfs_emit(buf, "%d\n",
> (status == TPACPI_RFK_RADIO_ON) ? 1 : 0);
> }
>
> @@ -1370,14 +1370,14 @@ static int tpacpi_rfk_procfs_write(const enum tpacpi_rfk_id id, char *buf)
> /* interface_version --------------------------------------------------- */
> static ssize_t interface_version_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n", TPACPI_SYSFS_VERSION);
> + return sysfs_emit(buf, "0x%08x\n", TPACPI_SYSFS_VERSION);
> }
> static DRIVER_ATTR_RO(interface_version);
>
> /* debug_level --------------------------------------------------------- */
> static ssize_t debug_level_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%04x\n", dbg_level);
> + return sysfs_emit(buf, "0x%04x\n", dbg_level);
> }
>
> static ssize_t debug_level_store(struct device_driver *drv, const char *buf,
> @@ -1397,7 +1397,7 @@ static DRIVER_ATTR_RW(debug_level);
> /* version ------------------------------------------------------------- */
> static ssize_t version_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%s v%s\n",
> + return sysfs_emit(buf, "%s v%s\n",
> TPACPI_DESC, TPACPI_VERSION);
> }
> static DRIVER_ATTR_RO(version);
> @@ -1409,7 +1409,7 @@ static DRIVER_ATTR_RO(version);
> /* wlsw_emulstate ------------------------------------------------------ */
> static ssize_t wlsw_emulstate_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wlsw_emulstate);
> + return sysfs_emit(buf, "%d\n", !!tpacpi_wlsw_emulstate);
> }
>
> static ssize_t wlsw_emulstate_store(struct device_driver *drv, const char *buf,
> @@ -1432,7 +1432,7 @@ static DRIVER_ATTR_RW(wlsw_emulstate);
> /* bluetooth_emulstate ------------------------------------------------- */
> static ssize_t bluetooth_emulstate_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_bluetooth_emulstate);
> + return sysfs_emit(buf, "%d\n", !!tpacpi_bluetooth_emulstate);
> }
>
> static ssize_t bluetooth_emulstate_store(struct device_driver *drv,
> @@ -1452,7 +1452,7 @@ static DRIVER_ATTR_RW(bluetooth_emulstate);
> /* wwan_emulstate ------------------------------------------------- */
> static ssize_t wwan_emulstate_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wwan_emulstate);
> + return sysfs_emit(buf, "%d\n", !!tpacpi_wwan_emulstate);
> }
>
> static ssize_t wwan_emulstate_store(struct device_driver *drv, const char *buf,
> @@ -1472,7 +1472,7 @@ static DRIVER_ATTR_RW(wwan_emulstate);
> /* uwb_emulstate ------------------------------------------------- */
> static ssize_t uwb_emulstate_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_uwb_emulstate);
> + return sysfs_emit(buf, "%d\n", !!tpacpi_uwb_emulstate);
> }
>
> static ssize_t uwb_emulstate_store(struct device_driver *drv, const char *buf,
> @@ -2680,7 +2680,7 @@ static ssize_t hotkey_enable_show(struct device *dev,
> if (res)
> return res;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buf, "%d\n", status);
> }
>
> static ssize_t hotkey_enable_store(struct device *dev,
> @@ -2708,7 +2708,7 @@ static ssize_t hotkey_mask_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_user_mask);
> + return sysfs_emit(buf, "0x%08x\n", hotkey_user_mask);
> }
>
> static ssize_t hotkey_mask_store(struct device *dev,
> @@ -2756,7 +2756,7 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
> {
> printk_deprecated_attribute("hotkey_bios_mask",
> "This attribute is useless.");
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
> + return sysfs_emit(buf, "0x%08x\n", hotkey_orig_mask);
> }
>
> static DEVICE_ATTR_RO(hotkey_bios_mask);
> @@ -2766,7 +2766,7 @@ static ssize_t hotkey_all_mask_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n",
> + return sysfs_emit(buf, "0x%08x\n",
> hotkey_all_mask | hotkey_source_mask);
> }
>
> @@ -2777,7 +2777,7 @@ static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n",
> + return sysfs_emit(buf, "0x%08x\n",
> hotkey_adaptive_all_mask | hotkey_source_mask);
> }
>
> @@ -2788,7 +2788,7 @@ static ssize_t hotkey_recommended_mask_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n",
> + return sysfs_emit(buf, "0x%08x\n",
> (hotkey_all_mask | hotkey_source_mask)
> & ~hotkey_reserved_mask);
> }
> @@ -2802,7 +2802,7 @@ static ssize_t hotkey_source_mask_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_source_mask);
> + return sysfs_emit(buf, "0x%08x\n", hotkey_source_mask);
> }
>
> static ssize_t hotkey_source_mask_store(struct device *dev,
> @@ -2853,7 +2853,7 @@ static ssize_t hotkey_poll_freq_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_poll_freq);
> + return sysfs_emit(buf, "%d\n", hotkey_poll_freq);
> }
>
> static ssize_t hotkey_poll_freq_store(struct device *dev,
> @@ -2895,7 +2895,7 @@ static ssize_t hotkey_radio_sw_show(struct device *dev,
> /* Opportunistic update */
> tpacpi_rfk_update_hwblock_state((res == TPACPI_RFK_RADIO_OFF));
>
> - return snprintf(buf, PAGE_SIZE, "%d\n",
> + return sysfs_emit(buf, "%d\n",
> (res == TPACPI_RFK_RADIO_OFF) ? 0 : 1);
> }
>
> @@ -2918,7 +2918,7 @@ static ssize_t hotkey_tablet_mode_show(struct device *dev,
> if (res < 0)
> return res;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
> + return sysfs_emit(buf, "%d\n", !!s);
> }
>
> static DEVICE_ATTR_RO(hotkey_tablet_mode);
> @@ -2935,7 +2935,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_wakeup_reason);
> + return sysfs_emit(buf, "%d\n", hotkey_wakeup_reason);
> }
>
> static DEVICE_ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL);
> @@ -2951,7 +2951,7 @@ static ssize_t hotkey_wakeup_hotunplug_complete_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_autosleep_ack);
> + return sysfs_emit(buf, "%d\n", hotkey_autosleep_ack);
> }
>
> static DEVICE_ATTR(wakeup_hotunplug_complete, S_IRUGO,
> @@ -2986,7 +2986,7 @@ static ssize_t adaptive_kbd_mode_show(struct device *dev,
> if (current_mode < 0)
> return current_mode;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", current_mode);
> + return sysfs_emit(buf, "%d\n", current_mode);
> }
>
> static ssize_t adaptive_kbd_mode_store(struct device *dev,
> @@ -6350,7 +6350,7 @@ static ssize_t thermal_temp_input_show(struct device *dev,
> if (value == TPACPI_THERMAL_SENSOR_NA)
> return -ENXIO;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", value);
> + return sysfs_emit(buf, "%d\n", value);
> }
>
> #define THERMAL_SENSOR_ATTR_TEMP(_idxA, _idxB) \
> @@ -8583,7 +8583,7 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
> } else
> mode = 1;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", mode);
> + return sysfs_emit(buf, "%d\n", mode);
> }
>
> static ssize_t fan_pwm1_enable_store(struct device *dev,
> @@ -8649,7 +8649,7 @@ static ssize_t fan_pwm1_show(struct device *dev,
> if (status > 7)
> status = 7;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", (status * 255) / 7);
> + return sysfs_emit(buf, "%u\n", (status * 255) / 7);
> }
>
> static ssize_t fan_pwm1_store(struct device *dev,
> @@ -8702,7 +8702,7 @@ static ssize_t fan_fan1_input_show(struct device *dev,
> if (res < 0)
> return res;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", speed);
> + return sysfs_emit(buf, "%u\n", speed);
> }
>
> static DEVICE_ATTR(fan1_input, S_IRUGO, fan_fan1_input_show, NULL);
> @@ -8719,7 +8719,7 @@ static ssize_t fan_fan2_input_show(struct device *dev,
> if (res < 0)
> return res;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", speed);
> + return sysfs_emit(buf, "%u\n", speed);
> }
>
> static DEVICE_ATTR(fan2_input, S_IRUGO, fan_fan2_input_show, NULL);
> @@ -8727,7 +8727,7 @@ static DEVICE_ATTR(fan2_input, S_IRUGO, fan_fan2_input_show, NULL);
> /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
> static ssize_t fan_watchdog_show(struct device_driver *drv, char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%u\n", fan_watchdog_maxinterval);
> + return sysfs_emit(buf, "%u\n", fan_watchdog_maxinterval);
> }
>
> static ssize_t fan_watchdog_store(struct device_driver *drv, const char *buf,
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-19 15:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 9:17 [PATCH] platform/x86: thinkpad_acpi: fix coccinelle warnings Ye Guojin
2021-10-19 15:20 ` Hans de Goede
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).