Skip to content

Commit

Permalink
hwmon: (max1111) Convert to use devm_ functions
Browse files Browse the repository at this point in the history
Convert to use devm_ functions to reduce code size and simplify the code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Guenter Roeck committed Jul 22, 2012
1 parent 4a8ad25 commit 661f020
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/hwmon/max1111.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ static int __devinit max1111_probe(struct spi_device *spi)
if (err < 0)
return err;

data = kzalloc(sizeof(struct max1111_data), GFP_KERNEL);
data = devm_kzalloc(&spi->dev, sizeof(struct max1111_data), GFP_KERNEL);
if (data == NULL) {
dev_err(&spi->dev, "failed to allocate memory\n");
return -ENOMEM;
}

err = setup_transfer(data);
if (err)
goto err_free_data;
return err;

mutex_init(&data->drvdata_lock);

Expand All @@ -186,7 +186,7 @@ static int __devinit max1111_probe(struct spi_device *spi)
err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group);
if (err) {
dev_err(&spi->dev, "failed to create attribute group\n");
goto err_free_data;
return err;
}

data->hwmon_dev = hwmon_device_register(&spi->dev);
Expand All @@ -203,8 +203,6 @@ static int __devinit max1111_probe(struct spi_device *spi)

err_remove:
sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
err_free_data:
kfree(data);
return err;
}

Expand All @@ -215,7 +213,6 @@ static int __devexit max1111_remove(struct spi_device *spi)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);
mutex_destroy(&data->drvdata_lock);
kfree(data);
return 0;
}

Expand Down

0 comments on commit 661f020

Please sign in to comment.