Skip to contentSkip to conversation

ACPI: use sysfs_emit() to instead of scnprintf()

PATCH Applied [email protected] 2 participants 2 messages Nov 30, 2022 – Dec 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ACPI: use sysfs_emit() to instead of scnprintf()

From: ye xingchen <[email protected]>

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

---
v1 -> v2
combine patchs in drivers/acpi/.

 drivers/acpi/acpi_pad.c  | 4 ++--
 drivers/acpi/cppc_acpi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/acpi_pad.c +2 -2
index edbb28faee2a..02f1a1b1143c 100644
@@ -287,7 +287,7 @@ static ssize_t rrtime_store(struct device *dev,
 static ssize_t rrtime_show(struct device *dev,
 	struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time);
+	return sysfs_emit(buf, "%d\n", round_robin_time);
 }
 static DEVICE_ATTR_RW(rrtime);
 
@@ -309,7 +309,7 @@ static ssize_t idlepct_store(struct device *dev,
 static ssize_t idlepct_show(struct device *dev,
 	struct device_attribute *attr, char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct);
+	return sysfs_emit(buf, "%d\n", idle_pct);
 }
 static DEVICE_ATTR_RW(idlepct);
 
drivers/acpi/cppc_acpi.c +2 -2
index 093675b1a1ff..0f17b1c32718 100644
@@ -148,7 +148,7 @@ __ATTR(_name, 0444, show_##_name, NULL)
 		if (ret)						\
 			return ret;					\
 									\
-		return scnprintf(buf, PAGE_SIZE, "%llu\n",		\
+		return sysfs_emit(buf, "%llu\n",		\
 				(u64)st_name.member_name);		\
 	}								\
 	define_one_cppc_ro(member_name)
@@ -174,7 +174,7 @@ static ssize_t show_feedback_ctrs(struct kobject *kobj,
 	if (ret)
 		return ret;
 
-	return scnprintf(buf, PAGE_SIZE, "ref:%llu del:%llu\n",
+	return sysfs_emit(buf, "ref:%llu del:%llu\n",
 			fb_ctrs.reference, fb_ctrs.delivered);
 }
 define_one_cppc_ro(feedback_ctrs);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 49 lines · On Wed, Nov 30, 2022 at 9:16 AM <[email protected]> wrote:

From: ye xingchen <[email protected]>

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

---
v1 -> v2
combine patchs in drivers/acpi/.

 drivers/acpi/acpi_pad.c  | 4 ++--
 drivers/acpi/cppc_acpi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/acpi_pad.c +2 -2
index edbb28faee2a..02f1a1b1143c 100644
@@ -287,7 +287,7 @@ static ssize_t rrtime_store(struct device *dev,
 static ssize_t rrtime_show(struct device *dev,
        struct device_attribute *attr, char *buf)
 {
-       return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time);
+       return sysfs_emit(buf, "%d\n", round_robin_time);
 }
 static DEVICE_ATTR_RW(rrtime);
 
@@ -309,7 +309,7 @@ static ssize_t idlepct_store(struct device *dev,
 static ssize_t idlepct_show(struct device *dev,
        struct device_attribute *attr, char *buf)
 {
-       return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct);
+       return sysfs_emit(buf, "%d\n", idle_pct);
 }
 static DEVICE_ATTR_RW(idlepct);
 
drivers/acpi/cppc_acpi.c +1 -1
index 093675b1a1ff..0f17b1c32718 100644
@@ -148,7 +148,7 @@ __ATTR(_name, 0444, show_##_name, NULL)
                if (ret)                                                \
                        return ret;                                     \
                                                                        \
-               return scnprintf(buf, PAGE_SIZE, "%llu\n",              \
+               return sysfs_emit(buf, "%llu\n",                \
                                (u64)st_name.member_name);              \
        }                                                               \
        define_one_cppc_ro(member_name)

drivers/acpi/cppc_acpi.c static ssize_t show_feedback_ctrs(struct kobject *kobj,

Quoted 9 lines
drivers/acpi/cppc_acpi.c +1 -2
@@ -174,7 +174,7 @@ static ssize_t show_feedback_ctrs(struct kobject *kobj,
        if (ret)
                return ret;
 
-       return scnprintf(buf, PAGE_SIZE, "ref:%llu del:%llu\n",
+       return sysfs_emit(buf, "ref:%llu del:%llu\n",
                        fb_ctrs.reference, fb_ctrs.delivered);
 }
 define_one_cppc_ro(feedback_ctrs);
--

Applied as 6.2 material, thanks!