From: Greg KH <greg@kroah.com>
To: Per Liden <per@fukt.bth.se>,
linux-hotplug-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] hotplug-ng 002 release
Date: Thu, 12 May 2005 21:42:29 +0000 [thread overview]
Message-ID: <20050512214229.GA30233@kroah.com> (raw)
In-Reply-To: <20050509211323.GB5297@tsiryulnik>
On Mon, May 09, 2005 at 11:13:24PM +0200, Per Svennerbrandt wrote:
> * Per Liden (per@fukt.bth.se) wrote:
> > On Fri, 6 May 2005, Greg KH wrote:
> >
> > [...]
> > > Now, with the 2.6.12-rc3 kernel, and a patch for module-init-tools, the
> > > USB hotplug program can be written with a simple one line shell script:
> > > modprobe $MODALIAS
> >
> > Nice, but why not just convert all this to a call to
> > request_module($MODALIAS)? Seems to me like the natural thing to do.
>
> I actually have a pretty hackish proof-of-consept patch that does
> basicly that, and have been running it on my systems for the past five
> months or so, if anybody's interested.
>
> Along with it I also have a patch witch exports the module aliases for
> PCI and USB devices through sysfs. With it the "coldplugging" of a
> system (module wise) can be reduced to pretty much:
>
> #!/bin/sh
>
> for DEV in /sys/bus/{pci,usb}/devices/*; do
> modprobe `cat $DEV/modalias`
> done
Ok, as you never posted your patch, I had to do it myself :)
Here's 3 patches that I just added to my trees, and will show up in the
next -mm release. They create the modalias file for usb and pci
devices, and add the MODALIAS env variable for the pci hotplug event.
thanks,
greg k-h
Subject: PCI: add MODALIAS to hotplug event for pci devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/hotplug.c | 10 ++++++++++
1 files changed, 10 insertions(+)
--- gregkh-2.6.orig/drivers/pci/hotplug.c 2005-05-12 14:28:39.000000000 -0700
+++ gregkh-2.6/drivers/pci/hotplug.c 2005-05-12 14:28:47.000000000 -0700
@@ -52,6 +52,16 @@
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
+ envp[i++] = scratch;
+ length += scnprintf (scratch, buffer_size - length,
+ "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
+ pdev->vendor, pdev->device,
+ pdev->subsystem_vendor, pdev->subsystem_device,
+ (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
+ (u8)(pdev->class));
+ if ((buffer_size - length <= 0) || (i >= num_envp))
+ return -ENOMEM;
+
envp[i] = NULL;
return 0;
Subject: PCI: add modalias sysfs file for pci devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/pci-sysfs.c | 12 ++++++++++++
1 files changed, 12 insertions(+)
--- gregkh-2.6.orig/drivers/pci/pci-sysfs.c 2005-05-12 14:28:25.000000000 -0700
+++ gregkh-2.6/drivers/pci/pci-sysfs.c 2005-05-12 14:28:40.000000000 -0700
@@ -73,6 +73,17 @@
return (str - buf);
}
+static ssize_t modalias_show(struct device *dev, char *buf)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+
+ return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
+ pci_dev->vendor, pci_dev->device,
+ pci_dev->subsystem_vendor, pci_dev->subsystem_device,
+ (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
+ (u8)(pci_dev->class));
+}
+
struct device_attribute pci_dev_attrs[] = {
__ATTR_RO(resource),
__ATTR_RO(vendor),
@@ -82,6 +93,7 @@
__ATTR_RO(class),
__ATTR_RO(irq),
__ATTR_RO(local_cpus),
+ __ATTR_RO(modalias),
__ATTR_NULL,
};
Subject: USB: add modalias sysfs file for usb devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/core/sysfs.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+)
--- gregkh-2.6.orig/drivers/usb/core/sysfs.c 2005-05-12 14:28:59.000000000 -0700
+++ gregkh-2.6/drivers/usb/core/sysfs.c 2005-05-12 14:29:05.000000000 -0700
@@ -286,6 +286,39 @@
}
static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
+static ssize_t show_modalias(struct device *dev, char *buf)
+{
+ struct usb_interface *intf;
+ struct usb_device *udev;
+
+ intf = to_usb_interface(dev);
+ udev = interface_to_usbdev(intf);
+ if (udev->descriptor.bDeviceClass = 0) {
+ struct usb_host_interface *alt = intf->cur_altsetting;
+
+ return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct),
+ le16_to_cpu(udev->descriptor.bcdDevice),
+ udev->descriptor.bDeviceClass,
+ udev->descriptor.bDeviceSubClass,
+ udev->descriptor.bDeviceProtocol,
+ alt->desc.bInterfaceClass,
+ alt->desc.bInterfaceSubClass,
+ alt->desc.bInterfaceProtocol);
+ } else {
+ return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct),
+ le16_to_cpu(udev->descriptor.bcdDevice),
+ udev->descriptor.bDeviceClass,
+ udev->descriptor.bDeviceSubClass,
+ udev->descriptor.bDeviceProtocol);
+ }
+
+}
+static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
+
static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceNumber.attr,
&dev_attr_bAlternateSetting.attr,
@@ -293,6 +326,7 @@
&dev_attr_bInterfaceClass.attr,
&dev_attr_bInterfaceSubClass.attr,
&dev_attr_bInterfaceProtocol.attr,
+ &dev_attr_modalias.attr,
NULL,
};
static struct attribute_group intf_attr_grp = {
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_ids93&alloc_id\x16281&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg@kroah.com>
To: Per Liden <per@fukt.bth.se>,
linux-hotplug-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] hotplug-ng 002 release
Date: Thu, 12 May 2005 14:42:29 -0700 [thread overview]
Message-ID: <20050512214229.GA30233@kroah.com> (raw)
In-Reply-To: <20050509211323.GB5297@tsiryulnik>
On Mon, May 09, 2005 at 11:13:24PM +0200, Per Svennerbrandt wrote:
> * Per Liden (per@fukt.bth.se) wrote:
> > On Fri, 6 May 2005, Greg KH wrote:
> >
> > [...]
> > > Now, with the 2.6.12-rc3 kernel, and a patch for module-init-tools, the
> > > USB hotplug program can be written with a simple one line shell script:
> > > modprobe $MODALIAS
> >
> > Nice, but why not just convert all this to a call to
> > request_module($MODALIAS)? Seems to me like the natural thing to do.
>
> I actually have a pretty hackish proof-of-consept patch that does
> basicly that, and have been running it on my systems for the past five
> months or so, if anybody's interested.
>
> Along with it I also have a patch witch exports the module aliases for
> PCI and USB devices through sysfs. With it the "coldplugging" of a
> system (module wise) can be reduced to pretty much:
>
> #!/bin/sh
>
> for DEV in /sys/bus/{pci,usb}/devices/*; do
> modprobe `cat $DEV/modalias`
> done
Ok, as you never posted your patch, I had to do it myself :)
Here's 3 patches that I just added to my trees, and will show up in the
next -mm release. They create the modalias file for usb and pci
devices, and add the MODALIAS env variable for the pci hotplug event.
thanks,
greg k-h
Subject: PCI: add MODALIAS to hotplug event for pci devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/hotplug.c | 10 ++++++++++
1 files changed, 10 insertions(+)
--- gregkh-2.6.orig/drivers/pci/hotplug.c 2005-05-12 14:28:39.000000000 -0700
+++ gregkh-2.6/drivers/pci/hotplug.c 2005-05-12 14:28:47.000000000 -0700
@@ -52,6 +52,16 @@
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
+ envp[i++] = scratch;
+ length += scnprintf (scratch, buffer_size - length,
+ "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
+ pdev->vendor, pdev->device,
+ pdev->subsystem_vendor, pdev->subsystem_device,
+ (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
+ (u8)(pdev->class));
+ if ((buffer_size - length <= 0) || (i >= num_envp))
+ return -ENOMEM;
+
envp[i] = NULL;
return 0;
Subject: PCI: add modalias sysfs file for pci devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/pci/pci-sysfs.c | 12 ++++++++++++
1 files changed, 12 insertions(+)
--- gregkh-2.6.orig/drivers/pci/pci-sysfs.c 2005-05-12 14:28:25.000000000 -0700
+++ gregkh-2.6/drivers/pci/pci-sysfs.c 2005-05-12 14:28:40.000000000 -0700
@@ -73,6 +73,17 @@
return (str - buf);
}
+static ssize_t modalias_show(struct device *dev, char *buf)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+
+ return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
+ pci_dev->vendor, pci_dev->device,
+ pci_dev->subsystem_vendor, pci_dev->subsystem_device,
+ (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
+ (u8)(pci_dev->class));
+}
+
struct device_attribute pci_dev_attrs[] = {
__ATTR_RO(resource),
__ATTR_RO(vendor),
@@ -82,6 +93,7 @@
__ATTR_RO(class),
__ATTR_RO(irq),
__ATTR_RO(local_cpus),
+ __ATTR_RO(modalias),
__ATTR_NULL,
};
Subject: USB: add modalias sysfs file for usb devices
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/core/sysfs.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+)
--- gregkh-2.6.orig/drivers/usb/core/sysfs.c 2005-05-12 14:28:59.000000000 -0700
+++ gregkh-2.6/drivers/usb/core/sysfs.c 2005-05-12 14:29:05.000000000 -0700
@@ -286,6 +286,39 @@
}
static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
+static ssize_t show_modalias(struct device *dev, char *buf)
+{
+ struct usb_interface *intf;
+ struct usb_device *udev;
+
+ intf = to_usb_interface(dev);
+ udev = interface_to_usbdev(intf);
+ if (udev->descriptor.bDeviceClass == 0) {
+ struct usb_host_interface *alt = intf->cur_altsetting;
+
+ return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct),
+ le16_to_cpu(udev->descriptor.bcdDevice),
+ udev->descriptor.bDeviceClass,
+ udev->descriptor.bDeviceSubClass,
+ udev->descriptor.bDeviceProtocol,
+ alt->desc.bInterfaceClass,
+ alt->desc.bInterfaceSubClass,
+ alt->desc.bInterfaceProtocol);
+ } else {
+ return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n",
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct),
+ le16_to_cpu(udev->descriptor.bcdDevice),
+ udev->descriptor.bDeviceClass,
+ udev->descriptor.bDeviceSubClass,
+ udev->descriptor.bDeviceProtocol);
+ }
+
+}
+static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
+
static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceNumber.attr,
&dev_attr_bAlternateSetting.attr,
@@ -293,6 +326,7 @@
&dev_attr_bInterfaceClass.attr,
&dev_attr_bInterfaceSubClass.attr,
&dev_attr_bInterfaceProtocol.attr,
+ &dev_attr_modalias.attr,
NULL,
};
static struct attribute_group intf_attr_grp = {
next prev parent reply other threads:[~2005-05-12 21:42 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-06 21:22 [ANNOUNCE] hotplug-ng 002 release Greg KH
2005-05-06 21:22 ` Greg KH
2005-05-08 22:52 ` Per Liden
2005-05-08 22:52 ` Per Liden
2005-05-09 21:13 ` Per Svennerbrandt
2005-05-09 21:13 ` Per Svennerbrandt
2005-05-10 22:17 ` Per Liden
2005-05-10 22:17 ` Per Liden
2005-05-10 22:41 ` Greg KH
2005-05-10 22:41 ` Greg KH
2005-05-10 23:56 ` Per Liden
2005-05-10 23:56 ` Per Liden
2005-05-11 1:22 ` Brian Gerst
2005-05-11 1:22 ` Brian Gerst
2005-05-11 5:33 ` Greg KH
2005-05-11 5:33 ` Greg KH
2005-05-11 17:36 ` Per Liden
2005-05-11 17:41 ` Greg KH
2005-05-18 23:00 ` Per Svennerbrandt
2005-05-18 23:00 ` Per Svennerbrandt
2005-05-18 23:00 ` [PATCH][RFC] __request_module: fixed argument request_module with waitflag Per Svennerbrandt
2005-05-18 23:00 ` Per Svennerbrandt
2005-05-18 23:01 ` [PATCH][RFC] request_modalias: MODALIAS based module loading Per Svennerbrandt
2005-05-18 23:01 ` Per Svennerbrandt
2005-05-18 23:37 ` Per Svennerbrandt
2005-05-10 22:41 ` [ANNOUNCE] hotplug-ng 002 release Greg KH
2005-05-10 22:41 ` Greg KH
2005-05-12 21:42 ` Greg KH [this message]
2005-05-12 21:42 ` Greg KH
2005-05-13 8:19 ` Michael Tokarev
2005-05-13 8:19 ` Michael Tokarev
2005-05-13 16:02 ` Greg KH
2005-05-13 16:02 ` Greg KH
2005-05-13 23:21 ` Per Svennerbrandt
2005-05-13 23:21 ` Per Svennerbrandt
2005-05-14 5:59 ` Greg KH
2005-05-14 5:59 ` Greg KH
2005-05-15 22:37 ` Per Svennerbrandt
2005-05-18 9:27 ` David Weinehall
2005-05-18 9:27 ` David Weinehall
2005-05-09 23:22 ` Greg KH
2005-05-09 23:22 ` Greg KH
2005-05-10 21:51 ` Per Liden
2005-05-10 21:51 ` Per Liden
2005-05-11 5:36 ` Greg KH
2005-05-11 5:36 ` Greg KH
2005-05-09 3:57 ` Rusty Russell
2005-05-09 3:57 ` Rusty Russell
2005-05-09 23:21 ` Greg KH
2005-05-09 23:21 ` Greg KH
2005-05-10 9:29 ` Rusty Russell
2005-05-10 9:29 ` Rusty Russell
2005-05-10 9:43 ` Marco d'Itri
2005-05-10 9:43 ` Marco d'Itri
2005-05-10 12:58 ` Alexander E. Patrakov
2005-05-10 12:58 ` Alexander E. Patrakov
2005-05-10 17:24 ` Marco d'Itri
2005-05-10 17:24 ` Marco d'Itri
2005-05-10 20:13 ` Greg KH
2005-05-10 20:13 ` Greg KH
2005-05-10 20:28 ` Lee Revell
2005-05-10 20:28 ` Lee Revell
2005-05-10 20:59 ` Greg KH
2005-05-10 20:59 ` Greg KH
2005-05-10 21:02 ` Marco d'Itri
2005-05-10 21:02 ` Marco d'Itri
2005-05-10 20:31 ` Marco d'Itri
2005-05-10 20:31 ` Marco d'Itri
2005-05-10 20:52 ` Greg KH
2005-05-10 20:52 ` Greg KH
2005-05-10 20:59 ` Bill Nottingham
2005-05-10 20:59 ` Bill Nottingham
2005-05-10 21:08 ` Marco d'Itri
2005-05-10 21:08 ` Marco d'Itri
2005-05-10 21:22 ` Erik van Konijnenburg
2005-05-10 21:22 ` Erik van Konijnenburg
2005-05-10 23:55 ` [PATCH] " Erik van Konijnenburg
2005-05-10 23:55 ` Erik van Konijnenburg
2005-05-11 0:05 ` Marco d'Itri
2005-05-11 0:05 ` Marco d'Itri
2005-05-11 5:40 ` Greg KH
2005-05-11 5:40 ` Greg KH
2005-05-11 0:08 ` [PATCH] " Rusty Russell
2005-05-11 0:08 ` Rusty Russell
2005-05-11 1:11 ` Erik van Konijnenburg
2005-05-11 1:11 ` Erik van Konijnenburg
2005-05-11 3:39 ` Rusty Russell
2005-05-11 3:39 ` Rusty Russell
2005-05-11 9:59 ` Erik van Konijnenburg
2005-05-11 9:59 ` Erik van Konijnenburg
2005-05-11 10:52 ` Rusty Russell
2005-05-11 10:52 ` Rusty Russell
2005-05-11 10:58 ` Marco d'Itri
2005-05-11 10:58 ` Marco d'Itri
2005-05-11 13:06 ` Erik van Konijnenburg
2005-05-11 13:06 ` Erik van Konijnenburg
2005-05-12 4:39 ` Rusty Russell
2005-05-12 4:39 ` Rusty Russell
2005-05-12 7:47 ` Erik van Konijnenburg
2005-05-12 7:47 ` Erik van Konijnenburg
2005-05-10 21:21 ` Giuseppe Bilotta
2005-05-11 0:01 ` Rusty Russell
2005-05-11 0:01 ` Rusty Russell
2005-05-11 0:10 ` Marco d'Itri
2005-05-11 0:10 ` Marco d'Itri
2005-05-11 1:09 ` Rusty Russell
2005-05-11 1:09 ` Rusty Russell
2005-05-11 7:31 ` Christian Zoz
2005-05-14 23:02 ` Michael Tokarev
2005-05-14 23:02 ` Michael Tokarev
2005-05-16 19:11 ` Greg KH
2005-05-16 19:11 ` Greg KH
2005-05-16 21:24 ` Marco d'Itri
[not found] <41iyE-8mI-11@gated-at.bofh.it>
[not found] ` <427KM-h4-9@gated-at.bofh.it>
[not found] ` <42pRx-75A-19@gated-at.bofh.it>
[not found] ` <42znJ-6x7-25@gated-at.bofh.it>
[not found] ` <42zQL-70r-25@gated-at.bofh.it>
[not found] ` <42CF0-YV-37@gated-at.bofh.it>
[not found] ` <42GIH-4u3-31@gated-at.bofh.it>
[not found] ` <42Jn3-6Qj-5@gated-at.bofh.it>
[not found] ` <42KsY-7KW-33@gated-at.bofh.it>
2005-05-11 2:04 ` Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>
2005-05-11 2:04 ` Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>
2005-05-18 7:23 ` Giuseppe Bilotta
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=20050512214229.GA30233@kroah.com \
--to=greg@kroah.com \
--cc=linux-hotplug-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=per@fukt.bth.se \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.