misc: uclass: Introduce misc_init_by_ofnode
Introduce misc_init_by_ofnode to probe a misc device using its ofnode. Signed-off-by: Keerthy <j-keerthy@ti.com>
This commit is contained in:
parent
2ae138d289
commit
9d9fd0a3b1
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <errno.h>
|
||||
#include <misc.h>
|
||||
|
||||
|
|
@ -65,6 +67,29 @@ int misc_set_enabled(struct udevice *dev, bool val)
|
|||
return ops->set_enabled(dev, val);
|
||||
}
|
||||
|
||||
int misc_init_by_ofnode(ofnode node)
|
||||
{
|
||||
struct udevice *dev = NULL;
|
||||
struct uclass *uc;
|
||||
int ret;
|
||||
|
||||
ret = uclass_get(UCLASS_MISC, &uc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
uclass_foreach_dev(dev, uc) {
|
||||
if (ofnode_equal(node, dev_ofnode(dev))) {
|
||||
ret = device_probe(dev);
|
||||
if (ret)
|
||||
debug("%s: Failed to initialize - %d\n",
|
||||
dev->name, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(misc) = {
|
||||
.id = UCLASS_MISC,
|
||||
.name = "misc",
|
||||
|
|
|
|||
|
|
@ -76,6 +76,15 @@ int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
|
|||
*/
|
||||
int misc_set_enabled(struct udevice *dev, bool val);
|
||||
|
||||
/**
|
||||
* misc_init_by_ofnode() - Probe a misc device by using ofnode.
|
||||
* @node: ofnode of the misc device.
|
||||
*
|
||||
* A misc device is probed using ofnode.
|
||||
*
|
||||
* Return: -ve on error, 0 on success
|
||||
*/
|
||||
int misc_init_by_ofnode(ofnode node);
|
||||
/*
|
||||
* struct misc_ops - Driver model Misc operations
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue