From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Conor Dooley" <conor+dt@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Lee Jones" <lee@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Rob Herring" <robh@kernel.org>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Haibo Chen" <haibo.chen@nxp.com>
Subject: Re: [PATCH v2 3/4] gpio: adp5585: Add Analog Devices ADP5585 support
Date: Wed, 29 May 2024 09:16:43 +0300 [thread overview]
Message-ID: <CAHp75Vc2-jOMybL7vwJHgrvb_434p094tgdLo1SyK4i_RXYiDw@mail.gmail.com> (raw)
In-Reply-To: <20240528202044.GB8500@pendragon.ideasonboard.com>
On Tue, May 28, 2024 at 11:20 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Tue, May 28, 2024 at 10:36:06PM +0300, Andy Shevchenko wrote:
...
> > > + bit = off * 2 + (off > 5 ? 4 : 0);
> >
> > Right, but can you use >= 6 here which immediately follows to the next
> > question, i.e. why not use bank in this conditional?
>
> The ADP5585_BANK() macro is meant to be used with ADP5585_BIT(), for a
> set of registers with the same layout. Here the layout is different, the
> registers contain multi-bit fields. I can't use ADP5585_BIT(), so I'd
> rather not use ADP5585_BANK() either. I have decided to use > 5 instead
> of >= 6 to match the R5 field name in the comment above:
>
> /*
> * The bias configuration fields are 2 bits wide and laid down in
> * consecutive registers ADP5585_RPULL_CONFIG_*, with a hole of 4 bits
> * after R5.
> */
First of all, the 5 sounds misleading as one needs to think about "how
many are exactly per the register" and the answer AFAIU is 6. >= 6
shows this. Second, I haven't mentioned _BANK(), what I meant is
something to
unsigned int bank = ... >= 6 ? : ;
...
> > > + struct adp5585_dev *adp5585 = dev_get_drvdata(pdev->dev.parent);
> >
> > (see below)
> >
> > > + struct adp5585_gpio_dev *adp5585_gpio;
> > > + struct device *dev = &pdev->dev;
> >
> > struct adp5585_dev *adp5585 = dev_get_drvdata(dev->parent);
>
> I prefer keeping the current ordering, with long lines first, I think
> that's more readable.
Does the compiler optimise these two?
> > > + struct gpio_chip *gc;
> > > + int ret;
...
> > > + device_set_of_node_from_dev(dev, dev->parent);
> >
> > Why not device_set_node()?
>
> Because device_set_of_node_from_dev() is meant for this exact use case,
> where the same node is used for multiple devices. It also puts any
> previous dev->of_node, ensuring proper refcounting when devices are
> unbound and rebound, without being deleted.
When will the refcount be dropped (in case of removal of this device)?
Or you mean it shouldn't?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-05-29 6:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 19:03 [PATCH v2 0/4] ADP5585 GPIO expander, PWM and keypad controller support Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 1/4] dt-bindings: Add bindings for the Analog Devices ADP5585 Laurent Pinchart
2024-05-28 20:41 ` Rob Herring (Arm)
2024-05-28 20:49 ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 2/4] mfd: adp5585: Add Analog Devices ADP5585 core support Laurent Pinchart
2024-05-28 19:27 ` Andy Shevchenko
2024-05-28 20:13 ` Laurent Pinchart
2024-05-29 5:44 ` Andy Shevchenko
2024-05-29 9:35 ` Laurent Pinchart
2024-05-29 13:38 ` Andy Shevchenko
2024-05-28 19:03 ` [PATCH v2 3/4] gpio: adp5585: Add Analog Devices ADP5585 support Laurent Pinchart
2024-05-28 19:36 ` Andy Shevchenko
2024-05-28 20:20 ` Laurent Pinchart
2024-05-28 20:22 ` Laurent Pinchart
2024-05-28 20:23 ` Laurent Pinchart
2024-05-29 6:16 ` Andy Shevchenko [this message]
2024-05-29 9:47 ` Laurent Pinchart
2024-05-29 14:24 ` Andy Shevchenko
2024-05-29 14:35 ` Laurent Pinchart
2024-05-29 15:00 ` Andy Shevchenko
2024-05-29 15:17 ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 4/4] pwm: " Laurent Pinchart
2024-05-28 19:41 ` Andy Shevchenko
2024-05-28 20:27 ` Laurent Pinchart
2024-05-29 6:22 ` 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=CAHp75Vc2-jOMybL7vwJHgrvb_434p094tgdLo1SyK4i_RXYiDw@mail.gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=haibo.chen@nxp.com \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ukleinek@kernel.org \
/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).