37cb927b10022099f6ee520aed81963f906ec29a
[openwrt/staging/neocturne.git] /
1 From 912517345b867a69542dc9f5c2cc3e9d8beaccf5 Mon Sep 17 00:00:00 2001
2 From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
3 Date: Sun, 11 Jun 2023 15:03:16 +0100
4 Subject: [PATCH] nvmem: rockchip-otp: Improve probe error handling
5
6 Enhance error handling in the probe function by making use of
7 dev_err_probe(), which ensures the error code is always printed, in
8 addition to the specified error message.
9
10 Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
11 Tested-by: Vincent Legoll <vincent.legoll@gmail.com>
12 Reviewed-by: Heiko Stuebner <heiko@sntech.de>
13 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
14 Message-ID: <20230611140330.154222-13-srinivas.kandagatla@linaro.org>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 ---
17 drivers/nvmem/rockchip-otp.c | 21 ++++++++++++---------
18 1 file changed, 12 insertions(+), 9 deletions(-)
19
20 --- a/drivers/nvmem/rockchip-otp.c
21 +++ b/drivers/nvmem/rockchip-otp.c
22 @@ -235,10 +235,8 @@ static int rockchip_otp_probe(struct pla
23 int ret, i;
24
25 data = of_device_get_match_data(dev);
26 - if (!data) {
27 - dev_err(dev, "failed to get match data\n");
28 - return -EINVAL;
29 - }
30 + if (!data)
31 + return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
32
33 otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
34 GFP_KERNEL);
35 @@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct pla
36 otp->dev = dev;
37 otp->base = devm_platform_ioremap_resource(pdev, 0);
38 if (IS_ERR(otp->base))
39 - return PTR_ERR(otp->base);
40 + return dev_err_probe(dev, PTR_ERR(otp->base),
41 + "failed to ioremap resource\n");
42
43 otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
44 GFP_KERNEL);
45 @@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct pla
46
47 ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks);
48 if (ret)
49 - return ret;
50 + return dev_err_probe(dev, ret, "failed to get clocks\n");
51
52 otp->rst = devm_reset_control_array_get_exclusive(dev);
53 if (IS_ERR(otp->rst))
54 - return PTR_ERR(otp->rst);
55 + return dev_err_probe(dev, PTR_ERR(otp->rst),
56 + "failed to get resets\n");
57
58 otp_config.size = data->size;
59 otp_config.priv = otp;
60 otp_config.dev = dev;
61 - nvmem = devm_nvmem_register(dev, &otp_config);
62
63 - return PTR_ERR_OR_ZERO(nvmem);
64 + nvmem = devm_nvmem_register(dev, &otp_config);
65 + if (IS_ERR(nvmem))
66 + return dev_err_probe(dev, PTR_ERR(nvmem),
67 + "failed to register nvmem device\n");
68 + return 0;
69 }
70
71 static struct platform_driver rockchip_otp_driver = {