Commit 197027e6 authored by Jean Delvare's avatar Jean Delvare

hwmon: (lm78) Request I/O ports individually for probing

Different motherboards have different PNP declarations for LM78/LM79
chips. Some declare the whole range of I/O ports (8 ports), some
declare only the useful ports (2 ports at offset 5) and some declare
fancy ranges, for example 4 ports at offset 4. To properly handle all
cases, request all ports individually for probing. After we have
determined that we really have an LM78 or LM79 chip, the useful port
range will be requested again, as a single block.

This fixes the driver on the Olivetti M3000 DT 540, at least.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: stable@kernel.org
parent 85f8d3e5
...@@ -851,17 +851,16 @@ static struct lm78_data *lm78_update_device(struct device *dev) ...@@ -851,17 +851,16 @@ static struct lm78_data *lm78_update_device(struct device *dev)
static int __init lm78_isa_found(unsigned short address) static int __init lm78_isa_found(unsigned short address)
{ {
int val, save, found = 0; int val, save, found = 0;
int port;
/* We have to request the region in two parts because some
boards declare base+4 to base+7 as a PNP device */ /* Some boards declare base+0 to base+7 as a PNP device, some base+4
if (!request_region(address, 4, "lm78")) { * to base+7 and some base+5 to base+6. So we better request each port
pr_debug("lm78: Failed to request low part of region\n"); * individually for the probing phase. */
return 0; for (port = address; port < address + LM78_EXTENT; port++) {
if (!request_region(port, 1, "lm78")) {
pr_debug("lm78: Failed to request port 0x%x\n", port);
goto release;
} }
if (!request_region(address + 4, 4, "lm78")) {
pr_debug("lm78: Failed to request high part of region\n");
release_region(address, 4);
return 0;
} }
#define REALLY_SLOW_IO #define REALLY_SLOW_IO
...@@ -925,8 +924,8 @@ static int __init lm78_isa_found(unsigned short address) ...@@ -925,8 +924,8 @@ static int __init lm78_isa_found(unsigned short address)
val & 0x80 ? "LM79" : "LM78", (int)address); val & 0x80 ? "LM79" : "LM78", (int)address);
release: release:
release_region(address + 4, 4); for (port--; port >= address; port--)
release_region(address, 4); release_region(port, 1);
return found; return found;
} }
......
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