Commit 209eb1f3 authored by Li Zhijian's avatar Li Zhijian Committed by Jiri Kosina

HID: corsair,lenovo: Convert sprintf() family to sysfs_emit() family

Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

sprintf() and scnprintf() will be converted as well if they have.

Generally, this patch is generated by
make coccicheck M=<path/to/file> MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci

No functional change intended

CC: Jiri Kosina <jikos@kernel.org>
CC: Benjamin Tissoires <benjamin.tissoires@redhat.com>
CC: linux-input@vger.kernel.org
Signed-off-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 0336d4e9
...@@ -298,7 +298,7 @@ static ssize_t k90_show_macro_mode(struct device *dev, ...@@ -298,7 +298,7 @@ static ssize_t k90_show_macro_mode(struct device *dev,
goto out; goto out;
} }
ret = snprintf(buf, PAGE_SIZE, "%s\n", macro_mode); ret = sysfs_emit(buf, "%s\n", macro_mode);
out: out:
kfree(data); kfree(data);
...@@ -367,7 +367,7 @@ static ssize_t k90_show_current_profile(struct device *dev, ...@@ -367,7 +367,7 @@ static ssize_t k90_show_current_profile(struct device *dev,
goto out; goto out;
} }
ret = snprintf(buf, PAGE_SIZE, "%d\n", current_profile); ret = sysfs_emit(buf, "%d\n", current_profile);
out: out:
kfree(data); kfree(data);
......
...@@ -555,7 +555,7 @@ static ssize_t attr_fn_lock_show(struct device *dev, ...@@ -555,7 +555,7 @@ static ssize_t attr_fn_lock_show(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data = hid_get_drvdata(hdev); struct lenovo_drvdata *data = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock); return sysfs_emit(buf, "%u\n", data->fn_lock);
} }
static ssize_t attr_fn_lock_store(struct device *dev, static ssize_t attr_fn_lock_store(struct device *dev,
...@@ -599,8 +599,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev, ...@@ -599,8 +599,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", cptkbd_data->sensitivity);
cptkbd_data->sensitivity);
} }
static ssize_t attr_sensitivity_store_cptkbd(struct device *dev, static ssize_t attr_sensitivity_store_cptkbd(struct device *dev,
...@@ -628,8 +627,8 @@ static ssize_t attr_middleclick_workaround_show_cptkbd(struct device *dev, ...@@ -628,8 +627,8 @@ static ssize_t attr_middleclick_workaround_show_cptkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n",
cptkbd_data->middleclick_workaround_cptkbd); cptkbd_data->middleclick_workaround_cptkbd);
} }
static ssize_t attr_middleclick_workaround_store_cptkbd(struct device *dev, static ssize_t attr_middleclick_workaround_store_cptkbd(struct device *dev,
...@@ -809,7 +808,7 @@ static ssize_t attr_press_to_select_show_tpkbd(struct device *dev, ...@@ -809,7 +808,7 @@ static ssize_t attr_press_to_select_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); return sysfs_emit(buf, "%u\n", data_pointer->press_to_select);
} }
static ssize_t attr_press_to_select_store_tpkbd(struct device *dev, static ssize_t attr_press_to_select_store_tpkbd(struct device *dev,
...@@ -839,7 +838,7 @@ static ssize_t attr_dragging_show_tpkbd(struct device *dev, ...@@ -839,7 +838,7 @@ static ssize_t attr_dragging_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); return sysfs_emit(buf, "%u\n", data_pointer->dragging);
} }
static ssize_t attr_dragging_store_tpkbd(struct device *dev, static ssize_t attr_dragging_store_tpkbd(struct device *dev,
...@@ -869,7 +868,7 @@ static ssize_t attr_release_to_select_show_tpkbd(struct device *dev, ...@@ -869,7 +868,7 @@ static ssize_t attr_release_to_select_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); return sysfs_emit(buf, "%u\n", data_pointer->release_to_select);
} }
static ssize_t attr_release_to_select_store_tpkbd(struct device *dev, static ssize_t attr_release_to_select_store_tpkbd(struct device *dev,
...@@ -899,7 +898,7 @@ static ssize_t attr_select_right_show_tpkbd(struct device *dev, ...@@ -899,7 +898,7 @@ static ssize_t attr_select_right_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); return sysfs_emit(buf, "%u\n", data_pointer->select_right);
} }
static ssize_t attr_select_right_store_tpkbd(struct device *dev, static ssize_t attr_select_right_store_tpkbd(struct device *dev,
...@@ -929,8 +928,7 @@ static ssize_t attr_sensitivity_show_tpkbd(struct device *dev, ...@@ -929,8 +928,7 @@ static ssize_t attr_sensitivity_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", data_pointer->sensitivity);
data_pointer->sensitivity);
} }
static ssize_t attr_sensitivity_store_tpkbd(struct device *dev, static ssize_t attr_sensitivity_store_tpkbd(struct device *dev,
...@@ -958,8 +956,7 @@ static ssize_t attr_press_speed_show_tpkbd(struct device *dev, ...@@ -958,8 +956,7 @@ static ssize_t attr_press_speed_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", data_pointer->press_speed);
data_pointer->press_speed);
} }
static ssize_t attr_press_speed_store_tpkbd(struct device *dev, static ssize_t attr_press_speed_store_tpkbd(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment