From patchwork Wed Mar 29 15:59:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 76693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp524284vqo; Wed, 29 Mar 2023 09:08:32 -0700 (PDT) X-Google-Smtp-Source: AKy350YdmM4RIQvZRAK13TLXsl5AxkSWDjD4W/lGY++0Idw1FhAoY57/UX3SfaPjx9jjHeGlyaUA X-Received: by 2002:a17:90b:4c08:b0:237:97a3:1479 with SMTP id na8-20020a17090b4c0800b0023797a31479mr22943521pjb.28.1680106111837; Wed, 29 Mar 2023 09:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680106111; cv=none; d=google.com; s=arc-20160816; b=l94tj3iEN3GrGF+y9/x5cRPcvKfKt3vBp022PbyxeMgYs2Wgt8dz0hfm8jaWKyTzEE OO08QMry/QbzLQN4RLVHB2zYPfmOSfkTIgWqDUVjiwGP1v/udze+fa02Gsy7wIifD7Zh Mxg4MQmS/K6vtaNGQCKXEERsqnPmnI0HK3GFzxjsBQxzz50vSvdjSgoE6LNau7AeQ2rj 2XQRFb64D3P6gfw01iyWhdCP/wwadFgwwJYYQr+TM+h2yGIdyohERxJvb5S4WxMpH5cC VS5apnJ2RkI3yB7szoeaKnFPwRLy4KNQWJR4ls/03/nzUTZ+WIyVefuBp+yJvQ5DTVYL MlLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=l+DkvKIc4UikUz+XgK4Ir0YY4PqE6BVizpiJNliG644=; b=N4LhLnWSoOkQXkDSi1585V3SqshWPrxrp54jnIVTVefZiCcOKcuNrECQ5KTPb9QcXr v6EsexygWHkCqg6ddJnOnC3ASCKZsK5djW+bK8dgeQkfBEDkFvWhwEro9H9ZeDSoVKUh fRVZz/jgzJ/xfhIR8/tSVYLK9t/Y4quAfanODWLbmD7ncrh7+fVzXLeeLJWkoLQNLuGj BdNfeM/i31rREOubLBdaxQIEWk3UhKtHyPdiFTbnQnZ8kRPMcKC0kiu+ESixI0Y9Ny5Y jmfVEUunqZlHGdPO8TeymB4bsKoQJW+/6Bf8Nryafn3HDOx4xmtZcA5oG73A+kkuTbR+ Vq5g== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk7-20020a17090b224700b00233ebd4c537si1759036pjb.22.2023.03.29.09.08.18; Wed, 29 Mar 2023 09:08:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbjC2QAZ (ORCPT + 99 others); Wed, 29 Mar 2023 12:00:25 -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: X-Spam-Status: No, score=0.0 required=5.0 tests=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761718946377567648?= X-GMAIL-MSGID: =?utf-8?q?1761718946377567648?= 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); } +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); - if (priv->irq) - mt7530_free_irq(priv); - - dsa_unregister_switch(priv->ds); + mt7530_remove_common(priv); for (i = 0; i < 2; ++i) mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs); - - mutex_destroy(&priv->reg_mutex); } static void mt7530_shutdown(struct mdio_device *mdiodev)