hwmon: (via-cputemp) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
@@ -128,12 +128,10 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
|
|||||||
int err;
|
int err;
|
||||||
u32 eax, edx;
|
u32 eax, edx;
|
||||||
|
|
||||||
data = kzalloc(sizeof(struct via_cputemp_data), GFP_KERNEL);
|
data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data),
|
||||||
if (!data) {
|
GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
if (!data)
|
||||||
dev_err(&pdev->dev, "Out of memory\n");
|
return -ENOMEM;
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->id = pdev->id;
|
data->id = pdev->id;
|
||||||
data->name = "via_cputemp";
|
data->name = "via_cputemp";
|
||||||
@@ -151,8 +149,7 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
|
|||||||
data->msr_temp = 0x1423;
|
data->msr_temp = 0x1423;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err = -ENODEV;
|
return -ENODEV;
|
||||||
goto exit_free;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test if we can access the TEMPERATURE MSR */
|
/* test if we can access the TEMPERATURE MSR */
|
||||||
@@ -160,14 +157,14 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev)
|
|||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"Unable to access TEMPERATURE MSR, giving up\n");
|
"Unable to access TEMPERATURE MSR, giving up\n");
|
||||||
goto exit_free;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, data);
|
platform_set_drvdata(pdev, data);
|
||||||
|
|
||||||
err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group);
|
err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_free;
|
return err;
|
||||||
|
|
||||||
if (data->msr_vid)
|
if (data->msr_vid)
|
||||||
data->vrm = vid_which_vrm();
|
data->vrm = vid_which_vrm();
|
||||||
@@ -192,10 +189,6 @@ exit_remove:
|
|||||||
if (data->vrm)
|
if (data->vrm)
|
||||||
device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
|
device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
|
sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
|
||||||
exit_free:
|
|
||||||
platform_set_drvdata(pdev, NULL);
|
|
||||||
kfree(data);
|
|
||||||
exit:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,8 +200,6 @@ static int __devexit via_cputemp_remove(struct platform_device *pdev)
|
|||||||
if (data->vrm)
|
if (data->vrm)
|
||||||
device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
|
device_remove_file(&pdev->dev, &dev_attr_cpu0_vid);
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
|
sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
|
||||||
platform_set_drvdata(pdev, NULL);
|
|
||||||
kfree(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user