Skip to content

Commit

Permalink
hwmon: Use helper functions to set and get driver data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jean Delvare authored and Jean Delvare committed May 25, 2011
1 parent bc1f419 commit 95de3b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions drivers/hwmon/adcxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static ssize_t adcxx_read(struct device *dev,
{
struct spi_device *spi = to_spi_device(dev);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct adcxx *adc = dev_get_drvdata(&spi->dev);
struct adcxx *adc = spi_get_drvdata(spi);
u8 tx_buf[2];
u8 rx_buf[2];
int status;
Expand Down Expand Up @@ -105,7 +105,7 @@ static ssize_t adcxx_show_max(struct device *dev,
struct device_attribute *devattr, char *buf)
{
struct spi_device *spi = to_spi_device(dev);
struct adcxx *adc = dev_get_drvdata(&spi->dev);
struct adcxx *adc = spi_get_drvdata(spi);
u32 reference;

if (mutex_lock_interruptible(&adc->lock))
Expand All @@ -122,7 +122,7 @@ static ssize_t adcxx_set_max(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count)
{
struct spi_device *spi = to_spi_device(dev);
struct adcxx *adc = dev_get_drvdata(&spi->dev);
struct adcxx *adc = spi_get_drvdata(spi);
unsigned long value;

if (strict_strtoul(buf, 10, &value))
Expand All @@ -142,7 +142,7 @@ static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct spi_device *spi = to_spi_device(dev);
struct adcxx *adc = dev_get_drvdata(&spi->dev);
struct adcxx *adc = spi_get_drvdata(spi);

return sprintf(buf, "adcxx%ds\n", adc->channels);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)

mutex_lock(&adc->lock);

dev_set_drvdata(&spi->dev, adc);
spi_set_drvdata(spi, adc);

for (i = 0; i < 3 + adc->channels; i++) {
status = device_create_file(&spi->dev, &ad_input[i].dev_attr);
Expand All @@ -206,23 +206,23 @@ static int __devinit adcxx_probe(struct spi_device *spi)
for (i--; i >= 0; i--)
device_remove_file(&spi->dev, &ad_input[i].dev_attr);

dev_set_drvdata(&spi->dev, NULL);
spi_set_drvdata(spi, NULL);
mutex_unlock(&adc->lock);
kfree(adc);
return status;
}

static int __devexit adcxx_remove(struct spi_device *spi)
{
struct adcxx *adc = dev_get_drvdata(&spi->dev);
struct adcxx *adc = spi_get_drvdata(spi);
int i;

mutex_lock(&adc->lock);
hwmon_device_unregister(adc->hwmon_dev);
for (i = 0; i < 3 + adc->channels; i++)
device_remove_file(&spi->dev, &ad_input[i].dev_attr);

dev_set_drvdata(&spi->dev, NULL);
spi_set_drvdata(spi, NULL);
mutex_unlock(&adc->lock);
kfree(adc);

Expand Down
10 changes: 5 additions & 5 deletions drivers/hwmon/ibmaem.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ static void aem_delete(struct aem_data *data)
aem_remove_sensors(data);
hwmon_device_unregister(data->hwmon_dev);
ipmi_destroy_user(data->ipmi.user);
dev_set_drvdata(&data->pdev->dev, NULL);
platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev);
aem_idr_put(data->id);
kfree(data);
Expand Down Expand Up @@ -594,7 +594,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
if (res)
goto ipmi_err;

dev_set_drvdata(&data->pdev->dev, data);
platform_set_drvdata(data->pdev, data);

/* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface,
Expand Down Expand Up @@ -630,7 +630,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user);
ipmi_err:
dev_set_drvdata(&data->pdev->dev, NULL);
platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev);
dev_err:
aem_idr_put(data->id);
Expand Down Expand Up @@ -727,7 +727,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
if (res)
goto ipmi_err;

dev_set_drvdata(&data->pdev->dev, data);
platform_set_drvdata(data->pdev, data);

/* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface,
Expand Down Expand Up @@ -763,7 +763,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user);
ipmi_err:
dev_set_drvdata(&data->pdev->dev, NULL);
platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev);
dev_err:
aem_idr_put(data->id);
Expand Down
6 changes: 3 additions & 3 deletions drivers/hwmon/k10temp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev,
err = PTR_ERR(hwmon_dev);
goto exit_remove;
}
dev_set_drvdata(&pdev->dev, hwmon_dev);
pci_set_drvdata(pdev, hwmon_dev);

if (unreliable && force)
dev_warn(&pdev->dev,
Expand All @@ -194,15 +194,15 @@ static int __devinit k10temp_probe(struct pci_dev *pdev,

static void __devexit k10temp_remove(struct pci_dev *pdev)
{
hwmon_device_unregister(dev_get_drvdata(&pdev->dev));
hwmon_device_unregister(pci_get_drvdata(pdev));
device_remove_file(&pdev->dev, &dev_attr_name);
device_remove_file(&pdev->dev, &dev_attr_temp1_input);
device_remove_file(&pdev->dev, &dev_attr_temp1_max);
device_remove_file(&pdev->dev,
&sensor_dev_attr_temp1_crit.dev_attr);
device_remove_file(&pdev->dev,
&sensor_dev_attr_temp1_crit_hyst.dev_attr);
dev_set_drvdata(&pdev->dev, NULL);
pci_set_drvdata(pdev, NULL);
}

static const struct pci_device_id k10temp_id_table[] = {
Expand Down
8 changes: 4 additions & 4 deletions drivers/hwmon/k8temp.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,

data->name = "k8temp";
mutex_init(&data->update_lock);
dev_set_drvdata(&pdev->dev, data);
pci_set_drvdata(pdev, data);

/* Register sysfs hooks */
err = device_create_file(&pdev->dev,
Expand Down Expand Up @@ -307,15 +307,15 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
&sensor_dev_attr_temp4_input.dev_attr);
device_remove_file(&pdev->dev, &dev_attr_name);
exit_free:
dev_set_drvdata(&pdev->dev, NULL);
pci_set_drvdata(pdev, NULL);
kfree(data);
exit:
return err;
}

static void __devexit k8temp_remove(struct pci_dev *pdev)
{
struct k8temp_data *data = dev_get_drvdata(&pdev->dev);
struct k8temp_data *data = pci_get_drvdata(pdev);

hwmon_device_unregister(data->hwmon_dev);
device_remove_file(&pdev->dev,
Expand All @@ -327,7 +327,7 @@ static void __devexit k8temp_remove(struct pci_dev *pdev)
device_remove_file(&pdev->dev,
&sensor_dev_attr_temp4_input.dev_attr);
device_remove_file(&pdev->dev, &dev_attr_name);
dev_set_drvdata(&pdev->dev, NULL);
pci_set_drvdata(pdev, NULL);
kfree(data);
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/hwmon/lm70.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))) {
Expand All @@ -177,19 +177,19 @@ static int __devinit lm70_probe(struct spi_device *spi)
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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/hwmon/ultra45_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static int __devinit env_probe(struct platform_device *op)
goto out_sysfs_remove_group;
}

dev_set_drvdata(&op->dev, p);
platform_set_drvdata(op, p);
err = 0;

out:
Expand All @@ -277,7 +277,7 @@ static int __devinit env_probe(struct platform_device *op)

static int __devexit env_remove(struct platform_device *op)
{
struct env *p = dev_get_drvdata(&op->dev);
struct env *p = platform_get_drvdata(op);

if (p) {
sysfs_remove_group(&op->dev.kobj, &env_group);
Expand Down

0 comments on commit 95de3b2

Please sign in to comment.