linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver core: platform: Add ability to find resource by name or index
@ 2017-05-08 21:59 Jon Mason
  2017-05-09  5:42 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Mason @ 2017-05-08 21:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, bcm-kernel-feedback-list

It is not always possible to find a resource via the name.  This may be
due to using previous versions of device tree without the names or using
ACPI.  To allow for resources to be discovered by either the name or the
index, a wrapper was created.  It attempts to find the resource via
name, and if unable to find the resource, will then attempt to find the
resource via index.

Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 include/linux/platform_device.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 98c2a7c7108e..0f42e9cf96de 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -59,6 +59,21 @@ extern struct resource *platform_get_resource_byname(struct platform_device *,
 extern int platform_get_irq_byname(struct platform_device *, const char *);
 extern int platform_add_devices(struct platform_device **, int);
 
+static inline struct resource *
+platform_get_resource_by_name_or_index(struct platform_device *dev,
+				       unsigned int type,
+				       const char *name,
+				       unsigned int num)
+{
+	struct resource *r;
+
+	r = platform_get_resource_byname(dev, type, name);
+	if (r)
+		return r;
+
+	return platform_get_resource(dev, type, num);
+}
+
 struct platform_device_info {
 		struct device *parent;
 		struct fwnode_handle *fwnode;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: platform: Add ability to find resource by name or index
  2017-05-08 21:59 [PATCH] driver core: platform: Add ability to find resource by name or index Jon Mason
@ 2017-05-09  5:42 ` Greg Kroah-Hartman
  2017-05-09 22:24   ` Jon Mason
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-05-09  5:42 UTC (permalink / raw)
  To: Jon Mason; +Cc: linux-kernel, bcm-kernel-feedback-list

On Mon, May 08, 2017 at 05:59:48PM -0400, Jon Mason wrote:
> It is not always possible to find a resource via the name.  This may be
> due to using previous versions of device tree without the names or using
> ACPI.  To allow for resources to be discovered by either the name or the
> index, a wrapper was created.  It attempts to find the resource via
> name, and if unable to find the resource, will then attempt to find the
> resource via index.
> 
> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  include/linux/platform_device.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Do you have any users for this new function?  We don't like adding apis
without them...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: platform: Add ability to find resource by name or index
  2017-05-09  5:42 ` Greg Kroah-Hartman
@ 2017-05-09 22:24   ` Jon Mason
  0 siblings, 0 replies; 3+ messages in thread
From: Jon Mason @ 2017-05-09 22:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: open list, BCM Kernel Feedback

On Tue, May 9, 2017 at 1:42 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, May 08, 2017 at 05:59:48PM -0400, Jon Mason wrote:
>> It is not always possible to find a resource via the name.  This may be
>> due to using previous versions of device tree without the names or using
>> ACPI.  To allow for resources to be discovered by either the name or the
>> index, a wrapper was created.  It attempts to find the resource via
>> name, and if unable to find the resource, will then attempt to find the
>> resource via index.
>>
>> Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
>> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
>> ---
>>  include/linux/platform_device.h | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>
> Do you have any users for this new function?  We don't like adding apis
> without them...

That is fair.  I currently only have one for an Ethernet device (as I
am early in my ACPI enablement on this platform).  There could
possibly be more.  So, I'll wait until I'm finished and push them as a
series (unless you would prefer that I send what I have now and
follow-on as I come across them).

Thanks,
Jon

>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-09 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 21:59 [PATCH] driver core: platform: Add ability to find resource by name or index Jon Mason
2017-05-09  5:42 ` Greg Kroah-Hartman
2017-05-09 22:24   ` Jon Mason

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).