Skip to content

Commit b066a2c

Browse files
krzkandersson
authored andcommitted
soc: qcom: wcnss: simplify with cleanup.h
Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 0ed06fc commit b066a2c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/soc/qcom/wcnss_ctrl.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2016, Linaro Ltd.
44
* Copyright (c) 2015, Sony Mobile Communications Inc.
55
*/
6+
#include <linux/cleanup.h>
67
#include <linux/firmware.h>
78
#include <linux/module.h>
89
#include <linux/slab.h>
@@ -198,26 +199,26 @@ static int wcnss_request_version(struct wcnss_ctrl *wcnss)
198199
*/
199200
static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
200201
{
201-
struct wcnss_download_nv_req *req;
202202
const struct firmware *fw;
203203
struct device *dev = wcnss->dev;
204204
const char *nvbin = NVBIN_FILE;
205205
const void *data;
206206
ssize_t left;
207207
int ret;
208208

209-
req = kzalloc(sizeof(*req) + NV_FRAGMENT_SIZE, GFP_KERNEL);
209+
struct wcnss_download_nv_req *req __free(kfree) = kzalloc(sizeof(*req) + NV_FRAGMENT_SIZE,
210+
GFP_KERNEL);
210211
if (!req)
211212
return -ENOMEM;
212213

213214
ret = of_property_read_string(dev->of_node, "firmware-name", &nvbin);
214215
if (ret < 0 && ret != -EINVAL)
215-
goto free_req;
216+
return ret;
216217

217218
ret = request_firmware(&fw, nvbin, dev);
218219
if (ret < 0) {
219220
dev_err(dev, "Failed to load nv file %s: %d\n", nvbin, ret);
220-
goto free_req;
221+
return ret;
221222
}
222223

223224
data = fw->data;
@@ -263,8 +264,6 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
263264

264265
release_fw:
265266
release_firmware(fw);
266-
free_req:
267-
kfree(req);
268267

269268
return ret;
270269
}

0 commit comments

Comments
 (0)