staging: greybus: audio_manager: Add missing newline to sysfs_emit outputs
Subsystems (3)
PATCH 1/1 staging: greybus: audio_manager: Add missing newline to sysfs_emit outputs
sysfs_emit outputs in audio_manager_module.c do not include a terminating newline, which is required for proper sysfs formatting.
Add newline characters to all sysfs_emit format strings.
--- drivers/staging/greybus/audio_manager_module.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/greybus/audio_manager_module.c +6 -6
@@ -75,7 +75,7 @@ static void gb_audio_module_release(struct kobject *kobj)static ssize_t gb_audio_module_name_show (struct gb_audio_manager_module *module,struct gb_audio_manager_module_attribute *attr,char *buf) { -return sysfs_emit (buf,"%s" , module->desc.name); +return sysfs_emit (buf,"%s\n" , module->desc.name); } static struct gb_audio_manager_module_attribute gb_audio_module_name_attribute =
@@ -84,7 +84,7 @@ static struct gb_audio_manager_module_attribute gb_audio_module_name_attribute =static ssize_t gb_audio_module_vid_show (struct gb_audio_manager_module *module,struct gb_audio_manager_module_attribute *attr,char *buf) { -return sysfs_emit (buf,"%d" , module->desc.vid); +return sysfs_emit (buf,"%d\n" , module->desc.vid); } static struct gb_audio_manager_module_attribute gb_audio_module_vid_attribute =
@@ -93,7 +93,7 @@ static struct gb_audio_manager_module_attribute gb_audio_module_vid_attribute =static ssize_t gb_audio_module_pid_show (struct gb_audio_manager_module *module,struct gb_audio_manager_module_attribute *attr,char *buf) { -return sysfs_emit (buf,"%d" , module->desc.pid); +return sysfs_emit (buf,"%d\n" , module->desc.pid); } static struct gb_audio_manager_module_attribute gb_audio_module_pid_attribute =
@@ -103,7 +103,7 @@ static ssize_t gb_audio_module_intf_id_show(struct gb_audio_manager_module *modustruct gb_audio_manager_module_attribute *attr, char *buf) { - return sysfs_emit(buf, "%d", module->desc.intf_id); + return sysfs_emit(buf, "%d\n", module->desc.intf_id); } static struct gb_audio_manager_module_attribute
@@ -114,7 +114,7 @@ static ssize_t gb_audio_module_ip_devices_show(struct gb_audio_manager_module *mstruct gb_audio_manager_module_attribute *attr, char *buf) { - return sysfs_emit(buf, "0x%X", module->desc.ip_devices); + return sysfs_emit(buf, "0x%X\n", module->desc.ip_devices); } static struct gb_audio_manager_module_attribute
@@ -125,7 +125,7 @@ static ssize_t gb_audio_module_op_devices_show(struct gb_audio_manager_module *mstruct gb_audio_manager_module_attribute *attr, char *buf) { - return sysfs_emit(buf, "0x%X", module->desc.op_devices); + return sysfs_emit(buf, "0x%X\n", module->desc.op_devices); } static struct gb_audio_manager_module_attribute
Signature · 1 line
2.34.1
Greg KH
maintainerQuoted 6 lines · Shivam Gupta
sysfs_emitoutputs inaudio_manager_module.cdo not include a terminating newline, which is required for proper sysfs formatting.Add newline characters to all
sysfs_emitformat strings.Signed-off-by Shivam Gupta <[email protected]>
You just changed the user/kernel api here, are you _sure_ it is ok to do so? What tools just broke or were used to test this? What tool asked you to make this change?
thanks,
greg k-h
Quoted 6 lines · Shivam Gupta
Quoted 5 lines
sysfs_emitoutputs inaudio_manager_module.cdo not include a terminating newline, which is required for proper sysfs formatting.Add newline characters to all
sysfs_emitformat strings.
Quoted 9 lines
Quoted 1 line
Signed-off-by Shivam Gupta <[email protected]>You just changed the user/kernel api here, are you _sure_ it is ok to do so? What tools just broke or were used to test this? What tool asked you to make this change?
thanks,
greg k-h
I'm not the author, but I've been going through the staging tree, running checkpatch on various files, and reading documentation to get started with kernel development. This particular file (drivers/staging/greybus/audio_manager_module.c) triggers checkpatch warnings about missing newlines in sysfs_emit calls.
It seems fine to make this change tho, as it reflects the proper kernel API documented in Documentation/filesystems/sysfs.rst. One of the examples at line 266 shows the intended behaviour as:
static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%s\n", dev->name);
}
So to answer the question: checkpatch flagged it, and the kernel documentation confirms this is the correct usage of the function.
Happy to help.
Hadi Chokr
The "don't break user space" rule is more important than style guidelines.
regards,
dan carpenter
Quoted 7 lines · Shivam Gupta
sysfs_emitoutputs inaudio_manager_module.cdo not include a terminating newline, which is required for proper sysfs formatting.Add newline characters to all
sysfs_emitformat strings.Signed-off-by Shivam Gupta <[email protected]>---
"Proper sysfs format" is all well and good, but this is something which already exists and adding a newline is changing the API. If you were a maintainer of this code, then I would have more confidence that you know all the user space code which uses this API and are able to test it thouroughly.
We merged a similar change recently and, whatever, that's fine, probably it doesn't break anything. But the more we do it, the more likely we are to break something so my instinct is that we should discourage this kind of change.
regards,
dan carpenter