From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: David Brownell <david-b@pacbell.net>,
David Brownell <dbrownell@users.sourceforge.net>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 9/22] [PATCH] platform_bus learns about modalias
Date: Wed, 21 Jun 2006 12:45:52 -0700 [thread overview]
Message-ID: <1150919192294-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <11509191893358-git-send-email-greg@kroah.com>
From: David Brownell <david-b@pacbell.net>
This patch adds modalias support to platform devices, for simpler
hotplug/coldplug driven driver setup.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/platform.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 83f5c59..f807197 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -452,6 +452,37 @@ void platform_driver_unregister(struct p
EXPORT_SYMBOL_GPL(platform_driver_unregister);
+/* modalias support enables more hands-off userspace setup:
+ * (a) environment variable lets new-style hotplug events work once system is
+ * fully running: "modprobe $MODALIAS"
+ * (b) sysfs attribute lets new-style coldplug recover from hotplug events
+ * mishandled before system is fully running: "modprobe $(cat modalias)"
+ */
+static ssize_t
+modalias_show(struct device *dev, struct device_attribute *a, char *buf)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ int len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->name);
+
+ return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+}
+
+static struct device_attribute platform_dev_attrs[] = {
+ __ATTR_RO(modalias),
+ __ATTR_NULL,
+};
+
+static int platform_uevent(struct device *dev, char **envp, int num_envp,
+ char *buffer, int buffer_size)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+
+ envp[0] = buffer;
+ snprintf(buffer, buffer_size, "MODALIAS=%s", pdev->name);
+ return 0;
+}
+
+
/**
* platform_match - bind platform device to platform driver.
* @dev: device.
@@ -496,7 +527,9 @@ static int platform_resume(struct device
struct bus_type platform_bus_type = {
.name = "platform",
+ .dev_attrs = platform_dev_attrs,
.match = platform_match,
+ .uevent = platform_uevent,
.suspend = platform_suspend,
.resume = platform_resume,
};
--
1.4.0
next prev parent reply other threads:[~2006-06-21 19:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-21 19:45 [GIT PATCH] Driver Core patches for 2.6.17 Greg KH
2006-06-21 19:45 ` [PATCH 1/22] [PATCH] kobject: make people pay attention to kobject_add errors Greg KH
2006-06-21 19:45 ` [PATCH 2/22] [PATCH] Add kernel<->userspace ABI stability documentation Greg KH
2006-06-21 19:45 ` [PATCH 3/22] [PATCH] CCISS: add device symlink to the block cciss block devices in sysfs Greg KH
2006-06-21 19:45 ` [PATCH 4/22] [PATCH] Driver core: bus device event delay Greg KH
2006-06-21 19:45 ` [PATCH 5/22] [PATCH] TTY: return class device pointer from tty_register_device() Greg KH
2006-06-21 19:45 ` [PATCH 6/22] [PATCH] i4l gigaset: move sysfs entry to tty class device Greg KH
2006-06-21 19:45 ` [PATCH 7/22] [PATCH] Driver core: class_device_add needs error checks Greg KH
2006-06-21 19:45 ` [PATCH 8/22] [PATCH] Driver Core: CONFIG_DEBUG_PM covers drivers/base/power too Greg KH
2006-06-21 19:45 ` Greg KH [this message]
2006-06-21 19:45 ` [PATCH 10/22] [PATCH] Driver Core: remove unused exports Greg KH
2006-06-21 19:45 ` [PATCH 11/22] [PATCH] Driver Core: Allow sysdev_class have attributes Greg KH
2006-06-21 19:45 ` [PATCH 12/22] [PATCH] Driver Core: Fix platform_device_add to use device_add Greg KH
2006-06-21 19:45 ` [PATCH 13/22] [PATCH] Driver Core: Add /sys/hypervisor when needed Greg KH
2006-06-21 19:45 ` [PATCH 14/22] [PATCH] remove duplication from Documentation/power/devices.txt Greg KH
2006-06-21 19:45 ` [PATCH 15/22] [PATCH] Driver core: PM_DEBUG device suspend() messages become informative Greg KH
2006-06-21 19:45 ` [PATCH 16/22] [PATCH] firmware_class: s/semaphores/mutexes Greg KH
2006-06-21 19:46 ` [PATCH 17/22] [PATCH] Driver core: change make_class_name() to take kobjects Greg KH
2006-06-21 19:46 ` [PATCH 18/22] [PATCH] Driver core: allow struct device to have a dev_t Greg KH
2006-06-21 19:46 ` [PATCH 19/22] [PATCH] Driver core: add generic "subsystem" link to all devices Greg KH
2006-06-21 19:46 ` [PATCH 20/22] [PATCH] Driver core: add proper symlinks for devices Greg KH
2006-06-21 19:46 ` [PATCH 21/22] [PATCH] Driver Core: Make dev_info and friends print the bus name if there is no driver Greg KH
2006-06-21 19:46 ` [PATCH 22/22] [PATCH] Driver model: add ISA bus Greg KH
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=1150919192294-git-send-email-greg@kroah.com \
--to=greg@kroah.com \
--cc=david-b@pacbell.net \
--cc=dbrownell@users.sourceforge.net \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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