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
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.
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>
17 drivers/nvmem/rockchip-otp.c | 21 ++++++++++++---------
18 1 file changed, 12 insertions(+), 9 deletions(-)
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
25 data = of_device_get_match_data(dev);
27 - dev_err(dev, "failed to get match data\n");
31 + return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
33 otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
35 @@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct pla
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");
43 otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
45 @@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct pla
47 ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks);
50 + return dev_err_probe(dev, ret, "failed to get clocks\n");
52 otp->rst = devm_reset_control_array_get_exclusive(dev);
54 - return PTR_ERR(otp->rst);
55 + return dev_err_probe(dev, PTR_ERR(otp->rst),
56 + "failed to get resets\n");
58 otp_config.size = data->size;
59 otp_config.priv = otp;
61 - nvmem = devm_nvmem_register(dev, &otp_config);
63 - return PTR_ERR_OR_ZERO(nvmem);
64 + nvmem = devm_nvmem_register(dev, &otp_config);
66 + return dev_err_probe(dev, PTR_ERR(nvmem),
67 + "failed to register nvmem device\n");
71 static struct platform_driver rockchip_otp_driver = {