Skip to contentSkip to conversation

nvmem: Fix read/write access to partition devices

PATCH Applied Stefan Riedmueller 2 participants 2 messages Sep 27, 2019 – Sep 30, 2019 NVMEM framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmem: Fix read/write access to partition devices

Partition devices are not directly associated with the nvmem instance but via their master cdev. Thus reading and writing needs to be handled via the master.

---
 drivers/nvmem/core.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/nvmem/core.c +12 -2
index 25924872efa2..82e9d1996428 100644
@@ -57,9 +57,14 @@ int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
 static ssize_t nvmem_cdev_read(struct cdev *cdev, void *buf, size_t count,
 			       loff_t offset, unsigned long flags)
 {
-	struct nvmem_device *nvmem = container_of(cdev, struct nvmem_device, cdev);
+	struct nvmem_device *nvmem;
 	ssize_t retlen;
 
+	if (!cdev->master)
+		nvmem = container_of(cdev, struct nvmem_device, cdev);
+	else
+		nvmem = container_of(cdev->master, struct nvmem_device, cdev);
+
 	dev_dbg(cdev->dev, "read ofs: 0x%08llx count: 0x%08zx\n",
 		offset, count);
 
@@ -71,9 +76,14 @@ static ssize_t nvmem_cdev_read(struct cdev *cdev, void *buf, size_t count,
 static ssize_t nvmem_cdev_write(struct cdev *cdev, const void *buf, size_t count,
 				loff_t offset, unsigned long flags)
 {
-	struct nvmem_device *nvmem = container_of(cdev, struct nvmem_device, cdev);
+	struct nvmem_device *nvmem;
 	ssize_t retlen;
 
+	if (!cdev->master)
+		nvmem = container_of(cdev, struct nvmem_device, cdev);
+	else
+		nvmem = container_of(cdev->master, struct nvmem_device, cdev);
+
 	dev_dbg(cdev->dev, "write ofs: 0x%08llx count: 0x%08zx\n",
 		offset, count);
 
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 8 lines · Stefan Riedmueller

Partition devices are not directly associated with the nvmem instance but via their master cdev. Thus reading and writing needs to be handled via the master.

---
 drivers/nvmem/core.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox