Skip to content

Commit c6f1363

Browse files
endriftdtor
authored andcommitted
Input: userio - allow setting other id values
Previously, only the type value was settable. The proto value is used internally for choosing the right drivers, so we should expose it. The other values make sense to expose as well. Signed-off-by: Vicki Pfau <vi@endrift.com> Link: https://patch.msgid.link/20260522015040.3953472-2-vi@endrift.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 37340ac commit c6f1363

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

Documentation/input/userio.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,27 @@ USERIO_CMD_SET_PORT_TYPE
6666
~~~~~~~~~~~~~~~~~~~~~~~~
6767

6868
Sets the type of port we're emulating, where ``data`` is the port type being
69-
set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
70-
would set the port type to be a normal PS/2 port.
69+
set. Can be any of the serio type macros from <linux/serio.h>. For example:
70+
SERIO_8042 would set the port type to be a normal PS/2 port.
71+
72+
USERIO_CMD_SET_PORT_PROTO
73+
~~~~~~~~~~~~~~~~~~~~~~~~~
74+
75+
Sets the protocol of port we're emulating, where ``data`` is the protocol being
76+
set. Can be any of the serio proto macros from <linux/serio.h>. For example:
77+
SERIO_IFORCE would set the port type to be an I-Force serial joystick.
78+
79+
USERIO_CMD_SET_PORT_ID
80+
~~~~~~~~~~~~~~~~~~~~~~
81+
82+
Sets the ``id`` value on the identification of port we're emulating, where
83+
``data`` is the value being set.
84+
85+
USERIO_CMD_SET_PORT_EXTRA
86+
~~~~~~~~~~~~~~~~~~~~~~~~~
87+
88+
Sets the ``extra`` value on the identification of port we're emulating, where
89+
``data`` is the value being set.
7190

7291
USERIO_CMD_SEND_INTERRUPT
7392
~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/input/serio/userio.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,36 @@ static int userio_execute_cmd(struct userio_device *userio,
206206
userio->serio->id.type = cmd->data;
207207
break;
208208

209+
case USERIO_CMD_SET_PORT_EXTRA:
210+
if (userio->running) {
211+
dev_warn(userio_misc.this_device,
212+
"Can't change port extra on an already running userio instance\n");
213+
return -EBUSY;
214+
}
215+
216+
userio->serio->id.extra = cmd->data;
217+
break;
218+
219+
case USERIO_CMD_SET_PORT_ID:
220+
if (userio->running) {
221+
dev_warn(userio_misc.this_device,
222+
"Can't change port id on an already running userio instance\n");
223+
return -EBUSY;
224+
}
225+
226+
userio->serio->id.id = cmd->data;
227+
break;
228+
229+
case USERIO_CMD_SET_PORT_PROTO:
230+
if (userio->running) {
231+
dev_warn(userio_misc.this_device,
232+
"Can't change port proto on an already running userio instance\n");
233+
return -EBUSY;
234+
}
235+
236+
userio->serio->id.proto = cmd->data;
237+
break;
238+
209239
case USERIO_CMD_SEND_INTERRUPT:
210240
if (!userio->running) {
211241
dev_warn(userio_misc.this_device,

include/uapi/linux/userio.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
enum userio_cmd_type {
2828
USERIO_CMD_REGISTER = 0,
2929
USERIO_CMD_SET_PORT_TYPE = 1,
30-
USERIO_CMD_SEND_INTERRUPT = 2
30+
USERIO_CMD_SEND_INTERRUPT = 2,
31+
USERIO_CMD_SET_PORT_EXTRA = 3,
32+
USERIO_CMD_SET_PORT_ID = 4,
33+
USERIO_CMD_SET_PORT_PROTO = 5,
3134
};
3235

3336
/*

0 commit comments

Comments
 (0)