From patchwork Thu Sep 9 09:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 508712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CADCCC4332F for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFDEF61209 for ; Thu, 9 Sep 2021 09:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233617AbhIIJzL (ORCPT ); Thu, 9 Sep 2021 05:55:11 -0400 Received: from mout.gmx.net ([212.227.17.22]:34135 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbhIIJzI (ORCPT ); Thu, 9 Sep 2021 05:55:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631181226; bh=s/Hv4I9PogZdkQVbwtwCM/QWYxj2wQTqldNgJavrJoI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cEIMG72gAiMlxkREfNv0y8646lXORwA0hM4IPDxwf2IziBNYRSoxnEj1uorcgwdj9 EdYXf/vtlovblfDKYsTE211e8xbdMQF53oqwwYc5BL3lj+IK70oYC+Fh8jmWQuqox3 wEKzcFaBzFns+cHFD0pwgsXTMrmtnSBMlOz7aVAw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.119.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M72sJ-1mJ1Yk3tHz-008cns; Thu, 09 Sep 2021 11:53:46 +0200 From: Lino Sanfilippo To: olteanv@gmail.com Cc: p.rosenberger@kunbus.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 2/3] net: dsa: microchip: provide the function ksz_switch_shutdown() Date: Thu, 9 Sep 2021 11:53:23 +0200 Message-Id: <20210909095324.12978-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210909095324.12978-1-LinoSanfilippo@gmx.de> References: <20210909095324.12978-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VscG5hDGP1HJbbSfBbJ2MFcsUsJYwimuUKYpw5D0TDrP6oMrB/E zn2IGBdFjpgnmXaw5zzuvCsRYjR51zZdTf0ONqBUed8m2TcK8yXWwyXyZ9OJKWPR+aM37m+ KtEfHPFa0UL4KBM5y0MoIMXwUhYZIwbb060HTH/76DjOyU7NeMbRGdQgU1b60x3jBLD18Ue w9vxNXbgK46GkmPJRkUyw== X-UI-Out-Filterresults: notjunk:1; V03:K0:9tf3mufsHwg=:3HVGNeYjp6DvIBt2TUvV5+ U65PEKjBzSqCgy7psLlqiY7/MP1UQDaVyNXy5wsSWWruK7chENeqY5kzrlLGDma41ESvD0vRm e9WgMvWXC+py49gkuL71T8/AjhPfgth0XqYhx2hRJ2fRx/ocZpfs8BuCPINp9LHMgt5IOkulI /dL7y6ywNjqB/sR+Qvrskh1j0KSPqhefhZyOrZr5RBuYigT1lY5YyNBu/Z5FArPBYIpZVmbmk RelCUyy7K0AwJQ3C3X7MhLTilIc5J0U44l/Rb86pHZaxDokeBxvN7QTOYib7NugGf9ppcI1CN GXnyGjKVkS+VuQ4nJFurh2zRJg59oNzqo8y/aJrrxB+4uoAU+ngJmAD6HhvE4maacKq3djYBh SF6YCN/0CJP6V+UbN0ROPRW1EqXazBasWcKOVM73hybJ855ufPU6ytJBJj5VXsrbQzm8o6SZn a5g2rO9/R2aZxZ1m93NJKVS8kriMUGu/zYrIXw2uEjwoaMvJmaiMGTRqB297WxBjET8nbVhyG Nz1M3NC2VE22kg7F9I053ZuALNhx7ZFtoEswcOvhDWwb6g4RyW/W8/MolDrZCcGfoWdAmhvGU jwl8mVYDDkC61BKR5Ub+TL9wnb0o/2CeyNuIvM67kOTs0sWq3z+K33YM8iirFXOZeAXZ6eiFb sG262GtfGljpMyi7SMKm3Lnw2+/9QqCCmZKnSjMICLM6pvsuLffQRNmQTRdLAUO/ABXyC4cYD /wXbsKsWuB01qc6l8Nvlohm/5k9coFccHZ9qU3/Nyk233VAmBeAkrd5L3bJERQ+3yQLeIsR6j XOd/c/fqOjL6Ik/DB8Msq/QvkLogO3Oif3IcnvM+UftZfuIBdjjqpt2WSC1pQ1xE0aufxQYOE NrF0XMJbaKdFDDc6Atul0yRY0n8L/rP4ogUSTe887eUdOHtPRJ4lRbf4KUyGHOqCPLMb9u/5t QP1X5cpx2WwnnEjWMY4tJ+FpefZhJ6XdoWkhcVKKPWC8hKoF0nN64yUC9RXQ0vDkeqcEkyet3 NaIE1cCWmXC0I3Qa/8Ug/pa4fCMtatln8T9vXIhBk5ZeSCwFsNe6wJsaCs0FCZ5glC1XxRBQu FpQiT6H6AUvOvg= Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Provide a function ksz_switch_shutdown() which properly shuts down the KSZ switch by stopping the mib_read worker thread and then tearing down the DSA tree. Signed-off-by: Lino Sanfilippo --- drivers/net/dsa/microchip/ksz_common.c | 13 +++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 1542bfb8b5e5..aaa5c45f4823 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -446,6 +446,19 @@ int ksz_switch_register(struct ksz_device *dev, } EXPORT_SYMBOL(ksz_switch_register); +void ksz_switch_shutdown(struct ksz_device *dev) +{ + struct dsa_switch *ds = dev->ds; + + /* timer started */ + if (dev->mib_read_interval) { + cancel_delayed_work_sync(&dev->mib_read); + dev->mib_read_interval = 0; + } + dsa_tree_shutdown(ds->dst); +} +EXPORT_SYMBOL(ksz_switch_shutdown); + void ksz_switch_remove(struct ksz_device *dev) { /* timer started */ diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 1597c63988b4..9986f6c4c1e7 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -143,6 +143,7 @@ struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); int ksz_switch_register(struct ksz_device *dev, const struct ksz_dev_ops *ops); void ksz_switch_remove(struct ksz_device *dev); +void ksz_switch_shutdown(struct ksz_device *dev); int ksz8_switch_register(struct ksz_device *dev); int ksz9477_switch_register(struct ksz_device *dev);