hwmon: (vt1211) Use request_muxed_region for Super-IO accesses
[ Upstream commit 14b97ba5c20056102b3dd22696bf17b057e60976 ]
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: 2219cd81a6
("hwmon/vt1211: Add probing of alternate config index port")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
488920af3b
commit
e3e58378c6
1 changed files with 12 additions and 3 deletions
|
@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
|
||||||
outb(ldn, sio_cip + 1);
|
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);
|
||||||
outb(0x87, sio_cip);
|
outb(0x87, sio_cip);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void superio_exit(int sio_cip)
|
static inline void superio_exit(int sio_cip)
|
||||||
{
|
{
|
||||||
outb(0xaa, sio_cip);
|
outb(0xaa, sio_cip);
|
||||||
|
release_region(sio_cip, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
@ -1282,11 +1288,14 @@ EXIT:
|
||||||
|
|
||||||
static int __init vt1211_find(int sio_cip, unsigned short *address)
|
static int __init vt1211_find(int sio_cip, unsigned short *address)
|
||||||
{
|
{
|
||||||
int err = -ENODEV;
|
int err;
|
||||||
int devid;
|
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);
|
devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
|
||||||
if (devid != SIO_VT1211_ID)
|
if (devid != SIO_VT1211_ID)
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue