Re: [U-Boot] [PATCH v3 10/26] dm: core: Add a function to get a device's uclass ID

2015-01-26 Thread Simon Glass
On 25 January 2015 at 18:58, Masahiro Yamada yamad...@jp.panasonic.com wrote:

 On Sun, 25 Jan 2015 08:27:04 -0700
 Simon Glass s...@chromium.org wrote:

 This is useful to check which uclass a device is in.

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


 Reviewed-by: Masahiro Yamada yamad...@jp.panasonic.com


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


[U-Boot] [PATCH v3 10/26] dm: core: Add a function to get a device's uclass ID

2015-01-25 Thread Simon Glass
This is useful to check which uclass a device is in.

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

Changes in v3: None
Changes in v2: None

 drivers/core/device.c |  5 +
 include/dm/device.h   |  8 
 test/dm/core.c| 11 +++
 3 files changed, 24 insertions(+)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 365676b..2606d18 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -438,3 +438,8 @@ ulong dev_get_of_data(struct udevice *dev)
 {
return dev-of_id-data;
 }
+
+enum uclass_id device_get_uclass_id(struct udevice *dev)
+{
+   return dev-uclass-uc_drv-id;
+}
diff --git a/include/dm/device.h b/include/dm/device.h
index 50f1b4f..81afa8c 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -245,6 +245,14 @@ struct udevice *dev_get_parent(struct udevice *child);
  */
 ulong dev_get_of_data(struct udevice *dev);
 
+/*
+ * device_get_uclass_id() - return the uclass ID of a device
+ *
+ * @dev:   Device to check
+ * @return uclass ID for the device
+ */
+enum uclass_id device_get_uclass_id(struct udevice *dev);
+
 /**
  * device_get_child() - Get the child of a device by index
  *
diff --git a/test/dm/core.c b/test/dm/core.c
index ff5c2a7..eccda09 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -598,3 +598,14 @@ static int dm_test_uclass_before_ready(struct 
dm_test_state *dms)
 }
 
 DM_TEST(dm_test_uclass_before_ready, 0);
+
+static int dm_test_device_get_uclass_id(struct dm_test_state *dms)
+{
+   struct udevice *dev;
+
+   ut_assertok(uclass_get_device(UCLASS_TEST, 0, dev));
+   ut_asserteq(UCLASS_TEST, device_get_uclass_id(dev));
+
+   return 0;
+}
+DM_TEST(dm_test_device_get_uclass_id, DM_TESTF_SCAN_PDATA);
-- 
2.2.0.rc0.207.ga3a616c

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


Re: [U-Boot] [PATCH v3 10/26] dm: core: Add a function to get a device's uclass ID

2015-01-25 Thread Masahiro Yamada

On Sun, 25 Jan 2015 08:27:04 -0700
Simon Glass s...@chromium.org wrote:

 This is useful to check which uclass a device is in.
 
 Signed-off-by: Simon Glass s...@chromium.org


Reviewed-by: Masahiro Yamada yamad...@jp.panasonic.com

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