From patchwork Mon Apr 3 01:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 78325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2000944vqo; Sun, 2 Apr 2023 18:24:41 -0700 (PDT) X-Google-Smtp-Source: AKy350aZweK+/6svBjzMHgQVHH5kLE7XWFPpYJd0BfZgNckXix65eY0UE4v4zXB1wIz+27KDLJ1f X-Received: by 2002:a62:585:0:b0:592:de72:4750 with SMTP id 127-20020a620585000000b00592de724750mr29004999pff.23.1680485080988; Sun, 02 Apr 2023 18:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680485080; cv=none; d=google.com; s=arc-20160816; b=a0E5fr0ms7dtKcXnAaEoLpGl837vfEhBoahsSfdktczgzddSQsMPqKkMdO+mpZDrsJ ru+vOQTrSqPNu5wZaKVCmboIKhqhVv2cK6XsVTDatSTSgRBQCUb1A12VE0ESb9CMErqG vFwszIheQrmUM5TnlTNqnCeBoigPXCSpOzwkDJbxTS+i2X/rkI81mtgYbNqar469GvCR 6t04x/8KxLa0329iFG3ve0vNHlZFYnI3ZvM9n//mlcueK5ZZpAbZ0wYfxsTfGSiDcyqf vRNCQzKtyMJidoY5Ibl5Av5z2BAZq+UtcFm4aVhivmQBcHhuARWc1VetnUbOAwBu8weR EKGQ== 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=WNg911Z1kbTTjoGXUCudEtZagTPDGtcApyc8O3/lLLM=; b=IOcjpKDq1Qkej/ZRU0j6tabOyZxND0D3y3LIk3jcO5bt3uq89sLAp6SJoDDYDFGKsH wZHQd7fHWm4auLXZb6rBnu4to0tiCahCBj1ZopdQScBmnWsgCDDq8wgz8pB+BREexNuU 54r72dWlZEHmf0i3g6JgtW8DY7CQfUYdA1HlR1EWXAhYgvLKNrgCNygx+eeXCcjsKdTQ /GURRh5MAIvK4yXorhFqJrm1PJAdraBhDDkKZNNLqiDymmokuG1kMDV83ToZiP17Dx7C fDK7vqu17pRFOeRPbgdPdtHMDX7QEHHXGeKzVkmf2+zfHriNwLqVuexO8aMeOImnDVZo AyqQ== 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 i8-20020a056a00004800b0062d81078f89si7332985pfk.202.2023.04.02.18.24.27; Sun, 02 Apr 2023 18:24:40 -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 S231202AbjDCBTf (ORCPT + 99 others); Sun, 2 Apr 2023 21:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbjDCBTb (ORCPT ); Sun, 2 Apr 2023 21:19:31 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B342E5FF4; Sun, 2 Apr 2023 18:18:59 -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 1pj8qV-0004lV-0K; Mon, 03 Apr 2023 03:18:55 +0200 Date: Mon, 3 Apr 2023 02:18:50 +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 , Russell King , =?utf-8?b?QXLEsW7DpyDDnG5hbA==?= Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [PATCH net-next v2 09/14] net: dsa: mt7530: introduce mt7530_remove_common helper function Message-ID: <7a2829bb037d27a57e588fe0157174ee47d37c3b.1680483896.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?1762116323928929329?= X-GMAIL-MSGID: =?utf-8?q?1762116323928929329?= 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 a60ed8706ce35..9404675c47222 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -3259,6 +3259,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) { @@ -3278,15 +3289,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)