* [U-Boot] [PATCH] misc: uclass: Introduce misc_init_by_ofnode
@ 2019-04-24 11:06 Keerthy
2019-04-24 23:58 ` Simon Glass
0 siblings, 1 reply; 2+ messages in thread
From: Keerthy @ 2019-04-24 11:06 UTC (permalink / raw)
To: u-boot
Introduce misc_init_by_ofnode to probe a misc device
using its ofnode.
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
drivers/misc/misc-uclass.c | 25 +++++++++++++++++++++++++
include/misc.h | 9 +++++++++
2 files changed, 34 insertions(+)
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
index 55381edc98..835d3f7118 100644
--- a/drivers/misc/misc-uclass.c
+++ b/drivers/misc/misc-uclass.c
@@ -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;
+ int ret;
+ long temp1, temp2;
+
+ temp1 = ofnode_to_offset(node);
+
+ for (ret = uclass_find_first_device(UCLASS_MISC, &dev); dev;
+ ret = uclass_find_next_device(&dev)) {
+ temp2 = ofnode_to_offset(dev_ofnode(dev));
+ if (temp1 == temp2) {
+ 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",
diff --git a/include/misc.h b/include/misc.h
index 12d1325ee2..79263ed480 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -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
*
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] misc: uclass: Introduce misc_init_by_ofnode
2019-04-24 11:06 [U-Boot] [PATCH] misc: uclass: Introduce misc_init_by_ofnode Keerthy
@ 2019-04-24 23:58 ` Simon Glass
0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2019-04-24 23:58 UTC (permalink / raw)
To: u-boot
Hi Keerthy,
On Wed, 24 Apr 2019 at 05:06, Keerthy <j-keerthy@ti.com> wrote:
>
> Introduce misc_init_by_ofnode to probe a misc device
> using its ofnode.
Can you please add a motivation for this? Also please can you add a
test for your function in test/dm/misc.c
Regards,
Simon
>
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> ---
> drivers/misc/misc-uclass.c | 25 +++++++++++++++++++++++++
> include/misc.h | 9 +++++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
> index 55381edc98..835d3f7118 100644
> --- a/drivers/misc/misc-uclass.c
> +++ b/drivers/misc/misc-uclass.c
> @@ -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;
> + int ret;
> + long temp1, temp2;
> +
> + temp1 = ofnode_to_offset(node);
> +
> + for (ret = uclass_find_first_device(UCLASS_MISC, &dev); dev;
> + ret = uclass_find_next_device(&dev)) {
> + temp2 = ofnode_to_offset(dev_ofnode(dev));
> + if (temp1 == temp2) {
> + 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",
> diff --git a/include/misc.h b/include/misc.h
> index 12d1325ee2..79263ed480 100644
> --- a/include/misc.h
> +++ b/include/misc.h
> @@ -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
> *
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-24 23:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 11:06 [U-Boot] [PATCH] misc: uclass: Introduce misc_init_by_ofnode Keerthy
2019-04-24 23:58 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.