All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jeff LaBundy <jeff@labundy.com>
Cc: "Markus Elfring" <Markus.Elfring@web.de>,
	linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org,
	"Mattijs Korpershoek" <mkorpershoek@baylibre.com>,
	"Rob Herring" <robh@kernel.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"ye xingchen" <ye.xingchen@zte.com.cn>,
	LKML <linux-kernel@vger.kernel.org>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v2] Input: iqs269a - Use scope-based resource management in iqs269_parse_chan()
Date: Mon, 4 Mar 2024 09:13:49 -0800	[thread overview]
Message-ID: <ZeYBTUQRAp2u3bXX@google.com> (raw)
In-Reply-To: <ZeYAk830OUpaup5W@nixie71>

On Mon, Mar 04, 2024 at 11:10:43AM -0600, Jeff LaBundy wrote:
> Hi Markus,
> 
> On Mon, Mar 04, 2024 at 10:55:11AM +0100, Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Mon, 4 Mar 2024 10:30:52 +0100
> > 
> > Scope-based resource management became supported also for this software
> > area by contributions of Jonathan Cameron on 2024-02-17.
> > 
> > device property: Add cleanup.h based fwnode_handle_put() scope based cleanup.
> > https://lore.kernel.org/r/20240217164249.921878-3-jic23@kernel.org
> > 
> > 
> > * Thus use the attribute “__free(fwnode_handle)”.
> > 
> > * Reduce the scope for the local variable “ev_node” into a for loop.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> > 
> > v2:
> > An other cleanup technique was applied as requested by Dmitry Torokhov.
> > 
> > 
> >  drivers/input/misc/iqs269a.c | 73 ++++++++++++++++++------------------
> >  1 file changed, 37 insertions(+), 36 deletions(-)
> > 
> > diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
> > index cd14ff9f57cf..9caee936927b 100644
> > --- a/drivers/input/misc/iqs269a.c
> > +++ b/drivers/input/misc/iqs269a.c
> > @@ -557,7 +557,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
> >  			     const struct fwnode_handle *ch_node)
> >  {
> >  	struct i2c_client *client = iqs269->client;
> > -	struct fwnode_handle *ev_node;
> >  	struct iqs269_ch_reg *ch_reg;
> >  	u16 engine_a, engine_b;
> >  	unsigned int reg, val;
> > @@ -734,47 +733,49 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
> >  	}
> > 
> >  	for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) {
> > -		ev_node = fwnode_get_named_child_node(ch_node,
> > -						      iqs269_events[i].name);
> > -		if (!ev_node)
> > -			continue;
> > -
> > -		if (!fwnode_property_read_u32(ev_node, "azoteq,thresh", &val)) {
> > -			if (val > IQS269_CHx_THRESH_MAX) {
> > -				dev_err(&client->dev,
> > -					"Invalid channel %u threshold: %u\n",
> > -					reg, val);
> > -				fwnode_handle_put(ev_node);
> > -				return -EINVAL;
> > +		{
> > +			struct fwnode_handle *ev_node __free(fwnode_handle)
> > +						      = fwnode_get_named_child_node(ch_node,
> > +										    iqs269_events[i].name);
> > +
> > +			if (!ev_node)
> > +				continue;
> > +
> > +			if (!fwnode_property_read_u32(ev_node, "azoteq,thresh", &val)) {
> > +				if (val > IQS269_CHx_THRESH_MAX) {
> > +					dev_err(&client->dev,
> > +						"Invalid channel %u threshold: %u\n",
> > +						reg, val);
> > +					return -EINVAL;
> > +				}
> > +
> > +				ch_reg->thresh[iqs269_events[i].th_offs] = val;
> 
> I may just be a curmudgeon, but this is another NAK for me. The dummy
> curly braces and extra indentation make the code difficult to understand,
> and this simply does not seem like a natural way to write a driver. Just
> to remove 2-3 calls to fwnode_handle_put()?

The extra curly braces are absolutely not needed. The for loop's body
already defines scope, __cleanup()s should be called at the end of the
body.

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-03-04 17:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02  8:24 [PATCH] Input: iqs269a - Use common error handling code in iqs269_parse_chan() Markus Elfring
2024-03-03 22:31 ` Dmitry Torokhov
2024-03-04  9:55   ` [PATCH v2] Input: iqs269a - Use scope-based resource management " Markus Elfring
2024-03-04 17:10     ` Jeff LaBundy
2024-03-04 17:13       ` Dmitry Torokhov [this message]
2024-03-04 17:48         ` [v2] " Markus Elfring
2024-03-04 18:59           ` Dmitry Torokhov

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=ZeYBTUQRAp2u3bXX@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Markus.Elfring@web.de \
    --cc=jeff@labundy.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkorpershoek@baylibre.com \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ye.xingchen@zte.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.