From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3AFDAC433EF for ; Thu, 19 May 2022 09:32:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 797FF84281; Thu, 19 May 2022 11:32:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=solid-run.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=solid-run-com.20210112.gappssmtp.com header.i=@solid-run-com.20210112.gappssmtp.com header.b="jVhejGEt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3A4283D9F; Thu, 19 May 2022 11:32:14 +0200 (CEST) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 4BAD683D53 for ; Thu, 19 May 2022 11:32:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=solid-run.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=josua@solid-run.com Received: by mail-wr1-x432.google.com with SMTP id r30so6263661wra.13 for ; Thu, 19 May 2022 02:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solid-run-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3sCNY28Fi1okRLK37GtomT12bTk5fxg8/Pd54r4VRBE=; b=jVhejGEtC25z7tUgso0IIkjXCLCaLqUiSd/0/1mj7p/HLYs5jK3UmezWPZLTR8PRW6 /FNCaPkDmXf7CNPQytBxvr9+5QCyxsbsxiVfGmTK0tsahET2MujfHN9silnlDdm9xE+u 4bL9xKgF6qPml0+QuST9PeeoOvyKZf85kT0YJXbgBS1rZWU/iVvO/p42fJjVwj7gi0MA kU9P3KExX4R4aGuCh6nR/QeO10cipSHk9y0H9rUZWiVtLQkSuzoC3LScK87F7TWdGZMx SmfAVd9fhmxHBu6+IubSPL7O07D/DtSrQ3sBoGy1LJK1UWA9n2ecD0BmqWKhOiGjlwkh hdyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3sCNY28Fi1okRLK37GtomT12bTk5fxg8/Pd54r4VRBE=; b=K1msW7+shx+5baggnny7FYUPM6RGBUa80ab26hogQoblBSH/1S+AykSmjU+XmGkMHU TvTfI+WwvKBkO4Mgdqhmzcv34fS9Ymr+FjLgv0csf2pdAYqAV9/limXmMGt/6wP2g3ay 5vlXBmjj9mHPhGFa3BEePqo8r9YLFu7aEyannyT3+b47+Sr62FFbEnOLgzWISABN2Dec 62r2ihsY5DXMToAT+xSh7Y7A0gqyAH7EP2EBSUN6+MYsmTgxOKTyqLGXRRcYigCmp+zn 1wBGBh++6ld/meXQFvy3omi3IHb6GoRdU4UV2Pz/hJkUDxuHgQ9qgvq4SWJ16vh+fKxK UI+A== X-Gm-Message-State: AOAM533DUdOUvI71miRUonBdr7aZokgSnm/LhV0G4iEqwRHoeK5tVQRm ryPZUU6hMJwra9sGe1pg9mIAlP7H7ouSeeKh X-Google-Smtp-Source: ABdhPJxqOP0aJ5n0nVLeGVr2aU2kOeuaVl05QM7lp8DpJ50gVJP+pmhchpyol4GI2Bf+9PLn/XL1JQ== X-Received: by 2002:a5d:5910:0:b0:20d:6e9:d4e9 with SMTP id v16-20020a5d5910000000b0020d06e9d4e9mr3187281wrd.69.1652952726568; Thu, 19 May 2022 02:32:06 -0700 (PDT) Received: from josua-work.lan (bzq-82-81-222-124.cablep.bezeqint.net. [82.81.222.124]) by smtp.gmail.com with ESMTPSA id q9-20020adf9dc9000000b0020d02ddf4d5sm4390595wre.5.2022.05.19.02.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 02:32:06 -0700 (PDT) From: Josua Mayer To: u-boot@lists.denx.de Cc: alvaro.karsz@solid-run.com, Nate Drude , Josua Mayer , Joe Hershberger , Ramon Fried Subject: [PATCH v2 1/5] phy: adin: fix broken support for adi, phy-mode-override Date: Thu, 19 May 2022 12:31:56 +0300 Message-Id: <20220519093200.20571-2-josua@solid-run.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220519093200.20571-1-josua@solid-run.com> References: <20220519093200.20571-1-josua@solid-run.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean From: Nate Drude Currently, the adin driver fails to compile. The original patch introducing the adin driver used the function phy_get_interface_by_name to support the adi,phy-mode-override property. Unfortunately, a few days before the adin patch was accepted, another patch removed support for phy_get_interface_by_name: https://github.com/u-boot/u-boot/commit/123ca114e07ecf28aa2538748d733e2b22d8b8b5 This patch refactors adin_get_phy_mode_override, implementing the logic in the new function, ofnode_read_phy_mode, from the patch above. Signed-off-by: Nate Drude Tested-by: Josua Mayer Signed-off-by: Josua Mayer --- drivers/net/phy/adin.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index cff841ab3d..e60f288b9b 100644 --- a/drivers/net/phy/adin.c +++ b/drivers/net/phy/adin.c @@ -100,27 +100,27 @@ static u32 adin_get_reg_value(struct phy_device *phydev, * The function gets phy-mode string from property 'adi,phy-mode-override' * and return its index in phy_interface_strings table, or -1 in error case. */ -int adin_get_phy_mode_override(struct phy_device *phydev) +phy_interface_t adin_get_phy_mode_override(struct phy_device *phydev) { ofnode node = phy_get_ofnode(phydev); const char *phy_mode_override; const char *prop_phy_mode_override = "adi,phy-mode-override"; - int override_interface; + int i; phy_mode_override = ofnode_read_string(node, prop_phy_mode_override); if (!phy_mode_override) - return -ENODEV; + return PHY_INTERFACE_MODE_NA; debug("%s: %s = '%s'\n", __func__, prop_phy_mode_override, phy_mode_override); - override_interface = phy_get_interface_by_name(phy_mode_override); + for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) + if (!strcmp(phy_mode_override, phy_interface_strings[i])) + return (phy_interface_t) i; - if (override_interface < 0) - printf("%s: %s = '%s' is not valid\n", - __func__, prop_phy_mode_override, phy_mode_override); + printf("%s: Invalid PHY interface '%s'\n", __func__, phy_mode_override); - return override_interface; + return PHY_INTERFACE_MODE_NA; } static u16 adin_ext_read(struct phy_device *phydev, const u32 regnum) @@ -148,10 +148,10 @@ static int adin_config_rgmii_mode(struct phy_device *phydev) { u16 reg_val; u32 val; - int phy_mode_override = adin_get_phy_mode_override(phydev); + phy_interface_t phy_mode_override = adin_get_phy_mode_override(phydev); - if (phy_mode_override >= 0) { - phydev->interface = (phy_interface_t) phy_mode_override; + if (phy_mode_override != PHY_INTERFACE_MODE_NA) { + phydev->interface = phy_mode_override; } reg_val = adin_ext_read(phydev, ADIN1300_GE_RGMII_CFG); -- 2.35.3