drivers/bch, pipes, timers: Run drivers through tools/nxstyle, correcting as many complaints as possible.

This commit is contained in:
Gregory Nutt 2019-12-06 23:36:33 -06:00
parent d1584d60a2
commit 2761279839
10 changed files with 95 additions and 72 deletions

View file

@ -194,22 +194,22 @@ static int bch_close(FAR struct file *filep)
if (bch->refs == 0 && bch->unlinked)
{
/* Tear the driver down now. */
/* Tear the driver down now. */
ret = bchlib_teardown((FAR void *)bch);
ret = bchlib_teardown((FAR void *)bch);
/* bchlib_teardown() would only fail if there are outstanding
* references on the device. Since we know that is not true, it
* should not fail at all.
*/
/* bchlib_teardown() would only fail if there are outstanding
* references on the device. Since we know that is not true, it
* should not fail at all.
*/
DEBUGASSERT(ret >= 0);
if (ret >= 0)
{
/* Return without releasing the stale semaphore */
DEBUGASSERT(ret >= 0);
if (ret >= 0)
{
/* Return without releasing the stale semaphore */
return OK;
}
return OK;
}
}
}
@ -250,6 +250,7 @@ static off_t bch_seek(FAR struct file *filep, off_t offset, int whence)
break;
default:
/* Return EINVAL if the whence argument is invalid */
bchlib_semgive(bch);

View file

@ -65,8 +65,7 @@
*
* Description:
* Unregister character driver access to a block device that was created
/
* by a previous call to bchdev_register().
* by a previous call to bchdev_register().
*
****************************************************************************/

View file

@ -189,11 +189,13 @@ int bchlib_readsector(FAR struct bchlib_s *bch, size_t sector)
{
ferr("Read failed: %d\n");
}
bch->sector = sector;
#if defined(CONFIG_BCH_ENCRYPTION)
bch_cypher(bch, CYPHER_DECRYPT);
#endif
}
return (int)ret;
}

View file

@ -177,12 +177,12 @@ FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize)
nxsem_init(&dev->d_rdsem, 0, 0);
nxsem_init(&dev->d_wrsem, 0, 0);
/* The read/write wait semaphores are used for signaling and, hence,
* should not have priority inheritance enabled.
*/
/* The read/write wait semaphores are used for signaling and, hence,
* should not have priority inheritance enabled.
*/
nxsem_setprotocol(&dev->d_rdsem, SEM_PRIO_NONE);
nxsem_setprotocol(&dev->d_wrsem, SEM_PRIO_NONE);
nxsem_setprotocol(&dev->d_rdsem, SEM_PRIO_NONE);
nxsem_setprotocol(&dev->d_wrsem, SEM_PRIO_NONE);
dev->d_bufsize = bufsize;
}
@ -241,7 +241,6 @@ int pipecommon_open(FAR struct file *filep)
}
}
/* If opened for writing, increment the count of writers on the pipe instance */
if ((filep->f_oflags & O_WROK) != 0)
@ -790,7 +789,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
if (dev == NULL)
{
return -EBADF;
return -EBADF;
}
#endif

View file

