From nobody Thu Nov 14 17:21:03 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B441C77B73 for ; Wed, 29 Mar 2023 16:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbjC2QA0 (ORCPT ); Wed, 29 Mar 2023 12:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjC2P7m (ORCPT ); Wed, 29 Mar 2023 11:59:42 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E425FCA; Wed, 29 Mar 2023 08:59:12 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1phYCZ-0003PD-0M; Wed, 29 Mar 2023 17:59:07 +0200 Date: Wed, 29 Mar 2023 16:59:03 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Sean Wang , Landen Chao , DENG Qingfang , Philipp Zabel Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [RFC PATCH net-next v3 08/15] net: dsa: mt7530: introduce mt7530_remove_common helper function Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move commonly used parts from mt7530_remove into new mt7530_remove_common helper function which will be used by both, mt7530_remove and the to-be-introduced mt7988_remove. Signed-off-by: Daniel Golle Reviewed-by: Andrew Lunn --- drivers/net/dsa/mt7530.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 32875762b3d96..f84cbd251d1c1 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -3260,6 +3260,17 @@ mt7530_probe(struct mdio_device *mdiodev) return dsa_register_switch(priv->ds); } =20 +static void +mt7530_remove_common(struct mt7530_priv *priv) +{ + if (priv->irq) + mt7530_free_irq(priv); + + dsa_unregister_switch(priv->ds); + + mutex_destroy(&priv->reg_mutex); +} + static void mt7530_remove(struct mdio_device *mdiodev) { @@ -3279,15 +3290,10 @@ mt7530_remove(struct mdio_device *mdiodev) dev_err(priv->dev, "Failed to disable io pwr: %d\n", ret); =20 - if (priv->irq) - mt7530_free_irq(priv); - - dsa_unregister_switch(priv->ds); + mt7530_remove_common(priv); =20 for (i =3D 0; i < 2; ++i) mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs); - - mutex_destroy(&priv->reg_mutex); } =20 static void mt7530_shutdown(struct mdio_device *mdiodev) --=20 2.39.2