Skip to content

Commit

Permalink
hwmon: (vt1211) Use request_muxed_region for Super-IO accesses
Browse files Browse the repository at this point in the history
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: 2219cd8 ("hwmon/vt1211: Add probing of alternate config index port")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Apr 16, 2019
1 parent e95fd51 commit 14b97ba
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/hwmon/vt1211.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
outb(ldn, sio_cip + 1);
}

static inline void superio_enter(int sio_cip)
static inline int superio_enter(int sio_cip)
{
if (!request_muxed_region(sio_cip, 2, DRVNAME))
return -EBUSY;

outb(0x87, sio_cip);
outb(0x87, sio_cip);

return 0;
}

static inline void superio_exit(int sio_cip)
{
outb(0xaa, sio_cip);
release_region(sio_cip, 2);
}

/* ---------------------------------------------------------------------
Expand Down Expand Up @@ -1282,11 +1288,14 @@ static int __init vt1211_device_add(unsigned short address)

static int __init vt1211_find(int sio_cip, unsigned short *address)
{
int err = -ENODEV;
int err;
int devid;

superio_enter(sio_cip);
err = superio_enter(sio_cip);
if (err)
return err;

err = -ENODEV;
devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
if (devid != SIO_VT1211_ID)
goto EXIT;
Expand Down

0 comments on commit 14b97ba

Please sign in to comment.