drivers/bch: Adjust f_pos with the correct value
Fix the problem reported by: https://github.com/apache/incubator-nuttx/issues/6619 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
3276438984
commit
02ea79365a
@ -294,7 +294,7 @@ static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|||||||
{
|
{
|
||||||
FAR struct inode *inode = filep->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret;
|
ssize_t ret;
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
bch = (FAR struct bchlib_s *)inode->i_private;
|
bch = (FAR struct bchlib_s *)inode->i_private;
|
||||||
@ -302,13 +302,13 @@ static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|||||||
ret = bchlib_semtake(bch);
|
ret = bchlib_semtake(bch);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return (ssize_t)ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bchlib_read(bch, buffer, filep->f_pos, len);
|
ret = bchlib_read(bch, buffer, filep->f_pos, len);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
filep->f_pos += len;
|
filep->f_pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bchlib_semgive(bch);
|
bchlib_semgive(bch);
|
||||||
@ -324,7 +324,7 @@ static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
{
|
{
|
||||||
FAR struct inode *inode = filep->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret = -EACCES;
|
ssize_t ret = -EACCES;
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
bch = (FAR struct bchlib_s *)inode->i_private;
|
bch = (FAR struct bchlib_s *)inode->i_private;
|
||||||
@ -334,13 +334,13 @@ static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
ret = bchlib_semtake(bch);
|
ret = bchlib_semtake(bch);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return (ssize_t)ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bchlib_write(bch, buffer, filep->f_pos, len);
|
ret = bchlib_write(bch, buffer, filep->f_pos, len);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
filep->f_pos += len;
|
filep->f_pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bchlib_semgive(bch);
|
bchlib_semgive(bch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user