From patchwork Fri Aug 2 13:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 816234 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp269816wrh; Fri, 2 Aug 2024 06:15:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKHw3/Gbrp0yglN8paq/PJCoA7BEV6viLclOclX4e0G0GgVaOQ3cUYbhQXRBac3pufjG6EAoCfDLI5xuE7o+Vt X-Google-Smtp-Source: AGHT+IEB0zqMmVoXHrOK9odY3+bDFOsZ/iCd8hyHFf4Oil0A5NcCnmYAZwvctKVx3Y11R2ECufxX X-Received: by 2002:a05:6402:14da:b0:5a1:aa6d:9469 with SMTP id 4fb4d7f45d1cf-5b7f5dc6bc2mr2315974a12.38.1722604503153; Fri, 02 Aug 2024 06:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722604503; cv=none; d=google.com; s=arc-20160816; b=Hr13V0TJOqybUc2RjQcN+FwMF09zelT7Tyw3fv3W4yy3Imd8pQoli/VqwDjMtjgS1M /e7oKBB1tCuZFwP2r9ts83Izh/qrWoUByRo0NSI9vNB0hGW77/P/aa9KwxLtYRpLL1mi I78dOQgVA9FMgk8nMRxrP5FwgUvbryjjGxkA+ozJZtY9P98BRJmrKh/0V9+BHzzn0Go/ wRuP/8YQUv+Z4n6jxg8Q/3CGmgQJJrp5CoOjLy+Rbh0ICzYoNpGCIZjT3ZicbtB3dsQT CxInEMG/bCroDjmM96ul5XG6ZMu6MzJ2zXK5y9a3rezax4Scxpgzoaa2sWaw+nMUTNoM TsXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0kc5jErkHDqt4NR8kxa2tZ2WKp4oAlxRMnVV/OhyJiA=; fh=V19aj7452TFPWpSCyVsdBL7WhoTDDEnmEetLYt6vfq0=; b=O1SKyn9O68uQY+TdUgwtnT/zWyutWgrLdcS87+F8w3qXgCfF+INSW2FN9Bo+wRQbgu jPbVZU4MCdSrqmANwtfVaYBX8+AeSohQGbiemiQ2VCeMRGlZlRUEQO8INxB8Uiyln2fZ LV24jjE+aMQjKekJDC8tB5PFsxXxFVqUjN5zucpv4Ehk8AbCrqTDc6B4offIW7P44K7Q zDkdQCo/9MKdRbrsiezeW3JcUjr0XM/b7CS3jHRDvxzhqeWzeJ+09LLCB3SjHx2WHWx8 u4suBdjmgC72vy0r/sNWL+8esIE2NYx9Ugbb36DIO76d4q0GN8PuXf4sStD5QsK1LEfD 2UuQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9m2t1LA; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5b83c5246fcsi1042699a12.484.2024.08.02.06.15.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 06:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9m2t1LA; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CBC788BBF; Fri, 2 Aug 2024 15:14:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A9m2t1LA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 78D3788B9B; Fri, 2 Aug 2024 15:14:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8EBB488BB9 for ; Fri, 2 Aug 2024 15:14:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so3358722f8f.3 for ; Fri, 02 Aug 2024 06:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722604491; x=1723209291; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0kc5jErkHDqt4NR8kxa2tZ2WKp4oAlxRMnVV/OhyJiA=; b=A9m2t1LA5oZn4jJIqlXu0wzEqTx+7Z+A8SXZG95ypW7AZb45DWouRbtsrfmD0M4v/S fWd34fmyKoYHAT/eSzHbt4gmD5VGkabW4IQtQ634CD5xGw6W+8QiZyJ73hVPpmh7liHB nbCaQGrC/027I2vfX8UV3OelV016Y/cdOBoN2X1BmDRp82OsvFvY/G3PoAuZ0xne06Sd aPB+LdoWDUFLHiWqapTWhvABkLJQR347NPli+EA+BaLRBc1xRSod0T9fjZXRlIFuG2XY WqqF4QuTNdAPpDTWb8286EUPtxJ3HtgNCtv2RTttRo9muLfCeN1v0D0O7AZTMFMYhS3A 5Kmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722604491; x=1723209291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kc5jErkHDqt4NR8kxa2tZ2WKp4oAlxRMnVV/OhyJiA=; b=RM2jKKPDf7/ztRYnKvGaEsoQwL5gsxJDvKLHk1DMjueFFEApBwFZmVNzEQf9SRypiu MafFSaWgP7JCrkideHKXCxgOislCyKyIF+q4EyX96Bo5wZJcUG9Y/waamdwED4vSuGkj qO17G1w7QyxOcobujI1Ci7dQ3dFn8rYmpv0Z0ubBee9xtBdiO7hHIbAfWIeAoFCYZVUL ABVSddXCBCJ0nYHvDlcyKoTffhj6+1yPSLeP940jaKAqT1CqBywcXXBSNgboCNbW2Rt9 iMEE6xK48XthctGzMzUUlYXwhYel5PINsoNaf/FY2F6P4a+jxcEvuudpHhpQeIOC9Wxa Pg2Q== X-Gm-Message-State: AOJu0Yz8BW27To/MI6x/MeNY/EhJjSn5zoKC6ArsftyTFJa+MzAcL0+J rb5BVnRErpp0cLB1WCtgI9V/5//RO7RiORPw4VZOKPgYxr5ztdm332mh1KWyxplwBfxA5cdI/EF farH0rkGw X-Received: by 2002:a5d:4d89:0:b0:360:791c:aff2 with SMTP id ffacd0b85a97d-36bbc171338mr2110492f8f.47.1722604490798; Fri, 02 Aug 2024 06:14:50 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:4fc9:a3ab:c134:cdf4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbcf0cc58sm1970304f8f.2.2024.08.02.06.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 06:14:50 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Javier Tia , Raymond Mao , Maxim Uvarov , Tim Harvey , Jerome Forissier , Tom Rini , Joe Hershberger , Ramon Fried , William Zhang , Matthias Schiffer , Michal Simek , Fabio Estevam , Marek Vasut Subject: [PATCH v6 06/20] net: eth-uclass: add function eth_start_udev() Date: Fri, 2 Aug 2024 15:13:53 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a function to start a given network device, and update eth_init() to use it. Signed-off-by: Jerome Forissier Reviewed-by: Tom Rini --- drivers/mtd/altera_qspi.c | 4 ++-- include/net-common.h | 1 + net/eth-uclass.c | 38 +++++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c index c26615821c8..e5c8df750b7 100644 --- a/drivers/mtd/altera_qspi.c +++ b/drivers/mtd/altera_qspi.c @@ -96,7 +96,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) ret = mtd_erase(mtd, &instr); flash_set_verbose(0); if (ret) - return ERR_PROTECTED; + return FL_ERR_PROTECTED; puts(" done\n"); return 0; @@ -114,7 +114,7 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt) ret = mtd_write(mtd, to, cnt, &retlen, src); if (ret) - return ERR_PROTECTED; + return FL_ERR_PROTECTED; return 0; } diff --git a/include/net-common.h b/include/net-common.h index 0c294ad79f1..4f000368609 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -149,6 +149,7 @@ int eth_env_set_enetaddr_by_index(const char *base_name, int index, int usb_ether_init(void); int eth_init(void); /* Initialize the device */ +int eth_start_udev(struct udevice *dev); int eth_send(void *packet, int length); /* Send a packet */ #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) int eth_receive(void *packet, int length); /* Receive a packet*/ diff --git a/net/eth-uclass.c b/net/eth-uclass.c index e34d7af0229..6dd9b9bb98e 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -284,6 +284,27 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op, } U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); +int eth_start_udev(struct udevice *dev) +{ + struct eth_device_priv *priv = dev_get_uclass_priv(dev); + int ret; + + if (priv->running) + return 0; + + if (!device_active(dev)) + return -EINVAL; + + ret = eth_get_ops(dev)->start(dev); + if (ret >= 0) { + priv->state = ETH_STATE_ACTIVE; + priv->running = true; + ret = 0; + } + + return ret; +} + int eth_init(void) { struct udevice *current = NULL; @@ -328,20 +349,11 @@ int eth_init(void) if (current) { debug("Trying %s\n", current->name); - if (device_active(current)) { - ret = eth_get_ops(current)->start(current); - if (ret >= 0) { - struct eth_device_priv *priv = - dev_get_uclass_priv(current); - - priv->state = ETH_STATE_ACTIVE; - priv->running = true; - ret = 0; - goto end; - } - } else { + ret = eth_start_udev(current); + if (ret < 0) ret = eth_errno; - } + else + goto end; debug("FAIL\n"); } else {