Skip to content

Commit ba35896

Browse files
Wer-Wolfjwrdegoede
authored andcommitted
platform/x86: dell-smbios-wmi: Use devm_get_free_pages()
Use devres version of __get_free_pages() to simplify the error handling code. Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent ed72a2b commit ba35896

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/platform/x86/dell/dell-smbios-wmi.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
88

9+
#include <linux/device.h>
910
#include <linux/dmi.h>
1011
#include <linux/list.h>
1112
#include <linux/module.h>
@@ -183,15 +184,15 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context)
183184
return ret;
184185

185186
count = get_order(priv->req_buf_size);
186-
priv->buf = (void *)__get_free_pages(GFP_KERNEL, count);
187+
priv->buf = (void *)devm_get_free_pages(&wdev->dev, GFP_KERNEL, count);
187188
if (!priv->buf)
188189
return -ENOMEM;
189190

190191
/* ID is used by dell-smbios to set priority of drivers */
191192
wdev->dev.id = 1;
192193
ret = dell_smbios_register_device(&wdev->dev, &dell_smbios_wmi_call);
193194
if (ret)
194-
goto fail_register;
195+
return ret;
195196

196197
priv->wdev = wdev;
197198
dev_set_drvdata(&wdev->dev, priv);
@@ -200,24 +201,17 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context)
200201
mutex_unlock(&list_mutex);
201202

202203
return 0;
203-
204-
fail_register:
205-
free_pages((unsigned long)priv->buf, count);
206-
return ret;
207204
}
208205

209206
static void dell_smbios_wmi_remove(struct wmi_device *wdev)
210207
{
211208
struct wmi_smbios_priv *priv = dev_get_drvdata(&wdev->dev);
212-
int count;
213209

214210
mutex_lock(&call_mutex);
215211
mutex_lock(&list_mutex);
216212
list_del(&priv->list);
217213
mutex_unlock(&list_mutex);
218214
dell_smbios_unregister_device(&wdev->dev);
219-
count = get_order(priv->req_buf_size);
220-
free_pages((unsigned long)priv->buf, count);
221215
mutex_unlock(&call_mutex);
222216
}
223217

0 commit comments

Comments
 (0)