mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Reserver the name 'err' for other purposes
This commit is contained in:
@@ -320,14 +320,14 @@ static inline void up_configbaud(struct up_dev_s *priv)
|
||||
/* Test values calculated for every multiplier/divisor combination */
|
||||
|
||||
uint32_t tdiv;
|
||||
uint32_t terr;
|
||||
uint32_t tmperr;
|
||||
int tmulval;
|
||||
int tdivaddval;
|
||||
|
||||
/* Optimal multiplier/divider values */
|
||||
|
||||
uint32_t div = 0;
|
||||
uint32_t err = 100000;
|
||||
uint32_t errval = 100000;
|
||||
int mulval = 1;
|
||||
int divaddval = 0;
|
||||
|
||||
@@ -350,13 +350,13 @@ static inline void up_configbaud(struct up_dev_s *priv)
|
||||
|
||||
/* Try every valid multiplier, tmulval (or until a perfect match is found). */
|
||||
|
||||
for (tmulval = 1; tmulval <= 15 && err > 0; tmulval++)
|
||||
for (tmulval = 1; tmulval <= 15 && errval > 0; tmulval++)
|
||||
{
|
||||
/* Try every valid pre-scale div, tdivaddval (or until a perfect match is
|
||||
* found).
|
||||
*/
|
||||
|
||||
for (tdivaddval = 0; tdivaddval <= 15 && err > 0; tdivaddval++)
|
||||
for (tdivaddval = 0; tdivaddval <= 15 && errval > 0; tdivaddval++)
|
||||
{
|
||||
/* Calculate the divisor with these fractional divider settings */
|
||||
|
||||
@@ -373,16 +373,16 @@ static inline void up_configbaud(struct up_dev_s *priv)
|
||||
|
||||
if (actualbaud <= priv->baud)
|
||||
{
|
||||
terr = priv->baud - actualbaud;
|
||||
tmperr = priv->baud - actualbaud;
|
||||
}
|
||||
else
|
||||
{
|
||||
terr = actualbaud - priv->baud;
|
||||
tmperr = actualbaud - priv->baud;
|
||||
}
|
||||
|
||||
/* Is this the smallest error we have encountered? */
|
||||
|
||||
if (terr < err)
|
||||
if (tmperr < errval)
|
||||
{
|
||||
/* Yes, save these settings as the new, candidate optimal
|
||||
* settings
|
||||
@@ -391,7 +391,7 @@ static inline void up_configbaud(struct up_dev_s *priv)
|
||||
mulval = tmulval;
|
||||
divaddval = tdivaddval;
|
||||
div = tdiv;
|
||||
err = terr;
|
||||
errval = tmperr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,14 +144,14 @@ static inline void up_configbaud(void)
|
||||
/* Test values calculated for every multiplier/divisor combination */
|
||||
|
||||
uint32_t tdiv;
|
||||
uint32_t terr;
|
||||
uint32_t tmperr;
|
||||
int tmulval;
|
||||
int tdivaddval;
|
||||
|
||||
/* Optimal multiplier/divider values */
|
||||
|
||||
uint32_t div = 0;
|
||||
uint32_t err = 100000;
|
||||
uint32_t errval = 100000;
|
||||
int mulval = 1;
|
||||
int divaddval = 0;
|
||||
|
||||
@@ -176,13 +176,13 @@ static inline void up_configbaud(void)
|
||||
* match is found).
|
||||
*/
|
||||
|
||||
for (tmulval = 1 ; tmulval <= 15 && err > 0; tmulval++)
|
||||
for (tmulval = 1 ; tmulval <= 15 && errval > 0; tmulval++)
|
||||
{
|
||||
/* Try every valid pre-scale div, tdivaddval (or until a perfect
|
||||
* match is found).
|
||||
*/
|
||||
|
||||
for (tdivaddval = 0 ; tdivaddval <= 15 && err > 0; tdivaddval++)
|
||||
for (tdivaddval = 0 ; tdivaddval <= 15 && errval > 0; tdivaddval++)
|
||||
{
|
||||
/* Calculate the divisor with these fractional divider settings */
|
||||
|
||||
@@ -199,23 +199,23 @@ static inline void up_configbaud(void)
|
||||
|
||||
if (actualbaud <= CONFIG_UART_BAUD)
|
||||
{
|
||||
terr = CONFIG_UART_BAUD - actualbaud;
|
||||
tmperr = CONFIG_UART_BAUD - actualbaud;
|
||||
}
|
||||
else
|
||||
{
|
||||
terr = actualbaud - CONFIG_UART_BAUD;
|
||||
tmperr = actualbaud - CONFIG_UART_BAUD;
|
||||
}
|
||||
|
||||
/* Is this the smallest error we have encountered? */
|
||||
|
||||
if (terr < err)
|
||||
if (tmperr < errval)
|
||||
{
|
||||
/* Yes, save these settings as the new, candidate optimal settings */
|
||||
|
||||
mulval = tmulval ;
|
||||
mulval = tmulval ;
|
||||
divaddval = tdivaddval;
|
||||
div = tdiv;
|
||||
err = terr;
|
||||
errval = tmperr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,14 +215,14 @@ static inline void up_configbaud(void)
|
||||
/* Test values calculated for every multiplier/divisor combination */
|
||||
|
||||
uint32_t tdiv;
|
||||
uint32_t terr;
|
||||
uint32_t tmperr;
|
||||
int tmulval;
|
||||
int tdivaddval;
|
||||
|
||||
/* Optimal multiplier/divider values */
|
||||
|
||||
uint32_t div = 0;
|
||||
uint32_t err = 100000;
|
||||
uint32_t errval = 100000;
|
||||
int mulval = 1;
|
||||
int divaddval = 0;
|
||||
|
||||
@@ -247,13 +247,13 @@ static inline void up_configbaud(void)
|
||||
* match is found).
|
||||
*/
|
||||
|
||||
for (tmulval = 1 ; tmulval <= 15 && err > 0; tmulval++)
|
||||
for (tmulval = 1 ; tmulval <= 15 && errval > 0; tmulval++)
|
||||
{
|
||||
/* Try every valid pre-scale div, tdivaddval (or until a perfect
|
||||
* match is found).
|
||||
*/
|
||||
|
||||
for (tdivaddval = 0 ; tdivaddval <= 15 && err > 0; tdivaddval++)
|
||||
for (tdivaddval = 0 ; tdivaddval <= 15 && errval > 0; tdivaddval++)
|
||||
{
|
||||
/* Calculate the divisor with these fractional divider settings */
|
||||
|
||||
@@ -270,23 +270,23 @@ static inline void up_configbaud(void)
|
||||
|
||||
if (actualbaud <= CONFIG_UART_BAUD)
|
||||
{
|
||||
terr = CONFIG_UART_BAUD - actualbaud;
|
||||
tmperr = CONFIG_UART_BAUD - actualbaud;
|
||||
}
|
||||
else
|
||||
{
|
||||
terr = actualbaud - CONFIG_UART_BAUD;
|
||||
tmperr = actualbaud - CONFIG_UART_BAUD;
|
||||
}
|
||||
|
||||
/* Is this the smallest error we have encountered? */
|
||||
|
||||
if (terr < err)
|
||||
if (tmperr < errval)
|
||||
{
|
||||
/* Yes, save these settings as the new, candidate optimal settings */
|
||||
|
||||
mulval = tmulval ;
|
||||
mulval = tmulval ;
|
||||
divaddval = tdivaddval;
|
||||
div = tdiv;
|
||||
err = terr;
|
||||
errval = tmperr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,50 +785,50 @@ uint32_t spifiGetSubBlockFromBlock(const SPIFI_HANDLE_T *pHandle, uint32_t block
|
||||
SPIFI_ERR_T spifiProgram(const SPIFI_HANDLE_T *pHandle, uint32_t addr, const uint32_t *writeBuff, uint32_t bytes)
|
||||
{
|
||||
uint32_t sendBytes;
|
||||
SPIFI_ERR_T err = SPIFI_ERR_NONE;
|
||||
SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
|
||||
|
||||
/* Program using up to page size */
|
||||
while ((bytes > 0) && (err == SPIFI_ERR_NONE)) {
|
||||
while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) {
|
||||
sendBytes = bytes;
|
||||
if (sendBytes > pHandle->pInfoData->pageSize) {
|
||||
sendBytes = pHandle->pInfoData->pageSize;
|
||||
}
|
||||
|
||||
err = pHandle->pFamFx->pageProgram(pHandle, addr, writeBuff, sendBytes);
|
||||
errcode = pHandle->pFamFx->pageProgram(pHandle, addr, writeBuff, sendBytes);
|
||||
addr += sendBytes;
|
||||
writeBuff += (sendBytes >> 2);
|
||||
bytes -= sendBytes;
|
||||
}
|
||||
|
||||
return err;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/* Read the device into the passed buffer */
|
||||
SPIFI_ERR_T spifiRead(const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes)
|
||||
{
|
||||
uint32_t readBytes;
|
||||
SPIFI_ERR_T err = SPIFI_ERR_NONE;
|
||||
SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
|
||||
|
||||
/* Read using up to the maximum read size */
|
||||
while ((bytes > 0) && (err == SPIFI_ERR_NONE)) {
|
||||
while ((bytes > 0) && (errcode == SPIFI_ERR_NONE)) {
|
||||
readBytes = bytes;
|
||||
if (readBytes > pHandle->pInfoData->maxReadSize) {
|
||||
readBytes = pHandle->pInfoData->maxReadSize;
|
||||
}
|
||||
|
||||
err = pHandle->pFamFx->read(pHandle, addr, readBuff, readBytes);
|
||||
errcode = pHandle->pFamFx->read(pHandle, addr, readBuff, readBytes);
|
||||
addr += readBytes;
|
||||
readBuff += (readBytes / sizeof(uint32_t));
|
||||
bytes -= readBytes;
|
||||
}
|
||||
|
||||
return err;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/* Erase multiple blocks */
|
||||
SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks)
|
||||
{
|
||||
SPIFI_ERR_T err = SPIFI_ERR_NONE;
|
||||
SPIFI_ERR_T errcode = SPIFI_ERR_NONE;
|
||||
|
||||
if ((firstBlock + numBlocks) > pHandle->pInfoData->numBlocks) {
|
||||
return SPIFI_ERR_RANGE;
|
||||
@@ -836,20 +836,20 @@ SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint3
|
||||
|
||||
/* Only perform erase if numBlocks is != 0 */
|
||||
for (; (numBlocks); ++firstBlock, --numBlocks) {
|
||||
err = pHandle->pFamFx->eraseBlock(pHandle, firstBlock);
|
||||
if (err != SPIFI_ERR_NONE) {
|
||||
errcode = pHandle->pFamFx->eraseBlock(pHandle, firstBlock);
|
||||
if (errcode != SPIFI_ERR_NONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/* Erase multiple blocks by address range */
|
||||
SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr)
|
||||
{
|
||||
uint32_t firstBlock, lastBlock;
|
||||
SPIFI_ERR_T err = SPIFI_ERR_RANGE;
|
||||
SPIFI_ERR_T errcode = SPIFI_ERR_RANGE;
|
||||
|
||||
/* Get block numbers for addresses */
|
||||
firstBlock = spifiGetBlockFromAddr(pHandle, firstAddr);
|
||||
@@ -857,8 +857,8 @@ SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr,
|
||||
|
||||
/* Limit to legal address range */
|
||||
if ((firstBlock != ~0UL) && (lastBlock != ~0UL)) {
|
||||
err = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1));
|
||||
errcode = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1));
|
||||
}
|
||||
|
||||
return err;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
+12
-12
@@ -315,11 +315,11 @@ static void up_shutdown(struct uart_dev_s *dev)
|
||||
static int up_attach(struct uart_dev_s *dev)
|
||||
{
|
||||
struct up_dev_s *priv = dev->priv;
|
||||
int err;
|
||||
int errcode;
|
||||
|
||||
err = rgmp_request_irq(priv->irq, &priv->action, 0);
|
||||
errcode = rgmp_request_irq(priv->irq, &priv->action, 0);
|
||||
|
||||
return err;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -578,15 +578,15 @@ void up_earlyserialinit(void)
|
||||
void up_serialinit(void)
|
||||
{
|
||||
uart_dev_t *dev;
|
||||
int err;
|
||||
int errcode;
|
||||
|
||||
#ifdef CONFIG_COM1
|
||||
dev = up_alloc_com(COM1, 4);
|
||||
if (dev == NULL)
|
||||
dbg("alloc com1 fail\n");
|
||||
else {
|
||||
err = uart_register("/dev/ttyS0", dev);
|
||||
if (err)
|
||||
errcode = uart_register("/dev/ttyS0", dev);
|
||||
if (errcode)
|
||||
dbg("register com1 fail\n");
|
||||
}
|
||||
#endif
|
||||
@@ -595,8 +595,8 @@ void up_serialinit(void)
|
||||
if (dev == NULL)
|
||||
dbg("alloc com2 fail\n");
|
||||
else {
|
||||
err = uart_register("/dev/ttyS1", dev);
|
||||
if (err)
|
||||
errcode = uart_register("/dev/ttyS1", dev);
|
||||
if (errcode)
|
||||
dbg("register com2 fail\n");
|
||||
}
|
||||
#endif
|
||||
@@ -605,8 +605,8 @@ void up_serialinit(void)
|
||||
if (dev == NULL)
|
||||
dbg("alloc com3 fail\n");
|
||||
else {
|
||||
err = uart_register("/dev/ttyS2", dev);
|
||||
if (err)
|
||||
errcode = uart_register("/dev/ttyS2", dev);
|
||||
if (errcode)
|
||||
dbg("register com3 fail\n");
|
||||
}
|
||||
#endif
|
||||
@@ -615,8 +615,8 @@ void up_serialinit(void)
|
||||
if (dev == NULL)
|
||||
dbg("alloc com4 fail\n");
|
||||
else {
|
||||
err = uart_register("/dev/ttyS3", dev);
|
||||
if (err)
|
||||
errcode = uart_register("/dev/ttyS3", dev);
|
||||
if (errcode)
|
||||
dbg("register com4 fail\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user