1 From 85770069abc314bc8c98380d9851da23b3857a46 Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Thu, 4 Apr 2019 11:16:20 -0700
4 Subject: hwmon: (pc87427) Use request_muxed_region for Super-IO accesses
6 [ Upstream commit 755a9b0f8aaa5639ba5671ca50080852babb89ce ]
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: ba224e2c4f0a7 ("hwmon: New PC87427 hardware monitoring driver")
18 Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
19 Reported-by: John Garry <john.garry@huawei.com>
20 Cc: John Garry <john.garry@huawei.com>
21 Acked-by: John Garry <john.garry@huawei.com>
22 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
25 drivers/hwmon/pc87427.c | 14 +++++++++++++-
26 1 file changed, 13 insertions(+), 1 deletion(-)
28 diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
29 index cb9fdd37bd0d9..2b5b8c3de8fce 100644
30 --- a/drivers/hwmon/pc87427.c
31 +++ b/drivers/hwmon/pc87427.c
32 @@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
36 +static inline int superio_enter(int sioaddr)
38 + if (!request_muxed_region(sioaddr, 2, DRVNAME))
43 static inline void superio_outb(int sioaddr, int reg, int val)
46 @@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
49 outb(0x02, sioaddr + 1);
50 + release_region(sioaddr, 2);
54 @@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
61 + err = superio_enter(sioaddr);
66 val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);