From: Zev Weiss <zev@bewilderbeest.net>
To: linux-mtd@lists.infradead.org
Cc: Zev Weiss <zev@bewilderbeest.net>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Michael Walle <michael@walle.cc>,
Zhen Lei <thunder.leizhen@huawei.com>,
Lee Jones <lee.jones@linaro.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
Tian Tao <tiantao6@hisilicon.com>, Petr Malat <oss@malat.biz>,
Jon Hunter <jonathanh@nvidia.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: core: clear out unregistered devices a bit more
Date: Fri, 15 Oct 2021 11:50:48 -0700 [thread overview]
Message-ID: <20211015185049.3318-1-zev@bewilderbeest.net> (raw)
This allows an MTD device that has been unregistered to be easily
re-registered later without triggering spurious "already registered"
warnings in mtd_device_parse_register() and add_mtd_device().
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
drivers/mtd/mtdcore.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 153229198947..0a0fca737d43 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -747,6 +747,9 @@ int del_mtd_device(struct mtd_info *mtd)
device_unregister(&mtd->dev);
+ /* Clear dev so mtd can be safely re-registered later if desired */
+ memset(&mtd->dev, 0, sizeof(mtd->dev));
+
idr_remove(&mtd_idr, mtd->index);
of_node_put(mtd_get_of_node(mtd));
@@ -1018,8 +1021,10 @@ int mtd_device_unregister(struct mtd_info *master)
{
int err;
- if (master->_reboot)
+ if (master->_reboot) {
unregister_reboot_notifier(&master->reboot_notifier);
+ memset(&master->reboot_notifier, 0, sizeof(master->reboot_notifier));
+ }
if (master->otp_user_nvmem)
nvmem_unregister(master->otp_user_nvmem);
--
2.33.0
next reply other threads:[~2021-10-15 18:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 18:50 Zev Weiss [this message]
2021-11-19 18:48 ` [PATCH] mtd: core: clear out unregistered devices a bit more Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211015185049.3318-1-zev@bewilderbeest.net \
--to=zev@bewilderbeest.net \
--cc=dan.carpenter@oracle.com \
--cc=jonathanh@nvidia.com \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=oss@malat.biz \
--cc=richard@nod.at \
--cc=thunder.leizhen@huawei.com \
--cc=tiantao6@hisilicon.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).