X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Fadm9240.c;h=bc7faef162f7b562fc99a8c8481d73c0809e6e2c;hb=736c7b808f38f3bb72941345e11e236ec65dec3d;hp=ce2a6eb93f6e5d4c7baed6fc26797b86988559e4;hpb=2321fbd2b87539edc1fbfc2e186528a1ef93835f;p=linux-2.6 diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index ce2a6eb93f..bc7faef162 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -45,17 +45,16 @@ #include #include #include -#include -#include +#include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; - /* Insmod parameters */ -SENSORS_INSMOD_3(adm9240, ds1780, lm81); +I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); /* ADM9240 registers */ #define ADM9240_REG_MAN_ID 0x3e @@ -150,6 +149,7 @@ static struct i2c_driver adm9240_driver = { struct adm9240_data { enum chips type; struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; unsigned long last_updated_measure; @@ -582,6 +582,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) adm9240_init_client(new_client); /* populate sysfs filesystem */ + 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_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max); @@ -615,6 +621,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_cpu0_vid); return 0; + +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -625,20 +634,20 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, adm9240_detect); + return i2c_probe(adapter, &addr_data, adm9240_detect); } static int adm9240_detach_client(struct i2c_client *client) { + struct adm9240_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; } @@ -648,7 +657,7 @@ static void adm9240_init_client(struct i2c_client *client) u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; - data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ + data->vrm = vid_which_vrm(); /* need this to report vid as mV */ dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, data->vrm % 10);