Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476455 > unrolled thread

Re: [PATCH v4 05/15] drivers: platform: add fwnode base platform devices retrieval

Started byHanjun Guo <hanjun.guo@linaro.org>
First post2016-09-05 15:30 +0200
Last post2016-09-06 14:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 05/15] drivers: platform: add fwnode base platform  devices retrieval Hanjun Guo <hanjun.guo@linaro.org> - 2016-09-05 15:30 +0200
    Re: [PATCH v4 05/15] drivers: platform: add fwnode base platform  devices retrieval Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-09-05 17:00 +0200
      Re: [PATCH v4 05/15] drivers: platform: add fwnode base platform  devices retrieval Hanjun Guo <hanjun.guo@linaro.org> - 2016-09-06 14:10 +0200

#1476455 — Re: [PATCH v4 05/15] drivers: platform: add fwnode base platform devices retrieval

FromHanjun Guo <hanjun.guo@linaro.org>
Date2016-09-05 15:30 +0200
SubjectRe: [PATCH v4 05/15] drivers: platform: add fwnode base platform devices retrieval
Message-ID<se28k-4is-85@gated-at.bofh.it>
On 2016/8/15 23:23, Lorenzo Pieralisi wrote:
> The platform device kernel API does not provide functions to
> retrieve a platform device through the corresponding struct
> device fwnode pointer.
>
> Implement the fwnode platform_device look-up in drivers core
> code by using the bus_find_device() API and a corresponding
> matching function. The OF equivalent (eg of_find_device_by_node())
> will reuse the newly introduced function when OF code will
> take care of setting up the device->fwnode value that is
> currently left dangling for platform devices instantiated out
> of device tree nodes.
>
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> ---
>  drivers/base/platform.c         | 23 +++++++++++++++++++++++
>  include/linux/platform_device.h |  3 +++
>  2 files changed, 26 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 6482d47..3ef150d 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -760,6 +760,29 @@ err_out:
>  }
>  EXPORT_SYMBOL_GPL(__platform_create_bundle);
>
> +static int fwnode_dev_match(struct device *dev, void *data)
> +{
> +	return dev->fwnode == data;
> +}
> +
> +/**
> + * platform_find_device_by_fwnode() - Find the platform_device associated
> + *				      with a fwnode
> + * @fwnode: Pointer to firmware node
> + *
> + * Returns platform_device pointer, or NULL if not found
> + */
> +struct platform_device *
> +platform_find_device_by_fwnode(struct fwnode_handle *fwnode)
> +{
> +	struct device *dev;
> +
> +	dev = bus_find_device(&platform_bus_type, NULL, fwnode,
> +			      fwnode_dev_match);
> +	return dev ? to_platform_device(dev) : NULL;
> +}
> +EXPORT_SYMBOL(platform_find_device_by_fwnode);

As SMMU is registered as platform devices, I think we need such
API to retrieve the platform device with fwnode handle, actually
Kefeng introduced a similar patch [1], but your patch is more
generic, so this patch make sense to me,

Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks
Hanjun

[1]: https://patchwork.kernel.org/patch/7743661/

[toc] | [next] | [standalone]


#1476532

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2016-09-05 17:00 +0200
Message-ID<se3xo-57t-7@gated-at.bofh.it>
In reply to#1476455
On Mon, Sep 05, 2016 at 09:19:43PM +0800, Hanjun Guo wrote:
> On 2016/8/15 23:23, Lorenzo Pieralisi wrote:
> >The platform device kernel API does not provide functions to
> >retrieve a platform device through the corresponding struct
> >device fwnode pointer.
> >
> >Implement the fwnode platform_device look-up in drivers core
> >code by using the bus_find_device() API and a corresponding
> >matching function. The OF equivalent (eg of_find_device_by_node())
> >will reuse the newly introduced function when OF code will
> >take care of setting up the device->fwnode value that is
> >currently left dangling for platform devices instantiated out
> >of device tree nodes.
> >
> >Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> >Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> >---
> > drivers/base/platform.c         | 23 +++++++++++++++++++++++
> > include/linux/platform_device.h |  3 +++
> > 2 files changed, 26 insertions(+)
> >
> >diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> >index 6482d47..3ef150d 100644
> >--- a/drivers/base/platform.c
> >+++ b/drivers/base/platform.c
> >@@ -760,6 +760,29 @@ err_out:
> > }
> > EXPORT_SYMBOL_GPL(__platform_create_bundle);
> >
> >+static int fwnode_dev_match(struct device *dev, void *data)
> >+{
> >+	return dev->fwnode == data;
> >+}
> >+
> >+/**
> >+ * platform_find_device_by_fwnode() - Find the platform_device associated
> >+ *				      with a fwnode
> >+ * @fwnode: Pointer to firmware node
> >+ *
> >+ * Returns platform_device pointer, or NULL if not found
> >+ */
> >+struct platform_device *
> >+platform_find_device_by_fwnode(struct fwnode_handle *fwnode)
> >+{
> >+	struct device *dev;
> >+
> >+	dev = bus_find_device(&platform_bus_type, NULL, fwnode,
> >+			      fwnode_dev_match);
> >+	return dev ? to_platform_device(dev) : NULL;
> >+}
> >+EXPORT_SYMBOL(platform_find_device_by_fwnode);
> 
> As SMMU is registered as platform devices, I think we need such
> API to retrieve the platform device with fwnode handle, actually
> Kefeng introduced a similar patch [1], but your patch is more
> generic, so this patch make sense to me,
> 
> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks ! Strictly speaking, with Robin's new series:

