Change a few additional instances that could use sysfs_emit that
the coccinelle script could not convert.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/base/class.c    |  2 +-
 drivers/base/cpu.c      | 18 +++++++++---------
 drivers/base/node.c     | 15 +++------------
 drivers/base/platform.c |  4 +---
 4 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index bcd410e6d70a..c3451481194e 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -478,7 +478,7 @@ ssize_t show_class_attr_string(struct class *class,
        struct class_attribute_string *cs;
 
        cs = container_of(attr, struct class_attribute_string, attr);
-       return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
+       return sysfs_emit(buf, "%s\n", cs->str);
 }
 
 EXPORT_SYMBOL_GPL(show_class_attr_string);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 232f8146a8c4..d3dc48bf6b0f 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -241,30 +241,30 @@ unsigned int total_cpus;
 static ssize_t print_cpus_offline(struct device *dev,
                                  struct device_attribute *attr, char *buf)
 {
-       int n = 0, len = PAGE_SIZE-2;
+       int len = 0;
        cpumask_var_t offline;
 
        /* display offline cpus < nr_cpu_ids */
        if (!alloc_cpumask_var(&offline, GFP_KERNEL))
                return -ENOMEM;
        cpumask_andnot(offline, cpu_possible_mask, cpu_online_mask);
-       n = scnprintf(buf, len, "%*pbl", cpumask_pr_args(offline));
+       len += sysfs_emit_at(buf, len, "%*pbl", cpumask_pr_args(offline));
        free_cpumask_var(offline);
 
        /* display offline cpus >= nr_cpu_ids */
        if (total_cpus && nr_cpu_ids < total_cpus) {
-               if (n && n < len)
-                       buf[n++] = ',';
+               len += sysfs_emit_at(buf, len, "%s", ",");
 
                if (nr_cpu_ids == total_cpus-1)
-                       n += scnprintf(&buf[n], len - n, "%u", nr_cpu_ids);
+                       len += sysfs_emit_at(buf, len, "%u", nr_cpu_ids);
                else
-                       n += scnprintf(&buf[n], len - n, "%u-%d",
-                                                     nr_cpu_ids, total_cpus-1);
+                       len += sysfs_emit_at(buf, len, "%u-%d",
+                                            nr_cpu_ids, total_cpus-1);
        }
 
-       n += scnprintf(&buf[n], len - n, "\n");
-       return n;
+       len += sysfs_emit_at(buf, len, "%s", "\n");
+
+       return len;
 }
 static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
 
diff --git a/drivers/base/node.c b/drivers/base/node.c
index f10e8236aba8..e6092b81644d 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -945,17 +945,6 @@ void unregister_one_node(int nid)
  * node states attributes
  */
 
-static ssize_t print_nodes_state(enum node_states state, char *buf)
-{
-       int n;
-
-       n = scnprintf(buf, PAGE_SIZE - 1, "%*pbl",
-                     nodemask_pr_args(&node_states[state]));
-       buf[n++] = '\n';
-       buf[n] = '\0';
-       return n;
-}
-
 struct node_attr {
        struct device_attribute attr;
        enum node_states state;
@@ -965,7 +954,9 @@ static ssize_t show_node_state(struct device *dev,
                               struct device_attribute *attr, char *buf)
 {
        struct node_attr *na = container_of(attr, struct node_attr, attr);
-       return print_nodes_state(na->state, buf);
+
+       return sysfs_emit(buf, "%*pbl\n",
+                         nodemask_pr_args(&node_states[na->state]));
 }
 
 #define _NODE_ATTR(name, state) \
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 0e03168c657c..927047f9e6a4 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1023,9 +1023,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
        if (len != -ENODEV)
                return len;
 
-       len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
-
-       return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+       return sysfs_emit(buf, "platform:%s\n", pdev->name);
 }
 static DEVICE_ATTR_RO(modalias);
 
-- 
2.26.0

Reply via email to