[PATCH] hwmon: Static function fixes, 2 of 4
[powerpc.git] / drivers / hwmon / lm78.c
index a69e7d4..bde0cda 100644 (file)
@@ -24,8 +24,8 @@
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
 #include <linux/i2c-isa.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon.h>
+#include <linux/hwmon-vid.h>
 #include <linux/err.h>
 #include <asm/io.h>
 
@@ -34,10 +34,10 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
                                        0x25, 0x26, 0x27, 0x28, 0x29,
                                        0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
                                        0x2f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
+static unsigned short isa_address = 0x290;
 
 /* Insmod parameters */
-SENSORS_INSMOD_2(lm78, lm79);
+I2C_CLIENT_INSMOD_2(lm78, lm79);
 
 /* Many LM78 constants specified below */
 
@@ -107,13 +107,6 @@ static inline int TEMP_FROM_REG(s8 val)
        return val * 1000;
 }
 
-/* VID: mV
-   REG: (see doc/vid) */
-static inline int VID_FROM_REG(u8 val)
-{
-       return val==0x1f ? 0 : val>=0x10 ? 5100-val*100 : 2050-val*50;
-}
-
 #define DIV_FROM_REG(val) (1 << (val))
 
 /* There are some complications in a module like this. First off, LM78 chips
@@ -160,6 +153,7 @@ struct lm78_data {
 
 
 static int lm78_attach_adapter(struct i2c_adapter *adapter);
+static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
 static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
 static int lm78_detach_client(struct i2c_client *client);
 
@@ -181,7 +175,7 @@ static struct i2c_driver lm78_driver = {
 static struct i2c_driver lm78_isa_driver = {
        .owner          = THIS_MODULE,
        .name           = "lm78-isa",
-       .attach_adapter = lm78_attach_adapter,
+       .attach_adapter = lm78_isa_attach_adapter,
        .detach_client  = lm78_detach_client,
 };
 
@@ -457,7 +451,7 @@ static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);
 static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct lm78_data *data = lm78_update_device(dev);
-       return sprintf(buf, "%d\n", VID_FROM_REG(data->vid));
+       return sprintf(buf, "%d\n", vid_from_reg(82, data->vid));
 }
 static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
 
@@ -477,11 +471,16 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, lm78_detect);
+       return i2c_probe(adapter, &addr_data, lm78_detect);
 }
 
-/* This function is called by i2c_detect */
-int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
+static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
+{
+       return lm78_detect(adapter, isa_address, -1);
+}
+
+/* This function is called by i2c_probe */
+static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        int i, err;
        struct i2c_client *new_client;
@@ -541,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
           client structure, even though we cannot fill it completely yet.
           But it allows us to access lm78_{read,write}_value. */
 
-       if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto ERROR1;
        }
-       memset(data, 0, sizeof(struct lm78_data));
 
        new_client = &data->client;
        if (is_isa)
@@ -677,11 +675,8 @@ static int lm78_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;
-       }
 
        if(i2c_is_isa_client(client))
                release_region(client->addr, LM78_EXTENT);
@@ -730,7 +725,6 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
                return i2c_smbus_write_byte_data(client, reg, value);
 }
 
-/* Called when we have found a new LM78. It should set limits, etc. */
 static void lm78_init_client(struct i2c_client *client)
 {
        u8 config = lm78_read_value(client, LM78_REG_CONFIG);