Merge branch 'i915fb' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/intelf...
[linux-2.6-microblaze.git] / drivers / hwmon / atxp1.c
index deb4d34..728a1e8 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -50,9 +51,9 @@ static struct atxp1_data * atxp1_update_device(struct device *dev);
 static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind);
 
 static struct i2c_driver atxp1_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "atxp1",
-       .flags          = I2C_DF_NOTIFY,
+       .driver = {
+               .name   = "atxp1",
+       },
        .attach_adapter = atxp1_attach_adapter,
        .detach_client  = atxp1_detach_client,
 };
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = {
 struct atxp1_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        unsigned long last_updated;
        u8 valid;
        struct {
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
        client = to_i2c_client(dev);
        data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
 
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return(data);
 }
@@ -253,6 +254,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
 
 static int atxp1_attach_adapter(struct i2c_adapter *adapter)
 {
+       if (!(adapter->class & I2C_CLASS_HWMON))
+               return 0;
        return i2c_probe(adapter, &addr_data, &atxp1_detect);
 };
 
@@ -266,12 +269,11 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                goto exit;
 
-       if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
 
-       memset(data, 0, sizeof(struct atxp1_data));
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
 
@@ -308,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
 
        data->valid = 0;
 
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        err = i2c_attach_client(new_client);