Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp880654rwl; Fri, 7 Apr 2023 06:55:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZzwlfnqxjWKUHhayDcSJZY7n0SEz6oF9y0YeHzzXlD0LP6hcsY93zfA71YyMWoN46ZqwG3 X-Received: by 2002:a17:90b:4f89:b0:231:24c1:8028 with SMTP id qe9-20020a17090b4f8900b0023124c18028mr2837596pjb.29.1680875738464; Fri, 07 Apr 2023 06:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680875738; cv=none; d=google.com; s=arc-20160816; b=dwk29OPp6aXguR5F3K+oSuGdAcA779a2+L5UdazDS+2bzxgWEmy9ro4surl4AzahiD TCofV0Yg9Ux7C2rHz6Vsz+l8xRJA03AS5v1TnZ6LLu7YIjjZS44GkWpI2N5pqh0nNZhu 2a/MKlX7GaUUO3DkU+VrQWE5B0vkg+ALd9HPElXbaaKrWDJ0umHEXckWExF59Ea6WQ2P maix977Yj8bgU80xq7wKpSzzWqPj8wIWwZYJ5V6pvddJQFvct0TWRw1Tzd4N8/oZ0fFa 9pxj4y686NkJ6trpGV7Bdkopv4I163w5gFALr6ze6nlcZey1fhQzysqfvhJt6LpNmCmZ 3G1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wk3K9bbT+tv5kBnVohJcLc2nqRP/uYdhv43DLYVwvrA=; b=gBsESrf+W8Ogr5VmGyCnzamMNqEk3pfsGFSW5vvyXbLo1GtGyh6LKExFAoXQkxKtFe hIOsvD0h87P1iLbEgUFBofuf0e/iKCf4CaPDAfHK4avjzoolTcV/u/i5L3zECULHj6iK N9dAkQK3amYPPIJ3yThaYNxXDvcbZIFzSf27wAynKfcAzYKnf9a+97d69KmCtBsw1lZJ HaDjy/0EQ4zEaW+NCqhQKCxHFk45b9fPHvdJi3Rbca1z3+B4q4OWQOigDrbUfGRWpiH/ f4IYzJ1kMF0YsOxquR3YB9OSH9yXDtzCgskOKbedK1oKwTydosdhWsps1XIHYLvL0FAg 7H7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fRjxo2IW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 76-20020a63034f000000b004fc25858c33si3576389pgd.506.2023.04.07.06.55.26; Fri, 07 Apr 2023 06:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fRjxo2IW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237586AbjDGNus (ORCPT + 99 others); Fri, 7 Apr 2023 09:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbjDGNth (ORCPT ); Fri, 7 Apr 2023 09:49:37 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F6FC177; Fri, 7 Apr 2023 06:47:27 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-54e40113cf3so15928167b3.12; Fri, 07 Apr 2023 06:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680875241; 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=Wk3K9bbT+tv5kBnVohJcLc2nqRP/uYdhv43DLYVwvrA=; b=fRjxo2IWvt0K0aWF+f+Tf9xJkNfm8WGeqv4Fe295l8jhZZax7oguW/1MS97hQV4xEj mnXLBdgAoEP0hELbN0xHJmI94v+bITujHpGafKIL1p0t8KjZrY8/f6HV3i1y39k8lsxL xhPD0Su2OTMk7ob8ZiAS88FmoadArFKiAyiz6rHs6R84tg4J/fqMD0E1iOyUgHL+z9Wr vjETfz0YBwcNSJG3cGLV19YNnMW2Ktpvsjbq5HS9dKphz+RKhqbNLEf3TOL4iYrNyOmh 1wyHPDUUmH+Qe27vNZnnTCFa+O/bTkBIGWjYfldCL+MfHNyyl4MrYOvnOt0eqr1JHLOo RdHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680875241; 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=Wk3K9bbT+tv5kBnVohJcLc2nqRP/uYdhv43DLYVwvrA=; b=fsa+DpqZNMmkhYku9yBkmziKP62xWyH5DdvWLZWIrnQfoWe+bAHgZgEu+OyYqkVkd9 zz+X8UV56rDKFdV2Y+NY+VRBwROBmYaXaxdWO8+pJd6WM6Zwx9r7QPusEGRjBH6jkKh3 we1zzGgXCHgDbdFDGN891MjWP4gBYMWJ2BPrBHNzCVaq41lMOgyyvFXP4pEWUW4uqnvG OyZMX6qcpnqAS12p3HhWyFkFoC1vrNlV3kMCiHBFBY9qcJV78QAZv0XYtpY2iRnUWSjN 73bWhGs8FZZmXx4fT277OB/u0dIN1ZQYS/L3bT0q5p8/wPbp8EndBZ5rYVtCz6TZ63D2 xcIQ== X-Gm-Message-State: AAQBX9cV0ZZm4SogupZLTac/XzDLIj7x//3P9tvUkRwMP41TNTDIZyQ2 ZWclxCEG25hd0PW8XSxUPZo= X-Received: by 2002:a0d:e682:0:b0:53c:d480:f510 with SMTP id p124-20020a0de682000000b0053cd480f510mr1915752ywe.0.1680875240763; Fri, 07 Apr 2023 06:47:20 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id 139-20020a810e91000000b00545a0818473sm1034317ywo.3.2023.04.07.06.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 06:47:20 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC PATCH v2 net-next 10/14] net: dsa: mt7530: switch to if/else statements on mt7530_setup_port6() Date: Fri, 7 Apr 2023 16:46:22 +0300 Message-Id: <20230407134626.47928-11-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230407134626.47928-1-arinc.unal@arinc9.com> References: <20230407134626.47928-1-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arınç ÜNAL This code is from before this driver was converted to phylink API. Phylink deals with the unsupported interface cases before mt7530_setup_port6() is run. Therefore, the default case would never run. However, it must be defined nonetheless to handle all the remaining enumeration values, the phy-modes. Switch to if/else statements which simplifies the code. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 70a673347cf9..fe496d865478 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -404,7 +404,7 @@ static int mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - u32 ncpo1, ssc_delta, trgint, xtal, val; + u32 ncpo1, ssc_delta, xtal, val; val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_P6_DIS; @@ -419,16 +419,18 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) return -EINVAL; } - switch (interface) { - case PHY_INTERFACE_MODE_RGMII: - trgint = 0; - break; - case PHY_INTERFACE_MODE_TRGMII: - trgint = 1; + if (interface == PHY_INTERFACE_MODE_RGMII) { + mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, + P6_INTF_MODE(0)); + } else { + mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, + P6_INTF_MODE(1)); + if (xtal == HWTRAP_XTAL_25MHZ) ssc_delta = 0x57; else ssc_delta = 0x87; + if (priv->id == ID_MT7621) { /* PLL frequency: 150MHz: 1.2GBit */ if (xtal == HWTRAP_XTAL_40MHZ) @@ -441,17 +443,7 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) if (xtal == HWTRAP_XTAL_25MHZ) ncpo1 = 0x1400; } - break; - default: - dev_err(priv->dev, "xMII interface %d not supported\n", - interface); - return -EINVAL; - } - - mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, - P6_INTF_MODE(trgint)); - if (trgint) { /* Disable the MT7530 TRGMII clocks */ core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); -- 2.37.2