summaryrefslogtreecommitdiffstats
path: root/drivers/core/lists.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-11-11 10:46:18 -0700
committerSimon Glass <sjg@chromium.org>2014-11-22 10:16:45 +0100
commit2ef249b4420818d7ea31a031f48825e5f38ed3ac (patch)
tree5f02f7a902dd73e2c7bd0fafe9fa643d0f69c361 /drivers/core/lists.c
parentc1a6f371ae65f1a3709e872e08bed51321e292fc (diff)
downloadtalos-obmc-uboot-2ef249b4420818d7ea31a031f48825e5f38ed3ac.tar.gz
talos-obmc-uboot-2ef249b4420818d7ea31a031f48825e5f38ed3ac.zip
dm: core: Allow access to the device's driver_id data
When the device is created from a device tree node, it matches a compatible string. Allow access to that string and the associated data. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@ti.com> Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/core/lists.c')
-rw-r--r--drivers/core/lists.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 3a1ea85654..24d2864924 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -83,28 +83,33 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
*
* @param blob: Device tree pointer
* @param offset: Offset of node in device tree
- * @param of_matchL List of compatible strings to match
+ * @param of_match: List of compatible strings to match
+ * @param of_idp: Returns the match that was found
* @return 0 if there is a match, -ENOENT if no match, -ENODEV if the node
* does not have a compatible string, other error <0 if there is a device
* tree error
*/
static int driver_check_compatible(const void *blob, int offset,
- const struct udevice_id *of_match)
+ const struct udevice_id *of_match,
+ const struct udevice_id **of_idp)
{
int ret;
+ *of_idp = NULL;
if (!of_match)
return -ENOENT;
while (of_match->compatible) {
ret = fdt_node_check_compatible(blob, offset,
of_match->compatible);
- if (!ret)
+ if (!ret) {
+ *of_idp = of_match;
return 0;
- else if (ret == -FDT_ERR_NOTFOUND)
+ } else if (ret == -FDT_ERR_NOTFOUND) {
return -ENODEV;
- else if (ret < 0)
+ } else if (ret < 0) {
return -EINVAL;
+ }
of_match++;
}
@@ -116,6 +121,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
{
struct driver *driver = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
+ const struct udevice_id *id;
struct driver *entry;
struct udevice *dev;
bool found = false;
@@ -127,7 +133,8 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
if (devp)
*devp = NULL;
for (entry = driver; entry != driver + n_ents; entry++) {
- ret = driver_check_compatible(blob, offset, entry->of_match);
+ ret = driver_check_compatible(blob, offset, entry->of_match,
+ &id);
name = fdt_get_name(blob, offset, NULL);
if (ret == -ENOENT) {
continue;
@@ -147,6 +154,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
dm_warn("Error binding driver '%s'\n", entry->name);
return ret;
} else {
+ dev->of_id = id;
found = true;
if (devp)
*devp = dev;
OpenPOWER on IntegriCloud