Skip to content

Commit 0336d4e

Browse files
zhijianli88Jiri Kosina
authored andcommitted
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 <[email protected]> CC: Jiri Kosina <[email protected]> CC: Benjamin Tissoires <[email protected]> CC: [email protected] Signed-off-by: Li Zhijian <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 460560f commit 0336d4e

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

drivers/hid/hid-roccat-isku.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static ssize_t isku_sysfs_show_actual_profile(struct device *dev,
6161
{
6262
struct isku_device *isku =
6363
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
64-
return snprintf(buf, PAGE_SIZE, "%d\n", isku->actual_profile);
64+
return sysfs_emit(buf, "%d\n", isku->actual_profile);
6565
}
6666

6767
static ssize_t isku_sysfs_set_actual_profile(struct device *dev,

drivers/hid/hid-roccat-kone.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
400400
{
401401
struct kone_device *kone =
402402
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
403-
return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
403+
return sysfs_emit(buf, "%d\n", kone->actual_profile);
404404
}
405405
static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
406406

@@ -409,7 +409,7 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev,
409409
{
410410
struct kone_device *kone =
411411
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
412-
return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
412+
return sysfs_emit(buf, "%d\n", kone->actual_dpi);
413413
}
414414
static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
415415

@@ -432,7 +432,7 @@ static ssize_t kone_sysfs_show_weight(struct device *dev,
432432

433433
if (retval)
434434
return retval;
435-
return snprintf(buf, PAGE_SIZE, "%d\n", weight);
435+
return sysfs_emit(buf, "%d\n", weight);
436436
}
437437
static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
438438

@@ -441,7 +441,7 @@ static ssize_t kone_sysfs_show_firmware_version(struct device *dev,
441441
{
442442
struct kone_device *kone =
443443
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
444-
return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
444+
return sysfs_emit(buf, "%d\n", kone->firmware_version);
445445
}
446446
static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
447447
NULL);
@@ -451,7 +451,7 @@ static ssize_t kone_sysfs_show_tcu(struct device *dev,
451451
{
452452
struct kone_device *kone =
453453
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
454-
return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
454+
return sysfs_emit(buf, "%d\n", kone->settings.tcu);
455455
}
456456

457457
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,
553553
{
554554
struct kone_device *kone =
555555
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
556-
return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
556+
return sysfs_emit(buf, "%d\n", kone->settings.startup_profile);
557557
}
558558

559559
static ssize_t kone_sysfs_set_startup_profile(struct device *dev,

drivers/hid/hid-roccat-koneplus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
242242
{
243243
struct koneplus_device *koneplus =
244244
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
245-
return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);
245+
return sysfs_emit(buf, "%d\n", koneplus->actual_profile);
246246
}
247247

248248
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,
309309
&info, KONEPLUS_SIZE_INFO);
310310
mutex_unlock(&koneplus->koneplus_lock);
311311

312-
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
312+
return sysfs_emit(buf, "%d\n", info.firmware_version);
313313
}
314314
static DEVICE_ATTR(firmware_version, 0440,
315315
koneplus_sysfs_show_firmware_version, NULL);

drivers/hid/hid-roccat-kovaplus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev,
272272
{
273273
struct kovaplus_device *kovaplus =
274274
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
275-
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile);
275+
return sysfs_emit(buf, "%d\n", kovaplus->actual_profile);
276276
}
277277

278278
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,
325325
{
326326
struct kovaplus_device *kovaplus =
327327
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
328-
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi);
328+
return sysfs_emit(buf, "%d\n", kovaplus->actual_cpi);
329329
}
330330
static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL);
331331

@@ -334,7 +334,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_x(struct device *dev,
334334
{
335335
struct kovaplus_device *kovaplus =
336336
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
337-
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity);
337+
return sysfs_emit(buf, "%d\n", kovaplus->actual_x_sensitivity);
338338
}
339339
static DEVICE_ATTR(actual_sensitivity_x, 0440,
340340
kovaplus_sysfs_show_actual_sensitivity_x, NULL);
@@ -344,7 +344,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_y(struct device *dev,
344344
{
345345
struct kovaplus_device *kovaplus =
346346
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
347-
return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity);
347+
return sysfs_emit(buf, "%d\n", kovaplus->actual_y_sensitivity);
348348
}
349349
static DEVICE_ATTR(actual_sensitivity_y, 0440,
350350
kovaplus_sysfs_show_actual_sensitivity_y, NULL);
@@ -365,7 +365,7 @@ static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev,
365365
&info, KOVAPLUS_SIZE_INFO);
366366
mutex_unlock(&kovaplus->kovaplus_lock);
367367

368-
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
368+
return sysfs_emit(buf, "%d\n", info.firmware_version);
369369
}
370370
static DEVICE_ATTR(firmware_version, 0440,
371371
kovaplus_sysfs_show_firmware_version, NULL);

drivers/hid/hid-roccat-pyra.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
283283
{
284284
struct pyra_device *pyra =
285285
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
286-
return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
286+
return sysfs_emit(buf, "%d\n", pyra->actual_cpi);
287287
}
288288
static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
289289

@@ -300,7 +300,7 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
300300
&settings, PYRA_SIZE_SETTINGS);
301301
mutex_unlock(&pyra->pyra_lock);
302302

303-
return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
303+
return sysfs_emit(buf, "%d\n", settings.startup_profile);
304304
}
305305
static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
306306
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,
321321
&info, PYRA_SIZE_INFO);
322322
mutex_unlock(&pyra->pyra_lock);
323323

324-
return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
324+
return sysfs_emit(buf, "%d\n", info.firmware_version);
325325
}
326326
static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version,
327327
NULL);

0 commit comments

Comments
 (0)