drivers/i2c and drivers/spi: Fix compile if CONFIG_DISABLE_PSEUDOFS_OPERATIONS, fix bad NULL checks

This commit is contained in:
Juha Niskanen 2018-03-01 08:36:23 -06:00 committed by Gregory Nutt
parent 2da2a79104
commit b4a5cbb9de
2 changed files with 16 additions and 10 deletions

View File

@ -132,7 +132,7 @@ static const struct file_operations i2cdrvr_fops =
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int i2cdrvr_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct i2c_driver_s *priv;
int ret;
@ -152,7 +152,7 @@ static int i2cdrvr_open(FAR struct file *filep)
return ret;
}
/* Increment the count of open references on the RTC driver */
/* Increment the count of open references on the driver */
priv->crefs++;
DEBUGASSERT(priv->crefs > 0);
@ -169,7 +169,7 @@ static int i2cdrvr_open(FAR struct file *filep)
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int i2cdrvr_close(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct i2c_driver_s *priv;
int ret;
@ -189,7 +189,7 @@ static int i2cdrvr_close(FAR struct file *filep)
return ret;
}
/* Decrement the count of open references on the RTC driver */
/* Decrement the count of open references on the driver */
DEBUGASSERT(priv->crefs > 0);
priv->crefs--;
@ -236,7 +236,7 @@ static ssize_t i2cdrvr_write(FAR struct file *filep, FAR const char *buffer,
static int i2cdrvr_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct i2c_driver_s *priv;
FAR struct i2c_transfer_s *transfer;
int ret;

View File

@ -82,8 +82,10 @@ struct spi_driver_s
* Private Function Prototypes
****************************************************************************/
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int spidrvr_open(FAR struct file *filep);
static int spidrvr_close(FAR struct file *filep);
#endif
static ssize_t spidrvr_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t spidrvr_write(FAR struct file *filep, FAR const char *buffer,
@ -130,7 +132,7 @@ static const struct file_operations spidrvr_fops =
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int spidrvr_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct spi_driver_s *priv;
int ret;
@ -151,7 +153,7 @@ static int spidrvr_open(FAR struct file *filep)
return ret;
}
/* Increment the count of open references on the RTC driver */
/* Increment the count of open references on the driver */
priv->crefs++;
DEBUGASSERT(priv->crefs > 0);
@ -168,7 +170,7 @@ static int spidrvr_open(FAR struct file *filep)
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int spidrvr_close(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct spi_driver_s *priv;
int ret;
@ -189,7 +191,7 @@ static int spidrvr_close(FAR struct file *filep)
return ret;
}
/* Decrement the count of open references on the RTC driver */
/* Decrement the count of open references on the driver */
DEBUGASSERT(priv->crefs > 0);
priv->crefs--;
@ -236,7 +238,7 @@ static ssize_t spidrvr_write(FAR struct file *filep, FAR const char *buffer,
static int spidrvr_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct inode *inode;
FAR struct spi_driver_s *priv;
FAR struct spi_sequence_s *seq;
int ret;
@ -253,12 +255,14 @@ static int spidrvr_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
/* Get exclusive access to the SPI driver state structure */
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
ret = nxsem_wait(&priv->exclsem);
if (ret < 0)
{
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
return ret;
}
#endif
/* Process the IOCTL command */
@ -288,7 +292,9 @@ static int spidrvr_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break;
}
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
nxsem_post(&priv->exclsem);
#endif
return ret;
}