From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Wed, 5 Oct 2016 20:42:13 -0600 Subject: [U-Boot] [PATCH v2 05/12] dm: core: Add a function to get a uclass name In-Reply-To: <1475721740-15124-1-git-send-email-sjg@chromium.org> References: <1475721740-15124-1-git-send-email-sjg@chromium.org> Message-ID: <1475721740-15124-6-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de It is useful in debug() statements to display the name of the uclass for a device. Add a simple function to provide this. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v2: - Fix typo drive -> driver drivers/core/uclass.c | 9 +++++++++ include/dm/uclass.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index de602ae..60610e5 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -148,6 +148,15 @@ int uclass_get(enum uclass_id id, struct uclass **ucp) return 0; } +const char *uclass_get_name(enum uclass_id id) +{ + struct uclass *uc; + + if (uclass_get(id, &uc)) + return NULL; + return uc->uc_drv->name; +} + int uclass_find_device(enum uclass_id id, int index, struct udevice **devp) { struct uclass *uc; diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 84f05bc..b583aa8 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -119,6 +119,14 @@ struct uclass_driver { int uclass_get(enum uclass_id key, struct uclass **ucp); /** + * uclass_get_name() - Get the name of a uclass driver + * + * @id: ID to look up + * @returns the name of the uclass driver for that ID, or NULL if none + */ +const char *uclass_get_name(enum uclass_id id); + +/** * uclass_get_device() - Get a uclass device based on an ID and index * * The device is probed to activate it ready for use. -- 2.8.0.rc3.226.g39d4020