]> git.baikalelectronics.ru Git - kernel.git/commit
PCI: Hotplug: fakephp: Return success, not ENODEV, when bus rescan is triggered
authorTrent Piepho <tpiepho@freescale.com>
Mon, 7 Apr 2008 23:04:16 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Apr 2008 04:47:09 +0000 (21:47 -0700)
commit70c712535c13ae77b1c5d861b4f2f36a8f25df2e
tree27aef36da3065ef6e02f11aae34528894619ccfc
parent887678ca033a46b0122e271e8fcc2edff3f65db3
PCI: Hotplug: fakephp: Return success, not ENODEV, when bus rescan is triggered

The 'power' attribute of the fakephp driver originally only let one turn a
slot off.  If one tried to turn a slot on (echo 1 > .../power), it would
return ENODEV, as fakephp did not support this function.

An old (pre-git) patch changed this:
2004/11/11 16:33:31-08:00 jdittmer
[PATCH] fakephp: add pci bus rescan ability
http://article.gmane.org/gmane.linux.kernel/251183

Now writing "1" to the power attribute has the effect of triggering a bus
rescan, but it still returns ENODEV, probably an oversight in the above
patch.

Using the BusyBox echo will not produce an error message, but will
trigger *two* bus rescans (and return an exit code of 1):
~ # strace echo -n 1 > /sys/bus/pci/slots/0000:00:00.0/power
...
write(1, "1", 1)                        = -1 ENODEV (No such device)
write(1, "1", 1)                        = -1 ENODEV (No such device)
exit(1)                                 = ?

Using cp gives a write error, even though the write did happen and a rescan
was triggered:
~ # echo -n 1 > tmp ; cp tmp /sys/bus/pci/slots/0000:00:00.0/power
cp: Write Error: No such device

It seems much better to return success instead of failure.  The actual
status of the bus rescan is hard to return.  It happens asynchronously in a
work thread, so the sysfs store functions returns before any status is
ready (the whole point of the work queue).  And even if it didn't do this,
the rescan doesn't have any clear status to return.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
CC: Jan Dittmer <jdittmer@ppp0.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/hotplug/fakephp.c