@@ -89,7 +89,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
*/
if (CONFIG_IS_ENABLED(OF_CONTROL) &&
!CONFIG_IS_ENABLED(OF_PLATDATA)) {
- if (uc->uc_drv->name && ofnode_valid(node)) {
+ if ((uc->uc_drv->name || uc->uc_drv->name_seq_alias) &&
+ ofnode_valid(node)) {
if (!dev_read_alias_seq(dev, &dev->seq_)) {
auto_seq = false;
log_debug(" - seq=%d\n", dev->seq_);
@@ -347,9 +347,14 @@ const void *dev_read_prop_by_prop(struct ofprop *prop,
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
ofnode node = dev_ofnode(dev);
- const char *uc_name = dev->uclass->uc_drv->name;
+ const char *uc_name;
int ret = -ENOTSUPP;
+ if (dev->uclass->uc_drv->name_seq_alias)
+ uc_name = dev->uclass->uc_drv->name_seq_alias;
+ else
+ uc_name = dev->uclass->uc_drv->name;
+
if (ofnode_is_np(node)) {
ret = of_alias_get_id(ofnode_to_np(node), uc_name);
if (ret >= 0) {
@@ -308,11 +308,18 @@ int uclass_find_next_free_seq(struct uclass *uc)
{
struct udevice *dev;
int max = -1;
+ const char *uc_name;
/* If using aliases, start with the highest alias value */
if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
- (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS))
- max = dev_read_alias_highest_id(uc->uc_drv->name);
+ (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
+ if (uc->uc_drv->name_seq_alias)
+ uc_name = uc->uc_drv->name_seq_alias;
+ else
+ uc_name = uc->uc_drv->name;
+
+ max = dev_read_alias_highest_id(uc_name);
+ }
/* Avoid conflict with existing devices */
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
@@ -1169,7 +1169,14 @@ static inline const void *dev_read_prop_by_prop(struct ofprop *prop,
static inline int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
#if CONFIG_IS_ENABLED(OF_CONTROL)
- return fdtdec_get_alias_seq(gd->fdt_blob, dev->uclass->uc_drv->name,
+ const char *uc_name;
+
+ if (dev->uclass->uc_drv->name_seq_alias)
+ uc_name = dev->uclass->uc_drv->name_seq_alias;
+ else
+ uc_name = dev->uclass->uc_drv->name;
+
+ return fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
dev_of_offset(dev), devnump);
#else
return -ENOTSUPP;
@@ -57,6 +57,7 @@ struct udevice;
* drivers.
*
* @name: Name of uclass driver
+ * @name_seq_alias: Name used for alias sequence numbering
* @id: ID number of this uclass
* @post_bind: Called after a new device is bound to this uclass
* @pre_unbind: Called before a device is unbound from this uclass
@@ -88,6 +89,7 @@ struct udevice;
*/
struct uclass_driver {
const char *name;
+ const char *name_seq_alias;
enum uclass_id id;
int (*post_bind)(struct udevice *dev);
int (*pre_unbind)(struct udevice *dev);
A new field name_seq_alias is added to uclass_driver structure, which allows an uclass driver to use an alternate name for alias sequence numbering. For example an uclass named "usb_gadget" can share alias with "usb" uclass : UCLASS_DRIVER(usb_gadget_generic) = { .id = UCLASS_USB_GADGET_GENERIC, .name = "usb_gadget", .name_seq_alias = "usb", .flags = DM_UC_FLAG_SEQ_ALIAS, }; Currently there are some uclasses with duplicate name which break uclass functions like uclass_get_by_name(), with this patch it's now possible to rename these classes without break the existing alias function. Signed-off-by: Zixun LI <admin@hifiphile.com> --- drivers/core/device.c | 3 ++- drivers/core/read.c | 7 ++++++- drivers/core/uclass.c | 11 +++++++++-- include/dm/read.h | 9 ++++++++- include/dm/uclass.h | 2 ++ 5 files changed, 27 insertions(+), 5 deletions(-)