On Thu, Mar 25, 2010 at 09:54:50AM +0100, Giel van Schijndel wrote: > On Wed, Mar 24, 2010 at 03:51:51PM +0000, Alan Cox wrote: >>> hold on the SIO port range. This would thus interfere with the >>> operation of the f71882fg driver. I.e. it would prevent the device >>> probing stage from working, thus preventing it from loading *after* >>> my in-development watchdog driver. >> >> There are two ways to deal with that really >> >> ... snip ... >> >> 2. Fix the kernel request_resource stuff to support a sleeping non >> exclusive resource so request/free of regions can be used as a resource >> semaphore by co-operative devices. >> >> #2 is actually not hard but when I did the patch originally it then >> wasn't needed by the driver I had in mind for other reasons. >> >> See http://groups.google.com/group/linux.kernel/msg/1425fc2aad32e6ea >> >> Maybe its worth resurrecting ? > > In this particular case I most definitely think it's worth resurrecting. > Using your patch (I had to change the IORESOURCE_MUXED constant's value > though) I can completely solve the I/O sharing issue for the f71882fg + > watchdog case with only a single line modification to the f71882fg > driver. > > ... snip ... Using Alan's patch and the one following the dashed line I can implement (and have already done so) a separate watchdog driver for the Fintek F71808E. Should I just ask for this patch to be applied together with Alan's? Then submit the new driver? (I'm a bit new to the non-technical aspects of Linux kernel development). ======================================================================== hwmon: f71882fg: use a muxed resource lock for the Super I/O port Sleep while acquiring a resource lock on the Super I/O port. This should prevent collisions from causing the hardware probe to fail with -EBUSY. --- drivers/hwmon/f71882fg.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 7857ed3..e09416d 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -113,7 +113,7 @@ static struct platform_device *f71882fg_pdev; /* Super-I/O Function prototypes */ static inline int superio_inb(int base, int reg); static inline int superio_inw(int base, int reg); -static inline void superio_enter(int base); +static inline int superio_enter(int base); static inline void superio_select(int base, int ld); static inline void superio_exit(int base); @@ -883,11 +883,20 @@ static int superio_inw(int base, int reg) return val; } -static inline void superio_enter(int base) +static inline int superio_enter(int base) { + /* Don't step on other drivers' I/O space by accident */ + if (!request_muxed_region(base, 2, DRVNAME)) { + printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", + (int)base); + return -EBUSY; + } + /* according to the datasheet the key must be send twice! */ outb(SIO_UNLOCK_KEY, base); outb(SIO_UNLOCK_KEY, base); + + return 0; } static inline void superio_select(int base, int ld) @@ -899,6 +908,7 @@ static inline void superio_select(int base, int ld) static inline void superio_exit(int base) { outb(SIO_LOCK_KEY, base); + release_region(base, 2); } static inline int fan_from_reg(u16 reg) @@ -2239,17 +2249,10 @@ static int f71882fg_remove(struct platform_device *pdev) static int __init f71882fg_find(int sioaddr, unsigned short *address, struct f71882fg_sio_data *sio_data) { - int err = -ENODEV; u16 devid; - - /* Don't step on other drivers' I/O space by accident */ - if (!request_region(sioaddr, 2, DRVNAME)) { - printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", - (int)sioaddr); - return -EBUSY; - } - - superio_enter(sioaddr); + int err = superio_enter(sioaddr); + if (err) + return err; devid = superio_inw(sioaddr, SIO_REG_MANID); if (devid != SIO_FINTEK_ID) { @@ -2306,7 +2309,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, (int)superio_inb(sioaddr, SIO_REG_DEVREV)); exit: superio_exit(sioaddr); - release_region(sioaddr, 2); return err; } -- 1.6.4.4 -- Met vriendelijke groet, With kind regards, Giel van Schijndel
Attachment:
signature.asc
Description: Digital signature
_______________________________________________ lm-sensors mailing list lm-sensors@xxxxxxxxxxxxxx http://lists.lm-sensors.org/mailman/listinfo/lm-sensors