HID: roccat: 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: Stefan Achatz <erazor_de@users.sourceforge.net> CC: Jiri Kosina <jikos@kernel.org> CC: Benjamin Tissoires <benjamin.tissoires@redhat.com> CC: linux-input@vger.kernel.org Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
460560fda3
commit
0336d4e997
@ -61,7 +61,7 @@ static ssize_t isku_sysfs_show_actual_profile(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct isku_device *isku =
|
struct isku_device *isku =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", isku->actual_profile);
|
return sysfs_emit(buf, "%d\n", isku->actual_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t isku_sysfs_set_actual_profile(struct device *dev,
|
static ssize_t isku_sysfs_set_actual_profile(struct device *dev,
|
||||||
|
@ -400,7 +400,7 @@ static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kone_device *kone =
|
struct kone_device *kone =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
|
return sysfs_emit(buf, "%d\n", kone->actual_profile);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
|
static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kone_device *kone =
|
struct kone_device *kone =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
|
return sysfs_emit(buf, "%d\n", kone->actual_dpi);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
|
static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ static ssize_t kone_sysfs_show_weight(struct device *dev,
|
|||||||
|
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", weight);
|
return sysfs_emit(buf, "%d\n", weight);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
|
static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ static ssize_t kone_sysfs_show_firmware_version(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kone_device *kone =
|
struct kone_device *kone =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
|
return sysfs_emit(buf, "%d\n", kone->firmware_version);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
|
static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
|
||||||
NULL);
|
NULL);
|
||||||
@ -451,7 +451,7 @@ static ssize_t kone_sysfs_show_tcu(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kone_device *kone =
|
struct kone_device *kone =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
|
return sysfs_emit(buf, "%d\n", kone->settings.tcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kone_tcu_command(struct usb_device *usb_dev, int number)
|
static int kone_tcu_command(struct usb_device *usb_dev, int number)
|
||||||
@ -553,7 +553,7 @@ static ssize_t kone_sysfs_show_startup_profile(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kone_device *kone =
|
struct kone_device *kone =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
|
return sysfs_emit(buf, "%d\n", kone->settings.startup_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
|
static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
|
||||||
|
@ -242,7 +242,7 @@ static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct koneplus_device *koneplus =
|
struct koneplus_device *koneplus =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);
|
return sysfs_emit(buf, "%d\n", koneplus->actual_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
|
static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
|
||||||
@ -309,7 +309,7 @@ static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,
|
|||||||
&info, KONEPLUS_SIZE_INFO);
|
&info, KONEPLUS_SIZE_INFO);
|
||||||
mutex_unlock(&koneplus->koneplus_lock);
|
mutex_unlock(&koneplus->koneplus_lock);
|
||||||
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
|
return sysfs_emit(buf, "%d\n", info.firmware_version);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(firmware_version, 0440,
|
static DEVICE_ATTR(firmware_version, 0440,
|
||||||
koneplus_sysfs_show_firmware_version, NULL);
|
koneplus_sysfs_show_firmware_version, NULL);
|
||||||
|
@ -272,7 +272,7 @@ static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kovaplus_device *kovaplus =
|
struct kovaplus_device *kovaplus =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile);
|
return sysfs_emit(buf, "%d\n", kovaplus->actual_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev,
|
static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev,
|
||||||
@ -325,7 +325,7 @@ static ssize_t kovaplus_sysfs_show_actual_cpi(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kovaplus_device *kovaplus =
|
struct kovaplus_device *kovaplus =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi);
|
return sysfs_emit(buf, "%d\n", kovaplus->actual_cpi);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL);
|
static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL);
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_x(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kovaplus_device *kovaplus =
|
struct kovaplus_device *kovaplus =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity);
|
return sysfs_emit(buf, "%d\n", kovaplus->actual_x_sensitivity);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_sensitivity_x, 0440,
|
static DEVICE_ATTR(actual_sensitivity_x, 0440,
|
||||||
kovaplus_sysfs_show_actual_sensitivity_x, NULL);
|
kovaplus_sysfs_show_actual_sensitivity_x, NULL);
|
||||||
@ -344,7 +344,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_y(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct kovaplus_device *kovaplus =
|
struct kovaplus_device *kovaplus =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity);
|
return sysfs_emit(buf, "%d\n", kovaplus->actual_y_sensitivity);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_sensitivity_y, 0440,
|
static DEVICE_ATTR(actual_sensitivity_y, 0440,
|
||||||
kovaplus_sysfs_show_actual_sensitivity_y, NULL);
|
kovaplus_sysfs_show_actual_sensitivity_y, NULL);
|
||||||
@ -365,7 +365,7 @@ static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev,
|
|||||||
&info, KOVAPLUS_SIZE_INFO);
|
&info, KOVAPLUS_SIZE_INFO);
|
||||||
mutex_unlock(&kovaplus->kovaplus_lock);
|
mutex_unlock(&kovaplus->kovaplus_lock);
|
||||||
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
|
return sysfs_emit(buf, "%d\n", info.firmware_version);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(firmware_version, 0440,
|
static DEVICE_ATTR(firmware_version, 0440,
|
||||||
kovaplus_sysfs_show_firmware_version, NULL);
|
kovaplus_sysfs_show_firmware_version, NULL);
|
||||||
|
@ -283,7 +283,7 @@ static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct pyra_device *pyra =
|
struct pyra_device *pyra =
|
||||||
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
|
return sysfs_emit(buf, "%d\n", pyra->actual_cpi);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
|
static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
|
|||||||
&settings, PYRA_SIZE_SETTINGS);
|
&settings, PYRA_SIZE_SETTINGS);
|
||||||
mutex_unlock(&pyra->pyra_lock);
|
mutex_unlock(&pyra->pyra_lock);
|
||||||
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
|
return sysfs_emit(buf, "%d\n", settings.startup_profile);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
|
static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
|
||||||
static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
|
static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
|
||||||
@ -321,7 +321,7 @@ static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
|
|||||||
&info, PYRA_SIZE_INFO);
|
&info, PYRA_SIZE_INFO);
|
||||||
mutex_unlock(&pyra->pyra_lock);
|
mutex_unlock(&pyra->pyra_lock);
|
||||||
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
|
return sysfs_emit(buf, "%d\n", info.firmware_version);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version,
|
static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version,
|
||||||
NULL);
|
NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user