From patchwork Wed Aug 7 17:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 817413 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp493017wrt; Wed, 7 Aug 2024 10:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWP59kHPHmkUnphazBSTEsQ+YkVTi40fQi77fjxAG8hfuw1cKMKDh8EHT4EJbPzng7YQmZVijOCJ7OesHulzGh/ X-Google-Smtp-Source: AGHT+IGTJpeIR59KYCxAAqODV/rA3zRo7FPPDM2yq9pv4eBKHeB5kawdZC5k9umshwKg4BtG2wcs X-Received: by 2002:a17:906:6a0a:b0:a7a:bcbc:f7f4 with SMTP id a640c23a62f3a-a807903f9a6mr190560766b.14.1723050820117; Wed, 07 Aug 2024 10:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723050820; cv=none; d=google.com; s=arc-20160816; b=jze8b1W1or4Kbg6nXKQYFA46gxuYa0zDZ4/LVRkoQew82AabTtsiTZiZf5lSbzdkXK hSKGop+twHA+uBCThreyOrtxb+B1wmpfcimfzyeeBVGugjIz9f/K6Q1YLILIkHFLw9Fy vzdZfDLOLTMGkvtEEXBBaZRxjb+peMIwNK9bvgdjekoMAPP5ke0TUiMcG6Gsuw0bacm1 O3JY4Z4D27ifm2MVCHi0wxe5SGXZdOBuVtwIeEhKBLU2lAB1cLmJ+mTL2FYxHckks58X WxNS0kPOdR1YJFID8fxDj1xXCzGIARrTpf8tIlJGzbo0TXvuFbAlSSDsUoBCsIrFujjg JIbg== 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=mEyqG+Iht4weR7bZeLnJvJAHCYj/ay4Bd8uorlogBVo=; fh=B/9drU/Gb3vuGFKdftu08a0R4Q7Ziz+JtdjpbwH8SXg=; b=ENKf8iv71nffcCJjx+vep7ButAU95Q7Vu0mgHlljbWjrIGUQ0wTbJaGJAmgrSIizF7 2+XBbVcKEOWnZPDxACvc1ExuS+OIMjrN9UYji4SRP3ZimjAKFpHGirvo3QaG/5MjLcaK xIw8CdLiLvRvFRi9+yf5eVCCpOCyc+EiwBtEF/hPEqxJPEsHjABU2aVty5pVgbJzeQjQ bAPOgshg4ieh9Xm+BtcoJ/Ii5jhZPUl5ocyDbQGqmjDpZtUom2fvgy+qe8HStVoaGzxu 29h3mIB+mb4sDe6O5FG3r0baPQjYC8n15j8SWSja4CpuARuHkGkkhRitWcfnyh8HPdbQ ZOFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vlEuwBK2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a7dc9bcf121si705695466b.11.2024.08.07.10.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 10:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vlEuwBK2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 9639288BFB; Wed, 7 Aug 2024 19:13:07 +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="vlEuwBK2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14ECB87873; Wed, 7 Aug 2024 19:13:07 +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-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 2451588BFB for ; Wed, 7 Aug 2024 19:13:05 +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-x434.google.com with SMTP id ffacd0b85a97d-368313809a4so711298f8f.0 for ; Wed, 07 Aug 2024 10:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723050784; x=1723655584; 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=mEyqG+Iht4weR7bZeLnJvJAHCYj/ay4Bd8uorlogBVo=; b=vlEuwBK2tdGzwYSyGnPVWCtAhJWIN1Ug/dFXk8inT3wqTHC+8St8MSG4PsFzqSxK3o 3HrXAuMFQAZgGou46iC05dgQmCWKVwXwNgpysRSRNrCcbCx+e0AHr2iwRn+AUYDxPuRn f57e+Xm6lUxHu2z9bBtpq2zBqJrKBFIY2OSmeJmObhCRq7XbiMqI2aA3KtDexBhqCi7T zg0oSyYONX8yaWSGzSomW9EatZ1bulJ6/NwxxYZ385onQtNxZuogM/rsozHfWIqVOASf nVV+7kvyRPLsXbBLlJIoVEmrbzqR4Ou+Q9eKjtAKcEdE1r+JrN6/aVcX39LxKZxV5itT aWSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723050784; x=1723655584; 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=mEyqG+Iht4weR7bZeLnJvJAHCYj/ay4Bd8uorlogBVo=; b=F/wzzEOx9kHsjFQ71wheUVeP530hnID0Rc0X1UPNg99dwLdvvAOMLt0subwkCipQk0 p3SGqpxPZP4zXLiiHsKpftKZzwYy2p11I1Oyw8a+mOvKS/K56bux6fVONPw1FYQ+ZUJa COtcKckbAjqCEpEhQoD0Wwk6uY0KKUVzaVluQaQRpfdKjxK0hSh3nxdt4op8eKTsc71Z 0ntFkAcVnGdDsFBN+5kCsisp5wTYwGAwHB7eydUvwQ1oStNT5Qv8DGnEmw5Gzc8cfMet gW3RefgFXALSP+bzb1IwGYhRqD68PsdvLH56AZuCefRLjBcDTDuxpKfPSOW8IIrwqGOz Gkag== X-Gm-Message-State: AOJu0YwY0/pc/kBeeJHl9xho9f5eHyOnxJcacftTq1Agt50UqfHu04h/ 90jpX6oboqtA5nkSvOpgVOZNzZ4kJWsW+QksZuC4mLAK0KdtnfXEa4roif2Cpj6TmUwyn92ioJm f9UpTuyCs X-Received: by 2002:a5d:6949:0:b0:366:e9f7:4e73 with SMTP id ffacd0b85a97d-36bf0d91f99mr2349676f8f.5.1723050784361; Wed, 07 Aug 2024 10:13:04 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:bb3d:43b8:4780:757c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbd0597b2sm16623781f8f.81.2024.08.07.10.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 10:13:03 -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 , Fabio Estevam , Matthias Schiffer , Marek Vasut , Michal Simek Subject: [PATCH v8 08/23] net: eth-uclass: add function eth_start_udev() Date: Wed, 7 Aug 2024 19:11:52 +0200 Message-Id: <3f19edd18294de99119b361528dd2078f884e6db.1723050310.git.jerome.forissier@linaro.org> 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 ed6dbbf49fa..518e4889ab5 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -148,6 +148,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 {