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

From: Jonathan Cameron

Date: Sun Jul 05 2026 - 19:37:41 EST


On Sun, 5 Jul 2026 19:24:39 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx> wrote:

> 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().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
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


> ---
> drivers/iio/adc/ti-ads131m02.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads131m02.c b/drivers/iio/adc/ti-ads131m02.c
> index 2f8f75c8216b..27c8abff216b 100644
> --- a/drivers/iio/adc/ti-ads131m02.c
> +++ b/drivers/iio/adc/ti-ads131m02.c
> @@ -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)