summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorandy.hu <andy.hu@starfivetech.com>2023-01-06 09:25:28 +0300
committerandy.hu <andy.hu@starfivetech.com>2023-01-06 09:25:28 +0300
commitea54199468d02c93c2ed1a5a9d4e5e5303feffdd (patch)
tree1612ca24796d9408ca24b8b865fc2cea3842bc93 /drivers
parent84e25a12dcd71e41b7f858de38a744e072fc2491 (diff)
parent4db1f73604cda4a3dc95e130615862ecfd99c1a6 (diff)
downloadu-boot-ea54199468d02c93c2ed1a5a9d4e5e5303feffdd.tar.xz
Merge branch 'CR_3006_OTP_yanhong.wang' into 'jh7110-master'
CR_3006 misc: OTP: Starfive-jh7110: update the return value of starfive_otp_read See merge request sdk/u-boot!21
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/starfive-otp.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/misc/starfive-otp.c b/drivers/misc/starfive-otp.c
index 5fa91582a0..8ff189c35d 100644
--- a/drivers/misc/starfive-otp.c
+++ b/drivers/misc/starfive-otp.c
@@ -116,11 +116,19 @@ static int starfive_otp_read(struct udevice *dev, int offset,
int bytescnt;
int i;
- if (!buf || (offset >= OTP_MEM_SIZE) || (offset & 0x3)) {
- printf("%s:invalid parameter.\n", __func__);
+ if ((size % BYTES_PER_INT) || (offset % BYTES_PER_INT)) {
+ printf("%s: size and offset must be multiple of 4.\n", __func__);
return -EINVAL;
}
+ /* check bounds */
+ if (!buf)
+ return -EINVAL;
+ if (offset >= OTP_MEM_SIZE)
+ return -EINVAL;
+ if ((offset + size) > OTP_MEM_SIZE)
+ return -EINVAL;
+
bytescnt = size / BYTES_PER_INT;
for (i = 0; i < bytescnt; i++) {
@@ -133,7 +141,8 @@ static int starfive_otp_read(struct udevice *dev, int offset,
databuf[i] = data;
offset += 4;
}
- return 0;
+
+ return size;
}
static int starfive_otp_probe(struct udevice *dev)