mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
drivers/i2c and drivers/spi: Fix compile if CONFIG_DISABLE_PSEUDOFS_OPERATIONS, fix bad NULL checks
This commit is contained in:
committed by
Gregory Nutt
parent
2da2a79104
commit
b4a5cbb9de
@@ -132,7 +132,7 @@ static const struct file_operations i2cdrvr_fops =
|
|||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
static int i2cdrvr_open(FAR struct file *filep)
|
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;
|
FAR struct i2c_driver_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ static int i2cdrvr_open(FAR struct file *filep)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the count of open references on the RTC driver */
|
/* Increment the count of open references on the driver */
|
||||||
|
|
||||||
priv->crefs++;
|
priv->crefs++;
|
||||||
DEBUGASSERT(priv->crefs > 0);
|
DEBUGASSERT(priv->crefs > 0);
|
||||||
@@ -169,7 +169,7 @@ static int i2cdrvr_open(FAR struct file *filep)
|
|||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
static int i2cdrvr_close(FAR struct file *filep)
|
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;
|
FAR struct i2c_driver_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ static int i2cdrvr_close(FAR struct file *filep)
|
|||||||
return ret;
|
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);
|
DEBUGASSERT(priv->crefs > 0);
|
||||||
priv->crefs--;
|
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)
|
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_driver_s *priv;
|
||||||
FAR struct i2c_transfer_s *transfer;
|
FAR struct i2c_transfer_s *transfer;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
@@ -82,8 +82,10 @@ struct spi_driver_s
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
static int spidrvr_open(FAR struct file *filep);
|
static int spidrvr_open(FAR struct file *filep);
|
||||||
static int spidrvr_close(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,
|
static ssize_t spidrvr_read(FAR struct file *filep, FAR char *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
static ssize_t spidrvr_write(FAR struct file *filep, FAR const char *buffer,
|
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
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
static int spidrvr_open(FAR struct file *filep)
|
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;
|
FAR struct spi_driver_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ static int spidrvr_open(FAR struct file *filep)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the count of open references on the RTC driver */
|
/* Increment the count of open references on the driver */
|
||||||
|
|
||||||
priv->crefs++;
|
priv->crefs++;
|
||||||
DEBUGASSERT(priv->crefs > 0);
|
DEBUGASSERT(priv->crefs > 0);
|
||||||
@@ -168,7 +170,7 @@ static int spidrvr_open(FAR struct file *filep)
|
|||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
static int spidrvr_close(FAR struct file *filep)
|
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;
|
FAR struct spi_driver_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -189,7 +191,7 @@ static int spidrvr_close(FAR struct file *filep)
|
|||||||
return ret;
|
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);
|
DEBUGASSERT(priv->crefs > 0);
|
||||||
priv->crefs--;
|
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)
|
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_driver_s *priv;
|
||||||
FAR struct spi_sequence_s *seq;
|
FAR struct spi_sequence_s *seq;
|
||||||
int ret;
|
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 */
|
/* Get exclusive access to the SPI driver state structure */
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
ret = nxsem_wait(&priv->exclsem);
|
ret = nxsem_wait(&priv->exclsem);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
DEBUGASSERT(ret == -EINTR || ret == -ECANCELED);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Process the IOCTL command */
|
/* Process the IOCTL command */
|
||||||
|
|
||||||
@@ -288,7 +292,9 @@ static int spidrvr_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
nxsem_post(&priv->exclsem);
|
nxsem_post(&priv->exclsem);
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user