[S390] cio: make wait_events interruptible
[safe/jmp/linux-2.6] / drivers / hwmon / lm78.c
index b5e3b28..72ff2c4 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
-#include <asm/io.h>
+#include <linux/io.h>
 
 /* ISA device, if found */
 static struct platform_device *pdev;
@@ -41,8 +41,7 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                                0x2e, 0x2f, I2C_CLIENT_END };
 static unsigned short isa_address = 0x290;
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(lm78, lm79);
+enum chips { lm78, lm79 };
 
 /* Many LM78 constants specified below */
 
@@ -142,7 +141,7 @@ struct lm78_data {
 };
 
 
-static int lm78_i2c_detect(struct i2c_client *client, int kind,
+static int lm78_i2c_detect(struct i2c_client *client,
                           struct i2c_board_info *info);
 static int lm78_i2c_probe(struct i2c_client *client,
                          const struct i2c_device_id *id);
@@ -173,7 +172,7 @@ static struct i2c_driver lm78_driver = {
        .remove         = lm78_i2c_remove,
        .id_table       = lm78_i2c_id,
        .detect         = lm78_i2c_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static struct platform_driver lm78_isa_driver = {
@@ -182,7 +181,7 @@ static struct platform_driver lm78_isa_driver = {
                .name   = "lm78",
        },
        .probe          = lm78_isa_probe,
-       .remove         = lm78_isa_remove,
+       .remove         = __devexit_p(lm78_isa_remove),
 };
 
 
@@ -558,7 +557,7 @@ static int lm78_alias_detect(struct i2c_client *client, u8 chipid)
        return 1;
 }
 
-static int lm78_i2c_detect(struct i2c_client *client, int kind,
+static int lm78_i2c_detect(struct i2c_client *client,
                           struct i2c_board_info *info)
 {
        int i;
@@ -576,52 +575,34 @@ static int lm78_i2c_detect(struct i2c_client *client, int kind,
        if (isa)
                mutex_lock(&isa->update_lock);
 
-       if (kind < 0) {
-               if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80)
-                || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR)
-                   != address)
-                       goto err_nodev;
+       if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80)
+        || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) != address)
+               goto err_nodev;
 
-               /* Explicitly prevent the misdetection of Winbond chips */
-               i = i2c_smbus_read_byte_data(client, 0x4f);
-               if (i == 0xa3 || i == 0x5c)
-                       goto err_nodev;
-       }
+       /* Explicitly prevent the misdetection of Winbond chips */
+       i = i2c_smbus_read_byte_data(client, 0x4f);
+       if (i == 0xa3 || i == 0x5c)
+               goto err_nodev;
 
        /* Determine the chip type. */
-       if (kind <= 0) {
-               i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID);
-               if (i == 0x00 || i == 0x20      /* LM78 */
-                || i == 0x40)                  /* LM78-J */
-                       kind = lm78;
-               else if ((i & 0xfe) == 0xc0)
-                       kind = lm79;
-               else {
-                       if (kind == 0)
-                               dev_warn(&adapter->dev, "Ignoring 'force' "
-                                       "parameter for unknown chip at "
-                                       "adapter %d, address 0x%02x\n",
-                                       i2c_adapter_id(adapter), address);
-                       goto err_nodev;
-               }
+       i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID);
+       if (i == 0x00 || i == 0x20      /* LM78 */
+        || i == 0x40)                  /* LM78-J */
+               client_name = "lm78";
+       else if ((i & 0xfe) == 0xc0)
+               client_name = "lm79";
+       else
+               goto err_nodev;
 
-               if (lm78_alias_detect(client, i)) {
-                       dev_dbg(&adapter->dev, "Device at 0x%02x appears to "
-                               "be the same as ISA device\n", address);
-                       goto err_nodev;
-               }
+       if (lm78_alias_detect(client, i)) {
+               dev_dbg(&adapter->dev, "Device at 0x%02x appears to "
+                       "be the same as ISA device\n", address);
+               goto err_nodev;
        }
 
        if (isa)
                mutex_unlock(&isa->update_lock);
 
-       switch (kind) {
-       case lm79:
-               client_name = "lm79";
-               break;
-       default:
-               client_name = "lm78";
-       }
        strlcpy(info->type, client_name, I2C_NAME_SIZE);
 
        return 0;
@@ -870,17 +851,16 @@ static struct lm78_data *lm78_update_device(struct device *dev)
 static int __init lm78_isa_found(unsigned short address)
 {
        int val, save, found = 0;
-
-       /* We have to request the region in two parts because some
-          boards declare base+4 to base+7 as a PNP device */
-       if (!request_region(address, 4, "lm78")) {
-               pr_debug("lm78: Failed to request low part of region\n");
-               return 0;
-       }
-       if (!request_region(address + 4, 4, "lm78")) {
-               pr_debug("lm78: Failed to request high part of region\n");
-               release_region(address, 4);
-               return 0;
+       int port;
+
+       /* Some boards declare base+0 to base+7 as a PNP device, some base+4
+        * to base+7 and some base+5 to base+6. So we better request each port
+        * individually for the probing phase. */
+       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;
+               }
        }
 
 #define REALLY_SLOW_IO
@@ -944,8 +924,8 @@ static int __init lm78_isa_found(unsigned short address)
                        val & 0x80 ? "LM79" : "LM78", (int)address);
 
  release:
-       release_region(address + 4, 4);
-       release_region(address, 4);
+       for (port--; port >= address; port--)
+               release_region(port, 1);
        return found;
 }