From 1d19c6abe3552cc26d434cadd4f16f7bd3bc88ea Mon Sep 17 00:00:00 2001 From: ChenChuang Date: Fri, 17 May 2024 16:19:42 +0800 Subject: [PATCH] fix: call rwb->rhreload() when nblocks > 0 There is no need to call rwb->rhreloade() when nblocks is 0, and some platform(eg: BES) has the limit that the parameter of len in pltatform flash read function cant't be 0. --- drivers/misc/rwbuffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/misc/rwbuffer.c b/drivers/misc/rwbuffer.c index 4975227c69..8e57625dcf 100644 --- a/drivers/misc/rwbuffer.c +++ b/drivers/misc/rwbuffer.c @@ -352,8 +352,8 @@ static ssize_t rwb_writebuffer(FAR struct rwbuffer_s *rwb, padblocks = startblock % rwb->wralignblocks; rwb->wrblockstart = startblock - padblocks; - rwb_read_(rwb, rwb->wrblockstart, padblocks, rwb->wrbuffer); rwb->wrnblocks = padblocks; + rwb_read_(rwb, rwb->wrblockstart, padblocks, rwb->wrbuffer); if (remain > rwb->wrmaxblocks - padblocks) { @@ -977,7 +977,10 @@ static ssize_t rwb_read_(FAR struct rwbuffer_s *rwb, off_t startblock, * the user buffer. */ - ret = rwb->rhreload(rwb->dev, rdbuffer, startblock, nblocks); + if (nblocks) + { + ret = rwb->rhreload(rwb->dev, rdbuffer, startblock, nblocks); + } } return ret;