All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Finley Xiao <finley.xiao@rock-chips.com>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com
Subject: [PATCH 6/8] nvmem: rockchip-otp: Improve probe error handling
Date: Mon,  1 May 2023 11:43:58 +0300	[thread overview]
Message-ID: <20230501084401.765169-7-cristian.ciocaltea@collabora.com> (raw)
In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com>

Enhance error handling in the probe function by making use of
dev_err_probe(), which ensures the error code is always printed, in
addition to the specified error message.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/nvmem/rockchip-otp.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index b74d98f82ae5..4370d6c5e4e9 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -235,10 +235,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	int ret, i;
 
 	data = of_device_get_match_data(dev);
-	if (!data) {
-		dev_err(dev, "failed to get match data\n");
-		return -EINVAL;
-	}
+	if (!data)
+		return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
 
 	otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
 			   GFP_KERNEL);
@@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	otp->dev = dev;
 	otp->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(otp->base))
-		return PTR_ERR(otp->base);
+		return dev_err_probe(dev, PTR_ERR(otp->base),
+				     "failed to ioremap resource\n");
 
 	otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
 				 GFP_KERNEL);
@@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 
 	ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret, "failed to get clocks\n");
 
 	otp->rst = devm_reset_control_array_get_exclusive(dev);
 	if (IS_ERR(otp->rst))
-		return PTR_ERR(otp->rst);
+		return dev_err_probe(dev, PTR_ERR(otp->rst),
+				     "failed to get resets\n");
 
 	otp_config.size = data->size;
 	otp_config.priv = otp;
 	otp_config.dev = dev;
-	nvmem = devm_nvmem_register(dev, &otp_config);
 
-	return PTR_ERR_OR_ZERO(nvmem);
+	nvmem = devm_nvmem_register(dev, &otp_config);
+	if (IS_ERR(nvmem))
+		return dev_err_probe(dev, PTR_ERR(nvmem),
+				     "failed to register nvmem device\n");
+	return 0;
 }
 
 static struct platform_driver rockchip_otp_driver = {
-- 
2.40.0


WARNING: multiple messages have this Message-ID (diff)
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Finley Xiao <finley.xiao@rock-chips.com>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com
Subject: [PATCH 6/8] nvmem: rockchip-otp: Improve probe error handling
Date: Mon,  1 May 2023 11:43:58 +0300	[thread overview]
Message-ID: <20230501084401.765169-7-cristian.ciocaltea@collabora.com> (raw)
In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com>

Enhance error handling in the probe function by making use of
dev_err_probe(), which ensures the error code is always printed, in
addition to the specified error message.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/nvmem/rockchip-otp.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index b74d98f82ae5..4370d6c5e4e9 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -235,10 +235,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	int ret, i;
 
 	data = of_device_get_match_data(dev);
-	if (!data) {
-		dev_err(dev, "failed to get match data\n");
-		return -EINVAL;
-	}
+	if (!data)
+		return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
 
 	otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
 			   GFP_KERNEL);
@@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	otp->dev = dev;
 	otp->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(otp->base))
-		return PTR_ERR(otp->base);
+		return dev_err_probe(dev, PTR_ERR(otp->base),
+				     "failed to ioremap resource\n");
 
 	otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
 				 GFP_KERNEL);
@@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 
 	ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret, "failed to get clocks\n");
 
 	otp->rst = devm_reset_control_array_get_exclusive(dev);
 	if (IS_ERR(otp->rst))
-		return PTR_ERR(otp->rst);
+		return dev_err_probe(dev, PTR_ERR(otp->rst),
+				     "failed to get resets\n");
 
 	otp_config.size = data->size;
 	otp_config.priv = otp;
 	otp_config.dev = dev;
-	nvmem = devm_nvmem_register(dev, &otp_config);
 
-	return PTR_ERR_OR_ZERO(nvmem);
+	nvmem = devm_nvmem_register(dev, &otp_config);
+	if (IS_ERR(nvmem))
+		return dev_err_probe(dev, PTR_ERR(nvmem),
+				     "failed to register nvmem device\n");
+	return 0;
 }
 
 static struct platform_driver rockchip_otp_driver = {
-- 
2.40.0


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Finley Xiao <finley.xiao@rock-chips.com>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com
Subject: [PATCH 6/8] nvmem: rockchip-otp: Improve probe error handling
Date: Mon,  1 May 2023 11:43:58 +0300	[thread overview]
Message-ID: <20230501084401.765169-7-cristian.ciocaltea@collabora.com> (raw)
In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com>

Enhance error handling in the probe function by making use of
dev_err_probe(), which ensures the error code is always printed, in
addition to the specified error message.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/nvmem/rockchip-otp.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index b74d98f82ae5..4370d6c5e4e9 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -235,10 +235,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	int ret, i;
 
 	data = of_device_get_match_data(dev);
-	if (!data) {
-		dev_err(dev, "failed to get match data\n");
-		return -EINVAL;
-	}
+	if (!data)
+		return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
 
 	otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
 			   GFP_KERNEL);
@@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	otp->dev = dev;
 	otp->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(otp->base))
-		return PTR_ERR(otp->base);
+		return dev_err_probe(dev, PTR_ERR(otp->base),
+				     "failed to ioremap resource\n");
 
 	otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
 				 GFP_KERNEL);
