devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
	Rahul Tanwar <rahul.tanwar@linux.intel.com>,
	linux-pwm@vger.kernel.org, lee.jones@linaro.org,
	p.zabel@pengutronix.de, robh+dt@kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	songjun.Wu@intel.com, cheol.yong.kim@intel.com,
	qi-ming.wu@intel.com, rahul.tanwar.linux@gmail.com,
	rtanwar@maxlinear.com
Subject: Re: [PATCH v13 2/2] Add PWM fan controller driver for LGM SoC
Date: Mon, 28 Sep 2020 08:45:17 +0200	[thread overview]
Message-ID: <20200928064517.GA2837573@ulmo> (raw)
In-Reply-To: <20200924141659.4wov7w2l2bllpre4@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 3792 bytes --]

On Thu, Sep 24, 2020 at 04:16:59PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 24, 2020 at 04:23:34PM +0300, Andy Shevchenko wrote:
> > On Thu, Sep 24, 2020 at 08:55:34AM +0200, Uwe Kleine-König wrote:
> > > On Tue, Sep 15, 2020 at 04:23:37PM +0800, Rahul Tanwar wrote:
> > 
> > ...
> > 
> > > > +	ret = lgm_clk_enable(dev, pc);
> > > > +	if (ret) {
> > > > +		dev_err(dev, "failed to enable clock\n");
> > > 
> > > You used dev_err_probe four times for six error paths. I wonder why you
> > > didn't use it here (and below for a failing pwmchip_add()).
> > 
> > dev_err_probe() makes sense when we might experience deferred probe. In neither
> > of mentioned function this can be the case.
> > 
> > > > +		return ret;
> > > > +	}
> > 
> > ...
> > 
> > > > +	ret = lgm_reset_control_deassert(dev, pc);
> > > > +	if (ret)
> > > > +		return dev_err_probe(dev, ret, "cannot deassert reset control\n");
> > > 
> > > After lgm_reset_control_deassert is called pc->rst is unused. So there
> > > is no need to have this member in struct lgm_pwm_chip. The same applies
> > > to ->clk. (You have to pass rst (or clk) to devm_add_action_or_reset for
> > > that to work. Looks like a nice idea anyhow.)
> > 
> > True. And above dev_err_probe() is not needed.
> 
> You argue that dev_err_probe() gives no benefit as
> lgm_reset_control_deassert won't return -EPROBE_DEFER, right?
> 
> Still I consider it a useful function because
> 
>  a) I (as an author or as a reviewer) don't need to think if the
>     failing function might return -EPROBE_DEFER now or in the future.
>     dev_err_probe does the right thing even for functions that don't
>     return -EPROBE_DEFER.
> 
>  b) With dev_err_probe() I can accomplish things in a single line that
>     need two lines when open coding it.
> 
>  c) dev_err_probe() emits the symbolic error name without having to
>     resort to %pe + ERR_PTR.
> 
>  d) Using dev_err_probe() for all error paths gives a consistency that I
>     like with a maintainer's hat on.

That would perhaps be true if all error paths did use dev_err_probe().
And even if that were the case, dev_err_probe() doesn't guarantee that
error messages will actually be consistent because developers can still
provide whatever format string they like.

Also, the format of the messages that dev_err_probe() prints is unlike
anything that I've seen, so introducing dev_err_probe() actually makes
things more inconsistent, in my opinion.

I have in fact been advocating for people to use error messages of the
form:

	"failed to ...: %d\n", err

or:

	"unable to ...: %d\n", err

Or some other similar form because that's the most common type that I
have come across in the kernel. I think it's also easier to read those
error messages because they contain the important data (i.e. the
description, which tells you what went wrong) first and then are
followed by the error code (which tells you how it failed).

Now I suspect the current format was chosen because we need to have the
constant part first, because otherwise the arbitrary format string could
be something that doesn't lend itself to have an error code appended.

The current format is arguably also something that's easier to parse
from some script because the format is in a somewhat standard format. On
the other hand, I think this is a bit misguided because we already have
structured log messages, so I wonder if it might have been better to
make the error code part of structured log messages to make them truly
machine readable but leave the formatting up to developers so that they
can use whatever is consistent within the driver or whatever fits best
without actually adding a standard string to the log messages.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-09-28  6:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1600158087.git.rahul.tanwar@linux.intel.com>
2020-09-15  8:23 ` [PATCH v13 1/2] Add DT bindings YAML schema for PWM fan controller of LGM SoC Rahul Tanwar
2020-09-15  8:23 ` [PATCH v13 2/2] Add PWM fan controller driver for " Rahul Tanwar
2020-09-24  6:55   ` Uwe Kleine-König
2020-09-24  7:12     ` Thierry Reding
2020-09-24  7:38       ` Tanwar, Rahul
2020-09-24 13:23     ` Andy Shevchenko
2020-09-24 14:16       ` Uwe Kleine-König
2020-09-25  8:39         ` Andy Shevchenko
2020-09-28  6:45         ` Thierry Reding [this message]
2020-09-25  8:49     ` Tanwar, Rahul
2020-09-23 11:49 ` [PATCH v13 0/2] pwm: intel: Add PWM driver for a new SoC Thierry Reding

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=20200928064517.GA2837573@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=cheol.yong.kim@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=qi-ming.wu@intel.com \
    --cc=rahul.tanwar.linux@gmail.com \
    --cc=rahul.tanwar@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=rtanwar@maxlinear.com \
    --cc=songjun.Wu@intel.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).