aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index d2c774c32f45..e928cdb041cb 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -24,7 +24,8 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/i2c-sensor.h> 27#include <linux/hwmon.h>
28#include <linux/err.h>
28 29
29 30
30/* Addresses to scan */ 31/* Addresses to scan */
@@ -32,10 +33,9 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
32 0x29, 0x2a, 0x2b, 33 0x29, 0x2a, 0x2b,
33 0x4c, 0x4d, 0x4e, 34 0x4c, 0x4d, 0x4e,
34 I2C_CLIENT_END }; 35 I2C_CLIENT_END };
35static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
36 36
37/* Insmod parameters */ 37/* Insmod parameters */
38SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); 38I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
39 39
40/* adm1021 constants specified below */ 40/* adm1021 constants specified below */
41 41
@@ -89,6 +89,7 @@ clearing it. Weird, ey? --Phil */
89/* Each client has this additional data */ 89/* Each client has this additional data */
90struct adm1021_data { 90struct adm1021_data {
91 struct i2c_client client; 91 struct i2c_client client;
92 struct class_device *class_dev;
92 enum chips type; 93 enum chips type;
93 94
94 struct semaphore update_lock; 95 struct semaphore update_lock;
@@ -185,7 +186,7 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter)
185{ 186{
186 if (!(adapter->class & I2C_CLASS_HWMON)) 187 if (!(adapter->class & I2C_CLASS_HWMON))
187 return 0; 188 return 0;
188 return i2c_detect(adapter, &addr_data, adm1021_detect); 189 return i2c_probe(adapter, &addr_data, adm1021_detect);
189} 190}
190 191
191static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) 192static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -196,15 +197,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
196 int err = 0; 197 int err = 0;
197 const char *type_name = ""; 198 const char *type_name = "";
198 199
199 /* Make sure we aren't probing the ISA bus!! This is just a safety check
200 at this moment; i2c_detect really won't call us. */
201#ifdef DEBUG
202 if (i2c_is_isa_adapter(adapter)) {
203 dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n");
204 return 0;
205 }
206#endif
207
208 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 200 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
209 goto error0; 201 goto error0;
210 202
@@ -295,6 +287,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
295 adm1021_init_client(new_client); 287 adm1021_init_client(new_client);
296 288
297 /* Register sysfs hooks */ 289 /* Register sysfs hooks */
290 data->class_dev = hwmon_device_register(&new_client->dev);
291 if (IS_ERR(data->class_dev)) {
292 err = PTR_ERR(data->class_dev);
293 goto error2;
294 }
295
298 device_create_file(&new_client->dev, &dev_attr_temp1_max); 296 device_create_file(&new_client->dev, &dev_attr_temp1_max);
299 device_create_file(&new_client->dev, &dev_attr_temp1_min); 297 device_create_file(&new_client->dev, &dev_attr_temp1_min);
300 device_create_file(&new_client->dev, &dev_attr_temp1_input); 298 device_create_file(&new_client->dev, &dev_attr_temp1_input);
@@ -305,6 +303,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
305 303
306 return 0; 304 return 0;
307 305
306error2:
307 i2c_detach_client(new_client);
308error1: 308error1:
309 kfree(data); 309 kfree(data);
310error0: 310error0:
@@ -322,14 +322,15 @@ static void adm1021_init_client(struct i2c_client *client)
322 322
323static int adm1021_detach_client(struct i2c_client *client) 323static int adm1021_detach_client(struct i2c_client *client)
324{ 324{
325 struct adm1021_data *data = i2c_get_clientdata(client);
325 int err; 326 int err;
326 327
327 if ((err = i2c_detach_client(client))) { 328 hwmon_device_unregister(data->class_dev);
328 dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); 329
330 if ((err = i2c_detach_client(client)))
329 return err; 331 return err;
330 }
331 332
332 kfree(i2c_get_clientdata(client)); 333 kfree(data);
333 return 0; 334 return 0;
334} 335}
335 336