hwmon: Use helper functions to set and get driver data
Use helper functions to set and get driver data. This is more elegant. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Andreas Herrmann <andreas.herrmann3@amd.com> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
This commit is contained in:

کامیت شده توسط
Jean Delvare

والد
bc1f419c76
کامیت
95de3b2575
@@ -58,7 +58,7 @@ static ssize_t lm70_sense_temp(struct device *dev,
|
||||
int status, val = 0;
|
||||
u8 rxbuf[2];
|
||||
s16 raw=0;
|
||||
struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
|
||||
struct lm70 *p_lm70 = spi_get_drvdata(spi);
|
||||
|
||||
if (mutex_lock_interruptible(&p_lm70->lock))
|
||||
return -ERESTARTSYS;
|
||||
@@ -163,7 +163,7 @@ static int __devinit lm70_probe(struct spi_device *spi)
|
||||
status = PTR_ERR(p_lm70->hwmon_dev);
|
||||
goto out_dev_reg_failed;
|
||||
}
|
||||
dev_set_drvdata(&spi->dev, p_lm70);
|
||||
spi_set_drvdata(spi, p_lm70);
|
||||
|
||||
if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
|
||||
|| (status = device_create_file(&spi->dev, &dev_attr_name))) {
|
||||
@@ -177,19 +177,19 @@ out_dev_create_file_failed:
|
||||
device_remove_file(&spi->dev, &dev_attr_temp1_input);
|
||||
hwmon_device_unregister(p_lm70->hwmon_dev);
|
||||
out_dev_reg_failed:
|
||||
dev_set_drvdata(&spi->dev, NULL);
|
||||
spi_set_drvdata(spi, NULL);
|
||||
kfree(p_lm70);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int __devexit lm70_remove(struct spi_device *spi)
|
||||
{
|
||||
struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
|
||||
struct lm70 *p_lm70 = spi_get_drvdata(spi);
|
||||
|
||||
device_remove_file(&spi->dev, &dev_attr_temp1_input);
|
||||
device_remove_file(&spi->dev, &dev_attr_name);
|
||||
hwmon_device_unregister(p_lm70->hwmon_dev);
|
||||
dev_set_drvdata(&spi->dev, NULL);
|
||||
spi_set_drvdata(spi, NULL);
|
||||
kfree(p_lm70);
|
||||
|
||||
return 0;
|
||||
|
مرجع در شماره جدید
Block a user