Bug fixes for BCH and TSC2007 drivers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3921 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
8e123b2832
commit
f23f7fa365
@ -2040,4 +2040,6 @@
|
|||||||
the path to a block driver and then erases the underlying FLASH memory
|
the path to a block driver and then erases the underlying FLASH memory
|
||||||
(assuming that the block driver is an MTD driver wrapped in the FTL
|
(assuming that the block driver is an MTD driver wrapped in the FTL
|
||||||
layer).
|
layer).
|
||||||
|
* drivers/bch: Fixed some important bugs in the BCH driver (noted by
|
||||||
|
Li Zhuoyi (Lzyy)). This would have effected any large reads or writes
|
||||||
|
(larger than the hardware sector size).
|
||||||
|
@ -145,7 +145,9 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le
|
|||||||
len -= nbytes;
|
len -= nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then read all of the full sectors following the partial sector */
|
/* Then read all of the full sectors following the partial sector directly
|
||||||
|
* into the user buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
if (len >= bch->sectsize )
|
if (len >= bch->sectsize )
|
||||||
{
|
{
|
||||||
@ -155,7 +157,8 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le
|
|||||||
nsectors = bch->nsectors - sector;
|
nsectors = bch->nsectors - sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bch->inode->u.i_bops->read(bch->inode, bch->buffer, sector, nsectors);
|
ret = bch->inode->u.i_bops->read(bch->inode, (FAR uint8_t *)buffer,
|
||||||
|
sector, nsectors);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
fdbg("Read failed: %d\n");
|
fdbg("Read failed: %d\n");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/bch/bchlib_write.c
|
* drivers/bch/bchlib_write.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -145,7 +145,9 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
|
|||||||
len -= nbytes;
|
len -= nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then write all of the full sectors following the partial sector */
|
/* Then write all of the full sectors following the partial sector
|
||||||
|
* directly from the user buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
if (len >= bch->sectsize )
|
if (len >= bch->sectsize )
|
||||||
{
|
{
|
||||||
@ -157,10 +159,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
|
|||||||
|
|
||||||
/* Write the contiguous sectors */
|
/* Write the contiguous sectors */
|
||||||
|
|
||||||
ret = bch->inode->u.i_bops->write(bch->inode, bch->buffer, sector, nsectors);
|
ret = bch->inode->u.i_bops->write(bch->inode, (FAR uint8_t *)buffer,
|
||||||
|
sector, nsectors);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
fdbg("Write failed: %d\n");
|
fdbg("Write failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +202,15 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
|
|||||||
byteswritten += len;
|
byteswritten += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Finally, flush any cached writes to the device as well */
|
||||||
|
|
||||||
|
ret = bchlib_flushsector(bch);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
fdbg("Flush failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return byteswritten;
|
return byteswritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ static int tsc2007_transfer(FAR struct tsc2007_dev_s *priv, uint8_t cmd)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ret = (unsigned int)data12[0] << 4 | (unsigned int)data12[1] >> 4;
|
ret = (unsigned int)data12[0] << 4 | (unsigned int)data12[1] >> 4;
|
||||||
ivdbg(&tsc->client->dev, "data: 0x%04x\n", ret);
|
ivdbg("data: 0x%04x\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ static void tsc2007_worker(FAR void *arg)
|
|||||||
pressure = (x * config->rxplate * (z2 - z1)) / z1;
|
pressure = (x * config->rxplate * (z2 - z1)) / z1;
|
||||||
pressure = (pressure + 2048) >> 12;
|
pressure = (pressure + 2048) >> 12;
|
||||||
|
|
||||||
ivdbg("Position: (%d,%4d) pressure: %u z1/2: (%d,%d)\n"
|
ivdbg("Position: (%d,%4d) pressure: %u z1/2: (%d,%d)\n",
|
||||||
x, y, pressure, z1, z2);
|
x, y, pressure, z1, z2);
|
||||||
|
|
||||||
/* Ignore out of range caculcations */
|
/* Ignore out of range caculcations */
|
||||||
@ -1105,9 +1105,9 @@ int tsc2007_register(FAR struct i2c_dev_s *dev,
|
|||||||
|
|
||||||
/* Debug-only sanity checks */
|
/* Debug-only sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(dev != NULL && config != NULL && minor > 0 && minor < 100);
|
DEBUGASSERT(dev != NULL && config != NULL && minor >= 0 && minor < 100);
|
||||||
DEBUGASSERT((config->address & 0xfc) == 0x48);
|
DEBUGASSERT((config->address & 0xfc) == 0x48);
|
||||||
DEBUGASSERT(config->attach != NULL && config->enable != NULL
|
DEBUGASSERT(config->attach != NULL && config->enable != NULL &&
|
||||||
config->clear != NULL && config->pendown != NULL);
|
config->clear != NULL && config->pendown != NULL);
|
||||||
|
|
||||||
/* Create and initialize a TSC2007 device driver instance */
|
/* Create and initialize a TSC2007 device driver instance */
|
||||||
|
Loading…
Reference in New Issue
Block a user