[PATCH] hwmon: Drop legacy ISA address support from it87
[safe/jmp/linux-2.6] / drivers / hwmon / via686a.c
index e6fc43a..c6e64f4 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
 #include <linux/i2c-isa.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
 #include <linux/init.h>
 
 /* If force_addr is set to anything different from 0, we forcibly enable
    the device at the given address. */
-static unsigned short force_addr = 0;
+static unsigned short force_addr;
 module_param(force_addr, ushort, 0);
 MODULE_PARM_DESC(force_addr,
                 "Initialize the base address of the sensors");
 
-/* Addresses to scan.
+/* Device address
    Note that we can't determine the ISA address until we have initialized
    our module */
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
-
-/* Insmod parameters */
-SENSORS_INSMOD_1(via686a);
+static unsigned short address;
 
 /*
    The Via 686a southbridge has a LM78-like chip integrated on the same IC.
@@ -203,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
  but the function is very linear in the useful range (0-80 deg C), so
  we'll just use linear interpolation for 10-bit readings.)  So, tempLUT
  is the temp at via register values 0-255: */
-static const long tempLUT[] =
+static const s16 tempLUT[] =
 { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
        -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
        -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
@@ -275,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val)
 }
 
 /* for 8-bit temperature hyst and over registers */
-#define TEMP_FROM_REG(val) (tempLUT[(val)] * 100)
+#define TEMP_FROM_REG(val)     ((long)tempLUT[val] * 100)
 
 /* for 10-bit temperature readings */
 static inline long TEMP_FROM_REG10(u16 val)
@@ -319,8 +314,7 @@ struct via686a_data {
 
 static struct pci_dev *s_bridge;       /* pointer to the (only) via686a */
 
-static int via686a_attach_adapter(struct i2c_adapter *adapter);
-static int via686a_detect(struct i2c_adapter *adapter, int address, int kind);
+static int via686a_detect(struct i2c_adapter *adapter);
 static int via686a_detach_client(struct i2c_client *client);
 
 static inline int via686a_read_value(struct i2c_client *client, u8 reg)
@@ -580,22 +574,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
 static struct i2c_driver via686a_driver = {
        .owner          = THIS_MODULE,
        .name           = "via686a",
-       .id             = I2C_DRIVERID_VIA686A,
-       .flags          = I2C_DF_NOTIFY,
-       .attach_adapter = via686a_attach_adapter,
+       .attach_adapter = via686a_detect,
        .detach_client  = via686a_detach_client,
 };
 
 
 /* This is called when the module is loaded */
-static int via686a_attach_adapter(struct i2c_adapter *adapter)
-{
-       if (!(adapter->class & I2C_CLASS_HWMON))
-               return 0;
-       return i2c_detect(adapter, &addr_data, via686a_detect);
-}
-
-static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
+static int via686a_detect(struct i2c_adapter *adapter)
 {
        struct i2c_client *new_client;
        struct via686a_data *data;
@@ -603,18 +588,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
        const char client_name[] = "via686a";
        u16 val;
 
-       /* Make sure we are probing the ISA bus!!  */
-       if (!i2c_is_isa_adapter(adapter)) {
-               dev_err(&adapter->dev,
-               "via686a_detect called for an I2C bus adapter?!?\n");
-               return 0;
-       }
-
        /* 8231 requires multiple of 256, we enforce that on 686 as well */
-       if (force_addr)
-               address = force_addr & 0xFF00;
-
        if (force_addr) {
+               address = force_addr & 0xFF00;
                dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
                         address);
                if (PCIBIOS_SUCCESSFUL !=
@@ -625,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
            pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))
                return -ENODEV;
        if (!(val & 0x0001)) {
-               dev_warn(&adapter->dev, "enabling sensors\n");
-               if (PCIBIOS_SUCCESSFUL !=
-                   pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
-                                         val | 0x0001))
+               if (force_addr) {
+                       dev_info(&adapter->dev, "enabling sensors\n");
+                       if (PCIBIOS_SUCCESSFUL !=
+                           pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
+                                                 val | 0x0001))
+                               return -ENODEV;
+               } else {
+                       dev_warn(&adapter->dev, "sensors disabled - enable "
+                                "with force_addr=0x%x\n", address);
                        return -ENODEV;
+               }
        }
 
        /* Reserve the ISA region */
@@ -721,11 +703,8 @@ static int via686a_detach_client(struct i2c_client *client)
 
        hwmon_device_unregister(data->class_dev);
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-               "Client deregistration failed, client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        release_region(client->addr, VIA686A_EXTENT);
        kfree(data);
@@ -733,7 +712,6 @@ static int via686a_detach_client(struct i2c_client *client)
        return 0;
 }
 
-/* Called when we have found a new VIA686A. Set limits, etc. */
 static void via686a_init_client(struct i2c_client *client)
 {
        u8 reg;
@@ -825,26 +803,17 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
                                       const struct pci_device_id *id)
 {
        u16 val;
-       int addr = 0;
 
        if (PCIBIOS_SUCCESSFUL !=
            pci_read_config_word(dev, VIA686A_BASE_REG, &val))
                return -ENODEV;
 
-       addr = val & ~(VIA686A_EXTENT - 1);
-       if (addr == 0 && force_addr == 0) {
+       address = val & ~(VIA686A_EXTENT - 1);
+       if (address == 0 && force_addr == 0) {
                dev_err(&dev->dev, "base address not set - upgrade BIOS "
                        "or use force_addr=0xaddr\n");
                return -ENODEV;
        }
-       if (force_addr)
-               addr = force_addr;      /* so detect will get called */
-
-       if (!addr) {
-               dev_err(&dev->dev, "No Via 686A sensors found.\n");
-               return -ENODEV;
-       }
-       normal_isa[0] = addr;
 
        s_bridge = pci_dev_get(dev);
        if (i2c_isa_add_driver(&via686a_driver)) {