From patchwork Thu Jul 25 12:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 814344 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp379221wrn; Thu, 25 Jul 2024 05:59:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVht8Vl78o4ZkRpOHUr+fd0K5bIEo5n7s8Rpw0THHYvPPleCW5Ch7nXnVc8x5hkMAdnGhhLywbGum/beLSBJgel X-Google-Smtp-Source: AGHT+IFQX0zR9u4DjnpnPbWXELOdzxh+t/GenrihFVPstG+6hEtG4XSaf+5F8o+bXsroRkV2nsqc X-Received: by 2002:a05:6512:3189:b0:52c:1d8a:9716 with SMTP id 2adb3069b0e04-52fd602b3afmr1644229e87.19.1721912343316; Thu, 25 Jul 2024 05:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721912343; cv=none; d=google.com; s=arc-20160816; b=piokRLR6vU9JzpllUM0FqlXM1PZ8F8DgMTN52s4YKLQJOpRdeNn4oeYjMjnFz56Cg9 rHfH5nFLhpi26m4rdG6WVCiF4c6n2Bs9Ngmd+qYVoBq+NDiifbB+a6v4NsLhAC+I93Jc SbV+QGT9CuspzSwV2wZmgq1gbz3NAFq3hoiflRw7DNCcVjWm549tAp+l0TkCRIB107rL xTZWi/snQvvD8oLWA95wafyJ9wKNcZT/ITQBe8mbh9EmMAo2EwoGS0W/8DpCyV0cBwto owxeScXt7pHXzLhp+nw9d3ikIocx/ve86FOT+HxDRxhKWw7r1U+DnzFbg0vABb5sFFMf n+qA== 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=jSxhJAh+xcmIxhFAHlcMOYw5uKJVBcNmalgS9ipvLHI=; fh=u49hDgCjTEcCvkUJQx7nhgthGE7wYryqgIAicnPezP8=; b=trVOVc4jbEGokIv/zS6wJhDw9YyLxKnWbLSgGwSNz9w3rDj9FJks9r3cVe8eh2ihc0 gk3Q8+VgloqbJfBatJUCaVLDU/Gkw0tez62DTjsTM/2UMZT5r3nkdVkabSC8ygU45Axm ZsEtzjrRG0OnhdgiDBUW3m1fBIcgkCl7MgCgYh6HwXz01wICcswwbxrIaS+ZBHuTTD+x JCudinjyn4vS/+cX9XMvG5NwHKJkCwqEExoEubAXR22gIYGk7bqlzdZe96ILalKftUWD gtNPvdaerP+0hNeXf7dngMaN1fLboc+KnYqhQwCKtZcBvBQ8efufSjR0UngixrX6Wjhy 9STw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DNjJQH2J; 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 2adb3069b0e04-52fd5b95513si462504e87.116.2024.07.25.05.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 05:59: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=DNjJQH2J; 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 9854F87CEB; Thu, 25 Jul 2024 14:58:53 +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="DNjJQH2J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7721A87CEB; Thu, 25 Jul 2024 14:58:52 +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-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 3AD30882BE for ; Thu, 25 Jul 2024 14:58:49 +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-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-427cede1e86so7290795e9.0 for ; Thu, 25 Jul 2024 05:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721912328; x=1722517128; 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=jSxhJAh+xcmIxhFAHlcMOYw5uKJVBcNmalgS9ipvLHI=; b=DNjJQH2JzHcq4ps4NKX5wy4CfdFxb8IjCpIHecbA1aY+D8IivXMvMZTiwXXnBbbAsl LDYvmEytHCzvXioOXRX85DEGVoJ9paY+iQDihdjMujCyobeYND23G/GtISMRkg45s129 Mm4f67dT5+6IAYxOfLohPFmGktEPs4HZ3OwCijNvqcRNbtEWPWerhgwVWwZhz9VPa4qr 99RESKPzl/lv7rRzq1mhia9GgqecLasCGNSv6hi7enGKOFEucukTxGDbCZ/IsrsMwS0Q /ZUiJhP9KGiwvJ4uou/8wGBnrsgLiG4G+G9Bqx4KC7tgV7qGZCU27u6x53RKf3KPZe9D UUEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721912328; x=1722517128; 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=jSxhJAh+xcmIxhFAHlcMOYw5uKJVBcNmalgS9ipvLHI=; b=Ak4UBU9d1jlneWIbdPr8mSDSqoy2RGUbs1jXQtR9rYkztkvou7toUlRQ83x6WlCKTJ q6qNUX9T9Y80uNlH/eN4ZKr0id0mM7Y9/CuFtS0PDDIsULcE8M0i6YR2oqVhRwxAdahd guwQTenWwDBGb82x2c5xnFdRPV7UHKJlTvvgFryc6dGtgh2J+DOKQEECYaUJKgo3Bope xsDC5JTXnJW0R5sWanzCXqsNYJyKORZErh/2vTDiE1HiI5WrR36mxTOe90WP8Q9cdCzA o43T3wZuFe3C8dEIY5a5Wclv4iVsEKdb9exPmdH/ri8imJW0dWbFWuQoNOMUI8HmQHD+ lq6g== X-Gm-Message-State: AOJu0YyaLnlIQAyrliOwbbFlxsTP2mstRkCgzvQb14/N4fzEI9v3/0WD MUTLyH6T8+TOkDzccirzcr2Vy+GAFXFhh77Z5sBE+CM9UHvK/u+9NXxT95l04SbhiiimJ0JLgIf nOjB5ww== X-Received: by 2002:a05:600c:5114:b0:426:6eac:8314 with SMTP id 5b1f17b1804b1-42806b5b906mr15322475e9.1.1721912328493; Thu, 25 Jul 2024 05:58:48 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:a701:ef5f:d613:3e14]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4280573fd83sm34765205e9.19.2024.07.25.05.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 05:58:48 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Javier Tia , Raymond Mao , Maxim Uvarov , Jerome Forissier , Tom Rini , Joe Hershberger , Ramon Fried , Matthias Schiffer , Marek Vasut , Michal Simek , Fabio Estevam Subject: [PATCH v5 06/20] net: eth-uclass: add function eth_start_udev() Date: Thu, 25 Jul 2024 14:57:27 +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 etwork device, and update eth_init() to use it. Signed-off-by: Jerome Forissier Reviewed-by: Tom Rini --- include/net-common.h | 1 + net/eth-uclass.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/net-common.h b/include/net-common.h index 29342b6eee5..b9b47197e4a 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 {