Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1587686
| From | Rob Herring <robh+dt@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate |
| Date | 2017-02-24 15:20 +0100 |
| Message-ID | <teoT0-1iX-9@gated-at.bofh.it> (permalink) |
| References | <tbRRw-5tj-11@gated-at.bofh.it> <tbRRw-5tj-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
> 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.
> + * @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.
> + *
> + * Similar to of_platform_populate(), but will automatically call
> + * of_platform_depopulate() when the device is unbound from the bus.
> + *
> + * Returns 0 on success, < 0 on failure.
> + */
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v1 1/2] of: add devm_ functions for populate and depopulate Benjamin Gaignard <benjamin.gaignard@linaro.org> - 2017-02-17 15:40 +0100
Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Rob Herring <robh+dt@kernel.org> - 2017-02-24 15:20 +0100
Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Rob Herring <robh+dt@kernel.org> - 2017-02-24 16:30 +0100
Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Benjamin Gaignard <benjamin.gaignard@linaro.org> - 2017-02-24 16:30 +0100
Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Rob Herring <robh+dt@kernel.org> - 2017-02-24 16:50 +0100
Re: [PATCH v1 1/2] of: add devm_ functions for populate and depopulate Benjamin Gaignard <benjamin.gaignard@linaro.org> - 2017-02-24 16:30 +0100
csiph-web