mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Maxwell Doose <m32285159@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Tomasz Duszynski" <tomasz.duszynski@octakon.com>,
	"open list:IIO SUBSYSTEM AND DRIVERS" <linux-iio@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: chemical: scd30: Use devm_mutex_init() over non-devm mutex_init()
Date: Thu, 4 Jun 2026 10:43:26 +0300	[thread overview]
Message-ID: <aiEsnl1cwLRXrUq8@ashevche-desk.local> (raw)
In-Reply-To: <CAKqfh0G4xDUh7ZR=f760yOAqYqjSLhWGw4UP8KiRM=nnZhg6BQ@mail.gmail.com>

On Wed, Jun 03, 2026 at 12:27:18PM -0500, Maxwell Doose wrote:
> On Wed, Jun 3, 2026 at 11:44 AM Jonathan Cameron <jic23@kernel.org> wrote:
> > On Wed,  3 Jun 2026 09:51:33 -0500
> > Maxwell Doose <m32285159@gmail.com> wrote:

...

> > > +     ret = devm_mutex_init(dev, &state->lock);
> > > +     if (ret)
> > > +             return dev_err_probe(dev, ret, "Failed to init mutex\n");
> > The only thing it can return is -ENOMEM I think. Which doesn't print anything
> > so
> >         if (ret)
> >                 return ret;
> >
> > is enough.
> 
> If I'm not wrong (and after a quick google search), I think it also
> may return -EINVAL but then that means the device struct is invalid.

What?!

> Still may be worth doing dev_err_probe(dev, ret, "Failed to init mutex
> with error %d", ret); or something along those lines. If you want I
> can get this out today or I can also wait for more reviewer feedback,
> but your recommended changes seem pretty simple. TBH though I'd still
> argue for the case of either dev_err_probe() or dev_warn() since not
> having an initialized mutex is certainly an error.

I am on the side of dropping the message altogether. Invalid dev here is
nonsense. Just read the code.


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-06-04  7:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 14:51 Maxwell Doose
2026-06-03 16:44 ` Jonathan Cameron
2026-06-03 17:27   ` Maxwell Doose
2026-06-04  7:43     ` Andy Shevchenko [this message]
2026-06-04 13:20       ` Maxwell Doose
2026-06-04 20:54         ` Andy Shevchenko

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=aiEsnl1cwLRXrUq8@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m32285159@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=tomasz.duszynski@octakon.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®