HID: ft260: Use sysfs_emit to write formatted data to user buffer in sysfs show function.
PATCH 1/1 HID: ft260: Use sysfs_emit to write formatted data to user buffer in sysfs show function.
Inline with sysfs documentation, sysfs_emit is used in show function to write formatted data into user buffer. sysfs_emit is already PAGE_SIZE aware.
---
Note: Patch is compile tested and verified with checkpatch.
drivers/hid/hid-ft260.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-ft260.c +2 -2
@@ -826,7 +826,7 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" , *field); +return sysfs_emit (buf,"%d\n" , *field); } static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,
@@ -838,7 +838,7 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" ,le16_to_cpu (*field)); +return sysfs_emit (buf,"%d\n" ,le16_to_cpu (*field)); }#define FT260_ATTR_SHOW (name, reptype, id, type, func) \
Signature · 1 line
2.34.1
Quoted 25 lines · Bhanu Seshu Kumar Valluri
Inline with sysfs documentation,
sysfs_emitis used in show function to write formatted data into user buffer.sysfs_emitis alreadyPAGE_SIZEaware.Signed-off-by Bhanu Seshu Kumar Valluri <[email protected]>---
Note: Patch is compile tested and verified with checkpatch.drivers/hid/hid-ft260.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hid/hid-ft260.c +1
-1@@ -826,7 +826,7 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" , *field); +return sysfs_emit (buf,"%d\n" , *field); } static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,
drivers/hid/hid-ft260.c static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len, · line 841
Quoted 5 lines
drivers/hid/hid-ft260.c +1
-1@@ -838,7 +838,7 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" ,le16_to_cpu (*field)); +return sysfs_emit (buf,"%d\n" ,le16_to_cpu (*field));
There's no need to change existing users in the kernel for stuff like this, only try to do this for new sysfs files. We've had too many bugs where "simple" changes like this cause problems (recently in the USB core for example.)
thanks,
greg k-h
Quoted 37 lines · Greg KH
Quoted 25 lines · Bhanu Seshu Kumar Valluri
Inline with sysfs documentation,
sysfs_emitis used in show function to write formatted data into user buffer.sysfs_emitis alreadyPAGE_SIZEaware.Signed-off-by Bhanu Seshu Kumar Valluri <[email protected]>---
Note: Patch is compile tested and verified with checkpatch.drivers/hid/hid-ft260.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hid/hid-ft260.c +1
-1@@ -826,7 +826,7 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" , *field); +return sysfs_emit (buf,"%d\n" , *field); } static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,drivers/hid/hid-ft260.c static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len, · line 841
Quoted 5 lines
drivers/hid/hid-ft260.c +1
-1@@ -838,7 +838,7 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len,if (ret <0 )return ret; -return scnprintf (buf,PAGE_SIZE ,"%d\n" ,le16_to_cpu (*field)); +return sysfs_emit (buf,"%d\n" ,le16_to_cpu (*field));There's no need to change existing users in the kernel for stuff like this, only try to do this for new sysfs files. We've had too many bugs where "simple" changes like this cause problems (recently in the USB core for example.)
Quoted 3 lines
thanks,
greg k-h
OK. Thanks for the prompt feedback on this.