Re: [U-Boot] [PATCH v2 05/17] dm: Add a function to bind a device by driver name

2014-11-23 Thread Simon Glass
On 17 November 2014 at 07:29, Heiko Schocher h...@denx.de wrote:
 Hello Simon,

 Am 11.11.2014 18:46, schrieb Simon Glass:

 In some cases we need to manually bind a device to a particular driver.
 Add a function to do this.

 Signed-off-by: Simon Glass s...@chromium.org
 ---

 Changes in v2:
 - Add new patch to add a function to bind a device by driver name

   drivers/core/lists.c | 21 +
   include/dm/lists.h   | 13 +
   2 files changed, 34 insertions(+)


 Acked-by: Heiko Schocher h...@denx.de

Applied to u-boot-dm.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 05/17] dm: Add a function to bind a device by driver name

2014-11-16 Thread Heiko Schocher

Hello Simon,

Am 11.11.2014 18:46, schrieb Simon Glass:

In some cases we need to manually bind a device to a particular driver.
Add a function to do this.

Signed-off-by: Simon Glass s...@chromium.org
---

Changes in v2:
- Add new patch to add a function to bind a device by driver name

  drivers/core/lists.c | 21 +
  include/dm/lists.h   | 13 +
  2 files changed, 34 insertions(+)


Acked-by: Heiko Schocher h...@denx.de

bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 05/17] dm: Add a function to bind a device by driver name

2014-11-11 Thread Simon Glass
In some cases we need to manually bind a device to a particular driver.
Add a function to do this.

Signed-off-by: Simon Glass s...@chromium.org
---

Changes in v2:
- Add new patch to add a function to bind a device by driver name

 drivers/core/lists.c | 21 +
 include/dm/lists.h   | 13 +
 2 files changed, 34 insertions(+)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 9f33dde..32f2242 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -77,6 +77,27 @@ int lists_bind_drivers(struct udevice *parent, bool 
pre_reloc_only)
return result;
 }
 
+int device_bind_driver(struct udevice *parent, const char *drv_name,
+  const char *dev_name, struct udevice **devp)
+{
+   struct driver *drv;
+   int ret;
+
+   drv = lists_driver_lookup_name(drv_name);
+   if (!drv) {
+   printf(Cannot find driver '%s'\n, drv_name);
+   return -ENOENT;
+   }
+   ret = device_bind(parent, drv, dev_name, NULL, -1, devp);
+   if (ret) {
+   printf(Cannot create device named '%s' (err=%d)\n,
+  dev_name, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
 #ifdef CONFIG_OF_CONTROL
 /**
  * driver_check_compatible() - Check if a driver is compatible with this node
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 704e33e..1b50af9 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -60,4 +60,17 @@ int lists_bind_drivers(struct udevice *parent, bool 
pre_reloc_only);
 int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
   struct udevice **devp);
 
+/**
+ * device_bind_driver() - bind a device to a driver
+ *
+ * This binds a new device to a driver.
+ *
+ * @parent:Parent device
+ * @drv_name:  Name of driver to attach to this parent
+ * @dev_name:  Name of the new device thus created
+ * @devp:  Returns the newly bound device
+ */
+int device_bind_driver(struct udevice *parent, const char *drv_name,
+  const char *dev_name, struct udevice **devp);
+
 #endif
-- 
2.1.0.rc2.206.gedb03e5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 05/17] dm: Add a function to bind a device by driver name

2014-11-11 Thread Jagan Teki
On 11 November 2014 23:16, Simon Glass s...@chromium.org wrote:
 In some cases we need to manually bind a device to a particular driver.
 Add a function to do this.

 Signed-off-by: Simon Glass s...@chromium.org
 ---

 Changes in v2:
 - Add new patch to add a function to bind a device by driver name

  drivers/core/lists.c | 21 +
  include/dm/lists.h   | 13 +
  2 files changed, 34 insertions(+)

 diff --git a/drivers/core/lists.c b/drivers/core/lists.c
 index 9f33dde..32f2242 100644
 --- a/drivers/core/lists.c
 +++ b/drivers/core/lists.c
 @@ -77,6 +77,27 @@ int lists_bind_drivers(struct udevice *parent, bool 
 pre_reloc_only)
 return result;
  }

 +int device_bind_driver(struct udevice *parent, const char *drv_name,
 +  const char *dev_name, struct udevice **devp)
 +{
 +   struct driver *drv;
 +   int ret;
 +
 +   drv = lists_driver_lookup_name(drv_name);
 +   if (!drv) {
 +   printf(Cannot find driver '%s'\n, drv_name);
 +   return -ENOENT;
 +   }
 +   ret = device_bind(parent, drv, dev_name, NULL, -1, devp);
 +   if (ret) {
 +   printf(Cannot create device named '%s' (err=%d)\n,
 +  dev_name, ret);
 +   return ret;
 +   }
 +
 +   return 0;
 +}
 +
  #ifdef CONFIG_OF_CONTROL
  /**
   * driver_check_compatible() - Check if a driver is compatible with this node
 diff --git a/include/dm/lists.h b/include/dm/lists.h
 index 704e33e..1b50af9 100644
 --- a/include/dm/lists.h
 +++ b/include/dm/lists.h
 @@ -60,4 +60,17 @@ int lists_bind_drivers(struct udevice *parent, bool 
 pre_reloc_only);
  int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
struct udevice **devp);

 +/**
 + * device_bind_driver() - bind a device to a driver
 + *
 + * This binds a new device to a driver.
 + *
 + * @parent:Parent device
 + * @drv_name:  Name of driver to attach to this parent
 + * @dev_name:  Name of the new device thus created
 + * @devp:  Returns the newly bound device
 + */
 +int device_bind_driver(struct udevice *parent, const char *drv_name,
 +  const char *dev_name, struct udevice **devp);
 +
  #endif
 --
 2.1.0.rc2.206.gedb03e5

 ___
 U-Boot mailing list
 U-Boot@lists.denx.de
 http://lists.denx.de/mailman/listinfo/u-boot

Reviewed-by: Jagannadha Sutradharudu Teki jagannadh.t...@gmail.com

thanks!
-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot