1 From 056e4008ea95bfc4da7d8efab09fe2d779d9329f Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Thu, 4 Apr 2019 11:22:42 -0700
4 Subject: hwmon: (smsc47b397) Use request_muxed_region for Super-IO accesses
6 [ Upstream commit 8c0826756744c0ac1df600a5e4cca1a341b13101 ]
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: 8d5d45fb1468 ("I2C: Move hwmon drivers (2/3)")
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/smsc47b397.c | 13 +++++++++++--
26 1 file changed, 11 insertions(+), 2 deletions(-)
28 diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
29 index 6bd2007565603..cbdb5c4991ae3 100644
30 --- a/drivers/hwmon/smsc47b397.c
31 +++ b/drivers/hwmon/smsc47b397.c
32 @@ -72,14 +72,19 @@ static inline void superio_select(int ld)
33 superio_outb(0x07, ld);
36 -static inline void superio_enter(void)
37 +static inline int superio_enter(void)
39 + if (!request_muxed_region(REG, 2, DRVNAME))
46 static inline void superio_exit(void)
49 + release_region(REG, 2);
52 #define SUPERIO_REG_DEVID 0x20
53 @@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
59 + err = superio_enter();
64 id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);