mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
fix nxstyle warnings for drivers/analog/adc.c
This commit is contained in:
committed by
Xiang Xiao
parent
3884c96c75
commit
633e539362
+25
-21
@@ -74,7 +74,8 @@ static int adc_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
static int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch,
|
||||
int32_t data);
|
||||
static void adc_notify(FAR struct adc_dev_s *dev);
|
||||
static int adc_poll(FAR struct file *filep, struct pollfd *fds, bool setup);
|
||||
static int adc_poll(FAR struct file *filep, struct pollfd *fds,
|
||||
bool setup);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -103,13 +104,13 @@ static const struct adc_callback_s g_adc_callback =
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: adc_open
|
||||
*
|
||||
* Description:
|
||||
* This function is called whenever the ADC device is opened.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int adc_open(FAR struct file *filep)
|
||||
{
|
||||
@@ -124,8 +125,8 @@ static int adc_open(FAR struct file *filep)
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Increment the count of references to the device. If this the first
|
||||
* time that the driver has been opened for this device, then initialize
|
||||
* the device.
|
||||
* time that the driver has been opened for this device, then
|
||||
* initialize the device.
|
||||
*/
|
||||
|
||||
tmp = dev->ad_ocount + 1;
|
||||
@@ -171,14 +172,14 @@ static int adc_open(FAR struct file *filep)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: adc_close
|
||||
*
|
||||
* Description:
|
||||
* This routine is called when the ADC device is closed.
|
||||
* It waits for the last remaining data to be sent.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int adc_close(FAR struct file *filep)
|
||||
{
|
||||
@@ -207,7 +208,7 @@ static int adc_close(FAR struct file *filep)
|
||||
|
||||
/* Free the IRQ and disable the ADC device */
|
||||
|
||||
flags = enter_critical_section(); /* Disable interrupts */
|
||||
flags = enter_critical_section(); /* Disable interrupts */
|
||||
dev->ad_ops->ao_shutdown(dev); /* Disable the ADC */
|
||||
leave_critical_section(flags);
|
||||
|
||||
@@ -222,7 +223,8 @@ static int adc_close(FAR struct file *filep)
|
||||
* Name: adc_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
static ssize_t adc_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct adc_dev_s *dev = inode->i_private;
|
||||
@@ -299,14 +301,15 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
nread = 0;
|
||||
do
|
||||
{
|
||||
FAR struct adc_msg_s *msg = &dev->ad_recv.af_buffer[dev->ad_recv.af_head];
|
||||
FAR struct adc_msg_s *msg =
|
||||
&dev->ad_recv.af_buffer[dev->ad_recv.af_head];
|
||||
|
||||
/* Will the next message in the FIFO fit into the user buffer? */
|
||||
|
||||
if (nread + msglen > buflen)
|
||||
{
|
||||
/* No.. break out of the loop now with nread equal to the actual
|
||||
* number of bytes transferred.
|
||||
/* No.. break out of the loop now with nread equal to the
|
||||
* actual number of bytes transferred.
|
||||
*/
|
||||
|
||||
break;
|
||||
@@ -326,7 +329,8 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
}
|
||||
else if (msglen == 2)
|
||||
{
|
||||
/* Only one channel, return only the MS 16-bits of the sample.*/
|
||||
/* Only one channel, return only the MS 16-bits of the sample.
|
||||
*/
|
||||
|
||||
int16_t data16 = msg->am_data >> 16;
|
||||
memcpy(&buffer[nread], &data16, 2);
|
||||
@@ -383,8 +387,8 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
}
|
||||
while (dev->ad_recv.af_head != dev->ad_recv.af_tail);
|
||||
|
||||
/* All on the messages have bee transferred. Return the number of bytes
|
||||
* that were read.
|
||||
/* All on the messages have bee transferred. Return the number of
|
||||
* bytes that were read.
|
||||
*/
|
||||
|
||||
ret = nread;
|
||||
@@ -397,9 +401,9 @@ return_with_irqdisabled:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: adc_ioctl
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int adc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
@@ -421,8 +425,8 @@ static int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
|
||||
int nexttail;
|
||||
int errcode = -ENOMEM;
|
||||
|
||||
/* Check if adding this new message would over-run the drivers ability to enqueue
|
||||
* read data.
|
||||
/* Check if adding this new message would over-run the drivers ability to
|
||||
* enqueue read data.
|
||||
*/
|
||||
|
||||
nexttail = fifo->af_tail + 1;
|
||||
@@ -495,9 +499,9 @@ static void adc_notify(FAR struct adc_dev_s *dev)
|
||||
adc_pollnotify(dev, POLLIN);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: adc_poll
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int adc_poll(FAR struct file *filep, struct pollfd *fds, bool setup)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user