devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
To: Rob Herring <robh+dt@kernel.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
	Frank Rowand <frowand.list@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Vincent Abriou <vincent.abriou@st.com>
Subject: Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate
Date: Fri, 24 Feb 2017 16:26:22 +0100	[thread overview]
Message-ID: <CA+M3ks7ViNCEnmfEP-6kTCj4nUfMQRe7ktA-9cATb-AAGiS=sQ@mail.gmail.com> (raw)
In-Reply-To: <CAL_JsqLwDPYeO9fHvviCheKLrJv4qqcdbP4wseLLd_SVrsbw=A@mail.gmail.com>

2017-02-24 16:20 GMT+01:00 Rob Herring <robh+dt@kernel.org>:
> On Fri, Feb 24, 2017 at 9:13 AM, Benjamin Gaignard
> <benjamin.gaignard@linaro.org> wrote:
>> 2017-02-24 15:17 GMT+01:00 Rob Herring <robh+dt@kernel.org>:
>>> On Fri, Feb 17, 2017 at 8:31 AM, Benjamin Gaignard
>>> <benjamin.gaignard@linaro.org> wrote:
>>>> Lost of calls to of_platform_populate() are not unbalanced by a call
>>>
>>> s/Lost/Lots/
>>>
>>>> to of_platform_depopulate(). This create issues while drivers are
>>>> bind/unbind.
>>>>
>>>> In way to solve those issues is to add devm_of_platform_populate()
>>>> which will call of_platform_depopulate() when the device is unbound
>>>> from the bus.
>>>
>>> One complication is of_platform_populate is designed to be called
>>> multiple times. We call it with the default match table and then
>>> platforms can call it again with a custom match table for example.
>>
>> I do not plan to use it every where but only in some drivers probe()
>> to avoid adding goto to call of_platform_depopulate() for each error
>> cases which may occur after calling populate.
>>
>>>
>>>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>>>> ---
>>>>  drivers/of/platform.c       | 77 +++++++++++++++++++++++++++++++++++++++++++++
>>>>  include/linux/of_platform.h | 20 ++++++++++++
>>>>  2 files changed, 97 insertions(+)
>>>>
>>>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
>>>> index b8064bc..3dbebf7 100644
>>>> --- a/drivers/of/platform.c
>>>> +++ b/drivers/of/platform.c
>>>> @@ -571,6 +571,83 @@ void of_platform_depopulate(struct device *parent)
>>>>  }
>>>>  EXPORT_SYMBOL_GPL(of_platform_depopulate);
>>>>
>>>> +static void devm_of_platform_populate_release(struct device *dev, void *res)
>>>> +{
>>>> +       of_platform_depopulate(*(struct device **)res);
>>>> +}
>>>> +
>>>> +/**
>>>> + * devm_of_platform_populate() - Populate platform_devices from device tree data
>>>> + * @dev: device that requested to populate from device tree data
>>>> + * @root: parent of the first level to probe or NULL for the root of the tree
>>>> + * @matches: match table, NULL to use the default
>>>
>>> NULL is no match table, not the default which means only populate
>>> immediate children.
>>
>> I have copy of_platform_populate() description...
>> I replace it by: @matches: match table (could be NULL)
>>
>>>
>>>> + * @lookup: auxdata table for matching id and platform_data with device nodes
>>>> + * @parent: parent to hook devices from, NULL for toplevel
>>>
>>> I think this needs to be a bit different args as the use is limited.
>>> root and parent must not be NULL. dev should be the same as parent.
>>> lookup was for legacy, so drop that.
>>
>> So function prototype will become:
>> int devm_of_platform_populate(struct device *dev, struct device_node
>> *root, const struct of_device_id *matches)
>
> I just noticed something else too. dev->of_node should equal root I
> think, so we can get rid of root param.

match parameter is very often set to NULL since this function will
have a limited
scope why not also remove it and only keep dev ?

>
> Rob
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-02-24 15:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 14:31 [PATCH v1 0/2] Introduce devm_of_platform_populate() helper Benjamin Gaignard
2017-02-17 14:31 ` [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Benjamin Gaignard
2017-02-24 14:17   ` Rob Herring
2017-02-24 15:13     ` Benjamin Gaignard
2017-02-24 15:20       ` Rob Herring
2017-02-24 15:26         ` Benjamin Gaignard [this message]
2017-02-24 15:30           ` Rob Herring
2017-02-17 14:31 ` [PATCH v1 2/2] drm: sti: make driver use devm_of_platform_populate() Benjamin Gaignard

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='CA+M3ks7ViNCEnmfEP-6kTCj4nUfMQRe7ktA-9cATb-AAGiS=sQ@mail.gmail.com' \
    --to=benjamin.gaignard@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frowand.list@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vincent.abriou@st.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;
as well as URLs for NNTP newsgroup(s).