linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mru@kth.se (Måns Rullgård)
To: linux-hotplug@vger.kernel.org
Subject: Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
Date: Thu, 05 Feb 2004 17:32:51 +0000	[thread overview]
Message-ID: <yw1xu125whx8.fsf@kth.se> (raw)
In-Reply-To: <40214C0A.5070307@laposte.net>

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]

Martin Mares <mj@ucw.cz> writes:

>> You cannot use awk because it's in /usr/bin/, which may not be mounted
>> when hotplug is started.
>
> "cut -d' ' -f4" should be fine.

This patch is working well for me with Linux 2.6.2.  Please tell me if
I've missed something.

-- 
Måns Rullgård
mru@kth.se


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hotplug-linux2.6.diff --]
[-- Type: text/x-patch, Size: 2680 bytes --]

Index: etc/hotplug/hotplug.functions
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/hotplug.functions,v
retrieving revision 1.22
diff -u -r1.22 hotplug.functions
--- etc/hotplug/hotplug.functions	7 Oct 2003 21:15:38 -0000	1.22
+++ etc/hotplug/hotplug.functions	5 Jan 2004 18:33:33 -0000
@@ -139,7 +139,7 @@
     do
 	# maybe driver modules need loading
         LOADED=false
-	if ! lsmod | grep -q "^$MODULE " > /dev/null 2>&1; then
+	if ! lsmod | grep -q "^${MODULE//-/_} " > /dev/null 2>&1; then
 	    if grep -q "^$MODULE\$" $HOTPLUG_DIR/blacklist \
 		    >/dev/null 2>&1; then
 		debug_mesg "... blacklisted module:  $MODULE"
Index: etc/hotplug/pci.agent
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.agent,v
retrieving revision 1.13
diff -u -r1.13 pci.agent
--- etc/hotplug/pci.agent	16 Sep 2003 19:42:17 -0000	1.13
+++ etc/hotplug/pci.agent	5 Jan 2004 18:33:33 -0000
@@ -147,7 +147,7 @@
 add)
     pci_convert_vars
 
-    LABEL="PCI slot $PCI_SLOT_NAME"
+    LABEL="PCI slot $PCI_SLOT"
 
     # on 2.4 systems, modutils maintains MAP_CURRENT
     if [ -r $MAP_CURRENT ]; then
Index: etc/hotplug/pci.rc
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v
retrieving revision 1.7
diff -u -r1.7 pci.rc
--- etc/hotplug/pci.rc	6 Jun 2003 18:27:23 -0000	1.7
+++ etc/hotplug/pci.rc	5 Jan 2004 18:33:33 -0000
@@ -25,6 +25,11 @@
 #     . /etc/sysconfig/pci
 # fi
 
+sys_file ()
+{
+    cut -f2 -dx $DEVICE/$1
+}
+
 pci_boot_events ()
 {
     #
@@ -46,14 +51,27 @@
     PCI_SUBSYS_ID=0:0
     export ACTION PCI_CLASS PCI_ID PCI_SLOT 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
-	    /sbin/hotplug pci
+    case $KERNEL in
+	2.5*|2.6*)
+	    for DEVICE in /sys/bus/pci/devices/*; do
+		PCI_CLASS=`sys_file class`
+		PCI_ID=`sys_file vendor`:`sys_file device`
+		PCI_SLOT=`echo $DEVICE | cut -d: -f2-`
+		PCI_SUBSYS_ID=`sys_file subsystem_vendor`:`sys_file subsystem_device`
+		/sbin/hotplug pci
+	    done
+	    ;;
+	2.4*)
+	# 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
+		/sbin/hotplug pci
+	    done
 	done
-    done
+	;;
+    esac
 }
 
 # See how we were called.

      parent reply	other threads:[~2004-02-05 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-04 19:46 PATCH pci.rc with lspci instead of deprecated /proc/pci mjl
2004-02-04 20:41 ` Marco d'Itri
2004-02-05 10:50 ` mjl
2004-02-05 16:39 ` Martin Mares
2004-02-05 17:14 ` Arnd Bergmann
2004-02-05 17:21 ` Marco d'Itri
2004-02-05 17:32 ` Måns Rullgård [this message]

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=yw1xu125whx8.fsf@kth.se \
    --to=mru@kth.se \
    --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).