1 From 3bc527587a789c36f995437a91ae4d1f0363bfbf Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Fri, 5 Apr 2019 08:53:08 -0700
4 Subject: hwmon: (vt1211) Use request_muxed_region for Super-IO accesses
6 [ Upstream commit 14b97ba5c20056102b3dd22696bf17b057e60976 ]
8 Super-IO accesses may fail on a system with no or unmapped LPC bus.
10 Also, other drivers may attempt to access the LPC bus at the same time,
11 resulting in undefined behavior.
13 Use request_muxed_region() to ensure that IO access on the requested
14 address space is supported, and to ensure that access by multiple drivers
17 Fixes: 2219cd81a6cd ("hwmon/vt1211: Add probing of alternate config index port")
18 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
21 drivers/hwmon/vt1211.c | 15 ++++++++++++---
22 1 file changed, 12 insertions(+), 3 deletions(-)
24 diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
25 index 3a6bfa51cb94f..95d5e8ec8b7fc 100644
26 --- a/drivers/hwmon/vt1211.c
27 +++ b/drivers/hwmon/vt1211.c
28 @@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
29 outb(ldn, sio_cip + 1);
32 -static inline void superio_enter(int sio_cip)
33 +static inline int superio_enter(int sio_cip)
35 + if (!request_muxed_region(sio_cip, 2, DRVNAME))
44 static inline void superio_exit(int sio_cip)
47 + release_region(sio_cip, 2);
50 /* ---------------------------------------------------------------------
51 @@ -1282,11 +1288,14 @@ static int __init vt1211_device_add(unsigned short address)
53 static int __init vt1211_find(int sio_cip, unsigned short *address)
59 - superio_enter(sio_cip);
60 + err = superio_enter(sio_cip);
65 devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
66 if (devid != SIO_VT1211_ID)