Skip to contentSkip to conversation

iio: adc: ti-ads131m02: Drop redundant NULL check on devm_clk_get_enabled()

PATCH Applied Krzysztof Kozlowski 6 participants 12 messages Jul 5 – Jul 6

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

PATCH 1/2 iio: adc: ti-ads131m02: Drop redundant NULL check on devm_clk_get_enabled()

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

---
 drivers/iio/adc/ti-ads131m02.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/ti-ads131m02.c +2 -8
index 2f8f75c8216b..27c8abff216b 100644
@@ -848,14 +848,8 @@ static int ads131m_parse_clock(struct ads131m_priv *priv, bool *is_xtal)
 	int ret;
 
 	clk = devm_clk_get_enabled(dev, NULL);
-	if (IS_ERR_OR_NULL(clk)) {
-		if (IS_ERR(clk))
-			ret = PTR_ERR(clk);
-		else
-			ret = -ENODEV;
-
-		return dev_err_probe(dev, ret, "clk get enabled failed\n");
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "clk get enabled failed\n");
 
 	ret = device_property_match_string(dev, "clock-names", "xtal");
 	if (ret > 0)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 2/2 iio: adc: ade9000: Drop incorrect kerneldoc marker

Top-level comment is not a kerneldoc, so drop marker to fix W=1 warning:

drivers/iio/adc/ade9000.c:2 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

---
 drivers/iio/adc/ade9000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ade9000.c +1 -1
index b80cdd8ad982..c6c3ea953fea 100644
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * ADE9000 driver
  *
  * Copyright 2025 Analog Devices Inc.
Signature · 1 line
2.53.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] iio: adc: ade9000: Drop incorrect kerneldoc marker

Quoted 7 lines · Krzysztof Kozlowski

Top-level comment is not a kerneldoc, so drop marker to fix W=1 warning:

drivers/iio/adc/ade9000.c:2 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

---

Signature · 3 lines
Kind regards

CJD
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] iio: adc: ade9000: Drop incorrect kerneldoc marker

In reply to Krzysztof Kozlowski
Quoted 9 lines · CDT Krzysztof Kozlowski

Top-level comment is not a kerneldoc, so drop marker to fix W=1 warning:

drivers/iio/adc/ade9000.c:2 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

---
 drivers/iio/adc/ade9000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
best regards,
max
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] iio: adc: ade9000: Drop incorrect kerneldoc marker

Quoted 7 lines · On Sun, 05 Jul 2026 12:50:28 -0500 "Maxwell Doose" <[email protected]> wrote:
Quoted 4 lines · CDT Krzysztof Kozlowski

Top-level comment is not a kerneldoc, so drop marker to fix W=1 warning:

drivers/iio/adc/ade9000.c:2 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

Quoted 8 lines
Quoted 5 lines
---
 drivers/iio/adc/ade9000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied.

maintainer
#6 lore raw
In reply to Krzysztof Kozlowski
Quoted 4 lines · On Sun, 5 Jul 2026 19:24:39 +0200 Krzysztof Kozlowski…

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

See the stub.

static inline struct clk *devm_clk_get_enabled(struct device *dev,
const char *id)

{
	return NULL;
}

Not sure what the reasoning behind that is. Maybe that clock could be already on?

We could I guess make this driver depend on one of the clk related configs, but today it doesn't. So to me this NULL check smells of protection we don't need so I think the change is fine, but the patch description should reflect that stub and it being considered reasonable to plough on regardless.

Jonathan

Quoted 25 lines
---
 drivers/iio/adc/ti-ads131m02.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/ti-ads131m02.c +2 -8
index 2f8f75c8216b..27c8abff216b 100644
@@ -848,14 +848,8 @@ static int ads131m_parse_clock(struct ads131m_priv *priv, bool *is_xtal)
 	int ret;
 
 	clk = devm_clk_get_enabled(dev, NULL);
