From patchwork Thu Mar 30 15:22:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 77230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1209257vqo; Thu, 30 Mar 2023 08:26:09 -0700 (PDT) X-Google-Smtp-Source: AKy350aTSV7iYebXSlG+Db7q2uzqGUbSyU8hTQdMnHzLjTQDVpX95gRZ9CXOGC1vpbeN+qcHnVTb X-Received: by 2002:a17:906:5010:b0:92a:77dd:f6f with SMTP id s16-20020a170906501000b0092a77dd0f6fmr26173484ejj.73.1680189968897; Thu, 30 Mar 2023 08:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680189968; cv=none; d=google.com; s=arc-20160816; b=UJ9OhIofJy+cgDVkhBLB32N05YCg3KWxh57xuTw6PZOA3E0+jDnPeuF9ipaHKyqZre LtRzwZNBWl5qbeOuxU37oxyjID/t7XVuP/oMgecDTtAZCn/MiNiv8n7O+PDDCDcBehll z3Za5hVQuIOXyatVEdwZ31J18XIS0dFE1KxG21KsnpUz7RxA5bmWmUp43Hb17UbnUVnp 9sByn99NUszw3t0t+fLmhgxdVyjSkHGpUHIgALyFaDTj+7fzMKaPJCdppPx91R7FAvHf OPmAdMs5srLA+FawkWJXGKEDsmQ0L1Q6a5L6ikU6SniMeAQ+WXFBWctUDACD9ba5mBQg Z7Fw== 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=t9uimKcjm3fRrvJasPsvHFql22beiZRfNJYtizvIlzI=; b=Y7qEEr4TW7N2/vsUCHblOUKbobi42O919yVK57PffE4W6w7djxkWbhkJhJsEYoDWjF wbvvezApxIRLMyIjrw08kWAIa2rbKiFeqpg7G4OkQQ4PWROxN5hIEsvYO0Bgl20S8Mmv EXbnPF/+ZIx7HODNscaW4nBFBfvUx8YKdGG7oy4OJS8Qd5VOK7J7lz9hw5UgfrjYmBoh KCo6aDXP2tp0U8aUxfBAHFtb2ccrq+OYeQYUQhwX6q5JCDyoCjVBOHzFx9Hm3JZUZpaI NafJGjQGcmvGb8QPfdXrOgg0+3gQswpWDpkQzZ+Rz2zQCSB6Y0PtskwMnkUWyRnJg5KG qBrA== 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 nc38-20020a1709071c2600b009333601858fsi36838787ejc.247.2023.03.30.08.25.37; Thu, 30 Mar 2023 08:26:08 -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 S232989AbjC3PYC (ORCPT + 99 others); Thu, 30 Mar 2023 11:24:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232951AbjC3PXf (ORCPT ); Thu, 30 Mar 2023 11:23:35 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39FACCDC9; Thu, 30 Mar 2023 08:23:13 -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 1phu6W-0006hA-2e; Thu, 30 Mar 2023 17:22:21 +0200 Date: Thu, 30 Mar 2023 16:22:17 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Andrew Lunn , =?utf-8?b?QXI=?= =?utf-8?b?xLFuw6cgw5xuYWw=?= , 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: [PATCH net-next 09/15] net: dsa: mt7530: introduce mt7530_remove_common helper function Message-ID: <81b371db995cf19b670169ab1cdeeaf626ae5390.1680180959.git.daniel@makrotopia.org> 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?1761806876326344697?= X-GMAIL-MSGID: =?utf-8?q?1761806876326344697?= 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. Reviewed-by: Andrew Lunn Signed-off-by: Daniel Golle --- 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 b3a9eb40e45a9..de2fa5df9332c 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -3264,6 +3264,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) { @@ -3283,15 +3294,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)