https://lists.linuxfoundation.org/pipermail/iommu/2016-August/018230.html


(and corresponding v5 of this one that I have rebased on top of it) we
do not need this patch any longer and it is not really that generic
keeping in mind that it can't be used for DT matching (because in DT
dev->fwnode is dangling); I will see if I keep this patch according
to dependencies.

Side note: I have a problem with [1], since that code is there to
implement DT phandles in ACPI IIUC and we must really prevent that :)

Thanks !
Lorenzo

> Thanks
> Hanjun
> 
> [1]: https://patchwork.kernel.org/patch/7743661/
> 

[toc] | [prev] | [next] | [standalone]


#1477308

FromHanjun Guo <hanjun.guo@linaro.org>
Date2016-09-06 14:10 +0200
Message-ID<senmp-1Nb-27@gated-at.bofh.it>
In reply to#1476532
On 2016/9/5 22:57, Lorenzo Pieralisi wrote:
> On Mon, Sep 05, 2016 at 09:19:43PM +0800, Hanjun Guo wrote:
>> On 2016/8/15 23:23, Lorenzo Pieralisi wrote:
>>> The platform device kernel API does not provide functions to
>>> retrieve a platform device through the corresponding struct
>>> device fwnode pointer.
>>>
>>> Implement the fwnode platform_device look-up in drivers core
>>> code by using the bus_find_device() API and a corresponding
>>> matching function. The OF equivalent (eg of_find_device_by_node())
>>> will reuse the newly introduced function when OF code will
>>> take care of setting up the device->fwnode value that is
>>> currently left dangling for platform devices instantiated out
>>> of device tree nodes.
>>>
>>> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>>> ---
>>> drivers/base/platform.c         | 23 +++++++++++++++++++++++
>>> include/linux/platform_device.h |  3 +++
>>> 2 files changed, 26 insertions(+)
>>>
>>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>>> index 6482d47..3ef150d 100644
>>> --- a/drivers/base/platform.c
>>> +++ b/drivers/base/platform.c
>>> @@ -760,6 +760,29 @@ err_out:
>>> }
>>> EXPORT_SYMBOL_GPL(__platform_create_bundle);
>>>
>>> +static int fwnode_dev_match(struct device *dev, void *data)
>>> +{
>>> +	return dev->fwnode == data;
>>> +}
>>> +
>>> +/**
>>> + * platform_find_device_by_fwnode() - Find the platform_device associated
>>> + *				      with a fwnode
>>> + * @fwnode: Pointer to firmware node
>>> + *
>>> + * Returns platform_device pointer, or NULL if not found
>>> + */
>>> +struct platform_device *
>>> +platform_find_device_by_fwnode(struct fwnode_handle *fwnode)
>>> +{
>>> +	struct device *dev;
>>> +
>>> +	dev = bus_find_device(&platform_bus_type, NULL, fwnode,
>>> +			      fwnode_dev_match);
>>> +	return dev ? to_platform_device(dev) : NULL;
>>> +}
>>> +EXPORT_SYMBOL(platform_find_device_by_fwnode);
>>
>> As SMMU is registered as platform devices, I think we need such
>> API to retrieve the platform device with fwnode handle, actually
>> Kefeng introduced a similar patch [1], but your patch is more
>> generic, so this patch make sense to me,
>>
>> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
>
> Thanks ! Strictly speaking, with Robin's new series:
>
> https://lists.linuxfoundation.org/pipermail/iommu/2016-August/018230.html
>
>
> (and corresponding v5 of this one that I have rebased on top of it) we
> do not need this patch any longer and it is not really that generic
> keeping in mind that it can't be used for DT matching (because in DT
> dev->fwnode is dangling); I will see if I keep this patch according
> to dependencies.

OK, I think I will wait for your new version, then try another test
and review it, does it make sense?

>
> Side note: I have a problem with [1], since that code is there to
> implement DT phandles in ACPI IIUC and we must really prevent that :)

Agreed :)

Thanks
Hanjun

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web