Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2297415pxk; Sat, 5 Sep 2020 16:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdCgyZ3/al3ATxwd8PKpDQdGXYzErR7JrdhVAriz952dgPfdzqmLFIJjzOlY6TBfNIRBp0 X-Received: by 2002:a05:6402:483:: with SMTP id k3mr7221102edv.24.1599349689509; Sat, 05 Sep 2020 16:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599349689; cv=none; d=google.com; s=arc-20160816; b=vymSrW+TKRM3mNBTCCddHPQiqGiiFXskQEm5WtNv5f+psLyeJplznVnOZPWr70vEnl MJ9hwz4QlSEYlVYrwtAm4QoGLsTB+E9pkZSxo37oh5RhViKY1vJUGk2bCWCz5Pv+HjGs /ffLQxnhwasqCrz1kqNPczrZGjXRVj6RihQWR4aTvIdCRu31Nfc8R95t252Gt6FkClC5 G3l8+8Q6eM4RS2tUJEO2ZBnwBQx68oeKJ8IsonagVNn6quiFIpvhJ/MRK8A5GBfREdlR qksAzHyJ6z9+U/QjyPxokwVTxv8ne7wjsGdXbGGkRW7pLbv7BTH2YoxXbn+QdPkJ9Kf3 R+vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Q82CxE/eRCjFCBg5lGd4WYnbSoeTpTn1ekeooCtzUFs=; b=qlfuYsXD3qzbyeAzPQ5rxgLwjRgRDQxlil1d45G1xfK1u3tSnLo4IlL0Y3lUjUJhDi Uzl2FR6M/739Omyhxp2/d2QO/K52Qrw5A9cKHlncssV5UW3ziEdxDWDRkzEqGcRCdIL2 DtjU/JBNyt++I07o3V3XA8oyAxVyDp27T5kxNcs++9fLQNbjUPPDQSMmL9qWkTSOR2DS eBKqkKmh7Mt7jP1yJiJL1DiCoT7UYVT5uy9ViWaoNyHWp0JlC+Uj6/Jj4U1KqWoD2t4K 7Y1uUTqLcpsng9+Xwa2y67N4VeCnn1ICfn+RN5B9AnXf9I1s7Du4I+YkXevlnO4sRrV2 9lTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J1v6d2SU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si6664937edr.295.2020.09.05.16.47.43; Sat, 05 Sep 2020 16:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J1v6d2SU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbgIEXrF (ORCPT + 99 others); Sat, 5 Sep 2020 19:47:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgIEXrF (ORCPT ); Sat, 5 Sep 2020 19:47:05 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3D8020760; Sat, 5 Sep 2020 23:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599349624; bh=Jc4C4306EMKNApeBOPwe0aG1NL20wAkllgNlUjKDkF4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=J1v6d2SUgIcy4tmkWlM8Km+S/gablUSqu8w/cx9InbPwTAQNPb4FWvt/4bJ0YpncB OFJFeKFWZtGltJ/Gjp9Uyhiq945U6JhIdfx13gYx/YtysNVHFN+Gw3tsYrQ26edzi8 aUbaI5cAw5O3wuuFcZm9sHdaXZgHjDVRJ3tWrpVc= Date: Sat, 5 Sep 2020 16:47:02 -0700 From: Jakub Kicinski To: Landen Chao Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S . Miller" , Rob Herring , Matthias Brugger , Sean Wang , Philipp Zabel , Russell King , , , , , , , , Subject: Re: [PATCH net-next v3 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware Message-ID: <20200905164702.72edf26c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <3cf9909d7b06346b8aa339c346e19585cccf74c8.1599228079.git.landen.chao@mediatek.com> References: <3cf9909d7b06346b8aa339c346e19585cccf74c8.1599228079.git.landen.chao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Sep 2020 22:21:57 +0800 Landen Chao wrote: > +static bool > +mt7530_phy_mode_supported(struct dsa_switch *ds, int port, > + const struct phylink_link_state *state) > { > struct mt7530_priv *priv = ds->priv; > - u32 mcr_cur, mcr_new; > > switch (port) { > case 0: /* Internal phy */ > @@ -1363,33 +1364,114 @@ static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port, > case 3: > case 4: > if (state->interface != PHY_INTERFACE_MODE_GMII) > - return; > + goto unsupported; return false; Jumping to a label which does nothing but returns makes the code less readable. > break; > case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */ > - if (priv->p5_interface == state->interface) > - break; > if (!phy_interface_mode_is_rgmii(state->interface) && > state->interface != PHY_INTERFACE_MODE_MII && > state->interface != PHY_INTERFACE_MODE_GMII) > - return; > + goto unsupported; > + break; > + case 6: /* 1st cpu port */ > + if (state->interface != PHY_INTERFACE_MODE_RGMII && > + state->interface != PHY_INTERFACE_MODE_TRGMII) > + goto unsupported; > + break; > + default: > + dev_err(priv->dev, "%s: unsupported port: %i\n", __func__, > + port); > + goto unsupported; > + } > + > + return true; > + > +unsupported: > + return false; > +} > +static void > +mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, > + const struct phylink_link_state *state) > +{ > + struct mt7530_priv *priv = ds->priv; > + u32 mcr_cur, mcr_new; > + > + if (!mt753x_phy_mode_supported(ds, port, state)) > + goto unsupported; > + > + switch (port) { > + case 0: /* Internal phy */ > + case 1: > + case 2: > + case 3: > + case 4: case 0 ... 4: > + if (state->interface != PHY_INTERFACE_MODE_GMII) > + goto unsupported; > + break; > + case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */ > + if (priv->p5_interface == state->interface) > + break; > +static void > +mt753x_phylink_validate(struct dsa_switch *ds, int port, > + unsigned long *supported, > + struct phylink_link_state *state) > +{ > + struct mt7530_priv *priv = ds->priv; > __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; Please keep the variables longest to shortest (reverse xmas tree).