X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fhwmon%2Ffscpos.c;h=64e4edc64f8d40bcd93f8d0c4c4978b7dd9f6b2c;hb=dbe0580d0d2fccf63b0349840a7ae3dbb16f3074;hp=270015b626adefcc3fe66cd41fefc2391bb33706;hpb=1d492eb41371d9a5145651e8eb64bea1042a4057;p=powerpc.git diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 270015b626..64e4edc64f 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -34,19 +34,19 @@ #include #include #include -#include #include +#include +#include /* * Addresses to scan */ static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters */ -SENSORS_INSMOD_1(fscpos); +I2C_CLIENT_INSMOD_1(fscpos); /* * The FSCPOS registers @@ -113,6 +113,7 @@ static struct i2c_driver fscpos_driver = { */ struct fscpos_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* 0 until following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -167,7 +168,7 @@ static ssize_t set_temp_reset(struct i2c_client *client, struct fscpos_data "experience to the module author.\n"); /* Supported value: 2 (clears the status) */ - fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr], 2); + fscpos_write_value(client, FSCPOS_REG_TEMP_STATE[nr - 1], 2); return count; } @@ -434,10 +435,10 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, fscpos_detect); + return i2c_probe(adapter, &addr_data, fscpos_detect); } -int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) +static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) { struct i2c_client *new_client; struct fscpos_data *data; @@ -452,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) * But it allows us to access fscpos_{read,write}_value. */ - if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { + if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } - memset(data, 0, sizeof(struct fscpos_data)); new_client = &data->client; i2c_set_clientdata(new_client, data); @@ -496,6 +496,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); /* 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_event); device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); @@ -526,6 +532,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -534,14 +542,14 @@ exit: static int fscpos_detach_client(struct i2c_client *client) { + struct fscpos_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; }