X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Fmax1619.c;h=6a82ffae1bfd6af15ce3fb89c92cae3c62edaab7;hb=9359ede748ff1461bf0632fb4182f61da4a2f9e2;hp=3c159f1d49ee3e6e0bf6b8acd5ccbfa8093ec938;hpb=590f47a1d945c611530a85057e9ad7a3bbb50578;p=linux-2.6-omap-h63xx.git diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 3c159f1d49e..6a82ffae1bf 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -31,20 +31,19 @@ #include #include #include -#include - +#include +#include static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters */ -SENSORS_INSMOD_1(max1619); +I2C_CLIENT_INSMOD_1(max1619); /* * The MAX1619 registers @@ -104,6 +103,7 @@ static struct i2c_driver max1619_driver = { struct max1619_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -179,7 +179,7 @@ static int max1619_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, max1619_detect); + return i2c_probe(adapter, &addr_data, max1619_detect); } /* @@ -197,11 +197,10 @@ static int max1619_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 max1619_data), GFP_KERNEL))) { + if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } - memset(data, 0, sizeof(struct max1619_data)); /* The common I2C client data is placed right before the MAX1619-specific data. */ @@ -275,6 +274,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) max1619_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp2_min); @@ -285,6 +290,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -308,15 +315,15 @@ static void max1619_init_client(struct i2c_client *client) static int max1619_detach_client(struct i2c_client *client) { + struct max1619_data *data = i2c_get_clientdata(client); int err; - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + hwmon_device_unregister(data->class_dev); + + if ((err = i2c_detach_client(client))) return err; - } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; }