From: "Marco d'Itri" <md@Linux.IT>
To: linux-hotplug@vger.kernel.org
Subject: hotplug patches: fixes and sysfs support 4/5
Date: Sun, 07 Mar 2004 12:48:23 +0000 [thread overview]
Message-ID: <20040307124823.GB4345@wonderland.linux.it> (raw)
In-Reply-To: <20040205010507.GA12825@wonderland.linux.it>
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
004_2.6_pci_synthesis: added sysfs support to pci.rc, enabling boot time
events synthesis on lacking the pcimodules program.
--
ciao, |
Marco | [4959 priBDK6jz7vDA]
[-- Attachment #2: 004_2.6_pci_synthesis --]
[-- Type: text/plain, Size: 2340 bytes --]
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc 2004-02-01 18:00:45.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.rc 2004-02-01 17:49:59.000000000 +0100
@@ -13,33 +13,51 @@
pci_boot_events ()
{
- #
- # FIXME on 2.5, /sys/bus/pci/devices gives some of this
- # information, and more can be gotten with 'lspci'.
- # don't expect pcimodules to exist!!
- #
- LISTER=`which pcimodules`
- if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
- echo $"** can't synthesize pci hotplug events"
- return
- fi
-
# make sure the pci agent will run
ACTION=add
PCI_CLASS=0
PCI_ID=0:0
PCI_SLOT=0:0.0
+ PCI_SLOT_NAME=0:0.0
PCI_SUBSYS_ID=0:0
- export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
+ export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SLOT_NAME PCI_SUBSYS_ID
- # these notifications will be handled by pcimodules
- for BUS in `cd /proc/bus/pci;find * -type d -print`; do
- for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
- PCI_SLOT=$BUS:$SLOT_FUNC
- : hotplug pci for $PCI_SLOT
+ if [ -d /sys/bus/pci/devices/ ]; then
+ # 2.6 kernels
+ cd /sys/bus/pci/devices/
+ for PCI_DEVICE in *; do
+ set `echo $PCI_DEVICE \
+ | sed -e 's/\([^:]*\):\(.*\):\(.*\)\.\(.*\)/\1 \2 \3 \4/'`
+ PCI_SLOT_NAME=$2:$3.$4
+ PCI_CLASS="`cat $PCI_DEVICE/class`"
+ PCI_CLASS=${PCI_CLASS#0x}
+ vendor_id=`cat $PCI_DEVICE/vendor`
+ device_id=`cat $PCI_DEVICE/device`
+ PCI_ID="${vendor_id#0x}:${device_id#0x}"
+ sub_vendor_id=`cat $PCI_DEVICE/subsystem_vendor`
+ sub_device_id=`cat $PCI_DEVICE/subsystem_device`
+ PCI_SUBSYS_ID="${sub_vendor_id#0x}:${sub_device_id#0x}"
/sbin/hotplug pci
done
- done
+ else
+ # 2.4 kernels
+ LISTER=`which pcimodules`
+ if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices
+ -o ! -x pci.agent ]; then
+ echo $"** can't synthesize pci hotplug events"
+ return
+ fi
+
+ # these notifications will be handled by pcimodules
+ for BUS in `cd /proc/bus/pci;find * -type d -print`; do
+ for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
+ PCI_SLOT=$BUS:$SLOT_FUNC
+ /sbin/hotplug pci
+ done
+ done
+ fi
+
+ return 0
}
# See how we were called.
next prev parent reply other threads:[~2004-03-07 12:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-05 1:05 hotplug patches: fixes and sysfs support Marco d'Itri
2004-02-13 11:01 ` Marco d'Itri
2004-02-21 17:48 ` Marco d'Itri
2004-02-28 14:50 ` Marco d'Itri
2004-03-07 12:42 ` hotplug patches: fixes and sysfs support 1/5 Marco d'Itri
2004-03-07 12:43 ` hotplug patches: fixes and sysfs support 2/5 Marco d'Itri
2004-03-07 12:44 ` hotplug patches: fixes and sysfs support 3/5 Marco d'Itri
2004-03-07 12:48 ` Marco d'Itri [this message]
2004-03-07 12:49 ` hotplug patches: fixes and sysfs support 5/5 Marco d'Itri
2004-03-11 23:24 ` hotplug patches: fixes and sysfs support 1/5 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=20040307124823.GB4345@wonderland.linux.it \
--to=md@linux.it \
--cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).