diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 15:04:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:43 -0400 |
commit | a0d44cbcc0b92d1dbec5dda3a5b7ea929c05d522 (patch) | |
tree | b0b9cc776b358ab3aabcd2a1ad6585c5ff753ca9 /drivers/hwmon | |
parent | 6e13bb06f62f11797ceb5f28c392f703dc0aa548 (diff) |
hwmon: (k8temp) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Cc: Rudolf Marek <r.marek@assembler.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/k8temp.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 35aac82ee8eb..49a69c5b3b8d 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c | |||
@@ -183,21 +183,17 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, | |||
183 | u8 model, stepping; | 183 | u8 model, stepping; |
184 | struct k8temp_data *data; | 184 | struct k8temp_data *data; |
185 | 185 | ||
186 | data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL); | 186 | data = devm_kzalloc(&pdev->dev, sizeof(struct k8temp_data), GFP_KERNEL); |
187 | if (!data) { | 187 | if (!data) |
188 | err = -ENOMEM; | 188 | return -ENOMEM; |
189 | goto exit; | ||
190 | } | ||
191 | 189 | ||
192 | model = boot_cpu_data.x86_model; | 190 | model = boot_cpu_data.x86_model; |
193 | stepping = boot_cpu_data.x86_mask; | 191 | stepping = boot_cpu_data.x86_mask; |
194 | 192 | ||
195 | /* feature available since SH-C0, exclude older revisions */ | 193 | /* feature available since SH-C0, exclude older revisions */ |
196 | if (((model == 4) && (stepping == 0)) || | 194 | if ((model == 4 && stepping == 0) || |
197 | ((model == 5) && (stepping <= 1))) { | 195 | (model == 5 && stepping <= 1)) |
198 | err = -ENODEV; | 196 | return -ENODEV; |
199 | goto exit_free; | ||
200 | } | ||
201 | 197 | ||
202 | /* | 198 | /* |
203 | * AMD NPT family 0fh, i.e. RevF and RevG: | 199 | * AMD NPT family 0fh, i.e. RevF and RevG: |
@@ -224,8 +220,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, | |||
224 | 220 | ||
225 | if (scfg & (SEL_PLACE | SEL_CORE)) { | 221 | if (scfg & (SEL_PLACE | SEL_CORE)) { |
226 | dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); | 222 | dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); |
227 | err = -ENODEV; | 223 | return -ENODEV; |
228 | goto exit_free; | ||
229 | } | 224 | } |
230 | 225 | ||
231 | scfg |= (SEL_PLACE | SEL_CORE); | 226 | scfg |= (SEL_PLACE | SEL_CORE); |
@@ -307,10 +302,6 @@ exit_remove: | |||
307 | device_remove_file(&pdev->dev, | 302 | device_remove_file(&pdev->dev, |
308 | &sensor_dev_attr_temp4_input.dev_attr); | 303 | &sensor_dev_attr_temp4_input.dev_attr); |
309 | device_remove_file(&pdev->dev, &dev_attr_name); | 304 | device_remove_file(&pdev->dev, &dev_attr_name); |
310 | exit_free: | ||
311 | pci_set_drvdata(pdev, NULL); | ||
312 | kfree(data); | ||
313 | exit: | ||
314 | return err; | 305 | return err; |
315 | } | 306 | } |
316 | 307 | ||
@@ -328,8 +319,6 @@ static void __devexit k8temp_remove(struct pci_dev *pdev) | |||
328 | device_remove_file(&pdev->dev, | 319 | device_remove_file(&pdev->dev, |
329 | &sensor_dev_attr_temp4_input.dev_attr); | 320 | &sensor_dev_attr_temp4_input.dev_attr); |
330 | device_remove_file(&pdev->dev, &dev_attr_name); | 321 | device_remove_file(&pdev->dev, &dev_attr_name); |
331 | pci_set_drvdata(pdev, NULL); | ||
332 | kfree(data); | ||
333 | } | 322 | } |
334 | 323 | ||
335 | static struct pci_driver k8temp_driver = { | 324 | static struct pci_driver k8temp_driver = { |