Commit 95de3b25 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

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: default avatarJean Delvare <khali@linux-fr.org>
Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Acked-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
parent bc1f419c
...@@ -62,7 +62,7 @@ static ssize_t adcxx_read(struct device *dev, ...@@ -62,7 +62,7 @@ static ssize_t adcxx_read(struct device *dev,
{ {
struct spi_device *spi = to_spi_device(dev); struct spi_device *spi = to_spi_device(dev);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 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 tx_buf[2];
u8 rx_buf[2]; u8 rx_buf[2];
int status; int status;
...@@ -105,7 +105,7 @@ static ssize_t adcxx_show_max(struct device *dev, ...@@ -105,7 +105,7 @@ static ssize_t adcxx_show_max(struct device *dev,
struct device_attribute *devattr, char *buf) struct device_attribute *devattr, char *buf)
{ {
struct spi_device *spi = to_spi_device(dev); 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; u32 reference;
if (mutex_lock_interruptible(&adc->lock)) if (mutex_lock_interruptible(&adc->lock))
...@@ -122,7 +122,7 @@ static ssize_t adcxx_set_max(struct device *dev, ...@@ -122,7 +122,7 @@ static ssize_t adcxx_set_max(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count) struct device_attribute *devattr, const char *buf, size_t count)
{ {
struct spi_device *spi = to_spi_device(dev); 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; unsigned long value;
if (strict_strtoul(buf, 10, &value)) if (strict_strtoul(buf, 10, &value))
...@@ -142,7 +142,7 @@ static ssize_t adcxx_show_name(struct device *dev, struct device_attribute ...@@ -142,7 +142,7 @@ static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
*devattr, char *buf) *devattr, char *buf)
{ {
struct spi_device *spi = to_spi_device(dev); 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); return sprintf(buf, "adcxx%ds\n", adc->channels);
} }
...@@ -182,7 +182,7 @@ static int __devinit adcxx_probe(struct spi_device *spi) ...@@ -182,7 +182,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)
mutex_lock(&adc->lock); mutex_lock(&adc->lock);
dev_set_drvdata(&spi->dev, adc); spi_set_drvdata(spi, adc);
for (i = 0; i < 3 + adc->channels; i++) { for (i = 0; i < 3 + adc->channels; i++) {
status = device_create_file(&spi->dev, &ad_input[i].dev_attr); status = device_create_file(&spi->dev, &ad_input[i].dev_attr);
...@@ -206,7 +206,7 @@ static int __devinit adcxx_probe(struct spi_device *spi) ...@@ -206,7 +206,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
device_remove_file(&spi->dev, &ad_input[i].dev_attr); 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); mutex_unlock(&adc->lock);
kfree(adc); kfree(adc);
return status; return status;
...@@ -214,7 +214,7 @@ static int __devinit adcxx_probe(struct spi_device *spi) ...@@ -214,7 +214,7 @@ static int __devinit adcxx_probe(struct spi_device *spi)
static int __devexit adcxx_remove(struct spi_device *spi) 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; int i;
mutex_lock(&adc->lock); mutex_lock(&adc->lock);
...@@ -222,7 +222,7 @@ static int __devexit adcxx_remove(struct spi_device *spi) ...@@ -222,7 +222,7 @@ static int __devexit adcxx_remove(struct spi_device *spi)
for (i = 0; i < 3 + adc->channels; i++) for (i = 0; i < 3 + adc->channels; i++)
device_remove_file(&spi->dev, &ad_input[i].dev_attr); 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); mutex_unlock(&adc->lock);
kfree(adc); kfree(adc);
......
...@@ -523,7 +523,7 @@ static void aem_delete(struct aem_data *data) ...@@ -523,7 +523,7 @@ static void aem_delete(struct aem_data *data)
aem_remove_sensors(data); aem_remove_sensors(data);
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
dev_set_drvdata(&data->pdev->dev, NULL); platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev); platform_device_unregister(data->pdev);
aem_idr_put(data->id); aem_idr_put(data->id);
kfree(data); kfree(data);
...@@ -594,7 +594,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) ...@@ -594,7 +594,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
if (res) if (res)
goto ipmi_err; goto ipmi_err;
dev_set_drvdata(&data->pdev->dev, data); platform_set_drvdata(data->pdev, data);
/* Set up IPMI interface */ /* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface, if (aem_init_ipmi_data(&data->ipmi, probe->interface,
...@@ -630,7 +630,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) ...@@ -630,7 +630,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
hwmon_reg_err: hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
ipmi_err: ipmi_err:
dev_set_drvdata(&data->pdev->dev, NULL); platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev); platform_device_unregister(data->pdev);
dev_err: dev_err:
aem_idr_put(data->id); aem_idr_put(data->id);
...@@ -727,7 +727,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, ...@@ -727,7 +727,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
if (res) if (res)
goto ipmi_err; goto ipmi_err;
dev_set_drvdata(&data->pdev->dev, data); platform_set_drvdata(data->pdev, data);
/* Set up IPMI interface */ /* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface, if (aem_init_ipmi_data(&data->ipmi, probe->interface,
...@@ -763,7 +763,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, ...@@ -763,7 +763,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
hwmon_reg_err: hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
ipmi_err: ipmi_err:
dev_set_drvdata(&data->pdev->dev, NULL); platform_set_drvdata(data->pdev, NULL);
platform_device_unregister(data->pdev); platform_device_unregister(data->pdev);
dev_err: dev_err:
aem_idr_put(data->id); aem_idr_put(data->id);
......
...@@ -173,7 +173,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev, ...@@ -173,7 +173,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev,
err = PTR_ERR(hwmon_dev); err = PTR_ERR(hwmon_dev);
goto exit_remove; goto exit_remove;
} }
dev_set_drvdata(&pdev->dev, hwmon_dev); pci_set_drvdata(pdev, hwmon_dev);
if (unreliable && force) if (unreliable && force)
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
...@@ -194,7 +194,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev, ...@@ -194,7 +194,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev,
static void __devexit k10temp_remove(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_name);
device_remove_file(&pdev->dev, &dev_attr_temp1_input); device_remove_file(&pdev->dev, &dev_attr_temp1_input);
device_remove_file(&pdev->dev, &dev_attr_temp1_max); device_remove_file(&pdev->dev, &dev_attr_temp1_max);
...@@ -202,7 +202,7 @@ static void __devexit k10temp_remove(struct pci_dev *pdev) ...@@ -202,7 +202,7 @@ static void __devexit k10temp_remove(struct pci_dev *pdev)
&sensor_dev_attr_temp1_crit.dev_attr); &sensor_dev_attr_temp1_crit.dev_attr);
device_remove_file(&pdev->dev, device_remove_file(&pdev->dev,
&sensor_dev_attr_temp1_crit_hyst.dev_attr); &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[] = { static const struct pci_device_id k10temp_id_table[] = {
......
...@@ -252,7 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, ...@@ -252,7 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
data->name = "k8temp"; data->name = "k8temp";
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
dev_set_drvdata(&pdev->dev, data); pci_set_drvdata(pdev, data);
/* Register sysfs hooks */ /* Register sysfs hooks */
err = device_create_file(&pdev->dev, err = device_create_file(&pdev->dev,
...@@ -307,7 +307,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, ...@@ -307,7 +307,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
&sensor_dev_attr_temp4_input.dev_attr); &sensor_dev_attr_temp4_input.dev_attr);
device_remove_file(&pdev->dev, &dev_attr_name); device_remove_file(&pdev->dev, &dev_attr_name);
exit_free: exit_free:
dev_set_drvdata(&pdev->dev, NULL); pci_set_drvdata(pdev, NULL);
kfree(data); kfree(data);
exit: exit:
return err; return err;
...@@ -315,7 +315,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, ...@@ -315,7 +315,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
static void __devexit k8temp_remove(struct pci_dev *pdev) 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); hwmon_device_unregister(data->hwmon_dev);
device_remove_file(&pdev->dev, device_remove_file(&pdev->dev,
...@@ -327,7 +327,7 @@ static void __devexit k8temp_remove(struct pci_dev *pdev) ...@@ -327,7 +327,7 @@ static void __devexit k8temp_remove(struct pci_dev *pdev)
device_remove_file(&pdev->dev, device_remove_file(&pdev->dev,
&sensor_dev_attr_temp4_input.dev_attr); &sensor_dev_attr_temp4_input.dev_attr);
device_remove_file(&pdev->dev, &dev_attr_name); device_remove_file(&pdev->dev, &dev_attr_name);
dev_set_drvdata(&pdev->dev, NULL); pci_set_drvdata(pdev, NULL);
kfree(data); kfree(data);
} }
......
...@@ -58,7 +58,7 @@ static ssize_t lm70_sense_temp(struct device *dev, ...@@ -58,7 +58,7 @@ static ssize_t lm70_sense_temp(struct device *dev,
int status, val = 0; int status, val = 0;
u8 rxbuf[2]; u8 rxbuf[2];
s16 raw=0; 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)) if (mutex_lock_interruptible(&p_lm70->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -163,7 +163,7 @@ static int __devinit lm70_probe(struct spi_device *spi) ...@@ -163,7 +163,7 @@ static int __devinit lm70_probe(struct spi_device *spi)
status = PTR_ERR(p_lm70->hwmon_dev); status = PTR_ERR(p_lm70->hwmon_dev);
goto out_dev_reg_failed; 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)) if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
|| (status = device_create_file(&spi->dev, &dev_attr_name))) { || (status = device_create_file(&spi->dev, &dev_attr_name))) {
...@@ -177,19 +177,19 @@ static int __devinit lm70_probe(struct spi_device *spi) ...@@ -177,19 +177,19 @@ static int __devinit lm70_probe(struct spi_device *spi)
device_remove_file(&spi->dev, &dev_attr_temp1_input); device_remove_file(&spi->dev, &dev_attr_temp1_input);
hwmon_device_unregister(p_lm70->hwmon_dev); hwmon_device_unregister(p_lm70->hwmon_dev);
out_dev_reg_failed: out_dev_reg_failed:
dev_set_drvdata(&spi->dev, NULL); spi_set_drvdata(spi, NULL);
kfree(p_lm70); kfree(p_lm70);
return status; return status;
} }
static int __devexit lm70_remove(struct spi_device *spi) 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_temp1_input);
device_remove_file(&spi->dev, &dev_attr_name); device_remove_file(&spi->dev, &dev_attr_name);
hwmon_device_unregister(p_lm70->hwmon_dev); hwmon_device_unregister(p_lm70->hwmon_dev);
dev_set_drvdata(&spi->dev, NULL); spi_set_drvdata(spi, NULL);
kfree(p_lm70); kfree(p_lm70);
return 0; return 0;
......
...@@ -258,7 +258,7 @@ static int __devinit env_probe(struct platform_device *op) ...@@ -258,7 +258,7 @@ static int __devinit env_probe(struct platform_device *op)
goto out_sysfs_remove_group; goto out_sysfs_remove_group;
} }
dev_set_drvdata(&op->dev, p); platform_set_drvdata(op, p);
err = 0; err = 0;
out: out:
...@@ -277,7 +277,7 @@ static int __devinit env_probe(struct platform_device *op) ...@@ -277,7 +277,7 @@ static int __devinit env_probe(struct platform_device *op)
static int __devexit env_remove(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) { if (p) {
sysfs_remove_group(&op->dev.kobj, &env_group); sysfs_remove_group(&op->dev.kobj, &env_group);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment