aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorSimon Glass2018-11-06 15:21:39 -0700
committerSimon Glass2018-11-20 19:14:22 -0700
commit8729b1ae2cbda83059a55811614a2b0dbfdf7e53 (patch)
tree65fa9cfd636340f9c9fc97bb3fa76de36c5bf1e2 /drivers/misc
parent96794a3eaee9bf368efe475f0a040d0e08b09dc9 (diff)
misc: Update read() and write() methods to return bytes xfered
At present these functions return 0 on success. For some devices we want to know how many bytes were transferred. It seems useful to adjust the API to be more like the POSIX read() and write() functions. Update these two methods, a test and all users. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/altera_sysid.c2
-rw-r--r--drivers/misc/misc_sandbox.c4
-rw-r--r--drivers/misc/rockchip-efuse.c2
-rw-r--r--drivers/misc/stm32mp_fuse.c12
4 files changed, 16 insertions, 4 deletions
diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c
index 883b2a35e07..eff33f7343d 100644
--- a/drivers/misc/altera_sysid.c
+++ b/drivers/misc/altera_sysid.c
@@ -35,7 +35,7 @@ void display_sysid(void)
if (ret)
return;
ret = misc_read(dev, 0, &sysid, sizeof(sysid));
- if (ret)
+ if (ret < 0)
return;
stamp = sysid[1];
diff --git a/drivers/misc/misc_sandbox.c b/drivers/misc/misc_sandbox.c
index e4164f76fba..f7c5b2e25fa 100644
--- a/drivers/misc/misc_sandbox.c
+++ b/drivers/misc/misc_sandbox.c
@@ -20,7 +20,7 @@ int misc_sandbox_read(struct udevice *dev, int offset, void *buf, int size)
memcpy(buf, priv->mem + offset, size);
- return 0;
+ return size;
}
int misc_sandbox_write(struct udevice *dev, int offset, const void *buf,
@@ -30,7 +30,7 @@ int misc_sandbox_write(struct udevice *dev, int offset, const void *buf,
memcpy(priv->mem + offset, buf, size);
- return 0;
+ return size;
}
int misc_sandbox_ioctl(struct udevice *dev, unsigned long request, void *buf)
diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 8a213c9e270..2520c6a38ed 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -65,7 +65,7 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
}
ret = misc_read(dev, 0, &fuses, sizeof(fuses));
- if (ret) {
+ if (ret < 0) {
printf("%s: misc_read failed\n", __func__);
return 0;
}
diff --git a/drivers/misc/stm32mp_fuse.c b/drivers/misc/stm32mp_fuse.c
index 2d661351a17..33943a231b1 100644
--- a/drivers/misc/stm32mp_fuse.c
+++ b/drivers/misc/stm32mp_fuse.c
@@ -29,6 +29,9 @@ int fuse_read(u32 bank, u32 word, u32 *val)
return ret;
ret = misc_read(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
val, 4);
+ if (ret < 0)
+ return ret;
+ ret = 0;
break;
default:
@@ -54,6 +57,9 @@ int fuse_prog(u32 bank, u32 word, u32 val)
return ret;
ret = misc_write(dev, word * 4 + STM32_BSEC_OTP_OFFSET,
&val, 4);
+ if (ret < 0)
+ return ret;
+ ret = 0;
break;
default:
@@ -78,6 +84,9 @@ int fuse_sense(u32 bank, u32 word, u32 *val)
if (ret)
return ret;
ret = misc_read(dev, word * 4 + STM32_BSEC_OTP_OFFSET, val, 4);
+ if (ret < 0)
+ return ret;
+ ret = 0;
break;
default:
@@ -103,6 +112,9 @@ int fuse_override(u32 bank, u32 word, u32 val)
return ret;
ret = misc_write(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
&val, 4);
+ if (ret < 0)
+ return ret;
+ ret = 0;
break;
default: