From patchwork Mon Nov 17 08:19:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 411426 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E850514010C for ; Mon, 17 Nov 2014 19:20:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 060BF4B734; Mon, 17 Nov 2014 09:20:32 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tUavszOSBjq8; Mon, 17 Nov 2014 09:20:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B6374B764; Mon, 17 Nov 2014 09:20:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CE07F4B72A for ; Mon, 17 Nov 2014 09:20:04 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2gtqCXOnhC2O for ; Mon, 17 Nov 2014 09:20:04 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by theia.denx.de (Postfix) with ESMTP id D486E4B737 for ; Mon, 17 Nov 2014 09:19:59 +0100 (CET) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile12) with ESMTP id sAH8JnEh000702; Mon, 17 Nov 2014 17:19:49 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili12) with ESMTP id sAH8Jno02321; Mon, 17 Nov 2014 17:19:49 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi14) id sAH8JnZx018896; Mon, 17 Nov 2014 17:19:49 +0900 Received: from poodle by lomi14.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id sAH8JnSs018810; Mon, 17 Nov 2014 17:19:49 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id 7A8952740043; Mon, 17 Nov 2014 17:19:49 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 17 Nov 2014 17:19:42 +0900 Message-Id: <1416212385-23800-6-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416212385-23800-1-git-send-email-yamada.m@jp.panasonic.com> References: <1416212385-23800-1-git-send-email-yamada.m@jp.panasonic.com> Cc: Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH 5/8] dm: core: refactor linker lists lookup code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Acked-by: Simon Glass --- 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) {