From: Christian Marangi <ansuelsmth@gmail.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Joern Engel <joern@lazybastard.org>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Christian Marangi <ansuelsmth@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-mmc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-nvme@lists.infradead.org
Subject: [PATCH 4/6] block2mtd: attach device OF node to MTD device
Date: Sun, 4 Aug 2024 13:41:04 +0200 [thread overview]
Message-ID: <20240804114108.1893-5-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com>
Attach device OF node to MTD device if defined and the root blockdev is
being used to add support for partitions defined in DT node.
This permits the usage of fixed-partition or alternative parser with the
use of block2mtd module.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/mtd/devices/block2mtd.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index b06c8dd51562..0c4ecea51717 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -324,6 +324,15 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
dev->mtd.priv = dev;
dev->mtd.owner = THIS_MODULE;
+ /*
+ * Check if we are using root blockdev.
+ * If it's the case, connect the MTD of_node to the ddev parent
+ * to support providing partition in DT node.
+ */
+ ddev = disk_to_dev(dev->blkdev->bd_disk);
+ if (ddev == &dev->blkdev->bd_device)
+ dev->mtd.dev.of_node = of_node_get(ddev->parent->of_node);
+
if (mtd_device_register(&dev->mtd, NULL, 0)) {
/* Device didn't get added, so free the entry */
goto err_destroy_mutex;
@@ -337,6 +346,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
return dev;
err_destroy_mutex:
+ of_node_put(dev->mtd.dev.of_node);
mutex_destroy(&dev->write_mutex);
err_free_block2mtd:
block2mtd_free_device(dev);
@@ -515,6 +525,7 @@ static void block2mtd_exit(void)
struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list);
block2mtd_sync(&dev->mtd);
mtd_device_unregister(&dev->mtd);
+ of_node_put(dev->mtd.dev.of_node);
mutex_destroy(&dev->write_mutex);
pr_info("mtd%d: [%s] removed\n",
dev->mtd.index,
--
2.45.2
next prev parent reply other threads:[~2024-08-04 11:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
2024-08-04 11:41 ` [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible Christian Marangi
2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
2024-08-04 13:48 ` kernel test robot
2024-08-04 15:21 ` kernel test robot
2024-08-04 11:41 ` [PATCH 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Christian Marangi
2024-08-04 11:41 ` Christian Marangi [this message]
2024-08-04 13:58 ` [PATCH 4/6] block2mtd: attach device OF node to MTD device kernel test robot
2024-08-04 11:41 ` [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
2024-08-04 12:24 ` Rob Herring (Arm)
2024-08-04 11:41 ` [PATCH 6/6] mtd: parser: add support for Airoha parser Christian Marangi
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=20240804114108.1893-5-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=axboe@kernel.dk \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hch@lst.de \
--cc=joern@lazybastard.org \
--cc=kbusch@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nvme@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=sagi@grimberg.me \
--cc=tsbogend@alpha.franken.de \
--cc=ulf.hansson@linaro.org \
--cc=vigneshr@ti.com \
--cc=wsa+renesas@sang-engineering.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