[PATCH] board: st: common: update test on misc_read result in command stboard
Update management of misc_read/misc_write, which now returns length of data after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered"): raise a error when the result is not the expected length. Fixes: 658fde8a36ff ("board: stm32mp1: stboard: lock the OTP after programming") Signed-off-by: Patrick Delaunay --- board/st/common/cmd_stboard.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c index 2fba383168..c1ecd643b0 100644 --- a/board/st/common/cmd_stboard.c +++ b/board/st/common/cmd_stboard.c @@ -91,14 +91,14 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc, ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), &otp, sizeof(otp)); - if (ret < 0) { + if (ret != sizeof(otp)) { puts("OTP read error"); return CMD_RET_FAILURE; } ret = misc_read(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), &lock, sizeof(lock)); - if (ret < 0) { + if (ret != sizeof(lock)) { puts("LOCK read error"); return CMD_RET_FAILURE; } @@ -172,7 +172,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc, ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), &otp, sizeof(otp)); - if (ret < 0) { + if (ret != sizeof(otp)) { puts("BOARD programming error\n"); return CMD_RET_FAILURE; } @@ -181,7 +181,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc, otp = 1; ret = misc_write(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), &otp, sizeof(otp)); - if (ret < 0) { + if (ret != sizeof(otp)) { puts("BOARD lock error\n"); return CMD_RET_FAILURE; } -- 2.25.1
Re: [PATCH] board: st: common: update test on misc_read result in command stboard
Hi Patrick On 2/1/22 14:37, Patrick Delaunay wrote: > Update management of misc_read/misc_write, which now returns length of > data after the commit 8729b1ae2cbd ("misc: Update read() and write() > methods to return bytes xfered"): raise a error when the result is not > the expected length. > > Fixes: 658fde8a36ff ("board: stm32mp1: stboard: lock the OTP after > programming") > Signed-off-by: Patrick Delaunay > --- > > board/st/common/cmd_stboard.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c > index 2fba383168..c1ecd643b0 100644 > --- a/board/st/common/cmd_stboard.c > +++ b/board/st/common/cmd_stboard.c > @@ -91,14 +91,14 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, > int argc, > ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), > &otp, sizeof(otp)); > > - if (ret < 0) { > + if (ret != sizeof(otp)) { > puts("OTP read error"); > return CMD_RET_FAILURE; > } > > ret = misc_read(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), > &lock, sizeof(lock)); > - if (ret < 0) { > + if (ret != sizeof(lock)) { > puts("LOCK read error"); > return CMD_RET_FAILURE; > } > @@ -172,7 +172,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, > int argc, > ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), >&otp, sizeof(otp)); > > - if (ret < 0) { > + if (ret != sizeof(otp)) { > puts("BOARD programming error\n"); > return CMD_RET_FAILURE; > } > @@ -181,7 +181,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, > int argc, > otp = 1; > ret = misc_write(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), >&otp, sizeof(otp)); > - if (ret < 0) { > + if (ret != sizeof(otp)) { > puts("BOARD lock error\n"); > return CMD_RET_FAILURE; > } Reviewed-by: Patrice Chotard Thanks Patrice
Re: [Uboot-stm32] [PATCH] board: st: common: update test on misc_read result in command stboard
Hi Patrick On 2/23/22 08:43, Patrice CHOTARD wrote: > Hi Patrick > > On 2/1/22 14:37, Patrick Delaunay wrote: >> Update management of misc_read/misc_write, which now returns length of >> data after the commit 8729b1ae2cbd ("misc: Update read() and write() >> methods to return bytes xfered"): raise a error when the result is not >> the expected length. >> >> Fixes: 658fde8a36ff ("board: stm32mp1: stboard: lock the OTP after >> programming") >> Signed-off-by: Patrick Delaunay >> --- >> >> board/st/common/cmd_stboard.c | 8 >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c >> index 2fba383168..c1ecd643b0 100644 >> --- a/board/st/common/cmd_stboard.c >> +++ b/board/st/common/cmd_stboard.c >> @@ -91,14 +91,14 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, >> int argc, >> ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), >> &otp, sizeof(otp)); >> >> -if (ret < 0) { >> +if (ret != sizeof(otp)) { >> puts("OTP read error"); >> return CMD_RET_FAILURE; >> } >> >> ret = misc_read(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), >> &lock, sizeof(lock)); >> -if (ret < 0) { >> +if (ret != sizeof(lock)) { >> puts("LOCK read error"); >> return CMD_RET_FAILURE; >> } >> @@ -172,7 +172,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, >> int argc, >> ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), >> &otp, sizeof(otp)); >> >> -if (ret < 0) { >> +if (ret != sizeof(otp)) { >> puts("BOARD programming error\n"); >> return CMD_RET_FAILURE; >> } >> @@ -181,7 +181,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, >> int argc, >> otp = 1; >> ret = misc_write(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD), >> &otp, sizeof(otp)); >> -if (ret < 0) { >> +if (ret != sizeof(otp)) { >> puts("BOARD lock error\n"); >> return CMD_RET_FAILURE; >> } > Reviewed-by: Patrice Chotard > > Thanks > Patrice > ___ > Uboot-stm32 mailing list > uboot-st...@st-md-mailman.stormreply.com > https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32 Applied to u-boot-stm32 Thanks Patrice