It looks simpler to use ll_entry_end() than ll_entry_count(). We can save one variable. (and it will be helpful for the upcoming commit.)
Signed-off-by: Masahiro Yamada <[email protected]> --- drivers/core/lists.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/core/lists.c b/drivers/core/lists.c index ddbac38..1476715 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -20,12 +20,10 @@ struct driver *lists_driver_lookup_name(const char *name) { - struct driver *drv = - ll_entry_start(struct driver, driver); - const int n_ents = ll_entry_count(struct driver, driver); - struct driver *entry; + struct driver *entry = ll_entry_start(struct driver, driver); + struct driver *end = ll_entry_end(struct driver, driver); - for (entry = drv; entry != drv + n_ents; entry++) { + for (; entry < end; entry++) { if (!strcmp(name, entry->name)) return entry; } @@ -36,12 +34,11 @@ struct driver *lists_driver_lookup_name(const char *name) struct uclass_driver *lists_uclass_lookup(enum uclass_id id) { - struct uclass_driver *uclass = + struct uclass_driver *entry = ll_entry_start(struct uclass_driver, uclass); - const int n_ents = ll_entry_count(struct uclass_driver, uclass); - struct uclass_driver *entry; + struct uclass_driver *end = ll_entry_end(struct uclass_driver, uclass); - for (entry = uclass; entry != uclass + n_ents; entry++) { + for (; entry < end; entry++) { if (entry->id == id) return entry; } @@ -51,15 +48,15 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id) int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only) { - struct driver_info *info = + struct driver_info *entry = ll_entry_start(struct driver_info, driver_info); - const int n_ents = ll_entry_count(struct driver_info, driver_info); - struct driver_info *entry; + struct driver_info *end = + ll_entry_end(struct driver_info, driver_info); struct udevice *dev; int result = 0; int ret; - for (entry = info; entry != info + n_ents; entry++) { + for (; entry < end; entry++) { ret = device_bind_by_name(parent, pre_reloc_only, entry, &dev); if (ret && ret != -EPERM) { dm_warn("No match for driver '%s'\n", entry->name); @@ -108,9 +105,8 @@ static int driver_check_compatible(const void *blob, int offset, int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, struct udevice **devp) { - struct driver *driver = ll_entry_start(struct driver, driver); - const int n_ents = ll_entry_count(struct driver, driver); - struct driver *entry; + struct driver *entry = ll_entry_start(struct driver, driver); + struct driver *end = ll_entry_end(struct driver, driver); struct udevice *dev; bool found = false; const char *name; @@ -120,7 +116,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL)); if (devp) *devp = NULL; - for (entry = driver; entry != driver + n_ents; entry++) { + for (; entry < end; entry++) { ret = driver_check_compatible(blob, offset, entry->of_match); name = fdt_get_name(blob, offset, NULL); if (ret == -ENOENT) { -- 1.9.1 _______________________________________________ U-Boot mailing list [email protected] http://lists.denx.de/mailman/listinfo/u-boot

