diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 16:12:58 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:33 -0400 |
commit | 505dc0cc7e99279d60f5c3508018682beee22d65 (patch) | |
tree | d43e9f5ff888833896c834aa95b70d678e740358 /drivers/hwmon/via-cputemp.c | |
parent | b25df2bfbe2e7faddbb4f517e39de0323eef3ec7 (diff) |
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>
Diffstat (limited to 'drivers/hwmon/via-cputemp.c')
-rw-r--r-- | drivers/hwmon/via-cputemp.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c index 2e56c6ce9fb6..4cddee04f2e6 100644 --- a/drivers/hwmon/via-cputemp.c +++ b/drivers/hwmon/via-cputemp.c | |||
@@ -128,12 +128,10 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev) | |||
128 | int err; | 128 | int err; |
129 | u32 eax, edx; | 129 | u32 eax, edx; |
130 | 130 | ||
131 | data = kzalloc(sizeof(struct via_cputemp_data), GFP_KERNEL); | 131 | data = devm_kzalloc(&pdev->dev, sizeof(struct via_cputemp_data), |
132 | if (!data) { | 132 | GFP_KERNEL); |
133 | err = -ENOMEM; | 133 | if (!data) |
134 | dev_err(&pdev->dev, "Out of memory\n"); | 134 | return -ENOMEM; |
135 | goto exit; | ||
136 | } | ||
137 | 135 | ||
138 | data->id = pdev->id; | 136 | data->id = pdev->id; |
139 | data->name = "via_cputemp"; | 137 | data->name = "via_cputemp"; |
@@ -151,8 +149,7 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev) | |||
151 | data->msr_temp = 0x1423; | 149 | data->msr_temp = 0x1423; |
152 | break; | 150 | break; |
153 | default: | 151 | default: |
154 | err = -ENODEV; | 152 | return -ENODEV; |
155 | goto exit_free; | ||
156 | } | 153 | } |
157 | 154 | ||
158 | /* test if we can access the TEMPERATURE MSR */ | 155 | /* test if we can access the TEMPERATURE MSR */ |
@@ -160,14 +157,14 @@ static int __devinit via_cputemp_probe(struct platform_device *pdev) | |||
160 | if (err) { | 157 | if (err) { |
161 | dev_err(&pdev->dev, | 158 | dev_err(&pdev->dev, |
162 | "Unable to access TEMPERATURE MSR, giving up\n"); | 159 | "Unable to access TEMPERATURE MSR, giving up\n"); |
163 | goto exit_free; | 160 | return err; |
164 | } | 161 | } |
165 | 162 | ||
166 | platform_set_drvdata(pdev, data); | 163 | platform_set_drvdata(pdev, data); |
167 | 164 | ||
168 | err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group); | 165 | err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group); |
169 | if (err) | 166 | if (err) |
170 | goto exit_free; | 167 | return err; |
171 | 168 | ||
172 | if (data->msr_vid) | 169 | if (data->msr_vid) |
173 | data->vrm = vid_which_vrm(); | 170 | data->vrm = vid_which_vrm(); |
@@ -192,10 +189,6 @@ exit_remove: | |||
192 | if (data->vrm) | 189 | if (data->vrm) |
193 | device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); | 190 | device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); |
194 | sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); | 191 | sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); |
195 | exit_free: | ||
196 | platform_set_drvdata(pdev, NULL); | ||
197 | kfree(data); | ||
198 | exit: | ||
199 | return err; | 192 | return err; |
200 | } | 193 | } |
201 | 194 | ||
@@ -207,8 +200,6 @@ static int __devexit via_cputemp_remove(struct platform_device *pdev) | |||
207 | if (data->vrm) | 200 | if (data->vrm) |
208 | device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); | 201 | device_remove_file(&pdev->dev, &dev_attr_cpu0_vid); |
209 | sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); | 202 | sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group); |
210 | platform_set_drvdata(pdev, NULL); | ||
211 | kfree(data); | ||
212 | return 0; | 203 | return 0; |
213 | } | 204 | } |
214 | 205 | ||