uc->priv_ = priv;
}
-enum uclass_id uclass_get_by_name_len(const char *name, int len)
+enum uclass_id uclass_get_by_namelen(const char *name, int len)
{
int i;
for (i = 0; i < UCLASS_COUNT; i++) {
struct uclass_driver *uc_drv = lists_uclass_lookup(i);
- if (uc_drv && !strncmp(uc_drv->name, name, len))
+ if (uc_drv && !strncmp(uc_drv->name, name, len) &&
+ strlen(uc_drv->name) == len)
return i;
}
enum uclass_id uclass_get_by_name(const char *name)
{
- return uclass_get_by_name_len(name, strlen(name));
+ return uclass_get_by_namelen(name, strlen(name));
}
int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
const char *uclass_get_name(enum uclass_id id);
/**
- * uclass_get_by_name_len() - Look up a uclass by its partial driver name
+ * uclass_get_by_namelen() - Look up a uclass by its driver name
*
* @name: Name to look up
- * @len: Length of the partial name
+ * @len: Length of @name (the uclass driver name must have the same length)
* Return: the associated uclass ID, or UCLASS_INVALID if not found
*/
-enum uclass_id uclass_get_by_name_len(const char *name, int len);
+enum uclass_id uclass_get_by_namelen(const char *name, int len);
/**
* uclass_get_by_name() - Look up a uclass by its driver name
ut_asserteq_str("test", uclass_get_name(UCLASS_TEST));
ut_asserteq(UCLASS_TEST, uclass_get_by_name("test"));
+ ut_asserteq(UCLASS_SPI, uclass_get_by_name("spi"));
+
return 0;
}
DM_TEST(dm_test_uclass_names, UT_TESTF_SCAN_PDATA);