Skip to contentSkip to conversation

spmi: pmic-arb: Replace three IS_ERR() calls by null pointer checks in spmi_pmic_arb_probe()

PATCH Applied Markus Elfring 5 participants 5 messages Feb 4, 2024 – Apr 8, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spmi: pmic-arb: Replace three IS_ERR() calls by null pointer checks in spmi_pmic_arb_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 09:39:48 +0100

The devm_ioremap() function does not return error pointers. It returns NULL on error.
This issue was detected once more also by using the Coccinelle software.

Update three checks (and corresponding error codes) for failed function calls accordingly.

Fixes ffdfbafdc4f4 ("spmi: Use devm_spmi_controller_alloc()")
Fixes 231601cd22bd ("spmi: pmic-arb: Add support for PMIC v7")

---

See also:
Suggestion by Peng Wu
[PATCH -next] spmi: pmic-arb: fix a NULL vs IS_ERR() check in spmi_pmic_arb_probe()
https://lore.kernel.org/lkml/[email protected]/
https://lkml.org/lkml/2022/11/15/197

 drivers/spmi/spmi-pmic-arb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spmi/spmi-pmic-arb.c +6 -6
index 9ed1180fe31f..937c15324513 100644
@@ -1462,8 +1462,8 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
 	 */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
 	core = devm_ioremap(&ctrl->dev, res->start, resource_size(res));
-	if (IS_ERR(core))
-		return PTR_ERR(core);
+	if (!core)
+		return -ENOMEM;
 
 	pmic_arb->core_size = resource_size(res);
 
@@ -1495,15 +1495,15 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
 						   "obsrvr");
 		pmic_arb->rd_base = devm_ioremap(&ctrl->dev, res->start,
 						 resource_size(res));
-		if (IS_ERR(pmic_arb->rd_base))
-			return PTR_ERR(pmic_arb->rd_base);
+		if (!pmic_arb->rd_base)
+			return -ENOMEM;
 
 		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 						   "chnls");
 		pmic_arb->wr_base = devm_ioremap(&ctrl->dev, res->start,
 						 resource_size(res));
-		if (IS_ERR(pmic_arb->wr_base))
-			return PTR_ERR(pmic_arb->wr_base);
+		if (!pmic_arb->wr_base)
+			return -ENOMEM;
 	}
 
 	pmic_arb->max_periphs = PMIC_ARB_MAX_PERIPHS;

--
2.43.0

Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 09:39:48 +0100

The devm_ioremap() function does not return error pointers. It returns NULL on error.
This issue was detected once more also by using the Coccinelle software.

Update three checks (and corresponding error codes) for failed function calls accordingly.

Fixes ffdfbafdc4f4 ("spmi: Use devm_spmi_controller_alloc()")
Fixes 231601cd22bd ("spmi: pmic-arb: Add support for PMIC v7")
Quoted 8 lines

---

See also:
Suggestion by Peng Wu
[PATCH -next] spmi: pmic-arb: fix a NULL vs IS_ERR() check in spmi_pmic_arb_probe()
https://lore.kernel.org/lkml/[email protected]/
https://lkml.org/lkml/2022/11/15/197

Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/1
#2 lore raw
In reply to Markus Elfring
Quoted 22 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 09:39:48 +0100

The devm_ioremap() function does not return error pointers. It returns NULL on error.
This issue was detected once more also by using the Coccinelle software.

Update three checks (and corresponding error codes) for failed function calls accordingly.

Fixes ffdfbafdc4f4 ("spmi: Use devm_spmi_controller_alloc()")
Fixes 231601cd22bd ("spmi: pmic-arb: Add support for PMIC v7")

---

See also:
Suggestion by Peng Wu
[PATCH -next] spmi: pmic-arb: fix a NULL vs IS_ERR() check in spmi_pmic_arb_probe()
https://lore.kernel.org/lkml/[email protected]/
https://lkml.org/lkml/2022/11/15/197

Quoted 2 lines
 drivers/spmi/spmi-pmic-arb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Thanks for making this fix.

Take care,
David

Reviewed-by on v1 1/1
#3 lore raw
In reply to Markus Elfring

Il 04/02/24 10:24, Markus Elfring ha scritto:

Quoted 7 lines

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 09:39:48 +0100

The devm_ioremap() function does not return error pointers. It returns NULL on error.
This issue was detected once more also by using the Coccinelle software.

Quoted 6 lines

Update three checks (and corresponding error codes) for failed function calls accordingly.

Fixes ffdfbafdc4f4 ("spmi: Use devm_spmi_controller_alloc()")
Fixes 231601cd22bd ("spmi: pmic-arb: Add support for PMIC v7")
maintainer Applied
#4 lore raw
In reply to Markus Elfring

Quoting Markus Elfring (2024-02-04 01:24:18)

Quoted 7 lines

From: Markus Elfring <[email protected]>
Date: Sun, 4 Feb 2024 09:39:48 +0100

The devm_ioremap() function does not return error pointers. It returns NULL on error.
This issue was detected once more also by using the Coccinelle software.

Quoted 7 lines

Update three checks (and corresponding error codes) for failed function calls accordingly.

Fixes ffdfbafdc4f4 ("spmi: Use devm_spmi_controller_alloc()")
Fixes 231601cd22bd ("spmi: pmic-arb: Add support for PMIC v7")

---

Applied to spmi-next