X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Flm85.c;h=ab214df9624bc423376bef632b4a87d0d1f2cf96;hb=736c7b808f38f3bb72941345e11e236ec65dec3d;hp=b4d7fd41826478a241d50535a70bbbf0507c8de4;hpb=c514720716c7b109ff980f8b3cb93f9af872c91c;p=linux-2.6 diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index b4d7fd4182..ab214df962 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -28,15 +28,15 @@ #include #include #include -#include -#include +#include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ -SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); +I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); /* The LM85 registers */ @@ -281,15 +281,6 @@ static int ZONE_TO_REG( int zone ) #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) -/* i2c-vid.h defines vid_from_reg() */ -#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) - -/* Unlike some other drivers we DO NOT set initial limits. Use - * the config file to set limits. Some users have reported - * motherboards shutting down when we set limits in a previous - * version of the driver. - */ - /* Chip sampling rates * * Some sensors are not updated more frequently than once per second @@ -339,6 +330,7 @@ struct lm85_autofan { struct lm85_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -1019,7 +1011,7 @@ int lm85_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm85_detect); + return i2c_probe(adapter, &addr_data, lm85_detect); } int lm85_detect(struct i2c_adapter *adapter, int address, @@ -1031,11 +1023,6 @@ int lm85_detect(struct i2c_adapter *adapter, int address, int err = 0; const char *type_name = ""; - if (i2c_is_isa_adapter(adapter)) { - /* This chip has no ISA interface */ - goto ERROR0 ; - }; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { /* We need to be able to do byte I/O */ @@ -1160,12 +1147,18 @@ int lm85_detect(struct i2c_adapter *adapter, int address, goto ERROR1; /* Set the VRM version */ - data->vrm = i2c_which_vrm(); + data->vrm = vid_which_vrm(); /* Initialize the LM85 chip */ lm85_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 ERROR2; + } + device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan2_input); device_create_file(&new_client->dev, &dev_attr_fan3_input); @@ -1235,6 +1228,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address, return 0; /* Error out and cleanup code */ + ERROR2: + i2c_detach_client(new_client); ERROR1: kfree(data); ERROR0: @@ -1243,8 +1238,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, int lm85_detach_client(struct i2c_client *client) { + struct lm85_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); i2c_detach_client(client); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; }