Skip to content

Commit 6d9b262

Browse files
TomAi0jwrdegoede
authored andcommitted
platform/x86: hp-wmi: use sysfs_emit() instead of sprintf()
Follow the advice in Documentation/filesystems/sysfs.rst: show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Ai Chao <aichao@kylinos.cn> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240314063703.315841-1-aichao@kylinos.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 3ff5873 commit 6d9b262

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/platform/x86/hp/hp-wmi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static ssize_t display_show(struct device *dev, struct device_attribute *attr,
681681

682682
if (value < 0)
683683
return value;
684-
return sprintf(buf, "%d\n", value);
684+
return sysfs_emit(buf, "%d\n", value);
685685
}
686686

687687
static ssize_t hddtemp_show(struct device *dev, struct device_attribute *attr,
@@ -691,7 +691,7 @@ static ssize_t hddtemp_show(struct device *dev, struct device_attribute *attr,
691691

692692
if (value < 0)
693693
return value;
694-
return sprintf(buf, "%d\n", value);
694+
return sysfs_emit(buf, "%d\n", value);
695695
}
696696

697697
static ssize_t als_show(struct device *dev, struct device_attribute *attr,
@@ -701,7 +701,7 @@ static ssize_t als_show(struct device *dev, struct device_attribute *attr,
701701

702702
if (value < 0)
703703
return value;
704-
return sprintf(buf, "%d\n", value);
704+
return sysfs_emit(buf, "%d\n", value);
705705
}
706706

707707
static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
@@ -711,7 +711,7 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
711711

712712
if (value < 0)
713713
return value;
714-
return sprintf(buf, "%d\n", value);
714+
return sysfs_emit(buf, "%d\n", value);
715715
}
716716

717717
static ssize_t tablet_show(struct device *dev, struct device_attribute *attr,
@@ -721,7 +721,7 @@ static ssize_t tablet_show(struct device *dev, struct device_attribute *attr,
721721

722722
if (value < 0)
723723
return value;
724-
return sprintf(buf, "%d\n", value);
724+
return sysfs_emit(buf, "%d\n", value);
725725
}
726726

727727
static ssize_t postcode_show(struct device *dev, struct device_attribute *attr,
@@ -732,7 +732,7 @@ static ssize_t postcode_show(struct device *dev, struct device_attribute *attr,
732732

733733
if (value < 0)
734734
return value;
735-
return sprintf(buf, "0x%x\n", value);
735+
return sysfs_emit(buf, "0x%x\n", value);
736736
}
737737

738738
static ssize_t als_store(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)