Skip to content

Commit 24c6268

Browse files
author
Codrin Ciubotariu
committed
input: misc: atmel_ptc: Rename input devices to atmel_ptcX
This patch sets the names for all the input devices (sliders, wheels, buttons) to atmel_ptcX, where X shows the order in which the input devices registered. This is neccessary because on the qt1 self capacitance board, a wheel is detected instead of a slider. Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent 592c16d commit 24c6268

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

drivers/input/misc/atmel_ptc.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,11 @@ static int atmel_ptc_conf_input_devs(struct atmel_ptc *ptc)
580580

581581
switch (atmel_qtm_get_scroller_type(ptc, i)) {
582582
case ATMEL_QTM_SCROLLER_TYPE_SLIDER:
583-
scroller->name = "atmel_ptc_slider";
584583
input_set_capability(scroller, EV_ABS, ABS_X);
585584
input_set_capability(scroller, EV_KEY, BTN_TOUCH);
586585
input_set_abs_params(scroller, ABS_X, 0, atmel_qtm_get_scroller_resolution(ptc, i), 0, 0);
587586
break;
588587
case ATMEL_QTM_SCROLLER_TYPE_WHEEL:
589-
scroller->name = "atmel_ptc_wheel";
590588
input_set_capability(scroller, EV_ABS, ABS_WHEEL);
591589
input_set_capability(scroller, EV_KEY, BTN_TOUCH);
592590
input_set_abs_params(scroller, ABS_WHEEL, 0, atmel_qtm_get_scroller_resolution(ptc, i), 0, 0);
@@ -607,7 +605,6 @@ static int atmel_ptc_conf_input_devs(struct atmel_ptc *ptc)
607605
if (!input_buttons)
608606
return -ENOMEM;
609607

610-
input_buttons->name = "atmel_ptc_buttons";
611608
input_buttons->dev.parent = ptc->dev;
612609
input_buttons->keycode = ptc->button_keycode;
613610
input_buttons->keycodesize = sizeof(ptc->button_keycode[0]);
@@ -646,10 +643,15 @@ static void atmel_ptc_unregister_input_devices(struct atmel_ptc *ptc)
646643

647644
static int atmel_ptc_register_input_devices(struct atmel_ptc *ptc)
648645
{
649-
int i, ret = 0;
646+
int i, ret = 0, id = 0;
650647

651648
if (ptc->buttons_input) {
652-
ret = input_register_device(ptc->buttons_input);
649+
struct input_dev *buttons = ptc->buttons_input;
650+
buttons->name = devm_kasprintf(&buttons->dev, GFP_KERNEL,
651+
"atmel_ptc%d", id++);
652+
if (!buttons->name)
653+
return -ENOMEM;
654+
ret = input_register_device(buttons);
653655
if (ret) {
654656
dev_err(ptc->dev, "can't register input button device.\n");
655657
atmel_ptc_unregister_input_devices(ptc);
@@ -665,6 +667,12 @@ static int atmel_ptc_register_input_devices(struct atmel_ptc *ptc)
665667
if (!scroller)
666668
continue;
667669

670+
scroller->name = devm_kasprintf(&scroller->dev, GFP_KERNEL,
671+
"atmel_ptc%d", id++);
672+
if (!scroller->name) {
673+
atmel_ptc_unregister_input_devices(ptc);
674+
return -ENOMEM;
675+
}
668676
ret = input_register_device(scroller);
669677
if (ret) {
670678
dev_err(ptc->dev, "can't register input scroller device.\n");

0 commit comments

Comments
 (0)