All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olh@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: Re: pci coldplug
Date: Wed, 05 Nov 2003 23:19:42 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-106807447907014@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-106806874232064@msgid-missing>

 On Wed, Nov 05, Olaf Hering wrote:

> Hello,
> 
> what is the purpose of pci_boot_events() in pci.rc? I mean, how can that
> ever work in the current cvs? I did it that way and it appears to work
> ok for a 2.4 kernel (probably also for 2.6):

Something that could work for 2.4:


Index: etc/hotplug/pci.agent
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.agent,v
retrieving revision 1.13
diff -u -p -r1.13 pci.agent
--- etc/hotplug/pci.agent	16 Sep 2003 19:42:17 -0000	1.13
+++ etc/hotplug/pci.agent	5 Nov 2003 23:08:02 -0000
@@ -9,7 +9,7 @@
 # Kernel Cardbus/PCI params are:
 #	
 #	ACTION=%s [add or remove]
-#	PCI_CLASS=%06X
+#	PCI_CLASS=%04X
 #	PCI_ID=%04X:%04X
 #	PCI_SLOT_NAME=%s
 #	PCI_SUBSYS_ID=%04X:%04X
@@ -41,7 +41,7 @@ MAP_CURRENT=$MODULE_DIR/modules.pcimap
 # accumulates list of modules we may care about
 DRIVERS 
-if [ "$PCI_CLASS" = ""  -o "$PCI_CLASS" = "" ]; then
+if [ "$PCI_CLASS" = "" ]; then
     mesg Bad PCI agent invocation
     exit 1
 fi
@@ -69,13 +69,30 @@ pci_convert_vars ()
 	exit 1
     fi
 
-    pci_class=0x$PCI_CLASS
-
-    set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_CLASS" in
+    	0x*) pci_class=$PCI_CLASS ;;
+	*) pci_class=0x$PCI_CLASS ;;
+    esac
+
+    case "$PCI_ID" in
+    	0x*)
+	set `echo $PCI_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    	;;
+    esac
     pci_id_vendor=$1
     pci_id_device=$2
 
-    set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_SUBSYS_ID" in
+	0x*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+	;;
+    esac
     pci_subid_vendor=$1
     pci_subid_device=$2
 }
Index: etc/hotplug/pci.rc
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v
retrieving revision 1.7
diff -u -p -r1.7 pci.rc
--- etc/hotplug/pci.rc	6 Jun 2003 18:27:23 -0000	1.7
+++ etc/hotplug/pci.rc	5 Nov 2003 23:08:02 -0000
@@ -27,32 +27,34 @@ fi
 
 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
+    if [ ! -x /sbin/lspci -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≠d
-    PCI_CLASS=0
-    PCI_ID=0:0
-    PCI_SLOT=0:0.0
-    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
-	done
+    /sbin/lspci -nm | sed 's/"//g' | while read pci_data ; do
+	set - $pci_data ''
+	ACTION≠d
+	PCI_SLOT=$1
+	shift 2
+	PCI_CLASS=$1
+	shift
+	PCI_ID=$1:$2
+	shift 2
+	case "$1" in
+		-r*) shift;;
+	esac
+	case "$1" in
+		-p*) pci_progif=${1#-p} ; shift ;;
+		*) pci_progif\0 ;;
+	esac
+	if [ "$1" = "" ] ; then
+		PCI_SUBSYS_ID=0:0
+	else
+		PCI_SUBSYS_ID=$1:$2
+	fi
+	echo ACTION=$ACTION PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug pci
+	env -i - ACTION=$ACTION PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug pci
     done
 }
 

-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, n√úRNBERG


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
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

  reply	other threads:[~2003-11-05 23:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-05 21:43 pci coldplug Olaf Hering
2003-11-05 23:19 ` Olaf Hering [this message]
2003-11-11 20:23 ` Olaf Hering

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=marc-linux-hotplug-106807447907014@msgid-missing \
    --to=olh@suse.de \
    --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 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.