From patchwork Tue Aug 25 07:22:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 510392 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 13BCA1401F0 for ; Tue, 25 Aug 2015 17:20:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Y3EmCmh3; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8FFB4B6B5; Tue, 25 Aug 2015 09:20:37 +0200 (CEST) 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 hQHQIw0MMuPv; Tue, 25 Aug 2015 09:20:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 24CC04B6BB; Tue, 25 Aug 2015 09:20:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 80DA44B65B for ; Tue, 25 Aug 2015 09:20:16 +0200 (CEST) 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 6gZh5Xz0IB0v for ; Tue, 25 Aug 2015 09:20:16 +0200 (CEST) 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 mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by theia.denx.de (Postfix) with ESMTPS id 0714A4B624 for ; Tue, 25 Aug 2015 09:20:13 +0200 (CEST) Received: by pdrh1 with SMTP id h1so64496731pdr.0 for ; Tue, 25 Aug 2015 00:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=QIC4R4FLrivkJJFlDSK49Uoj5KDpZc7cYdNf2684cqc=; b=Y3EmCmh3sFw43gw2Ua6sxYSHGwjHsIbp4pqDoPapXrd2XroOGPpjt/GVsSSFKCeKlI 07ib15rv42sFWunSYhbIsHnd2ILXdovhAuyWHpgrix4hRSG90lqVW9qkgR4caeJDhRVN QUCwBxBTU1FIQzDXO/s+tcOdtt+im7MYGpUWgK04e798oYsVGkvyMudPSYlIvUv96lkJ N00U6dd66O6yHPbom/c3xgJxn4e1IQ1LhC2xnPADyus9j/F/9HvilJJzboC+bSp2j+mJ nKralcKordX7jy28xE2gQomfreFcbpi4FzIWVBWbLxaqfpN9oA6r0xcvhks/VSHxJXef +U6Q== X-Received: by 10.70.46.133 with SMTP id v5mr53059100pdm.110.1440487211795; Tue, 25 Aug 2015 00:20:11 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id wj8sm8911367pab.3.2015.08.25.00.20.11 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Aug 2015 00:20:11 -0700 (PDT) From: Bin Meng To: Simon Glass , Joe Hershberger , Tom Rini , U-Boot Mailing List Date: Tue, 25 Aug 2015 00:22:22 -0700 Message-Id: <1440487347-10517-4-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1440487347-10517-1-git-send-email-bmeng.cn@gmail.com> References: <1440487347-10517-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH 4/9] dm: eth: Correctly detect alias in eth_get_dev_by_name() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When given a device name string, we should test if it contains "eth" before we treat it as an alias. With this commit, now we are really able to rotate between network interfaces with driver model (previously it was broken). Signed-off-by: Bin Meng --- net/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/eth.c b/net/eth.c index 0b4b08a..fbf30b0 100644 --- a/net/eth.c +++ b/net/eth.c @@ -197,7 +197,7 @@ struct udevice *eth_get_dev_by_name(const char *devname) struct uclass *uc; /* Must be longer than 3 to be an alias */ - if (strlen(devname) > strlen("eth")) { + if (strstr(devname, "eth") && strlen(devname) > strlen("eth")) { startp = devname + strlen("eth"); seq = simple_strtoul(startp, &endp, 10); }