@ -320,9 +320,11 @@ void up_timer_getmask(FAR uint64_t *mask)
{
break;
}
*mask = next;
}
}
}
#elif defined(CONFIG_SCHED_TICKLESS)
int up_timer_gettime(FAR struct timespec *ts)
{

View file

@ -466,38 +466,38 @@ static int cs2100_ratio(FAR const struct cs2100_config_s *config)
* a high-precision (b20) value.
*/
if (rudb24 < (1ull << (32+7)))
if (rudb24 < (1ull << (32 + 7)))
{
highmul = false;
/* Brute force! */
if (rudb24 >= (1ull << (32+6)))
if (rudb24 >= (1ull << (32 + 6)))
{
rud = (uint32_t)rudb24 >> 7; /* RUD = RUDb20 / 8 */
rmod = 3; /* Reff = 8 * RUD */
}
else if (rudb24 >= (1ull << (32+5)))
else if (rudb24 >= (1ull << (32 + 5)))
{
rud = (uint32_t)rudb24 >> 6; /* RUD = RUDb20 / 4 */
rmod = 3; /* Reff = 4 * RUD */
}
else if (rudb24 >= (1ull << (32+4)))
else if (rudb24 >= (1ull << (32 + 4)))
{
rud = (uint32_t)rudb24 >> 5; /* RUD = RUDb20 / 2 */
rmod = 1; /* Reff = 2 * RUD */
}
else if (rudb24 >= (1ull << (32+3)))
else if (rudb24 >= (1ull << (32 + 3)))
{
rud = (uint32_t)rudb24 >> 4; /* RUD = RUDb20 */
rmod = 0; /* Reff = RUD */
}
else if (rudb24 >= (1ull << (32+2)))
else if (rudb24 >= (1ull << (32 + 2)))
{
rud = (uint32_t)rudb24 >> 3; /* RUD -> 2*RUDb20 */
rmod = 4; /* Reff = RUD / 2 */
}
else if (rudb24 >= (1ull << (32+1)))
else if (rudb24 >= (1ull << (32 + 1)))
{
rud = (uint32_t)rudb24 >> 2; /* RUD -> 4*RUDb20 */
rmod = 5; /* Reff = RUD / 4 */
@ -518,31 +518,31 @@ static int cs2100_ratio(FAR const struct cs2100_config_s *config)
* a high-multiplication (b12) value.
*/
else if (rudb24 < (1ull << (32+12)))
else if (rudb24 < (1ull << (32 + 12)))
{
highmul = true;
if (rudb24 >= (1ull << (32+11)))
if (rudb24 >= (1ull << (32 + 11)))
{
rud = (uint32_t)rudb24 >> 12; /* RUD = RUDb12 */
rmod = 0; /* Reff = RUD */
}
else if (rudb24 >= (1ull << (32+10)))
else if (rudb24 >= (1ull << (32 + 10)))
{
rud = (uint32_t)rudb24 >> 11; /* RUD = 2*RUDb12 */
rmod = 4; /* Reff = RUD / 2 */
}
else if (rudb24 >= (1ull << (32+9)))
else if (rudb24 >= (1ull << (32 + 9)))
{
rud = (uint32_t)rudb24 >> 10; /* RUD = 4*RUDb12 */
rmod = 5; /* Reff = RUD / 4 */
}
else if (rudb24 >= (1ull << (32+8)))
else if (rudb24 >= (1ull << (32 + 8)))
{
rud = (uint32_t)rudb24 >> 9; /* RUD = 8*RUDb12 */
rmod = 6; /* Reff = RUD / 8 */
}
else /* if (rudb24 >= (1ull << (32+7))) */
else /* if (rudb24 >= (1ull << (32 + 7))) */
{
rud = (uint32_t)rudb24 >> 8; /* RUD = 16*RUDb12 */
rmod = 7; /* Reff = RUD / 16 */
@ -739,19 +739,20 @@ int cs2100_disable(FAR const struct cs2100_config_s *config)
return ret;
}
/********************************************************************************************
/****************************************************************************
* Name: cs2100_dump
*
* Description:
* Dump CS2100-CP registers to the SysLog
*
* Input Parameters:
* config - CS2100-CP configuration (Needed only for I2C access: i2c and i2caddr)
* config - CS2100-CP configuration (Needed only for I2C access: i2c and
* i2caddr)
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
********************************************************************************************/
****************************************************************************/
#ifdef CONFIG_CS2100CP_DEBUG
int cs2100_dump(FAR const struct cs2100_config_s *config)

View file

@ -55,7 +55,9 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration ********************************************************************/
/* This RTC implementation supports only date/time RTC hardware */
#ifndef CONFIG_RTC_DATETIME
@ -80,6 +82,7 @@
/************************************************************************************
* Priviate Types
************************************************************************************/
/* This structure describes the state of the DS3231 chip. Only a single RTC is
* supported.
*/
@ -100,6 +103,7 @@ volatile bool g_rtc_enabled = false;
/************************************************************************************
* Private Data
************************************************************************************/
/* The state of the DS3231 chip. Only a single RTC is supported */
static struct ds3231_dev_s g_ds3231;
@ -329,6 +333,7 @@ int up_rtc_getdatetime(FAR struct tm *tp)
(seconds & DSXXXX_TIME_SEC_BCDMASK));
/* Format the return time */
/* Return seconds (0-61) */
tp->tm_sec = rtc_bcd2bin(buffer[0] & DSXXXX_TIME_SEC_BCDMASK);
@ -427,23 +432,25 @@ int up_rtc_settime(FAR const struct timespec *tp)
newtime++;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n");
return -EINVAL;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n");
return -EINVAL;
}
#else
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n");
return -EINVAL;
}
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n");
return -EINVAL;
}
#endif
rtc_dumptime(&newtm, "New time");
/* Construct the message */
/* Write starting with the seconds regiser */
buffer[0] = DSXXXX_TIME_SECR;

