From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 1/2] driver core: emit uevents when device is bound to a driver
Date: Sun, 12 Feb 2017 16:36:18 -0800 [thread overview]
Message-ID: <20170213003619.4083-1-dmitry.torokhov@gmail.com> (raw)
Majority of standard for a subsystem device attributes are created at the
same time devices are created, before KOBJECT_ADD uevent is emitted by the
driver core. This means that attributes are there when userspace is
notified about new device appearance.
However many drivers create additional driver-specific device attributes
when binding to the device, to provide userspace with additional controls,
and such attributes may not be there yet when userpsace receives
KOBJECT_ADD event. Changing the drivers to introduce intermediate "dummy"
device as a container for such attributes would be wasteful, and in many
cases, braking our sysfs ABI. Let's add a new event, KOBJECT_BIND (and its
counterpart, KOBJECT_UNBIND) that is emitted after a driver is bound to a
device. It can be used by userspace wishing to use driver-specific
attributes of a device.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/base/dd.c | 4 ++++
include/linux/kobject.h | 2 ++
lib/kobject_uevent.c | 2 ++
3 files changed, 8 insertions(+)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a1fbf55c4d3a..a9a5cc0560e5 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -258,6 +258,8 @@ static void driver_bound(struct device *dev)
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_BOUND_DRIVER, dev);
+
+ kobject_uevent(&dev->kobj, KOBJ_BIND);
}
static int driver_sysfs_add(struct device *dev)
@@ -839,6 +841,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_UNBOUND_DRIVER,
dev);
+
+ kobject_uevent(&dev->kobj, KOBJ_UNBIND);
}
}
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e6284591599e..07292df4776e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -57,6 +57,8 @@ enum kobject_action {
KOBJ_MOVE,
KOBJ_ONLINE,
KOBJ_OFFLINE,
+ KOBJ_BIND,
+ KOBJ_UNBIND,
KOBJ_MAX
};
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 9a2b811966eb..4682e8545b5c 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -50,6 +50,8 @@ static const char *kobject_actions[] = {
[KOBJ_MOVE] = "move",
[KOBJ_ONLINE] = "online",
[KOBJ_OFFLINE] = "offline",
+ [KOBJ_BIND] = "bind",
+ [KOBJ_UNBIND] = "unbind",
};
/**
--
2.11.0.483.g087da7b7c-goog
next reply other threads:[~2017-02-13 0:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 0:36 Dmitry Torokhov [this message]
2017-02-13 0:36 ` [PATCH 2/2] sysfs: add devm_sysfs_create_group() and friends Dmitry Torokhov
2017-03-27 17:53 ` Dmitry Torokhov
2017-03-27 19:35 ` Greg Kroah-Hartman
2017-06-07 17:04 ` Dmitry Torokhov
2017-06-17 19:27 ` Greg Kroah-Hartman
2017-02-13 12:07 ` [PATCH 1/2] driver core: emit uevents when device is bound to a driver Greg Kroah-Hartman
2017-02-13 18:46 ` Dmitry Torokhov
2017-02-14 0:52 ` Greg Kroah-Hartman
2017-02-14 4:22 ` Dmitry Torokhov
2017-07-18 19:30 [PATCH 0/2] New bind/unbingd uevents Dmitry Torokhov
2017-07-18 19:30 ` [PATCH 1/2] driver core: emit uevents when device is bound to a driver Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170213003619.4083-1-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome