From: Jon Mason <jon.mason@broadcom.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com
Subject: [PATCH] driver core: platform: Add ability to find resource by name or index
Date: Mon, 8 May 2017 17:59:48 -0400 [thread overview]
Message-ID: <1494280788-9588-1-git-send-email-jon.mason@broadcom.com> (raw)
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
next reply other threads:[~2017-05-08 21:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 21:59 Jon Mason [this message]
2017-05-09 5:42 ` [PATCH] driver core: platform: Add ability to find resource by name or index Greg Kroah-Hartman
2017-05-09 22:24 ` Jon Mason
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=1494280788-9588-1-git-send-email-jon.mason@broadcom.com \
--to=jon.mason@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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