@@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 
 	ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret, "failed to get clocks\n");
 
 	otp->rst = devm_reset_control_array_get_exclusive(dev);
 	if (IS_ERR(otp->rst))
-		return PTR_ERR(otp->rst);
+		return dev_err_probe(dev, PTR_ERR(otp->rst),
+				     "failed to get resets\n");
 
 	otp_config.size = data->size;
 	otp_config.priv = otp;
 	otp_config.dev = dev;
-	nvmem = devm_nvmem_register(dev, &otp_config);
 
-	return PTR_ERR_OR_ZERO(nvmem);
+	nvmem = devm_nvmem_register(dev, &otp_config);
+	if (IS_ERR(nvmem))
+		return dev_err_probe(dev, PTR_ERR(nvmem),
+				     "failed to register nvmem device\n");
+	return 0;
 }
 
 static struct platform_driver rockchip_otp_driver = {
-- 
2.40.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-05-01  8:44 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01  8:43 [PATCH 0/8] Add RK3588 OTP memory support Cristian Ciocaltea
2023-05-01  8:43 ` Cristian Ciocaltea
2023-05-01  8:43 ` Cristian Ciocaltea
2023-05-01  8:43 ` [PATCH 1/8] dt-bindings: nvmem: Convert rockchip-otp.txt to dt-schema Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:38   ` Heiko Stübner
2023-05-02  8:38     ` Heiko Stübner
2023-05-02  8:38     ` Heiko Stübner
2023-05-03  6:27   ` Krzysztof Kozlowski
2023-05-03  6:27     ` Krzysztof Kozlowski
2023-05-03  6:27     ` Krzysztof Kozlowski
2023-05-01  8:43 ` [PATCH 2/8] dt-bindings: nvmem: rockchip-otp: Add compatible for RK3588 Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:42   ` Heiko Stübner
2023-05-02  8:42     ` Heiko Stübner
2023-05-02  8:42     ` Heiko Stübner
2023-05-02 12:46     ` Cristian Ciocaltea
2023-05-02 12:46       ` Cristian Ciocaltea
2023-05-02 12:46       ` Cristian Ciocaltea
2023-05-03  6:28   ` Krzysztof Kozlowski
2023-05-03  6:28     ` Krzysztof Kozlowski
2023-05-03  6:28     ` Krzysztof Kozlowski
2023-05-04 14:14     ` Cristian Ciocaltea
2023-05-04 14:14       ` Cristian Ciocaltea
2023-05-04 14:14       ` Cristian Ciocaltea
2023-05-04 14:39       ` Krzysztof Kozlowski
2023-05-04 14:39         ` Krzysztof Kozlowski
2023-05-04 14:39         ` Krzysztof Kozlowski
2023-05-01  8:43 ` [PATCH 3/8] nvmem: rockchip-otp: Add clocks and reg_read to rockchip_data Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:47   ` Heiko Stübner
2023-05-02  8:47     ` Heiko Stübner
2023-05-02  8:47     ` Heiko Stübner
2023-05-02 12:49     ` Cristian Ciocaltea
2023-05-02 12:49       ` Cristian Ciocaltea
2023-05-02 12:49       ` Cristian Ciocaltea
2023-05-01  8:43 ` [PATCH 4/8] nvmem: rockchip-otp: Generalize rockchip_otp_wait_status() Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:48   ` Heiko Stübner
2023-05-02  8:48     ` Heiko Stübner
2023-05-02  8:48     ` Heiko Stübner
2023-05-01  8:43 ` [PATCH 5/8] nvmem: rockchip-otp: Use devm_reset_control_array_get_exclusive() Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:51   ` Heiko Stübner
2023-05-02  8:51     ` Heiko Stübner
2023-05-02  8:51     ` Heiko Stübner
2023-05-01  8:43 ` Cristian Ciocaltea [this message]
2023-05-01  8:43   ` [PATCH 6/8] nvmem: rockchip-otp: Improve probe error handling Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:52   ` Heiko Stübner
2023-05-02  8:52     ` Heiko Stübner
2023-05-02  8:52     ` Heiko Stübner
2023-05-01  8:43 ` [PATCH 7/8] nvmem: rockchip-otp: Add support for RK3588 Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-01  8:43   ` Cristian Ciocaltea
2023-05-02  8:55   ` Heiko Stübner
2023-05-02  8:55     ` Heiko Stübner
2023-05-02  8:55     ` Heiko Stübner
2023-05-01  8:44 ` [PATCH 8/8] arm64: dts: rockchip: Add rk3588 OTP node Cristian Ciocaltea
2023-05-01  8:44   ` Cristian Ciocaltea
2023-05-01  8:44   ` Cristian Ciocaltea
2023-05-02  8:57   ` Heiko Stübner
2023-05-02  8:57     ` Heiko Stübner
2023-05-02  8:57     ` Heiko Stübner
2023-05-02  8:26 ` [PATCH 0/8] Add RK3588 OTP memory support Vincent Legoll
2023-05-02  8:26   ` Vincent Legoll
2023-05-02  8:26   ` Vincent Legoll
2023-05-02 12:40   ` Cristian Ciocaltea
2023-05-02 12:40     ` Cristian Ciocaltea
2023-05-02 12:40     ` Cristian Ciocaltea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230501084401.765169-7-cristian.ciocaltea@collabora.com \
    --to=cristian.ciocaltea@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=finley.xiao@rock-chips.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=kever.yang@rock-chips.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=shreeya.patel@collabora.com \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.