Skip to content

Commit 1455cf8

Browse files
dtorgregkh
authored andcommitted
driver core: emit uevents when device is bound to a driver
There are certain touch controllers that may come up in either normal (application) or boot mode, depending on whether firmware/configuration is corrupted when they are powered on. In boot mode the kernel does not create input device instance (because it does not necessarily know the characteristics of the input device in question). Another number of controllers does not store firmware in a non-volatile memory, and they similarly need to have firmware loaded before input device instance is created. There are also other types of devices with similar behavior. There is a desire to be able to trigger firmware loading via udev, but it has to happen only when driver is bound to a physical device (i2c or spi). These udev actions can not use ADD events, as those happen too early, so we are introducing BIND and UNBIND events that are emitted at the right moment. Also, many drivers create additional driver-specific device attributes when binding to the device, to provide userspace with additional controls. The new events allow userspace to adjust these driver-specific attributes without worrying that they are not there yet. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6f7da29 commit 1455cf8

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

drivers/base/dd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ static void driver_bound(struct device *dev)
259259
if (dev->bus)
260260
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
261261
BUS_NOTIFY_BOUND_DRIVER, dev);
262+
263+
kobject_uevent(&dev->kobj, KOBJ_BIND);
262264
}
263265

264266
static int driver_sysfs_add(struct device *dev)
@@ -848,6 +850,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
848850
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
849851
BUS_NOTIFY_UNBOUND_DRIVER,
850852
dev);
853+
854+
kobject_uevent(&dev->kobj, KOBJ_UNBIND);
851855
}
852856
}
853857

include/linux/kobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ enum kobject_action {
5757
KOBJ_MOVE,
5858
KOBJ_ONLINE,
5959
KOBJ_OFFLINE,
60+
KOBJ_BIND,
61+
KOBJ_UNBIND,
6062
KOBJ_MAX
6163
};
6264

lib/kobject_uevent.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ static const char *kobject_actions[] = {
5050
[KOBJ_MOVE] = "move",
5151
[KOBJ_ONLINE] = "online",
5252
[KOBJ_OFFLINE] = "offline",
53+
[KOBJ_BIND] = "bind",
54+
[KOBJ_UNBIND] = "unbind",
5355
};
5456

5557
/**

0 commit comments

Comments
 (0)