diff options
author | Yanhong Wang <yanhong.wang@starfivetech.com> | 2022-12-29 11:53:12 +0300 |
---|---|---|
committer | Yanhong Wang <yanhong.wang@starfivetech.com> | 2023-01-03 05:24:26 +0300 |
commit | 4db1f73604cda4a3dc95e130615862ecfd99c1a6 (patch) | |
tree | efd51a89d1a49f2970f87db0136f2e5b07d0678f /drivers | |
parent | 8a4e190ee227330d340324ea4c4277c702f2ae9b (diff) | |
download | u-boot-4db1f73604cda4a3dc95e130615862ecfd99c1a6.tar.xz |
misc: OTP: Starfive-jh7110: update the return value of starfive_otp_read
Update the return value to match the function prototype definition.
Signed-off-by: Yanhong Wang <yanhong.wang@starfivetech.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/starfive-otp.c | 15 |
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) |