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>
This commit is contained in:
Guenter Roeck 2012-06-02 12:04:06 -07:00
parent 6e13bb06f6
commit a0d44cbcc0

View File

@ -183,21 +183,17 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
u8 model, stepping; u8 model, stepping;
struct k8temp_data *data; struct k8temp_data *data;
data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(struct k8temp_data), GFP_KERNEL);
if (!data) { if (!data)
err = -ENOMEM; return -ENOMEM;
goto exit;
}
model = boot_cpu_data.x86_model; model = boot_cpu_data.x86_model;
stepping = boot_cpu_data.x86_mask; stepping = boot_cpu_data.x86_mask;
/* feature available since SH-C0, exclude older revisions */ /* feature available since SH-C0, exclude older revisions */
if (((model == 4) && (stepping == 0)) || if ((model == 4 && stepping == 0) ||
((model == 5) && (stepping <= 1))) { (model == 5 && stepping <= 1))
err = -ENODEV; return -ENODEV;
goto exit_free;
}
/* /*
* AMD NPT family 0fh, i.e. RevF and RevG: * AMD NPT family 0fh, i.e. RevF and RevG:
@ -224,8 +220,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
if (scfg & (SEL_PLACE | SEL_CORE)) { if (scfg & (SEL_PLACE | SEL_CORE)) {
dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n");
err = -ENODEV; return -ENODEV;
goto exit_free;
} }
scfg |= (SEL_PLACE | SEL_CORE); scfg |= (SEL_PLACE | SEL_CORE);
@ -307,10 +302,6 @@ exit_remove:
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);
exit_free:
pci_set_drvdata(pdev, NULL);
kfree(data);
exit:
return err; return err;
} }
@ -328,8 +319,6 @@ 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);
pci_set_drvdata(pdev, NULL);
kfree(data);
} }
static struct pci_driver k8temp_driver = { static struct pci_driver k8temp_driver = {