diff options
author | Stefan Riedmueller <s.riedmueller@phytec.de> | 2019-09-27 10:34:41 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-14 12:52:11 +0200 |
commit | 1c27d11de850da52ce2899ae57cc1e411bc97917 (patch) | |
tree | d555ac8ce02c92cb1161478dbd4724cfd3906bbe /drivers/nvmem | |
parent | 945d9a14097f51428b8f1711b2c3845ff820a7d1 (diff) | |
download | barebox-1c27d11de850da52ce2899ae57cc1e411bc97917.tar.gz barebox-1c27d11de850da52ce2899ae57cc1e411bc97917.tar.xz |
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.
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r-- | drivers/nvmem/core.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 25924872ef..06e1414769 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -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->master, struct nvmem_device, cdev); + else + nvmem = container_of(cdev, 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->master, struct nvmem_device, cdev); + else + nvmem = container_of(cdev, struct nvmem_device, cdev); + dev_dbg(cdev->dev, "write ofs: 0x%08llx count: 0x%08zx\n", offset, count); |