drivers core: Miscellaneous changes for sysfs_emit
Change additional instances that could use sysfs_emit and sysfs_emit_at that the coccinelle script could not convert. o macros creating show functions with ## concatenation o unbound sprintf uses with buf+len for start of output to sysfs_emit_at o returns with ?: tests and sprintf to sysfs_emit o sysfs output with struct class * not struct device * arguments Miscellanea: o remove unnecessary initializations around these changes o consistently use int len for return length of show functions o use octal permissions and not S_<FOO> o rename a few show function names so DEVICE_ATTR_<FOO> can be used o use DEVICE_ATTR_ADMIN_RO where appropriate o consistently use const char *output for strings o checkpatch/style neatening Signed-off-by: Joe Perches <joe@perches.com> Link: https://lore.kernel.org/r/8bc24444fe2049a9b2de6127389b57edfdfe324d.1600285923.git.joe@perches.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
27275d3018
commit
948b3edba8
@@ -240,27 +240,35 @@ void device_pm_move_to_tail(struct device *dev)
|
||||
#define to_devlink(dev) container_of((dev), struct device_link, link_dev)
|
||||
|
||||
static ssize_t status_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
char *status;
|
||||
const char *output;
|
||||
|
||||
switch (to_devlink(dev)->status) {
|
||||
case DL_STATE_NONE:
|
||||
status = "not tracked"; break;
|
||||
output = "not tracked";
|
||||
break;
|
||||
case DL_STATE_DORMANT:
|
||||
status = "dormant"; break;
|
||||
output = "dormant";
|
||||
break;
|
||||
case DL_STATE_AVAILABLE:
|
||||
status = "available"; break;
|
||||
output = "available";
|
||||
break;
|
||||
case DL_STATE_CONSUMER_PROBE:
|
||||
status = "consumer probing"; break;
|
||||
output = "consumer probing";
|
||||
break;
|
||||
case DL_STATE_ACTIVE:
|
||||
status = "active"; break;
|
||||
output = "active";
|
||||
break;
|
||||
case DL_STATE_SUPPLIER_UNBIND:
|
||||
status = "supplier unbinding"; break;
|
||||
output = "supplier unbinding";
|
||||
break;
|
||||
default:
|
||||
status = "unknown"; break;
|
||||
output = "unknown";
|
||||
break;
|
||||
}
|
||||
return sysfs_emit(buf, "%s\n", status);
|
||||
|
||||
return sysfs_emit(buf, "%s\n", output);
|
||||
}
|
||||
static DEVICE_ATTR_RO(status);
|
||||
|
||||
@@ -1934,7 +1942,7 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
|
||||
struct kset *kset;
|
||||
struct kobj_uevent_env *env = NULL;
|
||||
int i;
|
||||
size_t count = 0;
|
||||
int len = 0;
|
||||
int retval;
|
||||
|
||||
/* search the kset, the device belongs to */
|
||||
@@ -1964,10 +1972,10 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
|
||||
|
||||
/* copy keys to file */
|
||||
for (i = 0; i < env->envp_idx; i++)
|
||||
count += sprintf(&buf[count], "%s\n", env->envp[i]);
|
||||
len += sysfs_emit_at(buf, len, "%s\n", env->envp[i]);
|
||||
out:
|
||||
kfree(env);
|
||||
return count;
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
|
||||
|
Reference in New Issue
Block a user