Commit 0d023530 authored by Katsumi Sato's avatar Katsumi Sato Committed by Guenter Roeck

hwmon: (w83627ehf) Use request_muxed_region

Serialize access to the hardware by using "request_muxed_region".
Call to this macro will hold off the requestor if the resource is
currently busy. "superio_enter" will return an error if call to
"request_muxed_region" fails.
Signed-off-by: default avatarKatsumi Sato <sato@toshiba-tops.co.jp>
Signed-off-by: default avatarAtsushi Nemoto <nemoto@toshiba-tops.co.jp>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 3dead5d5
...@@ -135,11 +135,16 @@ superio_select(int ioreg, int ld) ...@@ -135,11 +135,16 @@ superio_select(int ioreg, int ld)
outb(ld, ioreg + 1); outb(ld, ioreg + 1);
} }
static inline void static inline int
superio_enter(int ioreg) superio_enter(int ioreg)
{ {
if (!request_muxed_region(ioreg, 2, DRVNAME))
return -EBUSY;
outb(0x87, ioreg); outb(0x87, ioreg);
outb(0x87, ioreg); outb(0x87, ioreg);
return 0;
} }
static inline void static inline void
...@@ -148,6 +153,7 @@ superio_exit(int ioreg) ...@@ -148,6 +153,7 @@ superio_exit(int ioreg)
outb(0xaa, ioreg); outb(0xaa, ioreg);
outb(0x02, ioreg); outb(0x02, ioreg);
outb(0x02, ioreg + 1); outb(0x02, ioreg + 1);
release_region(ioreg, 2);
} }
/* /*
...@@ -1970,8 +1976,6 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data, ...@@ -1970,8 +1976,6 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
return; return;
} }
superio_enter(sio_data->sioreg);
/* fan4 and fan5 share some pins with the GPIO and serial flash */ /* fan4 and fan5 share some pins with the GPIO and serial flash */
if (sio_data->kind == nct6775) { if (sio_data->kind == nct6775) {
/* On NCT6775, fan4 shares pins with the fdc interface */ /* On NCT6775, fan4 shares pins with the fdc interface */
...@@ -2013,8 +2017,6 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data, ...@@ -2013,8 +2017,6 @@ w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
fan4min = fan4pin; fan4min = fan4pin;
} }
superio_exit(sio_data->sioreg);
data->has_fan = data->has_fan_min = 0x03; /* fan1 and fan2 */ data->has_fan = data->has_fan_min = 0x03; /* fan1 and fan2 */
data->has_fan |= (fan3pin << 2); data->has_fan |= (fan3pin << 2);
data->has_fan_min |= (fan3pin << 2); data->has_fan_min |= (fan3pin << 2);
...@@ -2352,7 +2354,11 @@ static int w83627ehf_probe(struct platform_device *pdev) ...@@ -2352,7 +2354,11 @@ static int w83627ehf_probe(struct platform_device *pdev)
w83627ehf_init_device(data, sio_data->kind); w83627ehf_init_device(data, sio_data->kind);
data->vrm = vid_which_vrm(); data->vrm = vid_which_vrm();
superio_enter(sio_data->sioreg);
err = superio_enter(sio_data->sioreg);
if (err)
goto exit_release;
/* Read VID value */ /* Read VID value */
if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b || if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b ||
sio_data->kind == nct6775 || sio_data->kind == nct6776) { sio_data->kind == nct6775 || sio_data->kind == nct6776) {
...@@ -2364,8 +2370,10 @@ static int w83627ehf_probe(struct platform_device *pdev) ...@@ -2364,8 +2370,10 @@ static int w83627ehf_probe(struct platform_device *pdev)
superio_select(sio_data->sioreg, W83667HG_LD_VID); superio_select(sio_data->sioreg, W83667HG_LD_VID);
data->vid = superio_inb(sio_data->sioreg, 0xe3); data->vid = superio_inb(sio_data->sioreg, 0xe3);
err = device_create_file(dev, &dev_attr_cpu0_vid); err = device_create_file(dev, &dev_attr_cpu0_vid);
if (err) if (err) {
superio_exit(sio_data->sioreg);
goto exit_release; goto exit_release;
}
} else if (sio_data->kind != w83627uhg) { } else if (sio_data->kind != w83627uhg) {
superio_select(sio_data->sioreg, W83627EHF_LD_HWM); superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) { if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) {
...@@ -2401,8 +2409,10 @@ static int w83627ehf_probe(struct platform_device *pdev) ...@@ -2401,8 +2409,10 @@ static int w83627ehf_probe(struct platform_device *pdev)
data->vid &= 0x3f; data->vid &= 0x3f;
err = device_create_file(dev, &dev_attr_cpu0_vid); err = device_create_file(dev, &dev_attr_cpu0_vid);
if (err) if (err) {
superio_exit(sio_data->sioreg);
goto exit_release; goto exit_release;
}
} else { } else {
dev_info(dev, dev_info(dev,
"VID pins in output mode, CPU VID not available\n"); "VID pins in output mode, CPU VID not available\n");
...@@ -2424,10 +2434,10 @@ static int w83627ehf_probe(struct platform_device *pdev) ...@@ -2424,10 +2434,10 @@ static int w83627ehf_probe(struct platform_device *pdev)
pr_info("Enabled fan debounce for chip %s\n", data->name); pr_info("Enabled fan debounce for chip %s\n", data->name);
} }
superio_exit(sio_data->sioreg);
w83627ehf_check_fan_inputs(sio_data, data); w83627ehf_check_fan_inputs(sio_data, data);
superio_exit(sio_data->sioreg);
/* Read fan clock dividers immediately */ /* Read fan clock dividers immediately */
w83627ehf_update_fan_div_common(dev, data); w83627ehf_update_fan_div_common(dev, data);
...@@ -2712,8 +2722,11 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr, ...@@ -2712,8 +2722,11 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
u16 val; u16 val;
const char *sio_name; const char *sio_name;
int err;
superio_enter(sioaddr); err = superio_enter(sioaddr);
if (err)
return err;
if (force_id) if (force_id)
val = force_id; val = force_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment