|
Petr Mladek |
c8e2e5 |
From 948b3edba8988306b635578a72b0dab6091a5eb0 Mon Sep 17 00:00:00 2001
|
|
Petr Mladek |
c8e2e5 |
From: Joe Perches <joe@perches.com>
|
|
Petr Mladek |
c8e2e5 |
Date: Wed, 16 Sep 2020 13:40:42 -0700
|
|
Petr Mladek |
c8e2e5 |
Subject: [PATCH] drivers core: Miscellaneous changes for sysfs_emit
|
|
Petr Mladek |
c8e2e5 |
Git-commit: 948b3edba8988306b635578a72b0dab6091a5eb0
|
|
Petr Mladek |
c8e2e5 |
Patch-mainline: v5.10-rc1
|
|
Petr Mladek |
c8e2e5 |
References: bsc#1200598 CVE-2022-20166
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
Change additional instances that could use sysfs_emit and sysfs_emit_at
|
|
Petr Mladek |
c8e2e5 |
that the coccinelle script could not convert.
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
o macros creating show functions with ## concatenation
|
|
Petr Mladek |
c8e2e5 |
o unbound sprintf uses with buf+len for start of output to sysfs_emit_at
|
|
Petr Mladek |
c8e2e5 |
o returns with ?: tests and sprintf to sysfs_emit
|
|
Petr Mladek |
c8e2e5 |
o sysfs output with struct class * not struct device * arguments
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
Miscellanea:
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
o remove unnecessary initializations around these changes
|
|
Petr Mladek |
c8e2e5 |
o consistently use int len for return length of show functions
|
|
Petr Mladek |
c8e2e5 |
o use octal permissions and not S_<FOO>
|
|
Petr Mladek |
c8e2e5 |
o rename a few show function names so DEVICE_ATTR_<FOO> can be used
|
|
Petr Mladek |
c8e2e5 |
o use DEVICE_ATTR_ADMIN_RO where appropriate
|
|
Petr Mladek |
c8e2e5 |
o consistently use const char *output for strings
|
|
Petr Mladek |
c8e2e5 |
o checkpatch/style neatening
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
Signed-off-by: Joe Perches <joe@perches.com>
|
|
Petr Mladek |
c8e2e5 |
Link: https://lore.kernel.org/r/8bc24444fe2049a9b2de6127389b57edfdfe324d.1600285923.git.joe@perches.com
|
|
Petr Mladek |
c8e2e5 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
Petr Mladek |
c8e2e5 |
Acked-by: Petr Mladek <pmladek@suse.com>
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
[ pmladek@suse.com: Removed changes when the buffer could never overflow.
|
|
Petr Mladek |
c8e2e5 |
Also removed cosmetic changes.
|
|
Petr Mladek |
c8e2e5 |
]
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
---
|
|
Petr Mladek |
c8e2e5 |
drivers/base/class.c | 2 -
|
|
Petr Mladek |
c8e2e5 |
drivers/base/core.c | 6 ++---
|
|
Petr Mladek |
c8e2e5 |
drivers/base/cpu.c | 31 +++++++++++++++---------------
|
|
Petr Mladek |
c8e2e5 |
drivers/base/node.c | 49 ++++++++++++++++++++----------------------------
|
|
Petr Mladek |
c8e2e5 |
drivers/base/platform.c | 4 ---
|
|
Petr Mladek |
c8e2e5 |
5 files changed, 42 insertions(+), 50 deletions(-)
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
--- a/drivers/base/class.c
|
|
Petr Mladek |
c8e2e5 |
+++ b/drivers/base/class.c
|
|
Petr Mladek |
c8e2e5 |
@@ -506,7 +506,7 @@ ssize_t show_class_attr_string(struct cl
|
|
Petr Mladek |
c8e2e5 |
struct class_attribute_string *cs;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
cs = container_of(attr, struct class_attribute_string, attr);
|
|
Petr Mladek |
c8e2e5 |
- return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
|
|
Petr Mladek |
c8e2e5 |
+ return sysfs_emit(buf, "%s\n", cs->str);
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
EXPORT_SYMBOL_GPL(show_class_attr_string);
|
|
Petr Mladek |
c8e2e5 |
--- a/drivers/base/core.c
|
|
Petr Mladek |
c8e2e5 |
+++ b/drivers/base/core.c
|
|
Petr Mladek |
c8e2e5 |
@@ -960,7 +960,7 @@ static ssize_t uevent_show(struct device
|
|
Petr Mladek |
c8e2e5 |
struct kset *kset;
|
|
Petr Mladek |
c8e2e5 |
struct kobj_uevent_env *env = NULL;
|
|
Petr Mladek |
c8e2e5 |
int i;
|
|
Petr Mladek |
c8e2e5 |
- size_t count = 0;
|
|
Petr Mladek |
c8e2e5 |
+ int len = 0;
|
|
Petr Mladek |
c8e2e5 |
int retval;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
/* search the kset, the device belongs to */
|
|
Petr Mladek |
c8e2e5 |
@@ -990,10 +990,10 @@ static ssize_t uevent_show(struct device
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
/* copy keys to file */
|
|
Petr Mladek |
c8e2e5 |
for (i = 0; i < env->envp_idx; i++)
|
|
Petr Mladek |
c8e2e5 |
- count += sprintf(&buf[count], "%s\n", env->envp[i]);
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%s\n", env->envp[i]);
|
|
Petr Mladek |
c8e2e5 |
out:
|
|
Petr Mladek |
c8e2e5 |
kfree(env);
|
|
Petr Mladek |
c8e2e5 |
- return count;
|
|
Petr Mladek |
c8e2e5 |
+ return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
|
|
Petr Mladek |
c8e2e5 |
--- a/drivers/base/cpu.c
|
|
Petr Mladek |
c8e2e5 |
+++ b/drivers/base/cpu.c
|
|
Petr Mladek |
c8e2e5 |
@@ -240,30 +240,30 @@ unsigned int total_cpus;
|
|
Petr Mladek |
c8e2e5 |
static ssize_t print_cpus_offline(struct device *dev,
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute *attr, char *buf)
|
|
Petr Mladek |
c8e2e5 |
{
|
|
Petr Mladek |
c8e2e5 |
- int n = 0, len = PAGE_SIZE-2;
|
|
Petr Mladek |
c8e2e5 |
+ int len = 0;
|
|
Petr Mladek |
c8e2e5 |
cpumask_var_t offline;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
/* display offline cpus < nr_cpu_ids */
|
|
Petr Mladek |
c8e2e5 |
if (!alloc_cpumask_var(&offline, GFP_KERNEL))
|
|
Petr Mladek |
c8e2e5 |
return -ENOMEM;
|
|
Petr Mladek |
c8e2e5 |
cpumask_andnot(offline, cpu_possible_mask, cpu_online_mask);
|
|
Petr Mladek |
c8e2e5 |
- n = scnprintf(buf, len, "%*pbl", cpumask_pr_args(offline));
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%*pbl", cpumask_pr_args(offline));
|
|
Petr Mladek |
c8e2e5 |
free_cpumask_var(offline);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
/* display offline cpus >= nr_cpu_ids */
|
|
Petr Mladek |
c8e2e5 |
if (total_cpus && nr_cpu_ids < total_cpus) {
|
|
Petr Mladek |
c8e2e5 |
- if (n && n < len)
|
|
Petr Mladek |
c8e2e5 |
- buf[n++] = ',';
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, ",");
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
if (nr_cpu_ids == total_cpus-1)
|
|
Petr Mladek |
c8e2e5 |
- n += snprintf(&buf[n], len - n, "%u", nr_cpu_ids);
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%u", nr_cpu_ids);
|
|
Petr Mladek |
c8e2e5 |
else
|
|
Petr Mladek |
c8e2e5 |
- n += snprintf(&buf[n], len - n, "%u-%d",
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%u-%d",
|
|
Petr Mladek |
c8e2e5 |
nr_cpu_ids, total_cpus-1);
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- n += snprintf(&buf[n], len - n, "\n");
|
|
Petr Mladek |
c8e2e5 |
- return n;
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "\n");
|
|
Petr Mladek |
c8e2e5 |
+
|
|
Petr Mladek |
c8e2e5 |
+ return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
@@ -307,22 +307,23 @@ static ssize_t print_cpu_modalias(struct
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute *attr,
|
|
Petr Mladek |
c8e2e5 |
char *buf)
|
|
Petr Mladek |
c8e2e5 |
{
|
|
Petr Mladek |
c8e2e5 |
- ssize_t n;
|
|
Petr Mladek |
c8e2e5 |
+ int len = 0;
|
|
Petr Mladek |
c8e2e5 |
u32 i;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- n = sysfs_emit(buf, "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:",
|
|
Petr Mladek |
c8e2e5 |
- CPU_FEATURE_TYPEVAL);
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len,
|
|
Petr Mladek |
c8e2e5 |
+ "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:",
|
|
Petr Mladek |
c8e2e5 |
+ CPU_FEATURE_TYPEVAL);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
for (i = 0; i < MAX_CPU_FEATURES; i++)
|
|
Petr Mladek |
c8e2e5 |
if (cpu_have_feature(i)) {
|
|
Petr Mladek |
c8e2e5 |
- if (PAGE_SIZE < n + sizeof(",XXXX\n")) {
|
|
Petr Mladek |
c8e2e5 |
+ if (len + sizeof(",XXXX\n") >= PAGE_SIZE) {
|
|
Petr Mladek |
c8e2e5 |
WARN(1, "CPU features overflow page\n");
|
|
Petr Mladek |
c8e2e5 |
break;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(&buf[n], ",%04X", i);
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, ",%04X", i);
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
- buf[n++] = '\n';
|
|
Petr Mladek |
c8e2e5 |
- return n;
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "\n");
|
|
Petr Mladek |
c8e2e5 |
+ return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|
Petr Mladek |
c8e2e5 |
--- a/drivers/base/node.c
|
|
Petr Mladek |
c8e2e5 |
+++ b/drivers/base/node.c
|
|
Petr Mladek |
c8e2e5 |
@@ -54,13 +54,13 @@ static DEVICE_ATTR(cpulist, S_IRUGO, nod
|
|
Petr Mladek |
c8e2e5 |
static ssize_t node_read_meminfo(struct device *dev,
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute *attr, char *buf)
|
|
Petr Mladek |
c8e2e5 |
{
|
|
Petr Mladek |
c8e2e5 |
- int n;
|
|
Petr Mladek |
c8e2e5 |
+ int len = 0;
|
|
Petr Mladek |
c8e2e5 |
int nid = dev->id;
|
|
Petr Mladek |
c8e2e5 |
struct pglist_data *pgdat = NODE_DATA(nid);
|
|
Petr Mladek |
c8e2e5 |
struct sysinfo i;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
si_meminfo_node(&i, nid);
|
|
Petr Mladek |
c8e2e5 |
- n = sysfs_emit(buf,
|
|
Petr Mladek |
c8e2e5 |
+ len = sysfs_emit(buf,
|
|
Petr Mladek |
c8e2e5 |
"Node %d MemTotal: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d MemFree: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d MemUsed: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
@@ -87,7 +87,7 @@ static ssize_t node_read_meminfo(struct
|
|
Petr Mladek |
c8e2e5 |
nid, K(sum_zone_node_page_state(nid, NR_MLOCK)));
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
#ifdef CONFIG_HIGHMEM
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(buf + n,
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len,
|
|
Petr Mladek |
c8e2e5 |
"Node %d HighTotal: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d HighFree: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d LowTotal: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
@@ -97,7 +97,7 @@ static ssize_t node_read_meminfo(struct
|
|
Petr Mladek |
c8e2e5 |
nid, K(i.totalram - i.totalhigh),
|
|
Petr Mladek |
c8e2e5 |
nid, K(i.freeram - i.freehigh));
|
|
Petr Mladek |
c8e2e5 |
#endif
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(buf + n,
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len,
|
|
Petr Mladek |
c8e2e5 |
"Node %d Dirty: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d Writeback: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
"Node %d FilePages: %8lu kB\n"
|
|
Petr Mladek |
c8e2e5 |
@@ -143,8 +143,8 @@ static ssize_t node_read_meminfo(struct
|
|
Petr Mladek |
c8e2e5 |
#else
|
|
Petr Mladek |
c8e2e5 |
nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
|
|
Petr Mladek |
c8e2e5 |
#endif
|
|
Petr Mladek |
c8e2e5 |
- n += hugetlb_report_node_meminfo(nid, buf + n);
|
|
Petr Mladek |
c8e2e5 |
- return n;
|
|
Petr Mladek |
c8e2e5 |
+ len += hugetlb_report_node_meminfo(nid, buf + len);
|
|
Petr Mladek |
c8e2e5 |
+ return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
#undef K
|
|
Petr Mladek |
c8e2e5 |
@@ -175,28 +175,28 @@ static ssize_t node_read_vmstat(struct d
|
|
Petr Mladek |
c8e2e5 |
int nid = dev->id;
|
|
Petr Mladek |
c8e2e5 |
struct pglist_data *pgdat = NODE_DATA(nid);
|
|
Petr Mladek |
c8e2e5 |
int i;
|
|
Petr Mladek |
c8e2e5 |
- int n = 0;
|
|
Petr Mladek |
c8e2e5 |
+ int len = 0;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(buf+n, "%s %lu\n", vmstat_text[i],
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%s %lu\n", vmstat_text[i],
|
|
Petr Mladek |
c8e2e5 |
sum_zone_node_page_state(nid, i));
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
#ifdef CONFIG_NUMA
|
|
Petr Mladek |
c8e2e5 |
for (i = 0; i < NR_VM_NUMA_STAT_ITEMS; i++)
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(buf+n, "%s %lu\n",
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%s %lu\n",
|
|
Petr Mladek |
c8e2e5 |
vmstat_text[i + NR_VM_ZONE_STAT_ITEMS],
|
|
Petr Mladek |
c8e2e5 |
sum_zone_numa_state(nid, i));
|
|
Petr Mladek |
c8e2e5 |
#endif
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
|
|
Petr Mladek |
c8e2e5 |
- n += sprintf(buf+n, "%s %lu\n",
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%s %lu\n",
|
|
Petr Mladek |
c8e2e5 |
vmstat_text[i + NR_VM_ZONE_STAT_ITEMS +
|
|
Petr Mladek |
c8e2e5 |
NR_VM_NUMA_STAT_ITEMS],
|
|
Petr Mladek |
c8e2e5 |
node_page_state(pgdat, i));
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- return n;
|
|
Petr Mladek |
c8e2e5 |
+ return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
-static DEVICE_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL);
|
|
Petr Mladek |
c8e2e5 |
+static DEVICE_ATTR(vmstat, 0444, node_read_vmstat, NULL);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
static ssize_t node_read_distance(struct device *dev,
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute *attr, char *buf)
|
|
Petr Mladek |
c8e2e5 |
@@ -211,13 +211,15 @@ static ssize_t node_read_distance(struct
|
|
Petr Mladek |
c8e2e5 |
*/
|
|
Petr Mladek |
c8e2e5 |
BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- for_each_online_node(i)
|
|
Petr Mladek |
c8e2e5 |
- len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
|
|
Petr Mladek |
c8e2e5 |
+ for_each_online_node(i) {
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "%s%d",
|
|
Petr Mladek |
c8e2e5 |
+ i ? " " : "", node_distance(nid, i));
|
|
Petr Mladek |
c8e2e5 |
+ }
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- len += sprintf(buf + len, "\n");
|
|
Petr Mladek |
c8e2e5 |
+ len += sysfs_emit_at(buf, len, "\n");
|
|
Petr Mladek |
c8e2e5 |
return len;
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
-static DEVICE_ATTR(distance, S_IRUGO, node_read_distance, NULL);
|
|
Petr Mladek |
c8e2e5 |
+static DEVICE_ATTR(distance, 0444, node_read_distance, NULL);
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
static struct attribute *node_dev_attrs[] = {
|
|
Petr Mladek |
c8e2e5 |
&dev_attr_cpumap.attr,
|
|
Petr Mladek |
c8e2e5 |
@@ -615,17 +617,6 @@ void unregister_one_node(int nid)
|
|
Petr Mladek |
c8e2e5 |
* node states attributes
|
|
Petr Mladek |
c8e2e5 |
*/
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
-static ssize_t print_nodes_state(enum node_states state, char *buf)
|
|
Petr Mladek |
c8e2e5 |
-{
|
|
Petr Mladek |
c8e2e5 |
- int n;
|
|
Petr Mladek |
c8e2e5 |
-
|
|
Petr Mladek |
c8e2e5 |
- n = scnprintf(buf, PAGE_SIZE - 1, "%*pbl",
|
|
Petr Mladek |
c8e2e5 |
- nodemask_pr_args(&node_states[state]));
|
|
Petr Mladek |
c8e2e5 |
- buf[n++] = '\n';
|
|
Petr Mladek |
c8e2e5 |
- buf[n] = '\0';
|
|
Petr Mladek |
c8e2e5 |
- return n;
|
|
Petr Mladek |
c8e2e5 |
-}
|
|
Petr Mladek |
c8e2e5 |
-
|
|
Petr Mladek |
c8e2e5 |
struct node_attr {
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute attr;
|
|
Petr Mladek |
c8e2e5 |
enum node_states state;
|
|
Petr Mladek |
c8e2e5 |
@@ -635,7 +626,9 @@ static ssize_t show_node_state(struct de
|
|
Petr Mladek |
c8e2e5 |
struct device_attribute *attr, char *buf)
|
|
Petr Mladek |
c8e2e5 |
{
|
|
Petr Mladek |
c8e2e5 |
struct node_attr *na = container_of(attr, struct node_attr, attr);
|
|
Petr Mladek |
c8e2e5 |
- return print_nodes_state(na->state, buf);
|
|
Petr Mladek |
c8e2e5 |
+
|
|
Petr Mladek |
c8e2e5 |
+ return sysfs_emit(buf, "%*pbl\n",
|
|
Petr Mladek |
c8e2e5 |
+ nodemask_pr_args(&node_states[na->state]));
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
#define _NODE_ATTR(name, state) \
|
|
Petr Mladek |
c8e2e5 |
--- a/drivers/base/platform.c
|
|
Petr Mladek |
c8e2e5 |
+++ b/drivers/base/platform.c
|
|
Petr Mladek |
c8e2e5 |
@@ -858,9 +858,7 @@ static ssize_t modalias_show(struct devi
|
|
Petr Mladek |
c8e2e5 |
if (len != -ENODEV)
|
|
Petr Mladek |
c8e2e5 |
return len;
|
|
Petr Mladek |
c8e2e5 |
|
|
Petr Mladek |
c8e2e5 |
- len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
|
|
Petr Mladek |
c8e2e5 |
-
|
|
Petr Mladek |
c8e2e5 |
- return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
|
|
Petr Mladek |
c8e2e5 |
+ return sysfs_emit(buf, "platform:%s\n", pdev->name);
|
|
Petr Mladek |
c8e2e5 |
}
|
|
Petr Mladek |
c8e2e5 |
static DEVICE_ATTR_RO(modalias);
|
|
Petr Mladek |
c8e2e5 |
|