提交 53d22d88 编写于 作者: L Linus Torvalds

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging:
  hwmon: f71882fg: use a muxed resource lock for the Super I/O port
...@@ -111,7 +111,7 @@ static struct platform_device *f71882fg_pdev; ...@@ -111,7 +111,7 @@ static struct platform_device *f71882fg_pdev;
/* Super-I/O Function prototypes */ /* Super-I/O Function prototypes */
static inline int superio_inb(int base, int reg); static inline int superio_inb(int base, int reg);
static inline int superio_inw(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_select(int base, int ld);
static inline void superio_exit(int base); static inline void superio_exit(int base);
...@@ -861,11 +861,20 @@ static int superio_inw(int base, int reg) ...@@ -861,11 +861,20 @@ static int superio_inw(int base, int reg)
return val; 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",
base);
return -EBUSY;
}
/* according to the datasheet the key must be send twice! */ /* according to the datasheet the key must be send twice! */
outb(SIO_UNLOCK_KEY, base); outb(SIO_UNLOCK_KEY, base);
outb(SIO_UNLOCK_KEY, base); outb(SIO_UNLOCK_KEY, base);
return 0;
} }
static inline void superio_select(int base, int ld) static inline void superio_select(int base, int ld)
...@@ -877,6 +886,7 @@ static inline void superio_select(int base, int ld) ...@@ -877,6 +886,7 @@ static inline void superio_select(int base, int ld)
static inline void superio_exit(int base) static inline void superio_exit(int base)
{ {
outb(SIO_LOCK_KEY, base); outb(SIO_LOCK_KEY, base);
release_region(base, 2);
} }
static inline int fan_from_reg(u16 reg) static inline int fan_from_reg(u16 reg)
...@@ -2175,21 +2185,15 @@ static int f71882fg_remove(struct platform_device *pdev) ...@@ -2175,21 +2185,15 @@ static int f71882fg_remove(struct platform_device *pdev)
static int __init f71882fg_find(int sioaddr, unsigned short *address, static int __init f71882fg_find(int sioaddr, unsigned short *address,
struct f71882fg_sio_data *sio_data) struct f71882fg_sio_data *sio_data)
{ {
int err = -ENODEV;
u16 devid; u16 devid;
int err = superio_enter(sioaddr);
/* Don't step on other drivers' I/O space by accident */ if (err)
if (!request_region(sioaddr, 2, DRVNAME)) { return err;
printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n",
(int)sioaddr);
return -EBUSY;
}
superio_enter(sioaddr);
devid = superio_inw(sioaddr, SIO_REG_MANID); devid = superio_inw(sioaddr, SIO_REG_MANID);
if (devid != SIO_FINTEK_ID) { if (devid != SIO_FINTEK_ID) {
pr_debug(DRVNAME ": Not a Fintek device\n"); pr_debug(DRVNAME ": Not a Fintek device\n");
err = -ENODEV;
goto exit; goto exit;
} }
...@@ -2213,6 +2217,7 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, ...@@ -2213,6 +2217,7 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
default: default:
printk(KERN_INFO DRVNAME ": Unsupported Fintek device: %04x\n", printk(KERN_INFO DRVNAME ": Unsupported Fintek device: %04x\n",
(unsigned int)devid); (unsigned int)devid);
err = -ENODEV;
goto exit; goto exit;
} }
...@@ -2223,12 +2228,14 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, ...@@ -2223,12 +2228,14 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) {
printk(KERN_WARNING DRVNAME ": Device not activated\n"); printk(KERN_WARNING DRVNAME ": Device not activated\n");
err = -ENODEV;
goto exit; goto exit;
} }
*address = superio_inw(sioaddr, SIO_REG_ADDR); *address = superio_inw(sioaddr, SIO_REG_ADDR);
if (*address == 0) { if (*address == 0) {
printk(KERN_WARNING DRVNAME ": Base address not set\n"); printk(KERN_WARNING DRVNAME ": Base address not set\n");
err = -ENODEV;
goto exit; goto exit;
} }
*address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */
...@@ -2239,7 +2246,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, ...@@ -2239,7 +2246,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
(int)superio_inb(sioaddr, SIO_REG_DEVREV)); (int)superio_inb(sioaddr, SIO_REG_DEVREV));
exit: exit:
superio_exit(sioaddr); superio_exit(sioaddr);
release_region(sioaddr, 2);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册