diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-05-25 14:43:31 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-05-25 14:43:31 -0400 |
commit | 95de3b257516d21af6e0313c7bab119e4f80d6f4 (patch) | |
tree | 818026064f6a1602e08521f5adaed3aed6313013 | |
parent | bc1f419c76a2d6450413ce4349f4e4a07be011d5 (diff) |
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>
-rw-r--r-- | drivers/hwmon/adcxx.c | 16 | ||||
-rw-r--r-- | drivers/hwmon/ibmaem.c | 10 | ||||
-rw-r--r-- | drivers/hwmon/k10temp.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/k8temp.c | 8 | ||||
-rw-r--r-- | drivers/hwmon/lm70.c | 10 | ||||
-rw-r--r-- | drivers/hwmon/ultra45_env.c | 4 |
6 files changed, 27 insertions, 27 deletions
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c index fbdc7655303b..b2cacbe707a8 100644 --- a/drivers/hwmon/adcxx.c +++ b/drivers/hwmon/adcxx.c | |||
@@ -62,7 +62,7 @@ static ssize_t adcxx_read(struct device *dev, | |||
62 | { | 62 | { |
63 | struct spi_device *spi = to_spi_device(dev); | 63 | struct spi_device *spi = to_spi_device(dev); |
64 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 64 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
65 | struct adcxx *adc = dev_get_drvdata(&spi->dev); | 65 | struct adcxx *adc = spi_get_drvdata(spi); |
66 | u8 tx_buf[2]; | 66 | u8 tx_buf[2]; |
67 | u8 rx_buf[2]; | 67 | u8 rx_buf[2]; |
68 | int status; | 68 | int status; |
@@ -105,7 +105,7 @@ static ssize_t adcxx_show_max(struct device *dev, | |||
105 | struct device_attribute *devattr, char *buf) | 105 | struct device_attribute *devattr, char *buf) |
106 | { | 106 | { |
107 | struct spi_device *spi = to_spi_device(dev); | 107 | struct spi_device *spi = to_spi_device(dev); |
108 | struct adcxx *adc = dev_get_drvdata(&spi->dev); | 108 | struct adcxx *adc = spi_get_drvdata(spi); |
109 | u32 reference; | 109 | u32 reference; |
110 | 110 | ||
111 | if (mutex_lock_interruptible(&adc->lock)) | 111 | if (mutex_lock_interruptible(&adc->lock)) |
@@ -122,7 +122,7 @@ static ssize_t adcxx_set_max(struct device *dev, | |||
122 | struct device_attribute *devattr, const char *buf, size_t count) | 122 | struct device_attribute *devattr, const char *buf, size_t count) |
123 | { | 123 | { |
124 | struct spi_device *spi = to_spi_device(dev); | 124 | struct spi_device *spi = to_spi_device(dev); |
125 | struct adcxx *adc = dev_get_drvdata(&spi->dev); | 125 | struct adcxx *adc = spi_get_drvdata(spi); |
126 | unsigned long value; | 126 | unsigned long value; |
127 | 127 | ||
128 | if (strict_strtoul(buf, 10, &value)) | 128 | if (strict_strtoul(buf, 10, &value)) |
@@ -142,7 +142,7 @@ static ssize_t adcxx_show_name(struct device *dev, struct device_attribute | |||
142 | *devattr, char *buf) | 142 | *devattr, char *buf) |
143 | { | 143 | { |
144 | struct spi_device *spi = to_spi_device(dev); | 144 | struct spi_device *spi = to_spi_device(dev); |
145 | struct adcxx *adc = dev_get_drvdata(&spi->dev); | 145 | struct adcxx *adc = spi_get_drvdata(spi); |
146 | 146 | ||
147 | return sprintf(buf, "adcxx%ds\n", adc->channels); | 147 | return sprintf(buf, "adcxx%ds\n", adc->channels); |
148 | } | 148 | } |
@@ -182,7 +182,7 @@ static int __devinit adcxx_probe(struct spi_device *spi) | |||
182 | 182 | ||
183 | mutex_lock(&adc->lock); | 183 | mutex_lock(&adc->lock); |
184 | 184 | ||
185 | dev_set_drvdata(&spi->dev, adc); | 185 | spi_set_drvdata(spi, adc); |
186 | 186 | ||
187 | for (i = 0; i < 3 + adc->channels; i++) { | 187 | for (i = 0; i < 3 + adc->channels; i++) { |
188 | status = device_create_file(&spi->dev, &ad_input[i].dev_attr); | 188 | status = device_create_file(&spi->dev, &ad_input[i].dev_attr); |
@@ -206,7 +206,7 @@ out_err: | |||
206 | for (i--; i >= 0; i--) | 206 | for (i--; i >= 0; i--) |
207 | device_remove_file(&spi->dev, &ad_input[i].dev_attr); | 207 | device_remove_file(&spi->dev, &ad_input[i].dev_attr); |
208 | 208 | ||
209 | dev_set_drvdata(&spi->dev, NULL); | 209 | spi_set_drvdata(spi, NULL); |
210 | mutex_unlock(&adc->lock); | 210 | mutex_unlock(&adc->lock); |
211 | kfree(adc); | 211 | kfree(adc); |
212 | return status; | 212 | return status; |
@@ -214,7 +214,7 @@ out_err: | |||
214 | 214 | ||
215 | static int __devexit adcxx_remove(struct spi_device *spi) | 215 | static int __devexit adcxx_remove(struct spi_device *spi) |
216 | { | 216 | { |
217 | struct adcxx *adc = dev_get_drvdata(&spi->dev); | 217 | struct adcxx *adc = spi_get_drvdata(spi); |
218 | int i; | 218 | int i; |
219 | 219 | ||
220 | mutex_lock(&adc->lock); | 220 | mutex_lock(&adc->lock); |
@@ -222,7 +222,7 @@ static int __devexit adcxx_remove(struct spi_device *spi) | |||
222 | for (i = 0; i < 3 + adc->channels; i++) | 222 | for (i = 0; i < 3 + adc->channels; i++) |
223 | device_remove_file(&spi->dev, &ad_input[i].dev_attr); | 223 | device_remove_file(&spi->dev, &ad_input[i].dev_attr); |
224 | 224 | ||
225 | dev_set_drvdata(&spi->dev, NULL); | 225 | spi_set_drvdata(spi, NULL); |
226 | mutex_unlock(&adc->lock); | 226 | mutex_unlock(&adc->lock); |
227 | kfree(adc); | 227 | kfree(adc); |
228 | 228 | ||
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c index bc6e2ab3a361..537409d07ee7 100644 --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c | |||
@@ -523,7 +523,7 @@ static void aem_delete(struct aem_data *data) | |||
523 | aem_remove_sensors(data); | 523 | aem_remove_sensors(data); |
524 | hwmon_device_unregister(data->hwmon_dev); | 524 | hwmon_device_unregister(data->hwmon_dev); |
525 | ipmi_destroy_user(data->ipmi.user); | 525 | ipmi_destroy_user(data->ipmi.user); |
526 | dev_set_drvdata(&data->pdev->dev, NULL); | 526 | platform_set_drvdata(data->pdev, NULL); |
527 | platform_device_unregister(data->pdev); | 527 | platform_device_unregister(data->pdev); |
528 | aem_idr_put(data->id); | 528 | aem_idr_put(data->id); |
529 | kfree(data); | 529 | kfree(data); |
@@ -594,7 +594,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) | |||
594 | if (res) | 594 | if (res) |
595 | goto ipmi_err; | 595 | goto ipmi_err; |
596 | 596 | ||
597 | dev_set_drvdata(&data->pdev->dev, data); | 597 | platform_set_drvdata(data->pdev, data); |
598 | 598 | ||
599 | /* Set up IPMI interface */ | 599 | /* Set up IPMI interface */ |
600 | if (aem_init_ipmi_data(&data->ipmi, probe->interface, | 600 | if (aem_init_ipmi_data(&data->ipmi, probe->interface, |
@@ -630,7 +630,7 @@ sensor_err: | |||
630 | hwmon_reg_err: | 630 | hwmon_reg_err: |
631 | ipmi_destroy_user(data->ipmi.user); | 631 | ipmi_destroy_user(data->ipmi.user); |
632 | ipmi_err: | 632 | ipmi_err: |
633 | dev_set_drvdata(&data->pdev->dev, NULL); | 633 | platform_set_drvdata(data->pdev, NULL); |
634 | platform_device_unregister(data->pdev); | 634 | platform_device_unregister(data->pdev); |
635 | dev_err: | 635 | dev_err: |
636 | aem_idr_put(data->id); | 636 | aem_idr_put(data->id); |
@@ -727,7 +727,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, | |||
727 | if (res) | 727 | if (res) |
728 | goto ipmi_err; | 728 | goto ipmi_err; |
729 | 729 | ||
730 | dev_set_drvdata(&data->pdev->dev, data); | 730 | platform_set_drvdata(data->pdev, data); |
731 | 731 | ||
732 | /* Set up IPMI interface */ | 732 | /* Set up IPMI interface */ |
733 | if (aem_init_ipmi_data(&data->ipmi, probe->interface, | 733 | if (aem_init_ipmi_data(&data->ipmi, probe->interface, |
@@ -763,7 +763,7 @@ sensor_err: | |||
763 | hwmon_reg_err: | 763 | hwmon_reg_err: |
764 | ipmi_destroy_user(data->ipmi.user); | 764 | ipmi_destroy_user(data->ipmi.user); |
765 | ipmi_err: | 765 | ipmi_err: |
766 | dev_set_drvdata(&data->pdev->dev, NULL); | 766 | platform_set_drvdata(data->pdev, NULL); |
767 | platform_device_unregister(data->pdev); | 767 | platform_device_unregister(data->pdev); |
768 | dev_err: | 768 | dev_err: |
769 | aem_idr_put(data->id); | 769 | aem_idr_put(data->id); |
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 82bf65aa2968..91df4d516a6d 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c | |||
@@ -173,7 +173,7 @@ static int __devinit k10temp_probe(struct pci_dev *pdev, | |||
173 | err = PTR_ERR(hwmon_dev); | 173 | err = PTR_ERR(hwmon_dev); |
174 | goto exit_remove; | 174 | goto exit_remove; |
175 | } | 175 | } |
176 | dev_set_drvdata(&pdev->dev, hwmon_dev); | 176 | pci_set_drvdata(pdev, hwmon_dev); |
177 | 177 | ||
178 | if (unreliable && force) | 178 | if (unreliable && force) |
179 | dev_warn(&pdev->dev, | 179 | dev_warn(&pdev->dev, |
@@ -194,7 +194,7 @@ exit: | |||
194 | 194 | ||
195 | static void __devexit k10temp_remove(struct pci_dev *pdev) | 195 | static void __devexit k10temp_remove(struct pci_dev *pdev) |
196 | { | 196 | { |
197 | hwmon_device_unregister(dev_get_drvdata(&pdev->dev)); | 197 | hwmon_device_unregister(pci_get_drvdata(pdev)); |
198 | device_remove_file(&pdev->dev, &dev_attr_name); | 198 | device_remove_file(&pdev->dev, &dev_attr_name); |
199 | device_remove_file(&pdev->dev, &dev_attr_temp1_input); | 199 | device_remove_file(&pdev->dev, &dev_attr_temp1_input); |
200 | device_remove_file(&pdev->dev, &dev_attr_temp1_max); | 200 | device_remove_file(&pdev->dev, &dev_attr_temp1_max); |
@@ -202,7 +202,7 @@ static void __devexit k10temp_remove(struct pci_dev *pdev) | |||
202 | &sensor_dev_attr_temp1_crit.dev_attr); | 202 | &sensor_dev_attr_temp1_crit.dev_attr); |
203 | device_remove_file(&pdev->dev, | 203 | device_remove_file(&pdev->dev, |
204 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); | 204 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); |
205 | dev_set_drvdata(&pdev->dev, NULL); | 205 | pci_set_drvdata(pdev, NULL); |
206 | } | 206 | } |
207 | 207 | ||
208 | static const struct pci_device_id k10temp_id_table[] = { | 208 | static const struct pci_device_id k10temp_id_table[] = { |
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 418496f13020..b923bc2307ad 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c | |||
@@ -252,7 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, | |||
252 | 252 | ||
253 | data->name = "k8temp"; | 253 | data->name = "k8temp"; |
254 | mutex_init(&data->update_lock); | 254 | mutex_init(&data->update_lock); |
255 | dev_set_drvdata(&pdev->dev, data); | 255 | pci_set_drvdata(pdev, data); |
256 | 256 | ||
257 | /* Register sysfs hooks */ | 257 | /* Register sysfs hooks */ |
258 | err = device_create_file(&pdev->dev, | 258 | err = device_create_file(&pdev->dev, |
@@ -307,7 +307,7 @@ exit_remove: | |||
307 | &sensor_dev_attr_temp4_input.dev_attr); | 307 | &sensor_dev_attr_temp4_input.dev_attr); |
308 | device_remove_file(&pdev->dev, &dev_attr_name); | 308 | device_remove_file(&pdev->dev, &dev_attr_name); |
309 | exit_free: | 309 | exit_free: |
310 | dev_set_drvdata(&pdev->dev, NULL); | 310 | pci_set_drvdata(pdev, NULL); |
311 | kfree(data); | 311 | kfree(data); |
312 | exit: | 312 | exit: |
313 | return err; | 313 | return err; |
@@ -315,7 +315,7 @@ exit: | |||
315 | 315 | ||
316 | static void __devexit k8temp_remove(struct pci_dev *pdev) | 316 | static void __devexit k8temp_remove(struct pci_dev *pdev) |
317 | { | 317 | { |
318 | struct k8temp_data *data = dev_get_drvdata(&pdev->dev); | 318 | struct k8temp_data *data = pci_get_drvdata(pdev); |
319 | 319 | ||
320 | hwmon_device_unregister(data->hwmon_dev); | 320 | hwmon_device_unregister(data->hwmon_dev); |
321 | device_remove_file(&pdev->dev, | 321 | device_remove_file(&pdev->dev, |
@@ -327,7 +327,7 @@ static void __devexit k8temp_remove(struct pci_dev *pdev) | |||
327 | device_remove_file(&pdev->dev, | 327 | device_remove_file(&pdev->dev, |
328 | &sensor_dev_attr_temp4_input.dev_attr); | 328 | &sensor_dev_attr_temp4_input.dev_attr); |
329 | device_remove_file(&pdev->dev, &dev_attr_name); | 329 | device_remove_file(&pdev->dev, &dev_attr_name); |
330 | dev_set_drvdata(&pdev->dev, NULL); | 330 | pci_set_drvdata(pdev, NULL); |
331 | kfree(data); | 331 | kfree(data); |
332 | } | 332 | } |
333 | 333 | ||
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index 3b84fb503053..c274ea25d899 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c | |||
@@ -58,7 +58,7 @@ static ssize_t lm70_sense_temp(struct device *dev, | |||
58 | int status, val = 0; | 58 | int status, val = 0; |
59 | u8 rxbuf[2]; | 59 | u8 rxbuf[2]; |
60 | s16 raw=0; | 60 | s16 raw=0; |
61 | struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); | 61 | struct lm70 *p_lm70 = spi_get_drvdata(spi); |
62 | 62 | ||
63 | if (mutex_lock_interruptible(&p_lm70->lock)) | 63 | if (mutex_lock_interruptible(&p_lm70->lock)) |
64 | return -ERESTARTSYS; | 64 | return -ERESTARTSYS; |
@@ -163,7 +163,7 @@ static int __devinit lm70_probe(struct spi_device *spi) | |||
163 | status = PTR_ERR(p_lm70->hwmon_dev); | 163 | status = PTR_ERR(p_lm70->hwmon_dev); |
164 | goto out_dev_reg_failed; | 164 | goto out_dev_reg_failed; |
165 | } | 165 | } |
166 | dev_set_drvdata(&spi->dev, p_lm70); | 166 | spi_set_drvdata(spi, p_lm70); |
167 | 167 | ||
168 | if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input)) | 168 | if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input)) |
169 | || (status = device_create_file(&spi->dev, &dev_attr_name))) { | 169 | || (status = device_create_file(&spi->dev, &dev_attr_name))) { |
@@ -177,19 +177,19 @@ out_dev_create_file_failed: | |||
177 | device_remove_file(&spi->dev, &dev_attr_temp1_input); | 177 | device_remove_file(&spi->dev, &dev_attr_temp1_input); |
178 | hwmon_device_unregister(p_lm70->hwmon_dev); | 178 | hwmon_device_unregister(p_lm70->hwmon_dev); |
179 | out_dev_reg_failed: | 179 | out_dev_reg_failed: |
180 | dev_set_drvdata(&spi->dev, NULL); | 180 | spi_set_drvdata(spi, NULL); |
181 | kfree(p_lm70); | 181 | kfree(p_lm70); |
182 | return status; | 182 | return status; |
183 | } | 183 | } |
184 | 184 | ||
185 | static int __devexit lm70_remove(struct spi_device *spi) | 185 | static int __devexit lm70_remove(struct spi_device *spi) |
186 | { | 186 | { |
187 | struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); | 187 | struct lm70 *p_lm70 = spi_get_drvdata(spi); |
188 | 188 | ||
189 | device_remove_file(&spi->dev, &dev_attr_temp1_input); | 189 | device_remove_file(&spi->dev, &dev_attr_temp1_input); |
190 | device_remove_file(&spi->dev, &dev_attr_name); | 190 | device_remove_file(&spi->dev, &dev_attr_name); |
191 | hwmon_device_unregister(p_lm70->hwmon_dev); | 191 | hwmon_device_unregister(p_lm70->hwmon_dev); |
192 | dev_set_drvdata(&spi->dev, NULL); | 192 | spi_set_drvdata(spi, NULL); |
193 | kfree(p_lm70); | 193 | kfree(p_lm70); |
194 | 194 | ||
195 | return 0; | 195 | return 0; |
diff --git a/drivers/hwmon/ultra45_env.c b/drivers/hwmon/ultra45_env.c index 1f36c635d933..27a62711e0a6 100644 --- a/drivers/hwmon/ultra45_env.c +++ b/drivers/hwmon/ultra45_env.c | |||
@@ -258,7 +258,7 @@ static int __devinit env_probe(struct platform_device *op) | |||
258 | goto out_sysfs_remove_group; | 258 | goto out_sysfs_remove_group; |
259 | } | 259 | } |
260 | 260 | ||
261 | dev_set_drvdata(&op->dev, p); | 261 | platform_set_drvdata(op, p); |
262 | err = 0; | 262 | err = 0; |
263 | 263 | ||
264 | out: | 264 | out: |
@@ -277,7 +277,7 @@ out_free: | |||
277 | 277 | ||
278 | static int __devexit env_remove(struct platform_device *op) | 278 | static int __devexit env_remove(struct platform_device *op) |
279 | { | 279 | { |
280 | struct env *p = dev_get_drvdata(&op->dev); | 280 | struct env *p = platform_get_drvdata(op); |
281 | 281 | ||
282 | if (p) { | 282 | if (p) { |
283 | sysfs_remove_group(&op->dev.kobj, &env_group); | 283 | sysfs_remove_group(&op->dev.kobj, &env_group); |