Skip to contentSkip to conversation

pci.agent remove

DISCUSSION Eric O. Angell 2 participants 2 messages Dec 10, 2002

lore
Share & tools
lore
#0 lore raw

Disclaimer: I didn't really bother to poke through the stuff on Sourceforge or look at the latest version, so I don't know if this has already been covered. I'm running RedHat 7.3 on a Dell Inspiron 3500, and /etc/hotplug/pci.agent contains this line:
# $Id: pci.agent,v 1.11 2001/09/07 15:57:39 dbrownell Exp $

Anyway, I just got an Edimax EP-4103DL PCMCIA Ethernet card, which uses the Realtek 8139 driver (8139too.o). I've gleaned that since this is a PCI driver, hotplug handles it rather than PC card services. However, since I'm used to the way cardmgr handles my wireless card (namely, it unloads the required modules when the card is ejected), I wanted similar behavior with this card.

After poking at some of the neighboring files, I added a remove case to the action section, and I thought I'd give it to you guys in case it proved useful to anyone.

No diff since I don't want it to be particularly easy to add the code to your file - someone who has more than an hour of familiarity with the hotplug code should look at it first. It's also not structured like the rest of the code, since I wanted to keep my modifications contained within one file. Anyway, stick this in the section that begins as "case $ACTION in" to replicate what I've got now:

# EOA 2002/12/09, not originally supposed to be robust, just supposed to make

# my Edimax EP-4301 play nicely.  However, I ended up writing it in such a
# fashion that it might actually prove moderately robust.  I'll leave that up
# to someone else to decide and revise, so use at your own risk.  Works well
# enough for me for now.  (This code largely ripped from this file,
# /etc/hotplug/hotplug.functions, and /etc/hotplug/pci.rc):
remove)
    pci_convert_vars

LABEL="PCI slot $PCI_SLOT_NAME"

DRIVERS=""
LISTER=type -p pcimodules
if [ "$LISTER" != "" ]; then
mesg "pcimodules is scanning more than $PCI_SLOT ..." DRIVERS=$LISTER
fi

if [ -r $MAP_CURRENT ]; then
if [ "$LISTER" = "" ]; then
pci_map_modules < $MAP_CURRENT
fi

if [ "$DRIVERS" = "" ]; then
return
fi

debug_mesg Unsetup $DRIVERS for $DESCRIPTION

UNMODPROBE="/sbin/modprobe -s -r"

for MODULE in $DRIVERS
do
if lsmod | grep -q "^$MODULE "; then
if grep -q "^$MODULE\$" $HOTPLUG_DIR/blacklist \
>/dev/null 2>&1; then
mesg "... not unloading blacklisted module: $MODULE" continue
fi

$UNMODPROBE $MODULE >/dev/null 2>&1
fi
done
fi

;;

Hope it's of some use to somebody.

-E

---
Eric O. Angell
Harvey Mudd College c/o 2004
Computer Scientist, Mathematician, Reverse Engineer

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 3 lines · [email protected] said:

After poking at some of the neighboring files, I added a remove case to the action section, and I thought I'd give it to you guys in case it proved useful to anyone.

Wouldn't it be better to support remove via the REMOVER interface, as is done for USB? The remover spares the system a lookup by allowing the add to bind a script to the device when it is added. Much faster.

See etc/hotplug/usb.agent, and look in the comments for the REMOVER variable, and the remove) action in the case statement.

Signature · 16 lines
Steve Williams                "The woods are lovely, dark and deep.
steve at icarus.com           But I have promises to keep,
steve at picturel.com         and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel