Merge branch 'next' into for-linus
[pandora-kernel.git] / drivers / hwmon / f71882fg.c
index 68f5102..67067e9 100644 (file)
 
 #define FAN_MIN_DETECT                 366 /* Lowest detectable fanspeed */
 
+static unsigned short force_id;
+module_param(force_id, ushort, 0);
+MODULE_PARM_DESC(force_id, "Override the detected device ID");
+
 static struct platform_device *f71882fg_pdev = NULL;
 
 /* Super-I/O Function prototypes */
@@ -83,11 +87,9 @@ static inline void superio_enter(int base);
 static inline void superio_select(int base, int ld);
 static inline void superio_exit(int base);
 
-static inline u16 fan_from_reg ( u16 reg );
-
 struct f71882fg_data {
        unsigned short addr;
-       struct class_device *class_dev;
+       struct device *hwmon_dev;
 
        struct mutex update_lock;
        char valid;                     /* !=0 if following fields are valid */
@@ -112,10 +114,6 @@ struct f71882fg_data {
        u8      temp_diode_open;
 };
 
-static u8 f71882fg_read8(struct f71882fg_data *data, u8 reg);
-static u16 f71882fg_read16(struct f71882fg_data *data, u8 reg);
-static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val);
-
 /* Sysfs in*/
 static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
        char *buf);
@@ -384,7 +382,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device * dev)
        }
 
        /* Update every second */
-       if (time_after(jiffies, data->last_updated + HZ) || !data->valid)  {
+       if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
                data->temp_status = f71882fg_read8(data,
                                                F71882FG_REG_TEMP_STATUS);
                data->temp_diode_open = f71882fg_read8(data,
@@ -614,7 +612,7 @@ static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute
        data->temp_hyst[nr] = val;
 
        /* convert value to register contents */
-       switch(nr) {
+       switch (nr) {
                case 0:
                        val = val << 4;
                        break;
@@ -748,7 +746,7 @@ static int __devinit f71882fg_probe(struct platform_device * pdev)
        int err, i;
        u8 start_reg;
 
-       if(!(data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL)))
+       if (!(data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL)))
                return -ENOMEM;
 
        data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
@@ -781,9 +779,9 @@ static int __devinit f71882fg_probe(struct platform_device * pdev)
                }
        }
 
-       data->class_dev = hwmon_device_register(&pdev->dev);
-       if (IS_ERR(data->class_dev)) {
-               err = PTR_ERR(data->class_dev);
+       data->hwmon_dev = hwmon_device_register(&pdev->dev);
+       if (IS_ERR(data->hwmon_dev)) {
+               err = PTR_ERR(data->hwmon_dev);
                goto exit_unregister_sysfs;
        }
 
@@ -811,7 +809,7 @@ static int __devexit f71882fg_remove(struct platform_device *pdev)
        struct f71882fg_data *data = platform_get_drvdata(pdev);
 
        platform_set_drvdata(pdev, NULL);
-       hwmon_device_unregister(data->class_dev);
+       hwmon_device_unregister(data->hwmon_dev);
 
        for (i = 0; i < ARRAY_SIZE(f71882fg_dev_attr); i++)
                device_remove_file(&pdev->dev, &f71882fg_dev_attr[i]);
@@ -843,14 +841,14 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address)
                goto exit;
        }
 
-       devid = superio_inw(sioaddr, SIO_REG_DEVID);
+       devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID);
        if (devid != SIO_F71882_ID) {
                printk(KERN_INFO DRVNAME ": Unsupported Fintek device\n");
                goto exit;
        }
 
        superio_select(sioaddr, SIO_F71882FG_LD_HWM);
-       if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01))  {
+       if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) {
                printk(KERN_WARNING DRVNAME ": Device not activated\n");
                goto exit;
        }
@@ -890,18 +888,18 @@ static int __init f71882fg_device_add(unsigned short address)
        int err;
 
        f71882fg_pdev = platform_device_alloc(DRVNAME, address);
-       if(!f71882fg_pdev)
+       if (!f71882fg_pdev)
                return -ENOMEM;
 
        res.name = f71882fg_pdev->name;
        err = platform_device_add_resources(f71882fg_pdev, &res, 1);
-       if(err) {
+       if (err) {
                printk(KERN_ERR DRVNAME ": Device resource addition failed\n");
                goto exit_device_put;
        }
 
        err = platform_device_add(f71882fg_pdev);
-       if(err) {
+       if (err) {
                printk(KERN_ERR DRVNAME ": Device addition failed\n");
                goto exit_device_put;
        }