X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Flm87.c;h=eeec18177861ca67074189f03ce74df0019fa476;hb=89de09a9ba9ce293228b1f1aa3c68b5af33a70ce;hp=1921ed1af182df9f05dc68b114e7115f51009bea;hpb=5d2a22079c825669d91a3a200332f1053b4b61b0;p=linux-2.6-omap-h63xx.git diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 1921ed1af18..eeec1817786 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -57,8 +57,9 @@ #include #include #include -#include -#include +#include +#include +#include /* * 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); } /* @@ -553,11 +554,10 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto exit; - if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { + if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } - memset(data, 0, sizeof(struct lm87_data)); /* The common I2C client data is placed right before the LM87-specific data. */ @@ -608,6 +608,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 +679,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 +693,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 +727,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; }