mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
	patches@opensource.wolfsonmicro.com
Subject: Re: [PATCH] regulator: core: Get and put regulator of_node
Date: Thu, 3 Apr 2014 12:14:31 +0100	[thread overview]
Message-ID: <20140403111431.GU14763@sirena.org.uk> (raw)
In-Reply-To: <20140403105804.GP1665@opensource.wolfsonmicro.com>

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

On Thu, Apr 03, 2014 at 11:58:04AM +0100, Charles Keepax wrote:
> On Wed, Apr 02, 2014 at 05:53:54PM +0100, Mark Brown wrote:

> > To make this correct we need to at least ensure that the node passed
> > into the regulator API is valid and referenced at that time so there
> > should only be an issue for the core if the reference is dropped after
> > that.  In the above case the device model is holding a reference since
> > this is the of_node for the device itself so taking the reference won't
> > hurt but is redundant.  In cases where we have more than one regulator
> > and are using of_regulator_match() then things are more tricky.
> > Something needs to drop the references it returns (which isn't happening
> > at all at the minute).

> From what I can see of_regulator_match isn't taking any
> references at the minute? for_each_child_of_node will get a
> reference but it will also put that when we process the next
> child. We copy the pointer to the child into match->of_node
> but don't manually increment the reference at all. So
> of_regulator_match has no effect on the reference count of the
> of_node.

Right, so that needs fixing - like I say if there's no reference being
taken we already have a problem and taking another reference later on
isn't going to fix it.

> >  Doing it while doing the match and register
> > seems simple and neat from an error handling point of view so having the
> > core take an additional reference during the registration would join up
> > with that.

> The main issue I have is that devm_regualtor_register is a bit
> awkward. With regulator_register you will always be calling
> regulator_unregister so you can put the of_node there but with
> devm there isn't really a good place to put the of_node.

That's why I suggested it might be OK to take a reference in the core -
this would allow the device probe to safely drop its reference before it
returns.

> Would perhaps a sensible thing here be to add an of_node_get to
> of_regulator_match, since we seem to be expecting that to
> increase the ref count. And then just add an of_node_put to
> regulator_unregister. And for anything directly using
> regulator_register/devm_regulator_register they should add a
> manual of_node_get?

That seems very ugly.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-04-03 11:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 14:06 Charles Keepax
2014-04-02 14:23 ` Mark Brown
2014-04-02 16:04   ` Charles Keepax
2014-04-02 16:53     ` Mark Brown
2014-04-03 10:58       ` Charles Keepax
2014-04-03 11:14         ` Mark Brown [this message]
2014-04-03 11:48           ` Charles Keepax

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=20140403111431.GU14763@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.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®