View file

@ -64,6 +64,7 @@
#define MCP794XX_OSCRUN_READ_RETRY 5 /* How many time to read OSCRUN status */
/* Configuration ************************************************************/
/* This RTC implementation supports only date/time RTC hardware */
#ifndef CONFIG_RTC_DATETIME
@ -344,6 +345,7 @@ int up_rtc_getdatetime(FAR struct tm *tp)
(seconds & MCP794XX_RTCSEC_BCDMASK));
/* Format the return time */
/* Return seconds (0-59) */
tp->tm_sec = rtc_bcd2bin(buffer[0] & MCP794XX_RTCSEC_BCDMASK);
@ -431,18 +433,19 @@ int up_rtc_settime(FAR const struct timespec *tp)
newtime++;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n");
return -EINVAL;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n");
return -EINVAL;
}
#else
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n");
return -EINVAL;
}
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n");
return -EINVAL;
}
#endif
rtc_dumptime(&newtm, "New time");
@ -501,6 +504,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
while ((wkday & MCP794XX_RTCWKDAY_OSCRUN) != 0 && retries > 0);
/* Construct the message */
/* Write starting with the seconds register */
buffer[0] = MCP794XX_REG_RTCSEC;

View file

@ -55,7 +55,9 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration ********************************************************************/
/* This RTC implementation supports only date/time RTC hardware */
#ifndef CONFIG_RTC_DATETIME
@ -80,6 +82,7 @@
/************************************************************************************
* Priviate Types
************************************************************************************/
/* This structure describes the state of the PCF85263 chip. Only a single RTC is
* supported.
*/
@ -100,6 +103,7 @@ volatile bool g_rtc_enabled = false;
/************************************************************************************
* Private Data
************************************************************************************/
/* The state of the PCF85263 chip. Only a single RTC is supported */
static struct pcf85263_dev_s g_pcf85263;
@ -328,6 +332,7 @@ int up_rtc_getdatetime(FAR struct tm *tp)
(seconds & PCF85263_RTC_SECONDS_MASK));
/* Format the return time */
/* Return seconds (0-61) */
tp->tm_sec = rtc_bcd2bin(buffer[0] & PCF85263_RTC_SECONDS_MASK);
@ -410,23 +415,25 @@ int up_rtc_settime(FAR const struct timespec *tp)
newtime++;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n")
return -EINVAL;
}
#ifdef CONFIG_LIBC_LOCALTIME
if (localtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: localtime_r failed\n")
return -EINVAL;
}
#else
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n")
return -EINVAL;
}
if (gmtime_r(&newtime, &newtm) == NULL)
{
rtcerr("ERROR: gmtime_r failed\n")
return -EINVAL;
}
#endif
rtc_dumptime(&tm, "New time");
/* Construct the message */
/* Write starting with the 100ths of seconds register */
buffer[0] = PCF85263_RTC_100TH_SECONDS;

View file

@ -454,7 +454,8 @@ static int pwm_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
case PWMIOC_SETCHARACTERISTICS:
{
FAR const struct pwm_info_s *info = (FAR const struct pwm_info_s *)((uintptr_t)arg);
FAR const struct pwm_info_s *info =
(FAR const struct pwm_info_s *)((uintptr_t)arg);
DEBUGASSERT(info != NULL && lower->ops->start != NULL);
pwm_dump("PWMIOC_SETCHARACTERISTICS", info, upper->started);