diff options
Diffstat (limited to 'drivers/hwmon/smm665.c')
-rw-r--r-- | drivers/hwmon/smm665.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/drivers/hwmon/smm665.c b/drivers/hwmon/smm665.c index 411638181fd8..cbc51fb30dba 100644 --- a/drivers/hwmon/smm665.c +++ b/drivers/hwmon/smm665.c @@ -124,9 +124,9 @@ enum chips { smm465, smm665, smm665c, smm764, smm766 }; #define SMM665_AIN_ADC_TO_VOLTS(adc) ((adc) * vref / 512) /* Temp Sensor */ -#define SMM665_TEMP_ADC_TO_CELSIUS(adc) ((adc) <= 511) ? \ +#define SMM665_TEMP_ADC_TO_CELSIUS(adc) (((adc) <= 511) ? \ ((int)(adc) * 1000 / 4) : \ - (((int)(adc) - 0x400) * 1000 / 4) + (((int)(adc) - 0x400) * 1000 / 4)) #define SMM665_NUM_ADC 11 @@ -376,7 +376,7 @@ static ssize_t smm665_show_input(struct device *dev, } #define SMM665_SHOW(what) \ - static ssize_t smm665_show_##what(struct device *dev, \ +static ssize_t smm665_show_##what(struct device *dev, \ struct device_attribute *da, char *buf) \ { \ struct sensor_device_attribute *attr = to_sensor_dev_attr(da); \ @@ -389,7 +389,8 @@ SMM665_SHOW(max); SMM665_SHOW(lcrit); SMM665_SHOW(crit); -/* These macros are used below in constructing device attribute objects +/* + * These macros are used below in constructing device attribute objects * for use with sysfs_create_group() to make a sysfs device file * for each register. */ @@ -583,10 +584,9 @@ static int smm665_probe(struct i2c_client *client, if (i2c_smbus_read_byte_data(client, SMM665_ADOC_ENABLE) < 0) return -ENODEV; - ret = -ENOMEM; - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) - goto out_return; + return -ENOMEM; i2c_set_clientdata(client, data); mutex_init(&data->update_lock); @@ -595,7 +595,7 @@ static int smm665_probe(struct i2c_client *client, data->cmdreg = i2c_new_dummy(adapter, (client->addr & ~SMM665_REGMASK) | SMM665_CMDREG_BASE); if (!data->cmdreg) - goto out_kfree; + return -ENOMEM; switch (data->type) { case smm465: @@ -678,9 +678,6 @@ out_remove_group: sysfs_remove_group(&client->dev.kobj, &smm665_group); out_unregister: i2c_unregister_device(data->cmdreg); -out_kfree: - kfree(data); -out_return: return ret; } @@ -692,8 +689,6 @@ static int smm665_remove(struct i2c_client *client) hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &smm665_group); - kfree(data); - return 0; } @@ -718,19 +713,8 @@ static struct i2c_driver smm665_driver = { .id_table = smm665_id, }; -static int __init smm665_init(void) -{ - return i2c_add_driver(&smm665_driver); -} - -static void __exit smm665_exit(void) -{ - i2c_del_driver(&smm665_driver); -} +module_i2c_driver(smm665_driver); MODULE_AUTHOR("Guenter Roeck"); MODULE_DESCRIPTION("SMM665 driver"); MODULE_LICENSE("GPL"); - -module_init(smm665_init); -module_exit(smm665_exit); |