From nobody Sat Oct 4 06:29:31 2025 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E0EC277C9A; Wed, 20 Aug 2025 01:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755654887; cv=none; b=l2hJtBnWpCGkDxTHCofSBRlTnEtlBEDr7e5P+Ha4h2ANbm5Yj9PPsaLpwOFeYOzna4/VCP7bozP3nEmZ5Xz/gjO6hINuVwAKxqCOR/tg16QAWRW8CmeohA5VRTw08NX6jZazpee+7xyipn/X3KMmCdvEI3XhxYjmJAsvYALBj00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755654887; c=relaxed/simple; bh=PjUtVnwdc4FwlZjkMAy+ZNX6PX5hFUgVQfTNMaSrIZI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RXNu49052BmtY8nleECmOuK4t6XkitItMGyfcNzF5W89PLyV0UiCVTYhG5ziTRA+WPx1+AxdyLP6gNSrZilV09u3Ei1WsxOZ9R9L1XXlUxZ/6icrMysXe4CGueoMYyuQopxv3CZWkxFDiHfZL4AMRr2649IFofuHXhJFtjtjzew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98.2) (envelope-from ) id 1uoY25-000000006CE-0sWB; Wed, 20 Aug 2025 01:54:33 +0000 Date: Wed, 20 Aug 2025 02:54:28 +0100 From: Daniel Golle To: Hauke Mehrtens , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Philipp Zabel , Russell King , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Andreas Schirm , Lukas Stockmann , Alexander Sverdlin , Peter Christen , Avinash Jayaraman , Bing tao Xu , Liang Xu , Juraj Povazanec , "Fanni (Fang-Yi) Chan" , "Benny (Ying-Tsan) Weng" , "Livia M. Rosu" , John Crispin Subject: [PATCH net-next v3 1/8] net: dsa: lantiq_gswip: deduplicate dsa_switch_ops Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The two instances of struct dsa_switch_ops differ only by their .phylink_get_caps op. Instead of having two instances of dsa_switch_ops, rather just have a pointer to the phylink_get_caps function in struct gswip_hw_info. Signed-off-by: Daniel Golle Reviewed-by: Andrew Lunn Reviewed-by: Vladimir Oltean --- v3: no changes v2: no changes drivers/net/dsa/lantiq_gswip.c | 44 ++++++++++++---------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 6eb3140d4044..1cff938a87ef 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -254,7 +254,8 @@ struct gswip_hw_info { int max_ports; int cpu_port; - const struct dsa_switch_ops *ops; + void (*phylink_get_caps)(struct dsa_switch *ds, int port, + struct phylink_config *config); }; =20 struct xway_gphy_match_data { @@ -1554,6 +1555,14 @@ static void gswip_xrx300_phylink_get_caps(struct dsa= _switch *ds, int port, MAC_10 | MAC_100 | MAC_1000; } =20 +static void gswip_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct gswip_priv *priv =3D ds->priv; + + priv->hw_info->phylink_get_caps(ds, port, config); +} + static void gswip_port_set_link(struct gswip_priv *priv, int port, bool li= nk) { u32 mdio_phy; @@ -1826,30 +1835,7 @@ static const struct phylink_mac_ops gswip_phylink_ma= c_ops =3D { .mac_link_up =3D gswip_phylink_mac_link_up, }; =20 -static const struct dsa_switch_ops gswip_xrx200_switch_ops =3D { - .get_tag_protocol =3D gswip_get_tag_protocol, - .setup =3D gswip_setup, - .port_enable =3D gswip_port_enable, - .port_disable =3D gswip_port_disable, - .port_bridge_join =3D gswip_port_bridge_join, - .port_bridge_leave =3D gswip_port_bridge_leave, - .port_fast_age =3D gswip_port_fast_age, - .port_vlan_filtering =3D gswip_port_vlan_filtering, - .port_vlan_add =3D gswip_port_vlan_add, - .port_vlan_del =3D gswip_port_vlan_del, - .port_stp_state_set =3D gswip_port_stp_state_set, - .port_fdb_add =3D gswip_port_fdb_add, - .port_fdb_del =3D gswip_port_fdb_del, - .port_fdb_dump =3D gswip_port_fdb_dump, - .port_change_mtu =3D gswip_port_change_mtu, - .port_max_mtu =3D gswip_port_max_mtu, - .phylink_get_caps =3D gswip_xrx200_phylink_get_caps, - .get_strings =3D gswip_get_strings, - .get_ethtool_stats =3D gswip_get_ethtool_stats, - .get_sset_count =3D gswip_get_sset_count, -}; - -static const struct dsa_switch_ops gswip_xrx300_switch_ops =3D { +static const struct dsa_switch_ops gswip_switch_ops =3D { .get_tag_protocol =3D gswip_get_tag_protocol, .setup =3D gswip_setup, .port_enable =3D gswip_port_enable, @@ -1866,7 +1852,7 @@ static const struct dsa_switch_ops gswip_xrx300_switc= h_ops =3D { .port_fdb_dump =3D gswip_port_fdb_dump, .port_change_mtu =3D gswip_port_change_mtu, .port_max_mtu =3D gswip_port_max_mtu, - .phylink_get_caps =3D gswip_xrx300_phylink_get_caps, + .phylink_get_caps =3D gswip_phylink_get_caps, .get_strings =3D gswip_get_strings, .get_ethtool_stats =3D gswip_get_ethtool_stats, .get_sset_count =3D gswip_get_sset_count, @@ -2129,7 +2115,7 @@ static int gswip_probe(struct platform_device *pdev) priv->ds->dev =3D dev; priv->ds->num_ports =3D priv->hw_info->max_ports; priv->ds->priv =3D priv; - priv->ds->ops =3D priv->hw_info->ops; + priv->ds->ops =3D &gswip_switch_ops; priv->ds->phylink_mac_ops =3D &gswip_phylink_mac_ops; priv->dev =3D dev; mutex_init(&priv->pce_table_lock); @@ -2230,13 +2216,13 @@ static void gswip_shutdown(struct platform_device *= pdev) static const struct gswip_hw_info gswip_xrx200 =3D { .max_ports =3D 7, .cpu_port =3D 6, - .ops =3D &gswip_xrx200_switch_ops, + .phylink_get_caps =3D gswip_xrx200_phylink_get_caps, }; =20 static const struct gswip_hw_info gswip_xrx300 =3D { .max_ports =3D 7, .cpu_port =3D 6, - .ops =3D &gswip_xrx300_switch_ops, + .phylink_get_caps =3D gswip_xrx300_phylink_get_caps, }; =20 static const struct of_device_id gswip_of_match[] =3D { --=20 2.50.1