From: Loic Poulain <loic.poulain@oss.qualcomm.com>
To: Ulf Hansson <ulfh@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Johannes Berg <johannes@sipsolutions.net>,
Jeff Johnson <jjohnson@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Balakrishna Godavarthi <quic_bgodavar@quicinc.com>,
Rocky Liao <quic_rjliao@quicinc.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Srinivas Kandagatla <srini@kernel.org>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Saravana Kannan <saravanak@kernel.org>,
Christian Marangi <ansuelsmth@gmail.com>
Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-block@vger.kernel.org, linux-wireless@vger.kernel.org,
ath10k@lists.infradead.org, linux-bluetooth@vger.kernel.org,
netdev@vger.kernel.org, daniel@makrotopia.org,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Christoph Hellwig <hch@lst.de>
Subject: [PATCH v10 05/10] block: partitions: of: Attach partition fwnode to the block device
Date: Thu, 06 Aug 2026 16:38:38 +0200 [thread overview]
Message-ID: <20260806-block-as-nvmem-v10-5-be598b2a5606@oss.qualcomm.com> (raw)
In-Reply-To: <20260806-block-as-nvmem-v10-0-be598b2a5606@oss.qualcomm.com>
The OF partition parser reads offset, size and label from each
"fixed-partitions" child node but does not associate that node with the
resulting partition block device. As a result a partition has no
of_node, unlike the whole-disk device which gets its firmware node via
add_disk_fwnode().
Carry the partition's device tree node through the parser and attach it
to the partition's block device with device_set_node(), mirroring the
whole-disk case. This lets consumers describe per-partition properties
in the device tree (for example an NVMEM layout on a partition node) and
look them up through the partition device.
No functional change for existing users, partitions without a matching
device tree node simply get a NULL fwnode.
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
block/partitions/check.h | 1 +
block/partitions/core.c | 20 +++++++++++++++++---
block/partitions/of.c | 3 +++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/block/partitions/check.h b/block/partitions/check.h
index b0997467b61a54a8a621b9c155c8329289649460..326081499d9a6be730dbd659c110449cfa06921f 100644
--- a/block/partitions/check.h
+++ b/block/partitions/check.h
@@ -17,6 +17,7 @@ struct parsed_partitions {
int flags;
bool has_info;
struct partition_meta_info info;
+ struct fwnode_handle *fwnode;
} *parts;
int next;
int limit;
diff --git a/block/partitions/core.c b/block/partitions/core.c
index b5c59b79ca7cbb28d4d93478ee1c80908f76ee9f..eee954df1ac6ef7dd4f02ad5c9d49aed778bf015 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -11,6 +11,7 @@
#include <linux/sysfs.h>
#include <linux/ctype.h>
#include <linux/vmalloc.h>
+#include <linux/property.h>
#include <linux/raid/detect.h>
#include "check.h"
@@ -110,8 +111,17 @@ static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
return state;
}
+static void drop_partitions_fwnodes(struct parsed_partitions *state)
+{
+ for (int i = 0; i < state->limit; i++) {
+ fwnode_handle_put(state->parts[i].fwnode);
+ state->parts[i].fwnode = NULL;
+ }
+}
+
static void free_partitions(struct parsed_partitions *state)
{
+ drop_partitions_fwnodes(state);
vfree(state->parts);
kfree(state);
}
@@ -139,6 +149,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
i = res = err = 0;
while (!res && check_part[i]) {
+ drop_partitions_fwnodes(state);
memset(state->parts, 0, state->limit * sizeof(state->parts[0]));
res = check_part[i++](state);
if (res < 0) {
@@ -247,6 +258,7 @@ static const struct attribute_group *part_attr_groups[] = {
static void part_release(struct device *dev)
{
+ fwnode_handle_put(dev_fwnode(dev));
put_disk(dev_to_bdev(dev)->bd_disk);
bdev_drop(dev_to_bdev(dev));
}
@@ -294,7 +306,8 @@ static const DEVICE_ATTR(whole_disk, 0444, whole_disk_show, NULL);
*/
static struct block_device *add_partition(struct gendisk *disk, int partno,
sector_t start, sector_t len, int flags,
- struct partition_meta_info *info)
+ struct partition_meta_info *info,
+ struct fwnode_handle *fwnode)
{
dev_t devt = MKDEV(0, 0);
struct device *ddev = disk_to_dev(disk);
@@ -343,6 +356,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
pdev->class = &block_class;
pdev->type = &part_type;
pdev->parent = ddev;
+ device_set_node(pdev, fwnode_handle_get(fwnode));
/* in consecutive minor range? */
if (bdev_partno(bdev) < disk->minors) {
@@ -449,7 +463,7 @@ int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
}
part = add_partition(disk, partno, start, length,
- ADDPART_FLAG_NONE, NULL);
+ ADDPART_FLAG_NONE, NULL, NULL);
ret = PTR_ERR_OR_ZERO(part);
out:
mutex_unlock(&disk->open_mutex);
@@ -564,7 +578,7 @@ static bool blk_add_partition(struct gendisk *disk,
}
part = add_partition(disk, p, from, size, state->parts[p].flags,
- &state->parts[p].info);
+ &state->parts[p].info, state->parts[p].fwnode);
if (IS_ERR(part)) {
if (PTR_ERR(part) != -ENXIO) {
printk(KERN_ERR " %s: p%d could not be added: %pe\n",
diff --git a/block/partitions/of.c b/block/partitions/of.c
index dab36513eba336344c9558d486a8915624b0fca8..d4016f9b77ec078eb1adb32923107c012ca4a751 100644
--- a/block/partitions/of.c
+++ b/block/partitions/of.c
@@ -3,6 +3,7 @@
#include <linux/blkdev.h>
#include <linux/major.h>
#include <linux/of.h>
+#include <linux/property.h>
#include <linux/string.h>
#include "check.h"
@@ -65,6 +66,8 @@ static void add_of_partition(struct parsed_partitions *state, int slot,
partname = of_get_property(np, "name", &len);
strscpy(info->volname, partname, sizeof(info->volname));
+ state->parts[slot].fwnode = fwnode_handle_get(of_fwnode_handle(np));
+
seq_buf_printf(&state->pp_buf, "(%s)", info->volname);
}
--
2.34.1
next prev parent reply other threads:[~2026-08-06 14:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 14:38 [PATCH v10 00/10] Support for block device NVMEM providers Loic Poulain
2026-08-06 14:38 ` [PATCH v10 01/10] dt-bindings: mmc: Document fixed-layout NVMEM provider support Loic Poulain
2026-09-04 8:49 ` Ulf Hansson
2026-08-06 14:38 ` [PATCH v10 02/10] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-08-06 14:38 ` [PATCH v10 03/10] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-08-06 14:38 ` [PATCH v10 04/10] nvmem: layouts: Support fixed-layout as the nvmem device node itself Loic Poulain
2026-09-21 9:27 ` Srinivas Kandagatla
2026-08-06 14:38 ` Loic Poulain [this message]
2026-08-06 14:38 ` [PATCH v10 06/10] block: implement NVMEM provider Loic Poulain
2026-08-06 14:38 ` [PATCH v10 07/10] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-08-06 14:38 ` [PATCH v10 08/10] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-08-06 14:38 ` [PATCH v10 09/10] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-08-06 14:38 ` [PATCH v10 10/10] arm64: dts: qcom: arduino-imola: Add NVMEM layout for WiFi/BT Loic Poulain
2026-09-21 9:26 ` (subset) [PATCH v10 00/10] Support for block device NVMEM providers Srinivas Kandagatla
2026-09-25 13:38 ` Loic Poulain
2026-09-25 14:10 ` Jeff Johnson
2026-09-25 18:42 ` Loic Poulain
2026-09-25 22:22 ` Jeff Johnson
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=20260806-block-as-nvmem-v10-5-be598b2a5606@oss.qualcomm.com \
--to=loic.poulain@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=ath10k@lists.infradead.org \
--cc=axboe@kernel.dk \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hch@lst.de \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=jjohnson@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_bgodavar@quicinc.com \
--cc=quic_rjliao@quicinc.com \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
--cc=srini@kernel.org \
--cc=ulfh@kernel.org \
/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