linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH pci.rc with lspci instead of deprecated /proc/pci
@ 2004-02-04 19:46 mjl
  2004-02-04 20:41 ` Marco d'Itri
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mjl @ 2004-02-04 19:46 UTC (permalink / raw)
  To: linux-hotplug

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

greetings
this patch is for using lspci to generate pci semi coldplug events (ie 
load the modules...)
regards



[-- Attachment #2: hotplug.patch --]
[-- Type: text/plain, Size: 1198 bytes --]

diff -ru hotplug-2004_01_05/etc/hotplug/pci.rc hotplug-jlm/etc/hotplug/pci.rc
--- hotplug-2004_01_05/etc/hotplug/pci.rc	2003-06-28 02:13:10.000000000 +0200
+++ hotplug-jlm/etc/hotplug/pci.rc	2004-02-04 20:37:52.840130176 +0100
@@ -27,13 +27,9 @@
 
 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=`type -p pcimodules`
-    if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
+
+    LISTER=`type -p lspci`
+    if [ "$LISTER" = "" -o ! -x pci.agent ]; then
 	    echo $"** can't synthesize pci hotplug events"
 	    return
     fi
@@ -47,13 +43,11 @@
     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
+    lspci -n | gawk -F ' ' '{printf"%s\n",toupper($4)}' |
+	 while read PCI_ID; do
 	    : hotplug pci for $PCI_SLOT
 	    /sbin/hotplug pci
-	done
-    done
+	 done
 }
 
 # See how we were called.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Marco d'Itri @ 2004-02-04 20:41 UTC (permalink / raw)
  To: linux-hotplug

On Feb 04, mjl <malet.jean-luc@laposte.net> wrote:

 >this patch is for using lspci to generate pci semi coldplug events (ie 
 >load the modules...)
You cannot use awk because it's in /usr/bin/, which may not be mounted
when hotplug is started.

(I'm going to post soon a patch which will enable PCI events synthesis
for 2.6 kernels.)

-- 
ciao, |
Marco | [4457 ro0sPURkp5vwA]


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mjl @ 2004-02-05 10:50 UTC (permalink / raw)
  To: linux-hotplug

Marco d'Itri wrote:

>On Feb 04, mjl <malet.jean-luc@laposte.net> wrote:
>
> >this patch is for using lspci to generate pci semi coldplug events (ie 
> >load the modules...)
>You cannot use awk because it's in /usr/bin/, which may not be mounted
>when hotplug is started.
>
>(I'm going to post soon a patch which will enable PCI events synthesis
>for 2.6 kernels.)
>  
>
ijlm@Sorcerer:~/devel$ which lspci
/usr/sbin/lspci

so you can't use lspci too. if I remember correctly  /proc pci is a 
deprecated option....



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Mares @ 2004-02-05 16:39 UTC (permalink / raw)
  To: linux-hotplug

> 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.

				Have a nice fortnight
-- 
Martin `MJ' Mares   <mj@ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Don't take life too seriously -- you'll never get out of it alive.


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  2004-02-04 19:46 PATCH pci.rc with lspci instead of deprecated /proc/pci mjl
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2004-02-05 17:14 UTC (permalink / raw)
  To: linux-hotplug

On Thursday 05 February 2004 11:50, mjl wrote:
> Marco d'Itri wrote:

> >You cannot use awk because it's in /usr/bin/, which may not be mounted
> >when hotplug is started.

> so you can't use lspci too. if I remember correctly  /proc pci is a
> deprecated option....

How about "ls /sys/bus/pci/devices/ ; while read PCI_ID ; do ... ; done"?

	Arnd <><



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  2004-02-04 19:46 PATCH pci.rc with lspci instead of deprecated /proc/pci mjl
                   ` (3 preceding siblings ...)
  2004-02-05 17:14 ` Arnd Bergmann
@ 2004-02-05 17:21 ` Marco d'Itri
  2004-02-05 17:32 ` Måns Rullgård
  5 siblings, 0 replies; 7+ messages in thread
From: Marco d'Itri @ 2004-02-05 17:21 UTC (permalink / raw)
  To: linux-hotplug

On Feb 05, Arnd Bergmann <arnd@arndb.de> wrote:

 >How about "ls /sys/bus/pci/devices/ ; while read PCI_ID ; do ... ; done"?
Yesterday I send a patch which does this and more.
It will not support 2.4 kernels, but I don't care much.

-- 
ciao, |
Marco | [4472 esn2GieqovK/6]


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH pci.rc with lspci instead of deprecated /proc/pci
  2004-02-04 19:46 PATCH pci.rc with lspci instead of deprecated /proc/pci mjl
                   ` (4 preceding siblings ...)
  2004-02-05 17:21 ` Marco d'Itri
@ 2004-02-05 17:32 ` Måns Rullgård
  5 siblings, 0 replies; 7+ messages in thread
From: Måns Rullgård @ 2004-02-05 17:32 UTC (permalink / raw)
  To: linux-hotplug

[-- 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-02-05 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).