-	if (IS_ERR_OR_NULL(clk)) {
-		if (IS_ERR(clk))
-			ret = PTR_ERR(clk);
-		else
-			ret = -ENODEV;
-
-		return dev_err_probe(dev, ret, "clk get enabled failed\n");
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "clk get enabled failed\n");
 
 	ret = device_property_match_string(dev, "clock-names", "xtal");
 	if (ret > 0)
#7 lore raw
Quoted 14 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 5 Jul 2026 19:24:39 +0200 Krzysztof Kozlowski…

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

See the stub.

static inline struct clk *devm_clk_get_enabled(struct device *dev,
const char *id)

{
	return NULL;
}
Quoted 8 lines

Not sure what the reasoning behind that is. Maybe that clock could be already on?

We could I guess make this driver depend on one of the clk related configs, but today it doesn't. So to me this NULL check smells of protection we don't need so I think the change is fine, but the patch description should reflect that stub and it being considered reasonable to plough on regardless.

Oh, I missed the stub. Stub is wrong and should be fixed (and then this patch makes more sense).

Best regards,
Krzysztof

#8 lore raw
In reply to Jonathan Cameron
Quoted 14 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 5 Jul 2026 19:24:39 +0200 Krzysztof Kozlowski…

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

See the stub.

static inline struct clk *devm_clk_get_enabled(struct device *dev,
const char *id)

{
	return NULL;
}
Quoted 8 lines

Not sure what the reasoning behind that is. Maybe that clock could be already on?

We could I guess make this driver depend on one of the clk related configs, but today it doesn't. So to me this NULL check smells of protection we don't need so I think the change is fine, but the patch description should reflect that stub and it being considered reasonable to plough on regardless.

Ah, good catch! I have thought for a moment about this possibility, but I gave tag anyway as the stub thingy should be addressed separately anyway as there are many drivers (I think) that do not check for NULL.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw
Quoted 24 lines · Andy Shevchenko
Quoted 14 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 5 Jul 2026 19:24:39 +0200 Krzysztof Kozlowski…

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

See the stub.

static inline struct clk *devm_clk_get_enabled(struct device *dev,
const char *id)

{
	return NULL;
}
Quoted 8 lines

Not sure what the reasoning behind that is. Maybe that clock could be already on?

We could I guess make this driver depend on one of the clk related configs, but today it doesn't. So to me this NULL check smells of protection we don't need so I think the change is fine, but the patch description should reflect that stub and it being considered reasonable to plough on regardless.

Quoted 3 lines

Ah, good catch! I have thought for a moment about this possibility, but I gave tag anyway as the stub thingy should be addressed separately anyway as there are many drivers (I think) that do not check for NULL.

Except these ~8 cases I found (I sent a bunch of patches), no one checks for NULL...

Best regards,
Krzysztof

#10 lore raw
Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Andy Shevchenko
Quoted 22 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 5 Jul 2026 19:24:39 +0200 Krzysztof Kozlowski…

devm_clk_get_enabled() does not return NULL (only valid clock or ERR pointer), so simplify the code to drop redundant IS_ERR_OR_NULL().

See the stub.

static inline struct clk *devm_clk_get_enabled(struct device *dev,
const char *id)

{
     return NULL;
}

Not sure what the reasoning behind that is. Maybe that clock could be already on?

We could I guess make this driver depend on one of the clk related configs, but today it doesn't. So to me this NULL check smells of protection we don't need so I think the change is fine, but the patch description should reflect that stub and it being considered reasonable to plough on regardless.

Quoted 6 lines
Quoted 3 lines

Ah, good catch! I have thought for a moment about this possibility, but I gave tag anyway as the stub thingy should be addressed separately anyway as there are many drivers (I think) that do not check for NULL.

Except these ~8 cases I found (I sent a bunch of patches), no one checks for NULL...

Thanks for confirming. So, I think this patch is good to go (maybe with the updated commit message), but the stub perhaps should also be addressed at some point somehow.

Signature · 2 lines
With Best Regards,
Andy Shevchenko