hwmon: (ad7314) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
a34c26d8e2
commit
be92304034
|
@ -112,16 +112,16 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
|
||||||
int ret;
|
int ret;
|
||||||
struct ad7314_data *chip;
|
struct ad7314_data *chip;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
chip = devm_kzalloc(&spi_dev->dev, sizeof(*chip), GFP_KERNEL);
|
||||||
if (chip == NULL) {
|
if (chip == NULL)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto error_ret;
|
|
||||||
}
|
|
||||||
dev_set_drvdata(&spi_dev->dev, chip);
|
dev_set_drvdata(&spi_dev->dev, chip);
|
||||||
|
|
||||||
ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group);
|
ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_free_chip;
|
return ret;
|
||||||
|
|
||||||
chip->hwmon_dev = hwmon_device_register(&spi_dev->dev);
|
chip->hwmon_dev = hwmon_device_register(&spi_dev->dev);
|
||||||
if (IS_ERR(chip->hwmon_dev)) {
|
if (IS_ERR(chip->hwmon_dev)) {
|
||||||
ret = PTR_ERR(chip->hwmon_dev);
|
ret = PTR_ERR(chip->hwmon_dev);
|
||||||
|
@ -132,9 +132,6 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
|
||||||
return 0;
|
return 0;
|
||||||
error_remove_group:
|
error_remove_group:
|
||||||
sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
|
sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
|
||||||
error_free_chip:
|
|
||||||
kfree(chip);
|
|
||||||
error_ret:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +141,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev)
|
||||||
|
|
||||||
hwmon_device_unregister(chip->hwmon_dev);
|
hwmon_device_unregister(chip->hwmon_dev);
|
||||||
sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
|
sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group);
|
||||||
kfree(chip);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue