X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Flm80.c;h=83af8b3a0cac02ba04ef70f1ec4b8f118de210b5;hb=cc6120c6687c34501c0b1d49b4d7e46c63911fed;hp=8100595feb44640133c6ae6aa7308839f35c7711;hpb=6cd59f7a4119fef124677827a9b30684c2c8e674;p=linux-2.6 diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 8100595feb..83af8b3a0c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -26,15 +26,15 @@ #include #include #include -#include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ -SENSORS_INSMOD_1(lm80); +I2C_CLIENT_INSMOD_1(lm80); /* Many LM80 constants specified below */ @@ -107,6 +107,7 @@ static inline long TEMP_FROM_REG(u16 temp) struct lm80_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -389,7 +390,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm80_detect); + return i2c_probe(adapter, &addr_data, lm80_detect); } int lm80_detect(struct i2c_adapter *adapter, int address, int kind) @@ -451,6 +452,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); /* 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 error_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in2_min); @@ -487,6 +494,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +error_detach: + i2c_detach_client(new_client); error_free: kfree(data); exit: @@ -495,15 +504,15 @@ exit: static int lm80_detach_client(struct i2c_client *client) { + struct lm80_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; }