diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 07:31:02 (GMT) |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 07:31:02 (GMT) |
commit | 8566cfc9fe0934f52ddedc12b083176116c13978 (patch) | |
tree | b0f92fd0982a4dabaa2c108f4f1d130d2cff6798 /drivers/hwmon/lm87.c | |
parent | 7bdb2b6aca356c765bb697a4e9e7599357ee1542 (diff) | |
parent | 77ae84554cc0178e03862391599a0cedf96fa4c4 (diff) | |
download | linux-8566cfc9fe0934f52ddedc12b083176116c13978.tar.xz |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r-- | drivers/hwmon/lm87.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 1921ed1..dca996d 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -57,8 +57,9 @@ #include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> -#include <linux/i2c-vid.h> +#include <linux/hwmon.h> +#include <linux/hwmon-vid.h> +#include <linux/err.h> /* * Addresses to scan @@ -66,13 +67,12 @@ */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters */ -SENSORS_INSMOD_1(lm87); +I2C_CLIENT_INSMOD_1(lm87); /* * The LM87 registers @@ -175,6 +175,7 @@ static struct i2c_driver lm87_driver = { struct lm87_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 */ @@ -537,7 +538,7 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm87_detect); + return i2c_probe(adapter, &addr_data, lm87_detect); } /* @@ -608,6 +609,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) data->in_scale[7] = 1875; /* 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_in1_input); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in1_max); @@ -673,6 +680,8 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -685,7 +694,7 @@ static void lm87_init_client(struct i2c_client *client) u8 config; data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); - data->vrm = i2c_which_vrm(); + data->vrm = vid_which_vrm(); config = lm87_read_value(client, LM87_REG_CONFIG); if (!(config & 0x01)) { @@ -719,15 +728,15 @@ static void lm87_init_client(struct i2c_client *client) static int lm87_detach_client(struct i2c_client *client) { + struct lm87_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; } |