X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fhwmon%2Flm63.c;h=954ec249724974107a14964ec00c2e3e25eb261f;hb=d8d2061590c87c20bf78133461bc74df78803ecb;hp=7c6f9ea5a254c53614e2269a89263a4aad96184f;hpb=6cd59f7a4119fef124677827a9b30684c2c8e674;p=powerpc.git diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 7c6f9ea5a2..954ec24972 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -42,8 +42,9 @@ #include #include #include -#include #include +#include +#include /* * Addresses to scan @@ -51,13 +52,12 @@ */ static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters */ -SENSORS_INSMOD_1(lm63); +I2C_CLIENT_INSMOD_1(lm63); /* * The LM63 registers @@ -152,6 +152,7 @@ static struct i2c_driver lm63_driver = { struct lm63_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 */ @@ -358,7 +359,7 @@ static int lm63_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm63_detect); + return i2c_probe(adapter, &addr_data, lm63_detect); } /* @@ -374,11 +375,10 @@ static int lm63_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 lm63_data), GFP_KERNEL))) { + if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } - memset(data, 0, sizeof(struct lm63_data)); /* The common I2C client data is placed right before the LM63-specific data. */ @@ -437,6 +437,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) lm63_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 exit_detach; + } + if (data->config & 0x04) { /* tachometer enabled */ device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); @@ -462,6 +468,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -505,15 +513,15 @@ static void lm63_init_client(struct i2c_client *client) static int lm63_detach_client(struct i2c_client *client) { + struct lm63_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; }