Commit 8c082675 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (smsc47b397) Use request_muxed_region for Super-IO accesses

Super-IO accesses may fail on a system with no or unmapped LPC bus.

Also, other drivers may attempt to access the LPC bus at the same time,
resulting in undefined behavior.

Use request_muxed_region() to ensure that IO access on the requested
address space is supported, and to ensure that access by multiple drivers
is synchronized.

Fixes: 8d5d45fb ("I2C: Move hwmon drivers (2/3)")
Reported-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reported-by: default avatarJohn Garry <john.garry@huawei.com>
Cc: John Garry <john.garry@huawei.com>
Acked-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 755a9b0f
...@@ -72,14 +72,19 @@ static inline void superio_select(int ld) ...@@ -72,14 +72,19 @@ static inline void superio_select(int ld)
superio_outb(0x07, ld); superio_outb(0x07, ld);
} }
static inline void superio_enter(void) static inline int superio_enter(void)
{ {
if (!request_muxed_region(REG, 2, DRVNAME))
return -EBUSY;
outb(0x55, REG); outb(0x55, REG);
return 0;
} }
static inline void superio_exit(void) static inline void superio_exit(void)
{ {
outb(0xAA, REG); outb(0xAA, REG);
release_region(REG, 2);
} }
#define SUPERIO_REG_DEVID 0x20 #define SUPERIO_REG_DEVID 0x20
...@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void) ...@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
u8 id, rev; u8 id, rev;
char *name; char *name;
unsigned short addr; unsigned short addr;
int err;
err = superio_enter();
if (err)
return err;
superio_enter();
id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
switch (id) { switch (id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment