macintosh/mac_hid.c: don't load by default
Subsystems (2)
PATCH 1/1 macintosh/mac_hid.c: don't load by default
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.
--- drivers/macintosh/mac_hid.c | 2 -- 1 file changed, 2 deletions(-)
drivers/macintosh/mac_hid.c +0 -2
@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] = { { }, }; -MODULE_DEVICE_TABLE (input, mac_hid_emumouse_ids); -static struct input_handler mac_hid_emumouse_handler = { .filter = mac_hid_emumouse_filter, .connect = mac_hid_emumouse_connect,
base-commit: fef7fd48922d11b22620e19f9c9101647bfe943d
Signature · 1 line
2.38.1
Hi Thomas,
Quoted 6 lines · Thomas Weißschuh
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.
I think if someone does not need a driver they can either not enable it or blacklist it in /etc/modprobe.d/... There is no need to break module loading in the kernel.
Quoted 21 lines
Fixes 99b089c3c38a ("Input: Mac button emulation - implement as an input filter")Signed-off-by Thomas Weißschuh <[email protected]>--- drivers/macintosh/mac_hid.c | 2 -- 1 file changed, 2 deletions(-)drivers/macintosh/mac_hid.c +0
-2@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] = { { }, }; -MODULE_DEVICE_TABLE (input, mac_hid_emumouse_ids); -static struct input_handler mac_hid_emumouse_handler = { .filter = mac_hid_emumouse_filter, .connect = mac_hid_emumouse_connect,
Quoted 4 lines
base-commit:
fef7fd48922d11b22620e19f9c9101647bfe943dSignature · 1 line
2.38.1
Thanks.
Signature · 1 line
Dmitry
Cc Franz who wrote the driver originally.
(I hope I got the correct one)
Hi Dmitry,
Quoted 11 lines · Dmitry Torokhov
Quoted 6 lines · Thomas Weißschuh
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.I think if someone does not need a driver they can either not enable it or blacklist it in
/etc/modprobe.d/... There is no need to break module loading in the kernel.
But nobody needs the driver as it is autoloaded in its current state. Without manual configuration after loading the driver does not provide any functionality.
Furthermore the autoloading should load the driver for a specific hardware/resource that it can provide additional functionality for. Right now the driver loads automatically for any system that has an input device with a key and then just does nothing.
It only wastes memory and confuses users why it is loaded.
If somebody really needs this (fringe) driver it should be on them to load it it instead of everybody else having to disable it.
Furthermore the file has the following comment since the beginning of the git history in 2005:
Copyright (C) 2000 Franz Sirl
This file will soon be removed in favor of an uinput userspace tool.
Quoted 23 lines
Quoted 23 lines
Fixes 99b089c3c38a ("Input: Mac button emulation - implement as an input filter")Signed-off-by Thomas Weißschuh <[email protected]>--- drivers/macintosh/mac_hid.c | 2 -- 1 file changed, 2 deletions(-)drivers/macintosh/mac_hid.c +0
-2@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] = { { }, }; -MODULE_DEVICE_TABLE (input, mac_hid_emumouse_ids); -static struct input_handler mac_hid_emumouse_handler = { .filter = mac_hid_emumouse_filter, .connect = mac_hid_emumouse_connect,base-commit:
fef7fd48922d11b22620e19f9c9101647bfe943dSignature · 1 line
2.38.1
Quoted 27 lines · Thomas Weißschuh
Cc Franz who wrote the driver originally.
(I hope I got the correct one)Hi Dmitry,
Quoted 11 lines · Dmitry Torokhov
Quoted 6 lines · Thomas Weißschuh
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.I think if someone does not need a driver they can either not enable it or blacklist it in
/etc/modprobe.d/... There is no need to break module loading in the kernel.But nobody needs the driver as it is autoloaded in its current state. Without manual configuration after loading the driver does not provide any functionality.
Furthermore the autoloading should load the driver for a specific hardware/resource that it can provide additional functionality for. Right now the driver loads automatically for any system that has an input device with a key and then just does nothing.
Quoted 4 lines
It only wastes memory and confuses users why it is loaded.
If somebody really needs this (fringe) driver it should be on them to load it it instead of everybody else having to disable it.
The driver is not enabled by default, so somebody has to enable it in the first place. How did you end up with it?
Quoted 7 lines
Furthermore the file has the following comment since the beginning of the git history in 2005:
Copyright (C) 2000 Franz Sirl
This file will soon be removed in favor of an uinput userspace tool.
OK, that is a separate topic, if there are no users we can remove the driver. Do we know if this tool ever came into existence?
What I do not want is to break the autoload for one single driver because somebody enabled it without intending to use and now tries to implement a one-off.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Fixes 99b089c3c38a ("Input: Mac button emulation - implement as an input filter")Signed-off-by Thomas Weißschuh <[email protected]>--- drivers/macintosh/mac_hid.c | 2 -- 1 file changed, 2 deletions(-)drivers/macintosh/mac_hid.c +0
-2@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] = { { }, }; -MODULE_DEVICE_TABLE (input, mac_hid_emumouse_ids); -static struct input_handler mac_hid_emumouse_handler = { .filter = mac_hid_emumouse_filter, .connect = mac_hid_emumouse_connect,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
base-commit:
fef7fd48922d11b22620e19f9c9101647bfe943dSignature · 1 line
2.38.1
Thanks.
Signature · 1 line
Dmitry
Quoted 28 lines · Dmitry Torokhov
Quoted 27 lines · Thomas Weißschuh
Cc Franz who wrote the driver originally.
(I hope I got the correct one)Hi Dmitry,
Quoted 11 lines · Dmitry Torokhov
Quoted 6 lines · Thomas Weißschuh
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.I think if someone does not need a driver they can either not enable it or blacklist it in
/etc/modprobe.d/... There is no need to break module loading in the kernel.But nobody needs the driver as it is autoloaded in its current state. Without manual configuration after loading the driver does not provide any functionality.
Furthermore the autoloading should load the driver for a specific hardware/resource that it can provide additional functionality for. Right now the driver loads automatically for any system that has an input device with a key and then just does nothing.
Quoted 7 lines
Quoted 4 lines
It only wastes memory and confuses users why it is loaded.
If somebody really needs this (fringe) driver it should be on them to load it it instead of everybody else having to disable it.
The driver is not enabled by default, so somebody has to enable it in the first place. How did you end up with it?
My distro kernel configured it to be enabled as module.
So people who want to use it can do so. It would be nice if the rest of us wouldn't have to care about it.
Quoted 9 lines
Quoted 6 lines
Furthermore the file has the following comment since the beginning of the git history in 2005:
Copyright (C) 2000 Franz Sirl
This file will soon be removed in favor of an uinput userspace tool.
OK, that is a separate topic, if there are no users we can remove the driver. Do we know if this tool ever came into existence?
One interpretation of it is attached as "mac_hid_userspace.c".
Quoted 3 lines
What I do not want is to break the autoload for one single driver because somebody enabled it without intending to use and now tries to implement a one-off.
Is an autoloaded driver that then does not (ever) automatically provide any functionality not broken by definition?
It was enabled by the distro. Which seems correct, because maybe somebody will use it.
Taken to an illogical extreme: If it is fine for modules to load automatically even if they are not useful, why not just always load all available modules?
Maybe we can take the removal of the autoload as a first step of deprecation and finally removal of the module.
To quote you:
"I'd rather we did not promote from drivers/macintosh to other platforms,
but rather removed it. The same functionality can be done from userspace." [0]
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Fixes 99b089c3c38a ("Input: Mac button emulation - implement as an input filter")Signed-off-by Thomas Weißschuh <[email protected]>--- drivers/macintosh/mac_hid.c | 2 -- 1 file changed, 2 deletions(-)drivers/macintosh/mac_hid.c +0
-2@@ -149,8 +149,6 @@ static const struct input_device_id mac_hid_emumouse_ids[] = { { }, }; -MODULE_DEVICE_TABLE (input, mac_hid_emumouse_ids); -static struct input_handler mac_hid_emumouse_handler = { .filter = mac_hid_emumouse_filter, .connect = mac_hid_emumouse_connect,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
base-commit:
fef7fd48922d11b22620e19f9c9101647bfe943dSignature · 1 line
2.38.1
Thanks,
Thomas
[0] https://lore.kernel.org/all/20170510004327.GA32584@dtor-ws/
// SPDX-License-Identifier: GPL-2.0-only /*
* Userspace replacement for mac_hid.c from Linux. *
* Copyright (C) 2022 Thomas Weißschuh
*/
/* cc $(pkg-config --cflags libevdev) $(pkg-config --libs libevdev) mac_hid_userspace.c -o mac_hid_userspace */
#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <stdlib.h>
#include <libevdev/libevdev.h>
#include <libevdev/libevdev-uinput.h>
#include <linux/input-event-codes.h>
static void update_name(struct libevdev *dev)
{
char *name;
int rc = asprintf(&name, "%s (mac_hid)", libevdev_get_name(dev));
assert(rc > 0);
libevdev_set_name(dev, name);
free(name);
}int main(int argc, char **argv)
{
int button2 = KEY_RIGHTCTRL;
int button3 = KEY_RIGHTALT;
if (argc != 2 && argc != 4) {
fprintf(stderr, "usage: %s DEVICE [BUTTON2 BUTTON3]\n",
argv[0]);
return 1;
}
if (argc == 4) {
char *endptr;
button2 = strtol(argv[2], &endptr, 0);
assert(!*endptr);
button3 = strtol(argv[3], &endptr, 0);
assert(!*endptr);
}
struct libevdev *dev;
int fd = open(argv[1], O_RDONLY);
assert(fd != -1);
int rc = libevdev_new_from_fd(fd, &dev);
assert(rc == 0);
libevdev_enable_event_type(dev, EV_KEY);
libevdev_enable_event_code(dev, EV_KEY, BTN_MIDDLE, NULL);
libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
update_name(dev);
struct libevdev_uinput *uinput_dev;
rc = libevdev_uinput_create_from_device(
dev,
LIBEVDEV_UINPUT_OPEN_MANAGED,
&uinput_dev);
assert(rc == 0);
rc = libevdev_grab(dev, LIBEVDEV_GRAB);
assert(rc == 0);
while (1) {
struct input_event ev;
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
assert(rc == 0);
if (ev.type == EV_KEY) {
if (ev.code == button2)
ev.code = BTN_MIDDLE;
else if (ev.code == button3)
ev.code = BTN_RIGHT;
}
rc = libevdev_uinput_write_event(uinput_dev, ev.type, ev.code, ev.value);
assert(rc == 0);
}
libevdev_uinput_destroy(uinput_dev);
libevdev_free(dev);
}Quoted 31 lines · Thomas Weißschuh
Quoted 30 lines · Dmitry Torokhov
Quoted 29 lines · Thomas Weißschuh
Cc Franz who wrote the driver originally.
(I hope I got the correct one)Hi Dmitry,
Quoted 11 lines · Dmitry Torokhov
Quoted 6 lines · Thomas Weißschuh
There should be no need to automatically load this driver on *all* machines with a keyboard.
This driver is of very limited utility and has to be enabled by the user explicitly anyway.
Furthermore its own header comment has deprecated it for 17 years.I think if someone does not need a driver they can either not enable it or blacklist it in
/etc/modprobe.d/... There is no need to break module loading in the kernel.But nobody needs the driver as it is autoloaded in its current state. Without manual configuration after loading the driver does not provide any functionality.
Furthermore the autoloading should load the driver for a specific hardware/resource that it can provide additional functionality for. Right now the driver loads automatically for any system that has an input device with a key and then just does nothing.
It only wastes memory and confuses users why it is loaded.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If somebody really needs this (fringe) driver it should be on them to load it it instead of everybody else having to disable it.
The driver is not enabled by default, so somebody has to enable it in the first place. How did you end up with it?
My distro kernel configured it to be enabled as module.
Maybe you should talk to them? Which one is this? Not all distributions seem to enable it (Debian for example does not).
Quoted 13 lines
So people who want to use it can do so. It would be nice if the rest of us wouldn't have to care about it.
Quoted 9 lines
Quoted 6 lines
Furthermore the file has the following comment since the beginning of the git history in 2005:
Copyright (C) 2000 Franz Sirl
This file will soon be removed in favor of an uinput userspace tool.
OK, that is a separate topic, if there are no users we can remove the driver. Do we know if this tool ever came into existence?
Quoted 8 lines
One interpretation of it is attached as "
mac_hid_userspace.c".Quoted 3 lines
What I do not want is to break the autoload for one single driver because somebody enabled it without intending to use and now tries to implement a one-off.
Is an autoloaded driver that then does not (ever) automatically provide any functionality not broken by definition?
No because it does not result in any regression in behavior.
Quoted 5 lines
It was enabled by the distro. Which seems correct, because maybe somebody will use it.
Taken to an illogical extreme: If it is fine for modules to load automatically even if they are not useful, why not just always load all available modules?
Well, take for example a driver for a NIC. It is not really useful until you configure it by assigning an address to the interface, etc. Should we not automatically load drivers for NICs?
Quoted 9 lines
Maybe we can take the removal of the autoload as a first step of deprecation and finally removal of the module.
To quote you:"I'd rather we did not promote from
drivers/macintoshto other platforms,
but rather removed it. The same functionality can be done from userspace." [0]
I think if you talk to your distro and see if they stop enabling it and offer your userspace utility as a replacement if they indeed need the functionality would be the best way of deprecating the driver.
Thanks.
Signature · 1 line
Dmitry