From: Philipp Zabel <p.zabel@pengutronix.de>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
Val Packett <val@packett.cool>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH] reset: gpio: add a devlink between reset-gpio and its consumer
Date: Wed, 26 Nov 2025 11:38:11 +0100 [thread overview]
Message-ID: <ac9132249e594001801c2bbbc4245ff2e40c7a62.camel@pengutronix.de> (raw)
In-Reply-To: <CAMRc=Mf7CMeZSUJLnteC9Xk5WvG_EKn3vx+jzcWNaWAvpvT00Q@mail.gmail.com>
On Mi, 2025-11-26 at 09:56 +0100, Bartosz Golaszewski wrote:
[...]
> > > -static int reset_add_gpio_aux_device(struct device *parent,
> > > - struct fwnode_handle *swnode,
> > > - int id, void *pdata)
> > > +static struct auxiliary_device *
> > > +reset_add_gpio_aux_device(struct device *parent, struct fwnode_handle *swnode,
> > > + int id, void *pdata)
> >
> > This function grows ever more similar to auxiliary_device_create().
> >
>
> I could have used it if not for the fact that it calls
> device_set_of_node_from_dev() and we don't want it.
>
> > s/add/create/?
>
> I don't mind but would prefer to not overload this patch.
Ok.
[...]
> > > + consumer = get_dev_from_fwnode(of_fwnode_handle(np));
> >
> > If called via __reset_control_get(), this just reconstructs the device
> > from dev->of_node. I think it would be better to move the linking into
> > __reset_control_get() and use the passed in consumer device directly.
> >
>
> That would affect all users, do we want this? In most cases they will
> already have a link with different flags. I don't think this is
> correct.
Right. We could also pass an optional dev into __of_reset_control_get()
and then just go
if (gpio_fallback)
device_link_add(dev, rcdev->dev, DL_FLAG_STATELESS);
at the end.
> > > + if (consumer) {
> > > + if (!device_link_add(consumer, &rgpio_dev->adev->dev, DL_FLAG_STATELESS))
> >
> > Who removes this link when the consumer puts the reset control, or if
> > we error out later?
> >
>
> Nobody. Here's why: the reset-gpio device never gets removed. If we're
> here, this means it's already registered. If the consumer is unbound,
> the devlink stays in place. When we rebind, device_link_add() will do
> nothing. If the consumer device is released, we purge all links
> anyway. Let me know if I'm wrong, but seems to me, it's fine to leave
> it and make it stateless.
I think you are right. Still, the device_link_add() documentation says
that the caller is expected to call device_link_del/remove() and we
don't, so warrants a comment.
regards
Philipp
next prev parent reply other threads:[~2025-11-26 10:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 12:55 Bartosz Golaszewski
2025-11-25 14:33 ` Philipp Zabel
2025-11-26 8:56 ` Bartosz Golaszewski
2025-11-26 10:38 ` Philipp Zabel [this message]
2025-11-26 11:05 ` Bartosz Golaszewski
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=ac9132249e594001801c2bbbc4245ff2e40c7a62.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=val@packett.cool \
/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®