Commit 1f93cb22 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Vinod Koul

soundwire: amd_init: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240703-soundwire-cleanup-h-v1-3-24fa0dbb948f@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 02611eee
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/cleanup.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -69,7 +70,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) ...@@ -69,7 +70,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
{ {
struct sdw_amd_ctx *ctx; struct sdw_amd_ctx *ctx;
struct acpi_device *adev; struct acpi_device *adev;
struct resource *sdw_res;
struct acp_sdw_pdata sdw_pdata[2]; struct acp_sdw_pdata sdw_pdata[2];
struct platform_device_info pdevinfo[2]; struct platform_device_info pdevinfo[2];
u32 link_mask; u32 link_mask;
...@@ -104,7 +104,8 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) ...@@ -104,7 +104,8 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
ctx->count = count; ctx->count = count;
ctx->link_mask = res->link_mask; ctx->link_mask = res->link_mask;
sdw_res = kzalloc(sizeof(*sdw_res), GFP_KERNEL); struct resource *sdw_res __free(kfree) = kzalloc(sizeof(*sdw_res),
GFP_KERNEL);
if (!sdw_res) { if (!sdw_res) {
kfree(ctx); kfree(ctx);
return NULL; return NULL;
...@@ -132,7 +133,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) ...@@ -132,7 +133,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
if (IS_ERR(ctx->pdev[index])) if (IS_ERR(ctx->pdev[index]))
goto err; goto err;
} }
kfree(sdw_res);
return ctx; return ctx;
err: err:
while (index--) { while (index--) {
...@@ -142,7 +142,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) ...@@ -142,7 +142,6 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
platform_device_unregister(ctx->pdev[index]); platform_device_unregister(ctx->pdev[index]);
} }
kfree(sdw_res);
kfree(ctx); kfree(ctx);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment