Skip to content

Commit 88a8049

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.10/hid-sysfs-emit' into for-linus
- conversion from sprintf() to sysfs_emit() (Li Zhijian)
2 parents 5a95cc9 + 209eb1f commit 88a8049

10 files changed

+39
-45
lines changed

drivers/hid/hid-corsair.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static ssize_t k90_show_macro_mode(struct device *dev,
298298
goto out;
299299
}
300300

301-
ret = snprintf(buf, PAGE_SIZE, "%s\n", macro_mode);
301+
ret = sysfs_emit(buf, "%s\n", macro_mode);
302302
out:
303303
kfree(data);
304304

@@ -367,7 +367,7 @@ static ssize_t k90_show_current_profile(struct device *dev,
367367
goto out;
368368
}
369369

370-
ret = snprintf(buf, PAGE_SIZE, "%d\n", current_profile);
370+
ret = sysfs_emit(buf, "%d\n", current_profile);
371371
out:
372372
kfree(data);
373373

drivers/hid/hid-lenovo.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ static ssize_t attr_fn_lock_show(struct device *dev,
555555
struct hid_device *hdev = to_hid_device(dev);
556556
struct lenovo_drvdata *data = hid_get_drvdata(hdev);
557557

558-
return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock);
558+
return sysfs_emit(buf, "%u\n", data->fn_lock);
559559
}
560560

561561
static ssize_t attr_fn_lock_store(struct device *dev,
@@ -599,8 +599,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev,
599599
struct hid_device *hdev = to_hid_device(dev);
600600
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
601601

602-
return snprintf(buf, PAGE_SIZE, "%u\n",
603-
cptkbd_data->sensitivity);
602+
return sysfs_emit(buf, "%u\n", cptkbd_data->sensitivity);
604603
}
605604

606605
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,
628627
struct hid_device *hdev = to_hid_device(dev);
629628
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
630629

631-
return snprintf(buf, PAGE_SIZE, "%u\n",
632-
cptkbd_data->middleclick_workaround_cptkbd);
630+
return sysfs_emit(buf, "%u\n",
631+
cptkbd_data->middleclick_workaround_cptkbd);
633632
}
634633

635634
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,
809808
struct hid_device *hdev = to_hid_device(dev);
810809
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
811810

812-
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select);
811+
return sysfs_emit(buf, "%u\n", data_pointer->press_to_select);
813812
}
814813

815814
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,
839838
struct hid_device *hdev = to_hid_device(dev);
840839
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
841840

842-
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging);
841+
return sysfs_emit(buf, "%u\n", data_pointer->dragging);
843842
}
844843

845844
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,
869868
struct hid_device *hdev = to_hid_device(dev);
870869
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
871870

872-
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select);
871+
return sysfs_emit(buf, "%u\n", data_pointer->release_to_select);
873872
}
874873

875874
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,
899898
struct hid_device *hdev = to_hid_device(dev);
900899
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
901900

902-
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right);
901+
return sysfs_emit(buf, "%u\n", data_pointer->select_right);
903902
}
904903

905904
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,
929928
struct hid_device *hdev = to_hid_device(dev);
930929
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
931930

932-
return snprintf(buf, PAGE_SIZE, "%u\n",
933-
data_pointer->sensitivity);
931+
return sysfs_emit(buf, "%u\n", data_pointer->sensitivity);
934932
}
935933

936934
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,
958956
struct hid_device *hdev = to_hid_device(dev);
959957
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
960958

961-
return snprintf(buf, PAGE_SIZE, "%u\n",
962-
data_pointer->press_speed);
959+
return sysfs_emit(buf, "%u\n", data_pointer->press_speed);
963960
}
964961

965962
static ssize_t attr_press_speed_store_tpkbd(struct device *dev,

drivers/hid/hid-picolcd_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_show(struct device *dev,
256256
struct picolcd_data *data = dev_get_drvdata(dev);
257257

258258
if (data->status & PICOLCD_BOOTLOADER)
259-
return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n");
259+
return sysfs_emit(buf, "[bootloader] lcd\n");
260260
else
261-
return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n");
261+
return sysfs_emit(buf, "bootloader [lcd]\n");
262262
}
263263

264264
static ssize_t picolcd_operation_mode_store(struct device *dev,
@@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_delay_show(struct device *dev,
301301
{
302302
struct picolcd_data *data = dev_get_drvdata(dev);
303303

304-
return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay);
304+
return sysfs_emit(buf, "%hu\n", data->opmode_delay);
305305
}
306306

307307
static ssize_t picolcd_operation_mode_delay_store(struct device *dev,

drivers/hid/hid-picolcd_fb.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,10 @@ static ssize_t picolcd_fb_update_rate_show(struct device *dev,
421421
size_t ret = 0;
422422

423423
for (i = 1; i <= PICOLCDFB_UPDATE_RATE_LIMIT; i++)
424-
if (ret >= PAGE_SIZE)
425-
break;
426-
else if (i == fb_update_rate)
427-
ret += scnprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
424+
if (i == fb_update_rate)
425+
ret += sysfs_emit_at(buf, ret, "[%u] ", i);
428426
else
429-
ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
427+
ret += sysfs_emit_at(buf, ret, "%u ", i);
430428
if (ret > 0)
431429
buf[min(ret, (size_t)PAGE_SIZE)-1] = '\n';
432430
return ret;

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);

drivers/hid/hid-sensor-custom.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static ssize_t enable_sensor_show(struct device *dev,
155155
{
156156
struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
157157

158-
return sprintf(buf, "%d\n", sensor_inst->enable);
158+
return sysfs_emit(buf, "%d\n", sensor_inst->enable);
159159
}
160160

161161
static int set_power_report_state(struct hid_sensor_custom *sensor_inst,
@@ -372,14 +372,13 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
372372
sizeof(struct hid_custom_usage_desc),
373373
usage_id_cmp);
374374
if (usage_desc)
375-
return snprintf(buf, PAGE_SIZE, "%s\n",
376-
usage_desc->desc);
375+
return sysfs_emit(buf, "%s\n", usage_desc->desc);
377376
else
378-
return sprintf(buf, "not-specified\n");
377+
return sysfs_emit(buf, "not-specified\n");
379378
} else
380379
return -EINVAL;
381380

382-
return sprintf(buf, "%d\n", value);
381+
return sysfs_emit(buf, "%d\n", value);
383382
}
384383

385384
static ssize_t store_value(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)