Call nxsem_destroy or nxmutex_destry in the error path

1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
anjiahao
2022-09-06 14:18:45 +08:00
committed by Petro Karashchenko
parent 99cfffc96a
commit d7b4e91dda
53 changed files with 606 additions and 619 deletions
+1 -1
View File
@@ -379,7 +379,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo,
FAR struct nxflat_hdr_s *hdr; FAR struct nxflat_hdr_s *hdr;
FAR const struct symtab_s *symbol; FAR const struct symtab_s *symbol;
char *symname; FAR char *symname;
uint32_t offset; uint32_t offset;
uint16_t nimports; uint16_t nimports;
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
+3
View File
@@ -363,6 +363,8 @@ int comp_register(FAR const char *path, FAR struct comp_dev_s *dev)
if (ret < 0) if (ret < 0)
{ {
aerr("ERROR: Failed to bind callbacks: %d\n", ret); aerr("ERROR: Failed to bind callbacks: %d\n", ret);
nxmutex_destroy(&dev->ad_lock);
nxsem_destroy(&dev->ad_readsem);
return ret; return ret;
} }
} }
@@ -373,6 +375,7 @@ int comp_register(FAR const char *path, FAR struct comp_dev_s *dev)
if (ret < 0) if (ret < 0)
{ {
nxmutex_destroy(&dev->ad_lock); nxmutex_destroy(&dev->ad_lock);
nxsem_destroy(&dev->ad_readsem);
} }
return ret; return ret;
+1 -6
View File
@@ -331,12 +331,7 @@ int ltc1867l_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
adcpriv->channel_config = channel_config; adcpriv->channel_config = channel_config;
adcpriv->channel_config_count = channel_config_count; adcpriv->channel_config_count = channel_config_count;
ret = nxmutex_init(&adcpriv->lock); nxmutex_init(&adcpriv->lock);
if (ret < 0)
{
kmm_free(adcpriv);
return ret;
}
adcdev = (FAR struct adc_dev_s *)kmm_malloc(sizeof(struct adc_dev_s)); adcdev = (FAR struct adc_dev_s *)kmm_malloc(sizeof(struct adc_dev_s));
if (adcdev == NULL) if (adcdev == NULL)
-2
View File
@@ -1460,7 +1460,5 @@ FAR struct audio_lowerhalf_s *cs4344_initialize(FAR struct i2s_dev_s *i2s)
return &priv->dev; return &priv->dev;
} }
nxmutex_destroy(&priv->pendlock);
kmm_free(priv);
return NULL; return NULL;
} }
+4 -8
View File
@@ -196,7 +196,8 @@ enum can_state_s
struct mcp2515_can_s struct mcp2515_can_s
{ {
struct mcp2515_config_s *config; /* The constant configuration */ FAR struct mcp2515_config_s *config; /* The constant configuration */
uint8_t state; /* See enum can_state_s */ uint8_t state; /* See enum can_state_s */
uint8_t nalloc; /* Number of allocated filters */ uint8_t nalloc; /* Number of allocated filters */
mutex_t lock; /* Enforces mutually exclusive access */ mutex_t lock; /* Enforces mutually exclusive access */
@@ -1182,14 +1183,9 @@ static void mcp2515_reset_lowlevel(FAR struct mcp2515_can_s *priv)
nxsig_usleep(1000); nxsig_usleep(1000);
/* Make sure that all buffers are released. /* Make sure that all buffers are released. */
*
* REVISIT: What if a thread is waiting for a buffer? The following
* will not wake up any waiting threads.
*/
nxsem_destroy(&priv->txfsem); nxsem_reset(&priv->txfsem, MCP2515_NUM_TX_BUFFERS);
nxsem_init(&priv->txfsem, 0, MCP2515_NUM_TX_BUFFERS);
priv->txbuffers = 0b111; priv->txbuffers = 0b111;
/* Define the current state and unlock */ /* Define the current state and unlock */
+1
View File
@@ -1214,6 +1214,7 @@ int ads7843e_register(FAR struct spi_dev_s *spi,
errout_with_priv: errout_with_priv:
nxmutex_destroy(&priv->devlock); nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_ADS7843E_MULTIPLE #ifdef CONFIG_ADS7843E_MULTIPLE
kmm_free(priv); kmm_free(priv);
#endif #endif
+1
View File
@@ -1176,6 +1176,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
errout_with_priv: errout_with_priv:
nxmutex_destroy(&priv->devlock); nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
+1
View File
@@ -1248,6 +1248,7 @@ int max11802_register(FAR struct spi_dev_s *spi,
errout_with_priv: errout_with_priv:
nxmutex_destroy(&priv->devlock); nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_MAX11802_MULTIPLE #ifdef CONFIG_MAX11802_MULTIPLE
kmm_free(priv); kmm_free(priv);
#endif #endif
+1 -1
View File
@@ -188,7 +188,7 @@ static int nunchuck_sample(FAR struct nunchuck_dev_s *priv,
{ {
uint8_t cmd[2]; uint8_t cmd[2];
uint8_t data[6]; uint8_t data[6];
static bool initialized = false; static bool initialized;
if (!initialized) if (!initialized)
{ {
+2 -1
View File
@@ -994,7 +994,7 @@ int spq10kbd_register(FAR struct i2c_master_s *i2c,
priv->waiting = false; priv->waiting = false;
#ifdef CONFIG_SPQ10KBD_DJOY #ifdef CONFIG_SPQ10KBD_DJOY
priv->djoylower.config = (FAR void *)priv; priv->djoylower.config = priv;
priv->djoylower.dl_supported = djoy_supported; priv->djoylower.dl_supported = djoy_supported;
priv->djoylower.dl_sample = djoy_sample; priv->djoylower.dl_sample = djoy_sample;
priv->djoylower.dl_enable = djoy_enable; priv->djoylower.dl_enable = djoy_enable;
@@ -1045,6 +1045,7 @@ int spq10kbd_register(FAR struct i2c_master_s *i2c,
errout_with_priv: errout_with_priv:
nxmutex_destroy(&priv->lock); nxmutex_destroy(&priv->lock);
nxsem_destroy(&priv->waitsem);
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
+1
View File
@@ -1290,6 +1290,7 @@ int tsc2007_register(FAR struct i2c_master_s *dev,
errout_with_priv: errout_with_priv:
nxmutex_destroy(&priv->devlock); nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_TSC2007_MULTIPLE #ifdef CONFIG_TSC2007_MULTIPLE
kmm_free(priv); kmm_free(priv);
#endif #endif
+2 -2
View File
@@ -193,7 +193,7 @@ static inline void ht16k33_write_cmd(FAR struct ht16k33_dev_s *priv,
msg.frequency = CONFIG_HT16K33_I2C_FREQ; /* I2C frequency */ msg.frequency = CONFIG_HT16K33_I2C_FREQ; /* I2C frequency */
msg.addr = HT16K33_I2C_ADDR + dev_id; /* 7-bit address */ msg.addr = HT16K33_I2C_ADDR + dev_id; /* 7-bit address */
msg.flags = 0; /* Write transaction */ msg.flags = 0; /* Write transaction */
msg.buffer = (FAR uint8_t *) data; /* Transfer from this address */ msg.buffer = data; /* Transfer from this address */
msg.length = 1; /* Send one byte */ msg.length = 1; /* Send one byte */
/* Perform the transfer */ /* Perform the transfer */
@@ -236,7 +236,7 @@ static inline void ht16k33_write_data(FAR struct ht16k33_dev_s *priv,
msg.frequency = CONFIG_HT16K33_I2C_FREQ; /* I2C frequency */ msg.frequency = CONFIG_HT16K33_I2C_FREQ; /* I2C frequency */
msg.addr = HT16K33_I2C_ADDR + dev_id; /* 7-bit address */ msg.addr = HT16K33_I2C_ADDR + dev_id; /* 7-bit address */
msg.flags = 0; /* Write transaction */ msg.flags = 0; /* Write transaction */
msg.buffer = (FAR uint8_t *) data; /* Transfer from here */ msg.buffer = data; /* Transfer from here */
msg.length = nbytes + 1; /* Send cmd + nbytes */ msg.length = nbytes + 1; /* Send cmd + nbytes */
/* Perform the transfer */ /* Perform the transfer */
+1 -1
View File
@@ -158,7 +158,7 @@ static int userled_open(FAR struct file *filep)
/* Attach the open structure to the file structure */ /* Attach the open structure to the file structure */
filep->f_priv = (FAR void *)opriv; filep->f_priv = opriv;
ret = OK; ret = OK;
errout_with_lock: errout_with_lock:
+1 -1
View File
@@ -123,7 +123,7 @@ struct ws2812_dev_s
{ {
FAR struct spi_dev_s *spi; /* SPI interface */ FAR struct spi_dev_s *spi; /* SPI interface */
uint16_t nleds; /* Number of addressable LEDs */ uint16_t nleds; /* Number of addressable LEDs */
uint8_t *tx_buf; /* Buffer for write transaction and state */ FAR uint8_t *tx_buf; /* Buffer for write transaction and state */
mutex_t lock; /* Assures exclusive access to the driver */ mutex_t lock; /* Assures exclusive access to the driver */
}; };
+3 -6
View File
@@ -72,12 +72,9 @@ static ssize_t rwb_read_(FAR struct rwbuffer_s *rwb, off_t startblock,
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_DRVR_WRITEBUFFER) #if defined(CONFIG_DRVR_WRITEBUFFER)
static int rwb_lock(FAR mutex_t *lock) # define rwb_lock(l) nxmutex_lock(l)
{
return nxmutex_lock(lock);
}
#else #else
# define rwb_lock(s) OK # define rwb_lock(l) OK
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -211,7 +208,7 @@ static void rwb_wrstarttimeout(FAR struct rwbuffer_s *rwb)
*/ */
int ticks = MSEC2TICK(CONFIG_DRVR_WRDELAY); int ticks = MSEC2TICK(CONFIG_DRVR_WRDELAY);
work_queue(LPWORK, &rwb->work, rwb_wrtimeout, (FAR void *)rwb, ticks); work_queue(LPWORK, &rwb->work, rwb_wrtimeout, rwb, ticks);
#endif #endif
} }
#endif #endif
+2 -9
View File
@@ -2049,14 +2049,6 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
memset(slot, 0, sizeof(struct mmcsd_slot_s)); memset(slot, 0, sizeof(struct mmcsd_slot_s));
nxmutex_init(&slot->lock); nxmutex_init(&slot->lock);
#ifdef CONFIG_DEBUG_FEATURES
if (slot->spi)
{
ferr("ERROR: Already registered\n");
return -EBUSY;
}
#endif
/* Bind the SPI port to the slot */ /* Bind the SPI port to the slot */
slot->spi = spi; slot->spi = spi;
@@ -2094,6 +2086,7 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: register_blockdriver failed: %d\n", -ret); ferr("ERROR: register_blockdriver failed: %d\n", -ret);
nxmutex_destroy(&slot->lock);
slot->spi = NULL; slot->spi = NULL;
return ret; return ret;
} }
@@ -2102,7 +2095,7 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
* removal of cards. * removal of cards.
*/ */
SPI_REGISTERCALLBACK(spi, mmcsd_mediachanged, (FAR void *)slot); SPI_REGISTERCALLBACK(spi, mmcsd_mediachanged, slot);
return OK; return OK;
} }
+1
View File
@@ -423,6 +423,7 @@ int hcsr04_register(FAR const char *devpath,
if (ret < 0) if (ret < 0)
{ {
nxmutex_destroy(&priv->devlock); nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->conv_donesem);
kmm_free(priv); kmm_free(priv);
hcsr04_dbg("Error occurred during the driver registering = %d\n", ret); hcsr04_dbg("Error occurred during the driver registering = %d\n", ret);
return ret; return ret;
+3
View File
@@ -972,6 +972,9 @@ temp_err:
sensor_unregister(&priv->sensor[HYT271_SENSOR_TEMP].lower, devno); sensor_unregister(&priv->sensor[HYT271_SENSOR_TEMP].lower, devno);
nxmutex_destroy(&priv->lock_measure_cycle); nxmutex_destroy(&priv->lock_measure_cycle);
#ifdef CONFIG_SENSORS_HYT271_POLL
nxsem_destroy(&priv->run);
#endif
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
+3 -3
View File
@@ -709,7 +709,7 @@ static int lps25h_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break; break;
case SNIOC_PRESSURE_OUT: case SNIOC_PRESSURE_OUT:
ret = lps25h_read_pressure(dev, (lps25h_pressure_data_t *) arg); ret = lps25h_read_pressure(dev, (FAR lps25h_pressure_data_t *)arg);
break; break;
case SNIOC_TEMPERATURE_OUT: case SNIOC_TEMPERATURE_OUT:
@@ -717,7 +717,7 @@ static int lps25h_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* or results are bogus. * or results are bogus.
*/ */
ret = lps25h_read_temper(dev, (lps25h_temper_data_t *) arg); ret = lps25h_read_temper(dev, (FAR lps25h_temper_data_t *)arg);
break; break;
case SNIOC_SENSOR_OFF: case SNIOC_SENSOR_OFF:
@@ -725,7 +725,7 @@ static int lps25h_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break; break;
case SNIOC_GET_DEV_ID: case SNIOC_GET_DEV_ID:
ret = lps25h_who_am_i(dev, (lps25h_who_am_i_data *) arg); ret = lps25h_who_am_i(dev, (FAR lps25h_who_am_i_data *)arg);
break; break;
default: default:
+12 -12
View File
@@ -896,8 +896,8 @@ static ssize_t lsm330acl_dvr_read(FAR void *instance_handle,
DEBUGASSERT(priv != NULL); DEBUGASSERT(priv != NULL);
lsm330_read_acl_registerblk(priv, priv->seek_address, (uint8_t *)buffer, lsm330_read_acl_registerblk(priv, priv->seek_address,
buflen); (FAR uint8_t *)buffer, buflen);
return buflen; return buflen;
} }
@@ -912,8 +912,8 @@ static ssize_t lsm330gyro_dvr_read(FAR void *instance_handle,
DEBUGASSERT(priv != NULL); DEBUGASSERT(priv != NULL);
lsm330_read_gyro_registerblk(priv, priv->seek_address, (uint8_t *)buffer, lsm330_read_gyro_registerblk(priv, priv->seek_address,
buflen); (FAR uint8_t *)buffer, buflen);
return buflen; return buflen;
} }
@@ -933,8 +933,8 @@ static ssize_t lsm330acl_dvr_write(FAR void *instance_handle,
return -EROFS; return -EROFS;
} }
lsm330_write_acl_registerblk(priv, priv->seek_address, (uint8_t *)buffer, lsm330_write_acl_registerblk(priv, priv->seek_address,
buflen); (FAR uint8_t *)buffer, buflen);
return buflen; return buflen;
} }
@@ -1139,7 +1139,7 @@ static int lsm330acl_open(FAR struct file *filep)
FAR struct lsm330_dev_s *priv = inode->i_private; FAR struct lsm330_dev_s *priv = inode->i_private;
int ret; int ret;
ret = lsm330acl_dvr_open((FAR void *)priv, 0); ret = lsm330acl_dvr_open(priv, 0);
return ret; return ret;
} }
@@ -1153,7 +1153,7 @@ static int lsm330gyro_open(FAR struct file *filep)
FAR struct lsm330_dev_s *priv = inode->i_private; FAR struct lsm330_dev_s *priv = inode->i_private;
int ret; int ret;
ret = lsm330gyro_dvr_open((FAR void *)priv, 0); ret = lsm330gyro_dvr_open(priv, 0);
return ret; return ret;
} }
@@ -1167,7 +1167,7 @@ static int lsm330acl_close(FAR struct file *filep)
FAR struct lsm330_dev_s *priv = inode->i_private; FAR struct lsm330_dev_s *priv = inode->i_private;
int ret; int ret;
ret = lsm330acl_dvr_close((FAR void *)priv, 0); ret = lsm330acl_dvr_close(priv, 0);
return ret; return ret;
} }
@@ -1181,7 +1181,7 @@ static int lsm330gyro_close(FAR struct file *filep)
FAR struct lsm330_dev_s *priv = inode->i_private; FAR struct lsm330_dev_s *priv = inode->i_private;
int ret; int ret;
ret = lsm330gyro_dvr_close((FAR void *)priv, 0); ret = lsm330gyro_dvr_close(priv, 0);
return ret; return ret;
} }
@@ -1367,7 +1367,7 @@ int lsm330_register(FAR const char *devpath_acl,
priv->flink = g_lsm330a_list; priv->flink = g_lsm330a_list;
g_lsm330a_list = priv; g_lsm330a_list = priv;
priva = priv; priva = priv;
config_acl->leaf_handle = (void *)priv; config_acl->leaf_handle = priv;
/* Initialize the LSM330 gyroscope device structure. */ /* Initialize the LSM330 gyroscope device structure. */
@@ -1405,7 +1405,7 @@ int lsm330_register(FAR const char *devpath_acl,
priv->flink = g_lsm330g_list; priv->flink = g_lsm330g_list;
g_lsm330g_list = priv; g_lsm330g_list = priv;
config_gyro->leaf_handle = (void *)priv; config_gyro->leaf_handle = priv;
config_acl->sc_ops = &g_lsm330acl_dops; config_acl->sc_ops = &g_lsm330acl_dops;
config_gyro->sc_ops = &g_lsm330gyro_dops; config_gyro->sc_ops = &g_lsm330gyro_dops;
+3 -3
View File
@@ -473,7 +473,7 @@ static ssize_t mlx90393_read(FAR struct file *filep, FAR char *buffer,
/* Check if enough memory was provided for the read call */ /* Check if enough memory was provided for the read call */
if (buflen < sizeof(FAR struct mlx90393_sensor_data_s)) if (buflen < sizeof(struct mlx90393_sensor_data_s))
{ {
snerr("ERROR: " snerr("ERROR: "
"Not enough memory for reading out a sensor data sample\n"); "Not enough memory for reading out a sensor data sample\n");
@@ -492,7 +492,7 @@ static ssize_t mlx90393_read(FAR struct file *filep, FAR char *buffer,
} }
data = (FAR struct mlx90393_sensor_data_s *)buffer; data = (FAR struct mlx90393_sensor_data_s *)buffer;
memset(data, 0, sizeof(FAR struct mlx90393_sensor_data_s)); memset(data, 0, sizeof(struct mlx90393_sensor_data_s));
data->x_mag = priv->data.x_mag; data->x_mag = priv->data.x_mag;
data->y_mag = priv->data.y_mag; data->y_mag = priv->data.y_mag;
@@ -503,7 +503,7 @@ static ssize_t mlx90393_read(FAR struct file *filep, FAR char *buffer,
nxmutex_unlock(&priv->datalock); nxmutex_unlock(&priv->datalock);
return sizeof(FAR struct mlx90393_sensor_data_s); return sizeof(struct mlx90393_sensor_data_s);
} }
/**************************************************************************** /****************************************************************************
+3
View File
@@ -668,6 +668,7 @@ int ms5611_register(FAR struct i2c_master_s *i2c, int devno, uint8_t addr)
{ {
snerr("Failed to initialize physical device ms5611:%d\n", ret); snerr("Failed to initialize physical device ms5611:%d\n", ret);
nxmutex_destroy(&priv->lock); nxmutex_destroy(&priv->lock);
nxsem_destroy(&priv->run);
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
@@ -679,6 +680,7 @@ int ms5611_register(FAR struct i2c_master_s *i2c, int devno, uint8_t addr)
{ {
snerr("Failed to register driver: %d\n", ret); snerr("Failed to register driver: %d\n", ret);
nxmutex_destroy(&priv->lock); nxmutex_destroy(&priv->lock);
nxsem_destroy(&priv->run);
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
@@ -696,6 +698,7 @@ int ms5611_register(FAR struct i2c_master_s *i2c, int devno, uint8_t addr)
snerr("Failed to create the notification kthread!\n"); snerr("Failed to create the notification kthread!\n");
sensor_unregister(&priv->sensor_lower, devno); sensor_unregister(&priv->sensor_lower, devno);
nxmutex_destroy(&priv->lock); nxmutex_destroy(&priv->lock);
nxsem_destroy(&priv->run);
kmm_free(priv); kmm_free(priv);
return ret; return ret;
} }
+12 -3
View File
@@ -144,6 +144,15 @@ static inline int syslog_dev_lock(FAR struct syslog_dev_s *syslog_dev)
return nxrmutex_lock(&syslog_dev->sl_lock); return nxrmutex_lock(&syslog_dev->sl_lock);
} }
/****************************************************************************
* Name: syslog_dev_unlock
****************************************************************************/
static inline void syslog_dev_unlock(FAR struct syslog_dev_s *syslog_dev)
{
nxrmutex_unlock(&syslog_dev->sl_lock);
}
/**************************************************************************** /****************************************************************************
* Name: syslog_dev_open * Name: syslog_dev_open
* *
@@ -499,12 +508,12 @@ static ssize_t syslog_dev_write(FAR struct syslog_channel_s *channel,
} }
} }
nxrmutex_unlock(&syslog_dev->sl_lock); syslog_dev_unlock(syslog_dev);
return buflen; return buflen;
errout_with_lock: errout_with_lock:
syslog_dev->sl_state = SYSLOG_FAILURE; syslog_dev->sl_state = SYSLOG_FAILURE;
nxrmutex_unlock(&syslog_dev->sl_lock); syslog_dev_unlock(syslog_dev);
return ret; return ret;
} }
@@ -588,7 +597,7 @@ static int syslog_dev_putc(FAR struct syslog_channel_s *channel, int ch)
nbytes = file_write(&syslog_dev->sl_file, &uch, 1); nbytes = file_write(&syslog_dev->sl_file, &uch, 1);
} }
nxrmutex_unlock(&syslog_dev->sl_lock); syslog_dev_unlock(syslog_dev);
/* Check if the write was successful. If not, nbytes will be /* Check if the write was successful. If not, nbytes will be
* a negated errno value. * a negated errno value.
+6 -7
View File
@@ -658,7 +658,7 @@ static int start_capture(enum v4l2_buf_type type,
sf, sf,
&si); &si);
g_video_data_ops->start_capture(nr_fmt, df, &di, video_complete_capture); g_video_data_ops->start_capture(nr_fmt, df, &di, video_complete_capture);
g_video_data_ops->set_buf((uint8_t *)bufaddr, bufsize); g_video_data_ops->set_buf((FAR uint8_t *)bufaddr, bufsize);
return OK; return OK;
} }
@@ -847,7 +847,7 @@ static int32_t initialize_scene_gamma(uint8_t **gamma)
} }
*gamma = malloc(sz); *gamma = malloc(sz);
val.p_u8 = (uint8_t *)*gamma; val.p_u8 = (FAR uint8_t *)*gamma;
g_video_sensor_ops->get_value(IMGSENSOR_ID_GAMMA_CURVE, sz, &val); g_video_sensor_ops->get_value(IMGSENSOR_ID_GAMMA_CURVE, sz, &val);
return sz; return sz;
} }
@@ -1787,7 +1787,6 @@ static int video_takepict_start(FAR struct video_mng_s *vmng,
irqstate_t flags; irqstate_t flags;
enum video_state_e next_video_state; enum video_state_e next_video_state;
FAR vbuf_container_t *container; FAR vbuf_container_t *container;
int ret = OK; int ret = OK;
if (vmng == NULL) if (vmng == NULL)
@@ -2221,7 +2220,7 @@ static int set_pvalue(uint32_t id, int size, void *pval)
return -ENOTTY; return -ENOTTY;
} }
value.p_u8 = (uint8_t *)pval; value.p_u8 = (FAR uint8_t *)pval;
return g_video_sensor_ops->set_value(id, size, value); return g_video_sensor_ops->set_value(id, size, value);
} }
@@ -3128,7 +3127,7 @@ static FAR void *video_register(FAR const char *devpath)
return NULL; return NULL;
} }
return (FAR void *)priv; return priv;
} }
static int video_unregister(FAR video_mng_t *v_mgr) static int video_unregister(FAR video_mng_t *v_mgr)
@@ -3142,7 +3141,7 @@ static int video_unregister(FAR video_mng_t *v_mgr)
else else
{ {
nxmutex_destroy(&v_mgr->lock_open_num); nxmutex_destroy(&v_mgr->lock_open_num);
unregister_driver((const char *)v_mgr->devpath); unregister_driver(v_mgr->devpath);
kmm_free(v_mgr->devpath); kmm_free(v_mgr->devpath);
kmm_free(v_mgr); kmm_free(v_mgr);
@@ -3227,7 +3226,7 @@ static int video_complete_capture(uint8_t err_code, uint32_t datasize)
} }
else else
{ {
g_video_data_ops->set_buf((uint8_t *)container->buf.m.userptr, g_video_data_ops->set_buf((FAR uint8_t *)container->buf.m.userptr,
container->buf.length); container->buf.length);
} }
} }
+2 -2
View File
@@ -435,7 +435,7 @@ static ssize_t cc1101_file_write(FAR struct file *filep,
return ret; return ret;
} }
ret = cc1101_write(dev, (const uint8_t *)buffer, buflen); ret = cc1101_write(dev, (FAR const uint8_t *)buffer, buflen);
cc1101_send(dev); cc1101_send(dev);
nxmutex_unlock(&dev->devlock); nxmutex_unlock(&dev->devlock);
return ret; return ret;
@@ -560,7 +560,7 @@ static ssize_t cc1101_file_read(FAR struct file *filep, FAR char *buffer,
return ret; return ret;
} }
buflen = fifo_get(dev, (uint8_t *)buffer, buflen); buflen = fifo_get(dev, (FAR uint8_t *)buffer, buflen);
nxmutex_unlock(&dev->devlock); nxmutex_unlock(&dev->devlock);
return buflen; return buflen;
} }
+15 -12
View File
@@ -889,10 +889,10 @@ retry:
****************************************************************************/ ****************************************************************************/
enum spi_status_e gs2200m_hal_write(FAR struct gs2200m_dev_s *dev, enum spi_status_e gs2200m_hal_write(FAR struct gs2200m_dev_s *dev,
const void *data, FAR const void *data,
uint16_t txlen) uint16_t txlen)
{ {
uint8_t *tx = (uint8_t *)data; FAR uint8_t *tx = (FAR uint8_t *)data;
uint8_t hdr[8]; uint8_t hdr[8];
uint8_t res[8]; uint8_t res[8];
int n = 0; int n = 0;
@@ -1091,6 +1091,7 @@ static void _parse_pkt_in_s0(FAR struct pkt_ctx_s *pkt_ctx,
static void _parse_pkt_in_s1(FAR struct pkt_ctx_s *pkt_ctx, static void _parse_pkt_in_s1(FAR struct pkt_ctx_s *pkt_ctx,
FAR struct pkt_dat_s *pkt_dat) FAR struct pkt_dat_s *pkt_dat)
{ {
FAR char *msg;
int msize; int msize;
int n; int n;
@@ -1102,7 +1103,7 @@ static void _parse_pkt_in_s1(FAR struct pkt_ctx_s *pkt_ctx,
ASSERT(pkt_ctx->ptr > pkt_ctx->head); ASSERT(pkt_ctx->ptr > pkt_ctx->head);
msize = pkt_ctx->ptr - pkt_ctx->head; msize = pkt_ctx->ptr - pkt_ctx->head;
char *msg = (char *)kmm_calloc(msize + 1, 1); msg = (FAR char *)kmm_calloc(msize + 1, 1);
ASSERT(msg); ASSERT(msg);
memcpy(msg, pkt_ctx->head, msize); memcpy(msg, pkt_ctx->head, msize);
@@ -1219,7 +1220,7 @@ static void _parse_pkt_in_s3(FAR struct pkt_ctx_s *pkt_ctx,
/* Read data length */ /* Read data length */
pkt_ctx->dlen = _to_uint16((char *)pkt_ctx->ptr); pkt_ctx->dlen = _to_uint16((FAR char *)pkt_ctx->ptr);
pkt_ctx->ptr += 3; pkt_ctx->ptr += 3;
wlinfo("dlen=%d\n", pkt_ctx->dlen); wlinfo("dlen=%d\n", pkt_ctx->dlen);
@@ -1271,7 +1272,7 @@ static void _parse_pkt_in_s4(FAR struct pkt_ctx_s *pkt_ctx,
memset(addr, 0, sizeof(addr)); memset(addr, 0, sizeof(addr));
memset(port, 0, sizeof(port)); memset(port, 0, sizeof(port));
n = sscanf((char *)pkt_ctx->ptr, "%s %s\t", addr, port); n = sscanf((FAR const char *)pkt_ctx->ptr, "%s %s\t", addr, port);
ASSERT(2 == n); ASSERT(2 == n);
wlinfo("from (%s:%s)\n", addr, port); wlinfo("from (%s:%s)\n", addr, port);
@@ -1286,7 +1287,7 @@ static void _parse_pkt_in_s4(FAR struct pkt_ctx_s *pkt_ctx,
/* Read data length */ /* Read data length */
pkt_ctx->dlen = _to_uint16((char *)pkt_ctx->ptr); pkt_ctx->dlen = _to_uint16((FAR char *)pkt_ctx->ptr);
pkt_ctx->ptr += 3; pkt_ctx->ptr += 3;
wlinfo("dlen=%d\n", pkt_ctx->dlen); wlinfo("dlen=%d\n", pkt_ctx->dlen);
@@ -1367,7 +1368,7 @@ static enum pkt_type_e _parse_pkt(FAR uint8_t *p, uint16_t len,
static void _dup_pkt_dat_and_notify(FAR struct gs2200m_dev_s *dev, static void _dup_pkt_dat_and_notify(FAR struct gs2200m_dev_s *dev,
FAR struct pkt_dat_s *pkt_dat0) FAR struct pkt_dat_s *pkt_dat0)
{ {
struct pkt_dat_s *pkt_dat; FAR struct pkt_dat_s *pkt_dat;
uint8_t c; uint8_t c;
/* Only bulk data */ /* Only bulk data */
@@ -1419,9 +1420,9 @@ static enum pkt_type_e gs2200m_recv_pkt(FAR struct gs2200m_dev_s *dev,
enum pkt_type_e t = TYPE_ERROR; enum pkt_type_e t = TYPE_ERROR;
enum spi_status_e s; enum spi_status_e s;
uint16_t len; uint16_t len;
uint8_t *p; FAR uint8_t *p;
p = (uint8_t *)kmm_calloc(MAX_PKT_LEN, 1); p = (FAR uint8_t *)kmm_calloc(MAX_PKT_LEN, 1);
ASSERT(p); ASSERT(p);
s = gs2200m_hal_read(dev, p, &len); s = gs2200m_hal_read(dev, p, &len);
@@ -1633,7 +1634,7 @@ errout:
static enum pkt_type_e gs2200m_disassociate(FAR struct gs2200m_dev_s *dev) static enum pkt_type_e gs2200m_disassociate(FAR struct gs2200m_dev_s *dev)
{ {
return gs2200m_send_cmd2(dev, (char *)"AT+WD\r\n"); return gs2200m_send_cmd2(dev, "AT+WD\r\n");
} }
/**************************************************************************** /****************************************************************************
@@ -1826,7 +1827,7 @@ enum pkt_type_e gs2200m_get_wstatus(FAR struct gs2200m_dev_s *dev)
/* Initialize pkt_dat and send command */ /* Initialize pkt_dat and send command */
memset(&pkt_dat, 0, sizeof(pkt_dat)); memset(&pkt_dat, 0, sizeof(pkt_dat));
r = gs2200m_send_cmd(dev, (char *)"AT+WSTATUS\r\n", &pkt_dat); r = gs2200m_send_cmd(dev, "AT+WSTATUS\r\n", &pkt_dat);
if (r != TYPE_OK) if (r != TYPE_OK)
{ {
@@ -2017,7 +2018,8 @@ static enum pkt_type_e gs2200m_send_bulk(FAR struct gs2200m_dev_s *dev,
/* Send the bulk data */ /* Send the bulk data */
s = gs2200m_hal_write(dev, (char *)dev->tx_buff, msg->len + bulk_hdr_size); s = gs2200m_hal_write(dev, (FAR char *)dev->tx_buff,
msg->len + bulk_hdr_size);
if (s == SPI_TIMEOUT) if (s == SPI_TIMEOUT)
{ {
@@ -3502,6 +3504,7 @@ FAR void *gs2200m_register(FAR const char *devpath,
dev->spi = spi; dev->spi = spi;
dev->path = strdup(devpath); dev->path = strdup(devpath);
dev->lower = lower; dev->lower = lower;
dev->pfd = NULL;
nxmutex_init(&dev->dev_lock); nxmutex_init(&dev->dev_lock);
@@ -1980,17 +1980,7 @@ int bcmf_wl_set_ssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
/* Init authentication signal semaphore */ /* Init authentication signal semaphore */
ret = nxsem_init(&auth_signal, 0, 0); nxsem_init(&auth_signal, 0, 0);
if (ret == OK)
{
ret = nxsem_set_protocol(&auth_signal, SEM_PRIO_NONE);
}
if (ret < OK)
{
goto errout_with_auth;
}
priv->auth_signal = &auth_signal; priv->auth_signal = &auth_signal;
ssid.ssid_len = iwr->u.essid.length; ssid.ssid_len = iwr->u.essid.length;
@@ -337,7 +337,7 @@ static int bcmf_gspi_bus_lowpower(FAR bcmf_gspi_dev_t *gbus, bool enable)
* Name: bcmf_gspi_thread_isr * Name: bcmf_gspi_thread_isr
****************************************************************************/ ****************************************************************************/
static int bcmf_gspi_thread_isr(int isr, void *context, void *arg) static int bcmf_gspi_thread_isr(int isr, FAR void *context, FAR void *arg)
{ {
FAR bcmf_gspi_dev_t *gbus = (FAR bcmf_gspi_dev_t *)arg; FAR bcmf_gspi_dev_t *gbus = (FAR bcmf_gspi_dev_t *)arg;
FAR gspi_dev_t *gspi = gbus->gspi; FAR gspi_dev_t *gspi = gbus->gspi;
@@ -821,7 +821,6 @@ static int bcmf_bus_gspi_initialize(FAR struct bcmf_dev_s *priv,
FAR struct gspi_dev_s *gspi) FAR struct gspi_dev_s *gspi)
{ {
FAR bcmf_gspi_dev_t *gbus; FAR bcmf_gspi_dev_t *gbus;
int ret;
wlinfo("entered.\n"); wlinfo("entered.\n");
@@ -856,11 +855,7 @@ static int bcmf_bus_gspi_initialize(FAR struct bcmf_dev_s *priv,
/* Init transmit frames queue */ /* Init transmit frames queue */
if ((ret = nxmutex_init(&gbus->queue_lock)) != OK) nxmutex_init(&gbus->queue_lock);
{
goto exit_free_bus;
}
list_initialize(&gbus->tx_queue); list_initialize(&gbus->tx_queue);
list_initialize(&gbus->rx_queue); list_initialize(&gbus->rx_queue);
@@ -870,10 +865,7 @@ static int bcmf_bus_gspi_initialize(FAR struct bcmf_dev_s *priv,
/* Init thread semaphore */ /* Init thread semaphore */
if ((ret = nxsem_init(&gbus->thread_signal, 0, 0)) != OK) nxsem_init(&gbus->thread_signal, 0, 0);
{
goto exit_free_bus;
}
/* Register sdio bus */ /* Register sdio bus */
@@ -886,13 +878,6 @@ static int bcmf_bus_gspi_initialize(FAR struct bcmf_dev_s *priv,
wlinfo("complete.\n"); wlinfo("complete.\n");
return OK; return OK;
exit_free_bus:
wlinfo("failed.\n");
kmm_free(gbus);
priv->bus = NULL;
return ret;
} }
/**************************************************************************** /****************************************************************************
@@ -652,7 +652,6 @@ static int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv,
/* Allocate sdio bus structure */ /* Allocate sdio bus structure */
sbus = (FAR struct bcmf_sdio_dev_s *)kmm_malloc(sizeof(*sbus)); sbus = (FAR struct bcmf_sdio_dev_s *)kmm_malloc(sizeof(*sbus));
if (!sbus) if (!sbus)
{ {
return -ENOMEM; return -ENOMEM;
@@ -674,11 +673,7 @@ static int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv,
/* Init transmit frames queue */ /* Init transmit frames queue */
if ((ret = nxmutex_init(&sbus->queue_lock)) != OK) nxmutex_init(&sbus->queue_lock);
{
goto exit_free_bus;
}
list_initialize(&sbus->tx_queue); list_initialize(&sbus->tx_queue);
list_initialize(&sbus->rx_queue); list_initialize(&sbus->rx_queue);
@@ -688,10 +683,7 @@ static int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv,
/* Init thread semaphore */ /* Init thread semaphore */
if ((ret = nxsem_init(&sbus->thread_signal, 0, 0)) != OK) nxsem_init(&sbus->thread_signal, 0, 0);
{
goto exit_free_bus;
}
/* Configure hardware */ /* Configure hardware */
@@ -44,7 +44,7 @@
* Name: bcmf_hexdump * Name: bcmf_hexdump
****************************************************************************/ ****************************************************************************/
void bcmf_hexdump(uint8_t *data, unsigned int len, unsigned long offset) void bcmf_hexdump(FAR uint8_t *data, unsigned int len, unsigned long offset)
{ {
unsigned int i; unsigned int i;
unsigned int char_count = 0; unsigned int char_count = 0;
@@ -39,17 +39,17 @@
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
void bcmf_hexdump(uint8_t *data, unsigned int len, unsigned long offset); void bcmf_hexdump(FAR uint8_t *dat, unsigned int len, unsigned long offset);
static inline uint16_t bcmf_getle16(void *val) static inline uint16_t bcmf_getle16(FAR void *val)
{ {
uint8_t *valb = (uint8_t *)val; FAR uint8_t *valb = (FAR uint8_t *)val;
return (uint16_t)valb[0] << 8 | (uint16_t)valb[1]; return (uint16_t)valb[0] << 8 | (uint16_t)valb[1];
} }
static inline uint32_t bcmf_getle32(void *val) static inline uint32_t bcmf_getle32(FAR void *val)
{ {
uint16_t *valw = (uint16_t *)val; FAR uint16_t *valw = (FAR uint16_t *)val;
return (uint32_t)bcmf_getle16(valw) << 16 | bcmf_getle16(valw + 1); return (uint32_t)bcmf_getle16(valw) << 16 | bcmf_getle16(valw + 1);
} }
+11 -11
View File
@@ -415,10 +415,10 @@ static int sx127x_txfifo_write(FAR struct sx127x_dev_s *dev,
FAR const uint8_t *data, size_t datalen); FAR const uint8_t *data, size_t datalen);
#endif #endif
#ifdef CONFIG_LPWAN_SX127X_RXSUPPORT #ifdef CONFIG_LPWAN_SX127X_RXSUPPORT
static ssize_t sx127x_rxfifo_get(struct sx127x_dev_s *dev, static ssize_t sx127x_rxfifo_get(FAR struct sx127x_dev_s *dev,
FAR uint8_t *buffer, size_t buflen);
static void sx127x_rxfifo_put(FAR struct sx127x_dev_s *dev,
FAR uint8_t *buffer, size_t buflen); FAR uint8_t *buffer, size_t buflen);
static void sx127x_rxfifo_put(struct sx127x_dev_s *dev, FAR uint8_t *buffer,
size_t buflen);
#endif #endif
/* POSIX API */ /* POSIX API */
@@ -494,7 +494,7 @@ static void sx127x_unlock(FAR struct spi_dev_s *spi)
* Name: sx127x_select * Name: sx127x_select
****************************************************************************/ ****************************************************************************/
static inline void sx127x_select(struct sx127x_dev_s * dev) static inline void sx127x_select(FAR struct sx127x_dev_s *dev)
{ {
SPI_SELECT(dev->spi, SPIDEV_LPWAN(0), true); SPI_SELECT(dev->spi, SPIDEV_LPWAN(0), true);
} }
@@ -503,7 +503,7 @@ static inline void sx127x_select(struct sx127x_dev_s * dev)
* Name: sx127x_deselect * Name: sx127x_deselect
****************************************************************************/ ****************************************************************************/
static inline void sx127x_deselect(struct sx127x_dev_s * dev) static inline void sx127x_deselect(FAR struct sx127x_dev_s *dev)
{ {
SPI_SELECT(dev->spi, SPIDEV_LPWAN(0), false); SPI_SELECT(dev->spi, SPIDEV_LPWAN(0), false);
} }
@@ -866,7 +866,7 @@ static ssize_t sx127x_read(FAR struct file *filep, FAR char *buffer,
/* Get RX data from fifo */ /* Get RX data from fifo */
ret = sx127x_rxfifo_get(dev, (uint8_t *)buffer, buflen); ret = sx127x_rxfifo_get(dev, (FAR uint8_t *)buffer, buflen);
nxmutex_unlock(&dev->dev_lock); nxmutex_unlock(&dev->dev_lock);
return ret; return ret;
@@ -926,7 +926,7 @@ static ssize_t sx127x_write(FAR struct file *filep, FAR const char *buffer,
/* Call modulation specific send */ /* Call modulation specific send */
ret = dev->ops.send(dev, (uint8_t *)buffer, buflen); ret = dev->ops.send(dev, (FAR uint8_t *)buffer, buflen);
/* Change mode to TX to start data transfer */ /* Change mode to TX to start data transfer */
@@ -1497,7 +1497,7 @@ static void sx127x_isr0_process(FAR void *arg)
{ {
DEBUGASSERT(arg); DEBUGASSERT(arg);
FAR struct sx127x_dev_s *dev = (struct sx127x_dev_s *)arg; FAR struct sx127x_dev_s *dev = (FAR struct sx127x_dev_s *)arg;
int ret = OK; int ret = OK;
/* Return immediately if isr0_process is not initialized */ /* Return immediately if isr0_process is not initialized */
@@ -1606,7 +1606,7 @@ static size_t sx127x_fskook_rxhandle(FAR struct sx127x_dev_s *dev)
/* Put data on local fifo */ /* Put data on local fifo */
sx127x_rxfifo_put(dev, (uint8_t *)&rxdata, len); sx127x_rxfifo_put(dev, (FAR uint8_t *)&rxdata, len);
/* Return total length */ /* Return total length */
@@ -1684,7 +1684,7 @@ static size_t sx127x_lora_rxhandle(FAR struct sx127x_dev_s *dev)
/* Put data on local fifo */ /* Put data on local fifo */
sx127x_rxfifo_put(dev, (uint8_t *)&rxdata, len); sx127x_rxfifo_put(dev, (FAR uint8_t *)&rxdata, len);
/* Return total length */ /* Return total length */
@@ -1863,7 +1863,7 @@ static int sx127x_fskook_send(FAR struct sx127x_dev_s *dev,
{ {
/* First byte is length */ /* First byte is length */
ret = sx127x_txfifo_write(dev, (uint8_t *)&datalen, 1); ret = sx127x_txfifo_write(dev, (FAR uint8_t *)&datalen, 1);
} }
/* Write payload */ /* Write payload */
+5 -4
View File
@@ -330,7 +330,7 @@ static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi)
* Name: nrf24l01_select * Name: nrf24l01_select
****************************************************************************/ ****************************************************************************/
static inline void nrf24l01_select(struct nrf24l01_dev_s * dev) static inline void nrf24l01_select(FAR struct nrf24l01_dev_s *dev)
{ {
SPI_SELECT(dev->spi, SPIDEV_WIRELESS(0), true); SPI_SELECT(dev->spi, SPIDEV_WIRELESS(0), true);
} }
@@ -339,7 +339,7 @@ static inline void nrf24l01_select(struct nrf24l01_dev_s * dev)
* Name: nrf24l01_deselect * Name: nrf24l01_deselect
****************************************************************************/ ****************************************************************************/
static inline void nrf24l01_deselect(struct nrf24l01_dev_s * dev) static inline void nrf24l01_deselect(FAR struct nrf24l01_dev_s *dev)
{ {
SPI_SELECT(dev->spi, SPIDEV_WIRELESS(0), false); SPI_SELECT(dev->spi, SPIDEV_WIRELESS(0), false);
} }
@@ -1053,7 +1053,8 @@ static ssize_t nrf24l01_read(FAR struct file *filep, FAR char *buffer,
} }
} }
ret = nrf24l01_recv(dev, (uint8_t *)buffer, buflen, &dev->last_recvpipeno); ret = nrf24l01_recv(dev, (FAR uint8_t *)buffer, buflen,
&dev->last_recvpipeno);
errout: errout:
nxmutex_unlock(&dev->devlock); nxmutex_unlock(&dev->devlock);
@@ -1084,7 +1085,7 @@ static ssize_t nrf24l01_write(FAR struct file *filep, FAR const char *buffer,
return ret; return ret;
} }
ret = nrf24l01_send(dev, (const uint8_t *)buffer, buflen); ret = nrf24l01_send(dev, (FAR const uint8_t *)buffer, buflen);
nxmutex_unlock(&dev->devlock); nxmutex_unlock(&dev->devlock);
return ret; return ret;
+57 -52
View File
@@ -861,8 +861,8 @@
struct fat_file_s; struct fat_file_s;
struct fat_mountpt_s struct fat_mountpt_s
{ {
struct inode *fs_blkdriver; /* The block driver inode that hosts the FAT32 fs */ FAR struct inode *fs_blkdriver; /* The block driver inode that hosts the FAT32 fs */
struct fat_file_s *fs_head; /* A list to all files opened on this mountpoint */ FAR struct fat_file_s *fs_head; /* A list to all files opened on this mountpoint */
mutex_t fs_lock; /* Used to assume thread-safe access */ mutex_t fs_lock; /* Used to assume thread-safe access */
off_t fs_hwsectorsize; /* HW: Sector size reported by block driver */ off_t fs_hwsectorsize; /* HW: Sector size reported by block driver */
@@ -896,7 +896,7 @@ struct fat_mountpt_s
struct fat_file_s struct fat_file_s
{ {
struct fat_file_s *ff_next; /* Retained in a singly linked list */ FAR struct fat_file_s *ff_next; /* Retained in a singly linked list */
uint8_t ff_bflags; /* The file buffer/mount flags */ uint8_t ff_bflags; /* The file buffer/mount flags */
uint8_t ff_oflags; /* Flags provided when file was opened */ uint8_t ff_oflags; /* Flags provided when file was opened */
uint8_t ff_sectorsincluster; /* Sectors remaining in cluster */ uint8_t ff_sectorsincluster; /* Sectors remaining in cluster */
@@ -1013,10 +1013,10 @@ extern "C"
/* Utitilies to handle unaligned or byte swapped accesses */ /* Utitilies to handle unaligned or byte swapped accesses */
EXTERN uint16_t fat_getuint16(uint8_t *ptr); EXTERN uint16_t fat_getuint16(FAR uint8_t *ptr);
EXTERN uint32_t fat_getuint32(uint8_t *ptr); EXTERN uint32_t fat_getuint32(FAR uint8_t *ptr);
EXTERN void fat_putuint16(uint8_t *ptr, uint16_t value16); EXTERN void fat_putuint16(FAR uint8_t *ptr, uint16_t value16);
EXTERN void fat_putuint32(uint8_t *ptr, uint32_t value32); EXTERN void fat_putuint32(FAR uint8_t *ptr, uint32_t value32);
/* Get the current time for FAT creation and write times */ /* Get the current time for FAT creation and write times */
@@ -1025,79 +1025,84 @@ EXTERN time_t fat_fattime2systime(uint16_t fattime, uint16_t fatdate);
/* Handle hardware interactions for mounting */ /* Handle hardware interactions for mounting */
EXTERN int fat_mount(struct fat_mountpt_s *fs, bool writeable); EXTERN int fat_mount(FAR struct fat_mountpt_s *fs, bool writeable);
EXTERN int fat_checkmount(struct fat_mountpt_s *fs); EXTERN int fat_checkmount(FAR struct fat_mountpt_s *fs);
/* low-level hardware access */ /* low-level hardware access */
EXTERN int fat_hwread(struct fat_mountpt_s *fs, uint8_t *buffer, EXTERN int fat_hwread(FAR struct fat_mountpt_s *fs, FAR uint8_t *buffer,
off_t sector, unsigned int nsectors); off_t sector, unsigned int nsectors);
EXTERN int fat_hwwrite(struct fat_mountpt_s *fs, uint8_t *buffer, EXTERN int fat_hwwrite(FAR struct fat_mountpt_s *fs, FAR uint8_t *buffer,
off_t sector, unsigned int nsectors); off_t sector, unsigned int nsectors);
/* Cluster / cluster chain access helpers */ /* Cluster / cluster chain access helpers */
EXTERN off_t fat_cluster2sector(struct fat_mountpt_s *fs, uint32_t cluster); EXTERN off_t fat_cluster2sector(FAR struct fat_mountpt_s *fs,
EXTERN off_t fat_getcluster(struct fat_mountpt_s *fs, uint32_t clusterno); uint32_t cluster);
EXTERN int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno, EXTERN off_t fat_getcluster(FAR struct fat_mountpt_s *fs,
off_t startsector); uint32_t clusterno);
EXTERN int fat_removechain(struct fat_mountpt_s *fs, uint32_t cluster); EXTERN int fat_putcluster(FAR struct fat_mountpt_s *fs,
EXTERN int32_t fat_extendchain(struct fat_mountpt_s *fs, uint32_t cluster); uint32_t clusterno, off_t startsector);
EXTERN int fat_removechain(FAR struct fat_mountpt_s *fs,
uint32_t cluster);
EXTERN int32_t fat_extendchain(FAR struct fat_mountpt_s *fs,
uint32_t cluster);
#define fat_createchain(fs) fat_extendchain(fs, 0) #define fat_createchain(fs) fat_extendchain(fs, 0)
/* Help for traversing directory trees and accessing directory entries */ /* Help for traversing directory trees and accessing directory entries */
EXTERN int fat_nextdirentry(struct fat_mountpt_s *fs, EXTERN int fat_nextdirentry(FAR struct fat_mountpt_s *fs,
struct fs_fatdir_s *dir); FAR struct fs_fatdir_s *dir);
EXTERN int fat_finddirentry(struct fat_mountpt_s *fs, EXTERN int fat_finddirentry(FAR struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo, FAR struct fat_dirinfo_s *dirinfo,
const char *path); FAR const char *path);
EXTERN int fat_dirnamewrite(struct fat_mountpt_s *fs, EXTERN int fat_dirnamewrite(FAR struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo); FAR struct fat_dirinfo_s *dirinfo);
EXTERN int fat_dirwrite(struct fat_mountpt_s *fs, EXTERN int fat_dirwrite(FAR struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo, FAR struct fat_dirinfo_s *dirinfo,
uint8_t attributes, uint32_t fattime); uint8_t attributes, uint32_t fattime);
EXTERN int fat_allocatedirentry(struct fat_mountpt_s *fs, EXTERN int fat_allocatedirentry(FAR struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo); FAR struct fat_dirinfo_s *dirinfo);
EXTERN int fat_freedirentry(struct fat_mountpt_s *fs, EXTERN int fat_freedirentry(FAR struct fat_mountpt_s *fs,
struct fat_dirseq_s *seq); FAR struct fat_dirseq_s *seq);
EXTERN int fat_dirname2path(FAR struct fat_mountpt_s *fs, EXTERN int fat_dirname2path(FAR struct fat_mountpt_s *fs,
FAR struct fs_dirent_s *dir, FAR struct fs_dirent_s *dir,
FAR struct dirent *entry); FAR struct dirent *entry);
/* File creation and removal helpers */ /* File creation and removal helpers */
EXTERN int fat_dirtruncate(struct fat_mountpt_s *fs, EXTERN int fat_dirtruncate(FAR struct fat_mountpt_s *fs,
FAR uint8_t *direntry); FAR uint8_t *direntry);
EXTERN int fat_dirshrink(struct fat_mountpt_s *fs, FAR uint8_t *direntry, EXTERN int fat_dirshrink(FAR struct fat_mountpt_s *fs,
off_t length); FAR uint8_t *direntry, off_t length);
EXTERN int fat_dirextend(FAR struct fat_mountpt_s *fs, EXTERN int fat_dirextend(FAR FAR struct fat_mountpt_s *fs,
FAR struct fat_file_s *ff, off_t length); FAR FAR struct fat_file_s *ff, off_t length);
EXTERN int fat_dircreate(struct fat_mountpt_s *fs, EXTERN int fat_dircreate(FAR struct fat_mountpt_s *fs,
struct fat_dirinfo_s *dirinfo); FAR struct fat_dirinfo_s *dirinfo);
EXTERN int fat_remove(struct fat_mountpt_s *fs, const char *relpath, EXTERN int fat_remove(FAR struct fat_mountpt_s *fs,
FAR const char *relpath,
bool directory); bool directory);
/* Mountpoint and file buffer cache (for partial sector accesses) */ /* Mountpoint and file buffer cache (for partial sector accesses) */
EXTERN int fat_fscacheflush(struct fat_mountpt_s *fs); EXTERN int fat_fscacheflush(FAR struct fat_mountpt_s *fs);
EXTERN int fat_fscacheread(struct fat_mountpt_s *fs, off_t sector); EXTERN int fat_fscacheread(FAR struct fat_mountpt_s *fs, off_t sector);
EXTERN int fat_ffcacheflush(struct fat_mountpt_s *fs, EXTERN int fat_ffcacheflush(FAR struct fat_mountpt_s *fs,
struct fat_file_s *ff); FAR struct fat_file_s *ff);
EXTERN int fat_ffcacheread(struct fat_mountpt_s *fs, EXTERN int fat_ffcacheread(FAR struct fat_mountpt_s *fs,
struct fat_file_s *ff, off_t sector); FAR struct fat_file_s *ff, off_t sector);
EXTERN int fat_ffcacheinvalidate(struct fat_mountpt_s *fs, EXTERN int fat_ffcacheinvalidate(FAR struct fat_mountpt_s *fs,
struct fat_file_s *ff); FAR struct fat_file_s *ff);
/* FSINFO sector support */ /* FSINFO sector support */
EXTERN int fat_updatefsinfo(struct fat_mountpt_s *fs); EXTERN int fat_updatefsinfo(FAR struct fat_mountpt_s *fs);
EXTERN int fat_computefreeclusters(struct fat_mountpt_s *fs); EXTERN int fat_computefreeclusters(FAR struct fat_mountpt_s *fs);
EXTERN int fat_nfreeclusters(struct fat_mountpt_s *fs, EXTERN int fat_nfreeclusters(FAR struct fat_mountpt_s *fs,
fsblkcnt_t *pfreeclusters); FAR fsblkcnt_t *pfreeclusters);
EXTERN int fat_currentsector(struct fat_mountpt_s *fs, EXTERN int fat_currentsector(FAR struct fat_mountpt_s *fs,
struct fat_file_s *ff, off_t position); FAR struct fat_file_s *ff, off_t position);
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
+1 -1
View File
@@ -69,7 +69,7 @@ struct nfsmount
{ {
FAR struct nfsnode *nm_head; /* A list of all files opened on this mountpoint */ FAR struct nfsnode *nm_head; /* A list of all files opened on this mountpoint */
mutex_t nm_lock; /* Used to assure thread-safe access */ mutex_t nm_lock; /* Used to assure thread-safe access */
nfsfh_t *nm_fh; /* File handle of root dir */ FAR nfsfh_t *nm_fh; /* File handle of root dir */
char nm_path[90]; /* server's path of the directory being mounted */ char nm_path[90]; /* server's path of the directory being mounted */
struct nfs_fattr nm_fattr; /* nfs file attribute cache */ struct nfs_fattr nm_fattr; /* nfs file attribute cache */
FAR struct rpcclnt *nm_rpcclnt; /* RPC state */ FAR struct rpcclnt *nm_rpcclnt; /* RPC state */
+25 -25
View File
@@ -332,8 +332,8 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, FAR struct nfsnode *np,
nfs_statistics(NFSPROC_CREATE); nfs_statistics(NFSPROC_CREATE);
ret = nfs_request(nmp, NFSPROC_CREATE, ret = nfs_request(nmp, NFSPROC_CREATE,
(FAR void *)&nmp->nm_msgbuffer.create, reqlen, &nmp->nm_msgbuffer.create, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
/* Check for success */ /* Check for success */
@@ -499,8 +499,8 @@ static int nfs_filechstat(FAR struct nfsmount *nmp, FAR struct nfsnode *np,
nfs_statistics(NFSPROC_SETATTR); nfs_statistics(NFSPROC_SETATTR);
ret = nfs_request(nmp, NFSPROC_SETATTR, ret = nfs_request(nmp, NFSPROC_SETATTR,
(FAR void *)&nmp->nm_msgbuffer.setattr, reqlen, &nmp->nm_msgbuffer.setattr, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret != OK) if (ret != OK)
{ {
ferr("ERROR: nfs_request failed: %d\n", ret); ferr("ERROR: nfs_request failed: %d\n", ret);
@@ -957,8 +957,8 @@ static ssize_t nfs_read(FAR struct file *filep, FAR char *buffer,
finfo("Reading %zu bytes\n", readsize); finfo("Reading %zu bytes\n", readsize);
nfs_statistics(NFSPROC_READ); nfs_statistics(NFSPROC_READ);
ret = nfs_request(nmp, NFSPROC_READ, ret = nfs_request(nmp, NFSPROC_READ,
(FAR void *)&nmp->nm_msgbuffer.read, reqlen, &nmp->nm_msgbuffer.read, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret) if (ret)
{ {
ferr("ERROR: nfs_request failed: %d\n", ret); ferr("ERROR: nfs_request failed: %d\n", ret);
@@ -1140,8 +1140,8 @@ static ssize_t nfs_write(FAR struct file *filep, FAR const char *buffer,
nfs_statistics(NFSPROC_WRITE); nfs_statistics(NFSPROC_WRITE);
ret = nfs_request(nmp, NFSPROC_WRITE, ret = nfs_request(nmp, NFSPROC_WRITE,
(FAR void *)nmp->nm_iobuffer, reqlen, nmp->nm_iobuffer, reqlen,
(FAR void *)&nmp->nm_msgbuffer.write, &nmp->nm_msgbuffer.write,
sizeof(struct rpc_reply_write)); sizeof(struct rpc_reply_write));
if (ret) if (ret)
{ {
@@ -1579,8 +1579,8 @@ read_dir:
nfs_statistics(NFSPROC_READDIR); nfs_statistics(NFSPROC_READDIR);
ret = nfs_request(nmp, NFSPROC_READDIR, ret = nfs_request(nmp, NFSPROC_READDIR,
(FAR void *)&nmp->nm_msgbuffer.readdir, reqlen, &nmp->nm_msgbuffer.readdir, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret != OK) if (ret != OK)
{ {
ferr("ERROR: nfs_request failed: %d\n", ret); ferr("ERROR: nfs_request failed: %d\n", ret);
@@ -2081,7 +2081,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Mounted! */ /* Mounted! */
*handle = (FAR void *)nmp; *handle = nmp;
finfo("Successfully mounted\n"); finfo("Successfully mounted\n");
return OK; return OK;
@@ -2198,8 +2198,8 @@ static int nfs_fsinfo(FAR struct nfsmount *nmp)
nfs_statistics(NFSPROC_FSINFO); nfs_statistics(NFSPROC_FSINFO);
ret = nfs_request(nmp, NFSPROC_FSINFO, ret = nfs_request(nmp, NFSPROC_FSINFO,
(FAR void *)fsinfo, sizeof(struct FS3args), fsinfo, sizeof(struct FS3args),
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret) if (ret)
{ {
return ret; return ret;
@@ -2264,8 +2264,8 @@ static int nfs_fsinfo(FAR struct nfsmount *nmp)
{ {
nfs_statistics(NFSPROC_GETATTR); nfs_statistics(NFSPROC_GETATTR);
ret = nfs_request(nmp, NFSPROC_GETATTR, ret = nfs_request(nmp, NFSPROC_GETATTR,
(FAR void *)fsinfo, sizeof(struct FS3args), fsinfo, sizeof(struct FS3args),
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret) if (ret)
{ {
return ret; return ret;
@@ -2321,8 +2321,8 @@ static int nfs_statfs(FAR struct inode *mountpt, FAR struct statfs *sbp)
nfs_statistics(NFSPROC_FSSTAT); nfs_statistics(NFSPROC_FSSTAT);
ret = nfs_request(nmp, NFSPROC_FSSTAT, ret = nfs_request(nmp, NFSPROC_FSSTAT,
(FAR void *)fsstat, sizeof(struct FS3args), fsstat, sizeof(struct FS3args),
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
if (ret) if (ret)
{ {
goto errout_with_lock; goto errout_with_lock;
@@ -2420,8 +2420,8 @@ static int nfs_remove(FAR struct inode *mountpt, FAR const char *relpath)
nfs_statistics(NFSPROC_REMOVE); nfs_statistics(NFSPROC_REMOVE);
ret = nfs_request(nmp, NFSPROC_REMOVE, ret = nfs_request(nmp, NFSPROC_REMOVE,
(FAR void *)&nmp->nm_msgbuffer.removef, reqlen, &nmp->nm_msgbuffer.removef, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
errout_with_lock: errout_with_lock:
nxmutex_unlock(&nmp->nm_lock); nxmutex_unlock(&nmp->nm_lock);
@@ -2543,8 +2543,8 @@ static int nfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
nfs_statistics(NFSPROC_MKDIR); nfs_statistics(NFSPROC_MKDIR);
ret = nfs_request(nmp, NFSPROC_MKDIR, ret = nfs_request(nmp, NFSPROC_MKDIR,
(FAR void *)&nmp->nm_msgbuffer.mkdir, reqlen, &nmp->nm_msgbuffer.mkdir, reqlen,
(FAR void *)&nmp->nm_iobuffer, nmp->nm_buflen); &nmp->nm_iobuffer, nmp->nm_buflen);
if (ret) if (ret)
{ {
ferr("ERROR: nfs_request failed: %d\n", ret); ferr("ERROR: nfs_request failed: %d\n", ret);
@@ -2630,8 +2630,8 @@ static int nfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
nfs_statistics(NFSPROC_RMDIR); nfs_statistics(NFSPROC_RMDIR);
ret = nfs_request(nmp, NFSPROC_RMDIR, ret = nfs_request(nmp, NFSPROC_RMDIR,
(FAR void *)&nmp->nm_msgbuffer.rmdir, reqlen, &nmp->nm_msgbuffer.rmdir, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
errout_with_lock: errout_with_lock:
nxmutex_unlock(&nmp->nm_lock); nxmutex_unlock(&nmp->nm_lock);
@@ -2743,8 +2743,8 @@ static int nfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
nfs_statistics(NFSPROC_RENAME); nfs_statistics(NFSPROC_RENAME);
ret = nfs_request(nmp, NFSPROC_RENAME, ret = nfs_request(nmp, NFSPROC_RENAME,
(FAR void *)&nmp->nm_msgbuffer.renamef, reqlen, &nmp->nm_msgbuffer.renamef, reqlen,
(FAR void *)nmp->nm_iobuffer, nmp->nm_buflen); nmp->nm_iobuffer, nmp->nm_buflen);
errout_with_lock: errout_with_lock:
nxmutex_unlock(&nmp->nm_lock); nxmutex_unlock(&nmp->nm_lock);
+1
View File
@@ -305,6 +305,7 @@ errout_with_cache:
kmm_free(volume->cache); kmm_free(volume->cache);
errout_with_volume: errout_with_volume:
nxmutex_destroy(&volume->lock); nxmutex_destroy(&volume->lock);
nxsem_destroy(&volume->wrsem);
#ifndef CONFIG_NXFFS_PREALLOCATED #ifndef CONFIG_NXFFS_PREALLOCATED
kmm_free(volume); kmm_free(volume);
#endif #endif
+1 -1
View File
@@ -1094,7 +1094,7 @@ int nxffs_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Just increment the reference count on the ofile */ /* Just increment the reference count on the ofile */
ofile->crefs++; ofile->crefs++;
newp->f_priv = (FAR void *)ofile; newp->f_priv = ofile;
return OK; return OK;
} }
+2 -2
View File
@@ -602,7 +602,7 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* the file. * the file.
*/ */
*ppv = (FAR void *)(rm->rm_xipbase + rf->rf_startoffset); *ppv = rm->rm_xipbase + rf->rf_startoffset;
return OK; return OK;
} }
else if (cmd == FIOC_FILEPATH) else if (cmd == FIOC_FILEPATH)
@@ -1098,7 +1098,7 @@ static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Mounted! */ /* Mounted! */
*handle = (FAR void *)rm; *handle = rm;
return OK; return OK;
errout_with_buffer: errout_with_buffer:
+14 -15
View File
@@ -33,7 +33,6 @@
#include <nuttx/mtd/mtd.h> #include <nuttx/mtd/mtd.h>
#include <nuttx/fs/smart.h> #include <nuttx/fs/smart.h>
#include <nuttx/mutex.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@@ -194,7 +193,7 @@
#define SMARTFS_TRUNCBUFFER_SIZE 512 #define SMARTFS_TRUNCBUFFER_SIZE 512
#ifndef offsetof #ifndef offsetof
# define offsetof(type, member) ((size_t) & (((type *)0)->member)) # define offsetof(type, member) ((size_t)&(((FAR type *)0)->member))
#endif #endif
#ifdef CONFIG_SMARTFS_ALIGNED_ACCESS #ifdef CONFIG_SMARTFS_ALIGNED_ACCESS
@@ -207,12 +206,12 @@
(uint16_t)(v)) (uint16_t)(v))
#else #else
# define SMARTFS_NEXTSECTOR(h) (*((uint16_t *)h->nextsector)) # define SMARTFS_NEXTSECTOR(h) (*((FAR uint16_t *)h->nextsector))
# define SMARTFS_SET_NEXTSECTOR(h, v) ((*((uint16_t *)h->nextsector)) = \ # define SMARTFS_SET_NEXTSECTOR(h, v) ((*((FAR uint16_t *)h->nextsector)) = \
(uint16_t)(v)) (uint16_t)(v))
# define SMARTFS_USED(h) (*((uint16_t *)h->used)) # define SMARTFS_USED(h) (*((FAR uint16_t *)h->used))
# define SMARTFS_SET_USED(h, v) ((*((uint16_t *)h->used)) = \ # define SMARTFS_SET_USED(h, v) ((*((FAR uint16_t *)h->used)) = \
(uint16_t)(v)) (uint16_t)(v))
#endif #endif
@@ -290,9 +289,9 @@ struct smartfs_chain_header_s
struct smartfs_ofile_s struct smartfs_ofile_s
{ {
struct smartfs_ofile_s *fnext; /* Supports a singly linked list */ FAR struct smartfs_ofile_s *fnext; /* Supports a singly linked list */
#ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER #ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER
uint8_t *buffer; /* Sector buffer to reduce writes */ FAR uint8_t *buffer; /* Sector buffer to reduce writes */
uint8_t bflags; /* Buffer flags */ uint8_t bflags; /* Buffer flags */
#endif #endif
int16_t crefs; /* Reference count */ int16_t crefs; /* Reference count */
@@ -318,14 +317,14 @@ struct smartfs_ofile_s
struct smartfs_mountpt_s struct smartfs_mountpt_s
{ {
#if defined(CONFIG_SMARTFS_MULTI_ROOT_DIRS) || defined(CONFIG_FS_PROCFS) #if defined(CONFIG_SMARTFS_MULTI_ROOT_DIRS) || defined(CONFIG_FS_PROCFS)
struct smartfs_mountpt_s *fs_next; /* Pointer to next SMART filesystem */ FAR struct smartfs_mountpt_s *fs_next; /* Pointer to next SMART filesystem */
#endif #endif
FAR struct inode *fs_blkdriver; /* Our underlying block device */ FAR struct inode *fs_blkdriver; /* Our underlying block device */
FAR struct smartfs_ofile_s *fs_head; /* A singly-linked list of open files */ FAR struct smartfs_ofile_s *fs_head; /* A singly-linked list of open files */
bool fs_mounted; /* true: The file system is ready */ bool fs_mounted; /* true: The file system is ready */
struct smart_format_s fs_llformat; /* Low level device format info */ struct smart_format_s fs_llformat; /* Low level device format info */
char *fs_rwbuffer; /* Read/Write working buffer */ FAR char *fs_rwbuffer; /* Read/Write working buffer */
char *fs_workbuffer; /* Working buffer */ FAR char *fs_workbuffer; /* Working buffer */
uint8_t fs_rootsector; /* Root directory sector num */ uint8_t fs_rootsector; /* Root directory sector num */
}; };
@@ -377,18 +376,18 @@ int smartfs_extendfile(FAR struct smartfs_mountpt_s *fs,
uint16_t smartfs_rdle16(FAR const void *val); uint16_t smartfs_rdle16(FAR const void *val);
void smartfs_wrle16(void *dest, uint16_t val); void smartfs_wrle16(FAR void *dest, uint16_t val);
uint32_t smartfs_rdle32(FAR const void *val); uint32_t smartfs_rdle32(FAR const void *val);
void smartfs_wrle32(uint8_t *dest, uint32_t val); void smartfs_wrle32(FAR uint8_t *dest, uint32_t val);
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)
struct smartfs_mountpt_s *smartfs_get_first_mount(void); FAR struct smartfs_mountpt_s *smartfs_get_first_mount(void);
#endif #endif
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)
struct smartfs_mountpt_s *smartfs_get_first_mount(void); FAR struct smartfs_mountpt_s *smartfs_get_first_mount(void);
#endif #endif
struct file; /* Forward references */ struct file; /* Forward references */
+81 -80
View File
@@ -62,12 +62,12 @@ struct smartfs_dir_s
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static int smartfs_open(FAR struct file *filep, const char *relpath, static int smartfs_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode); int oflags, mode_t mode);
static int smartfs_close(FAR struct file *filep); static int smartfs_close(FAR struct file *filep);
static ssize_t smartfs_read(FAR struct file *filep, char *buffer, static ssize_t smartfs_read(FAR struct file *filep, FAR char *buffer,
size_t buflen); size_t buflen);
static ssize_t smartfs_write(FAR struct file *filep, const char *buffer, static ssize_t smartfs_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen); size_t buflen);
static off_t smartfs_seek(FAR struct file *filep, off_t offset, static off_t smartfs_seek(FAR struct file *filep, off_t offset,
int whence); int whence);
@@ -95,7 +95,7 @@ static int smartfs_rewinddir(FAR struct inode *mountpt,
static int smartfs_bind(FAR struct inode *blkdriver, static int smartfs_bind(FAR struct inode *blkdriver,
FAR const void *data, FAR const void *data,
FAR void **handle); FAR void **handle);
static int smartfs_unbind(void *handle, FAR struct inode **blkdriver, static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
unsigned int flags); unsigned int flags);
static int smartfs_statfs(FAR struct inode *mountpt, static int smartfs_statfs(FAR struct inode *mountpt,
FAR struct statfs *buf); FAR struct statfs *buf);
@@ -109,7 +109,7 @@ static int smartfs_rmdir(FAR struct inode *mountpt,
FAR const char *relpath); FAR const char *relpath);
static int smartfs_rename(FAR struct inode *mountpt, static int smartfs_rename(FAR struct inode *mountpt,
FAR const char *oldrelpath, FAR const char *oldrelpath,
const char *newrelpath); FAR const char *newrelpath);
static void smartfs_stat_common(FAR struct smartfs_mountpt_s *fs, static void smartfs_stat_common(FAR struct smartfs_mountpt_s *fs,
FAR struct smartfs_entry_s *entry, FAR struct smartfs_entry_s *entry,
FAR struct stat *buf); FAR struct stat *buf);
@@ -172,15 +172,15 @@ const struct mountpt_operations smartfs_operations =
* Name: smartfs_open * Name: smartfs_open
****************************************************************************/ ****************************************************************************/
static int smartfs_open(FAR struct file *filep, const char *relpath, static int smartfs_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode) int oflags, mode_t mode)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
uint16_t parentdirsector; uint16_t parentdirsector;
const char *filename; FAR const char *filename;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
#ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER #ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER
struct smart_read_write_s readwrite; struct smart_read_write_s readwrite;
#endif #endif
@@ -208,7 +208,7 @@ static int smartfs_open(FAR struct file *filep, const char *relpath,
/* Locate the directory entry for this path */ /* Locate the directory entry for this path */
sf = (struct smartfs_ofile_s *)kmm_malloc(sizeof *sf); sf = (FAR struct smartfs_ofile_s *)kmm_malloc(sizeof *sf);
if (sf == NULL) if (sf == NULL)
{ {
ret = -ENOMEM; ret = -ENOMEM;
@@ -218,7 +218,7 @@ static int smartfs_open(FAR struct file *filep, const char *relpath,
/* Allocate a sector buffer if CRC enabled in the MTD layer */ /* Allocate a sector buffer if CRC enabled in the MTD layer */
#ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER #ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER
sf->buffer = (uint8_t *)kmm_malloc(fs->fs_llformat.availbytes); sf->buffer = (FAR uint8_t *)kmm_malloc(fs->fs_llformat.availbytes);
if (sf->buffer == NULL) if (sf->buffer == NULL)
{ {
/* Error ... no memory */ /* Error ... no memory */
@@ -340,7 +340,7 @@ static int smartfs_open(FAR struct file *filep, const char *relpath,
readwrite.logsector = sf->currsector; readwrite.logsector = sf->currsector;
readwrite.offset = 0; readwrite.offset = 0;
readwrite.count = fs->fs_llformat.availbytes; readwrite.count = fs->fs_llformat.availbytes;
readwrite.buffer = (uint8_t *) sf->buffer; readwrite.buffer = (FAR uint8_t *)sf->buffer;
ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
@@ -409,11 +409,11 @@ errout_with_lock:
static int smartfs_close(FAR struct file *filep) static int smartfs_close(FAR struct file *filep)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
struct smartfs_ofile_s *nextfile; FAR struct smartfs_ofile_s *nextfile;
struct smartfs_ofile_s *prevfile; FAR struct smartfs_ofile_s *prevfile;
int ret; int ret;
/* Sanity checks */ /* Sanity checks */
@@ -511,14 +511,14 @@ okout:
* Name: smartfs_read * Name: smartfs_read
****************************************************************************/ ****************************************************************************/
static ssize_t smartfs_read(FAR struct file *filep, char *buffer, static ssize_t smartfs_read(FAR struct file *filep, FAR char *buffer,
size_t buflen) size_t buflen)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
struct smart_read_write_s readwrite; struct smart_read_write_s readwrite;
struct smartfs_chain_header_s *header; FAR struct smartfs_chain_header_s *header;
int ret = OK; int ret = OK;
uint32_t bytesread; uint32_t bytesread;
uint16_t bytestoread; uint16_t bytestoread;
@@ -562,7 +562,7 @@ static ssize_t smartfs_read(FAR struct file *filep, char *buffer,
readwrite.logsector = sf->currsector; readwrite.logsector = sf->currsector;
readwrite.offset = 0; readwrite.offset = 0;
readwrite.buffer = (uint8_t *) fs->fs_rwbuffer; readwrite.buffer = (FAR uint8_t *)fs->fs_rwbuffer;
readwrite.count = fs->fs_llformat.availbytes; readwrite.count = fs->fs_llformat.availbytes;
ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
@@ -574,7 +574,7 @@ static ssize_t smartfs_read(FAR struct file *filep, char *buffer,
/* Point header to the read data to get used byte count */ /* Point header to the read data to get used byte count */
header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; header = (FAR struct smartfs_chain_header_s *)fs->fs_rwbuffer;
/* Get number of used bytes in this sector */ /* Get number of used bytes in this sector */
@@ -644,14 +644,14 @@ errout_with_lock:
* Name: smartfs_write * Name: smartfs_write
****************************************************************************/ ****************************************************************************/
static ssize_t smartfs_write(FAR struct file *filep, const char *buffer, static ssize_t smartfs_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen) size_t buflen)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
struct smart_read_write_s readwrite; struct smart_read_write_s readwrite;
struct smartfs_chain_header_s *header; FAR struct smartfs_chain_header_s *header;
size_t byteswritten; size_t byteswritten;
int ret; int ret;
@@ -701,7 +701,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
* a new one. * a new one.
*/ */
header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; header = (FAR struct smartfs_chain_header_s *)fs->fs_rwbuffer;
byteswritten = 0; byteswritten = 0;
while ((sf->filepos < sf->entry.datlen) && (buflen > 0)) while ((sf->filepos < sf->entry.datlen) && (buflen > 0))
{ {
@@ -714,7 +714,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
readwrite.offset = sf->curroffset; readwrite.offset = sf->curroffset;
readwrite.logsector = sf->currsector; readwrite.logsector = sf->currsector;
readwrite.buffer = (uint8_t *) &buffer[byteswritten]; readwrite.buffer = (FAR uint8_t *)&buffer[byteswritten];
readwrite.count = fs->fs_llformat.availbytes - sf->curroffset; readwrite.count = fs->fs_llformat.availbytes - sf->curroffset;
/* Limit the write based on available data to write */ /* Limit the write based on available data to write */
@@ -763,7 +763,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
*/ */
readwrite.offset = 0; readwrite.offset = 0;
readwrite.buffer = (uint8_t *) fs->fs_rwbuffer; readwrite.buffer = (FAR uint8_t *)fs->fs_rwbuffer;
readwrite.count = sizeof(struct smartfs_chain_header_s); readwrite.count = sizeof(struct smartfs_chain_header_s);
ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
@@ -802,7 +802,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
#else /* CONFIG_SMARTFS_USE_SECTOR_BUFFER */ #else /* CONFIG_SMARTFS_USE_SECTOR_BUFFER */
readwrite.offset = sf->curroffset; readwrite.offset = sf->curroffset;
readwrite.logsector = sf->currsector; readwrite.logsector = sf->currsector;
readwrite.buffer = (uint8_t *) &buffer[byteswritten]; readwrite.buffer = (FAR uint8_t *)&buffer[byteswritten];
readwrite.count = fs->fs_llformat.availbytes - sf->curroffset; readwrite.count = fs->fs_llformat.availbytes - sf->curroffset;
if (readwrite.count > buflen) if (readwrite.count > buflen)
{ {
@@ -851,7 +851,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
/* Copy the new sector to the old one and chain it */ /* Copy the new sector to the old one and chain it */
header = (struct smartfs_chain_header_s *) sf->buffer; header = (FAR struct smartfs_chain_header_s *)sf->buffer;
SMARTFS_SET_NEXTSECTOR(header, ret); SMARTFS_SET_NEXTSECTOR(header, ret);
/* Now sync the file to write this sector out */ /* Now sync the file to write this sector out */
@@ -907,11 +907,11 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
/* Copy the new sector to the old one and chain it */ /* Copy the new sector to the old one and chain it */
header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; header = (FAR struct smartfs_chain_header_s *)fs->fs_rwbuffer;
SMARTFS_SET_NEXTSECTOR(header, ret); SMARTFS_SET_NEXTSECTOR(header, ret);
readwrite.offset = offsetof(struct smartfs_chain_header_s, readwrite.offset = offsetof(struct smartfs_chain_header_s,
nextsector); nextsector);
readwrite.buffer = (uint8_t *) header->nextsector; readwrite.buffer = (FAR uint8_t *)header->nextsector;
readwrite.count = sizeof(uint16_t); readwrite.count = sizeof(uint16_t);
ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
@@ -952,9 +952,9 @@ errout_with_lock:
static off_t smartfs_seek(FAR struct file *filep, off_t offset, int whence) static off_t smartfs_seek(FAR struct file *filep, off_t offset, int whence)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
int ret; int ret;
/* Sanity checks */ /* Sanity checks */
@@ -1010,9 +1010,9 @@ static int smartfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
static int smartfs_sync(FAR struct file *filep) static int smartfs_sync(FAR struct file *filep)
{ {
struct inode *inode; FAR struct inode *inode;
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
int ret; int ret;
/* Sanity checks */ /* Sanity checks */
@@ -1050,7 +1050,7 @@ static int smartfs_sync(FAR struct file *filep)
static int smartfs_dup(FAR const struct file *oldp, FAR struct file *newp) static int smartfs_dup(FAR const struct file *oldp, FAR struct file *newp)
{ {
struct smartfs_ofile_s *sf; FAR struct smartfs_ofile_s *sf;
finfo("Dup %p->%p\n", oldp, newp); finfo("Dup %p->%p\n", oldp, newp);
@@ -1069,7 +1069,7 @@ static int smartfs_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Just increment the reference count on the ofile */ /* Just increment the reference count on the ofile */
sf->crefs++; sf->crefs++;
newp->f_priv = (FAR void *)sf; newp->f_priv = sf;
return OK; return OK;
} }
@@ -1298,11 +1298,11 @@ static int smartfs_readdir(FAR struct inode *mountpt,
{ {
FAR struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
FAR struct smartfs_dir_s *sdir; FAR struct smartfs_dir_s *sdir;
int ret; FAR struct smartfs_chain_header_s *header;
uint16_t entrysize;
struct smartfs_chain_header_s *header;
struct smart_read_write_s readwrite; struct smart_read_write_s readwrite;
struct smartfs_entry_header_s *entry; FAR struct smartfs_entry_header_s *entry;
uint16_t entrysize;
int ret;
/* Sanity checks */ /* Sanity checks */
@@ -1332,7 +1332,7 @@ static int smartfs_readdir(FAR struct inode *mountpt,
readwrite.logsector = sdir->fs_currsector; readwrite.logsector = sdir->fs_currsector;
readwrite.count = fs->fs_llformat.availbytes; readwrite.count = fs->fs_llformat.availbytes;
readwrite.buffer = (uint8_t *)fs->fs_rwbuffer; readwrite.buffer = (FAR uint8_t *)fs->fs_rwbuffer;
readwrite.offset = 0; readwrite.offset = 0;
ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
@@ -1350,7 +1350,7 @@ static int smartfs_readdir(FAR struct inode *mountpt,
{ {
/* Point to next entry */ /* Point to next entry */
entry = (struct smartfs_entry_header_s *) &fs->fs_rwbuffer[ entry = (FAR struct smartfs_entry_header_s *)&fs->fs_rwbuffer[
sdir->fs_curroffset]; sdir->fs_curroffset];
/* Test if this entry is valid and active */ /* Test if this entry is valid and active */
@@ -1406,7 +1406,7 @@ static int smartfs_readdir(FAR struct inode *mountpt,
sdir->fs_curroffset = sdir->fs_curroffset =
sizeof(struct smartfs_chain_header_s); sizeof(struct smartfs_chain_header_s);
header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; header = (FAR struct smartfs_chain_header_s *)fs->fs_rwbuffer;
sdir->fs_currsector = SMARTFS_NEXTSECTOR(header); sdir->fs_currsector = SMARTFS_NEXTSECTOR(header);
} }
@@ -1421,7 +1421,7 @@ static int smartfs_readdir(FAR struct inode *mountpt,
* done and will report ENOENT. * done and will report ENOENT.
*/ */
header = (struct smartfs_chain_header_s *) fs->fs_rwbuffer; header = (FAR struct smartfs_chain_header_s *)fs->fs_rwbuffer;
sdir->fs_curroffset = sizeof(struct smartfs_chain_header_s); sdir->fs_curroffset = sizeof(struct smartfs_chain_header_s);
sdir->fs_currsector = SMARTFS_NEXTSECTOR(header); sdir->fs_currsector = SMARTFS_NEXTSECTOR(header);
} }
@@ -1442,7 +1442,8 @@ errout_with_lock:
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir) static int smartfs_rewinddir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{ {
FAR struct smartfs_dir_s *sdir = (FAR struct smartfs_dir_s *)dir; FAR struct smartfs_dir_s *sdir = (FAR struct smartfs_dir_s *)dir;
@@ -1469,10 +1470,10 @@ static int smartfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_bind(FAR struct inode *blkdriver, const void *data, static int smartfs_bind(FAR struct inode *blkdriver, FAR const void *data,
void **handle) FAR void **handle)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
/* Open the block driver */ /* Open the block driver */
@@ -1490,7 +1491,7 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data,
/* Create an instance of the mountpt state structure */ /* Create an instance of the mountpt state structure */
fs = (struct smartfs_mountpt_s *) fs = (FAR struct smartfs_mountpt_s *)
kmm_zalloc(sizeof(struct smartfs_mountpt_s)); kmm_zalloc(sizeof(struct smartfs_mountpt_s));
if (!fs) if (!fs)
{ {
@@ -1522,7 +1523,7 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data,
return ret; return ret;
} }
*handle = (FAR void *)fs; *handle = fs;
nxmutex_unlock(&g_lock); nxmutex_unlock(&g_lock);
return OK; return OK;
} }
@@ -1587,9 +1588,9 @@ static int smartfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_statfs(struct inode *mountpt, struct statfs *buf) static int smartfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
/* Sanity checks */ /* Sanity checks */
@@ -1639,12 +1640,12 @@ static int smartfs_statfs(struct inode *mountpt, struct statfs *buf)
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_unlink(struct inode *mountpt, const char *relpath) static int smartfs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
struct smartfs_entry_s entry; struct smartfs_entry_s entry;
const char *filename; FAR const char *filename;
uint16_t parentdirsector; uint16_t parentdirsector;
/* Sanity checks */ /* Sanity checks */
@@ -1711,14 +1712,14 @@ errout_with_lock:
* *
****************************************************************************/ ****************************************************************************/
static int smartfs_mkdir(struct inode *mountpt, const char *relpath, static int smartfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
mode_t mode) mode_t mode)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
struct smartfs_entry_s entry; struct smartfs_entry_s entry;
uint16_t parentdirsector; uint16_t parentdirsector;
const char *filename; FAR const char *filename;
/* Sanity checks */ /* Sanity checks */
@@ -1799,12 +1800,12 @@ errout_with_lock:
* *
****************************************************************************/ ****************************************************************************/
int smartfs_rmdir(struct inode *mountpt, const char *relpath) int smartfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
struct smartfs_entry_s entry; struct smartfs_entry_s entry;
const char *filename; FAR const char *filename;
uint16_t parentdirsector; uint16_t parentdirsector;
/* Sanity checks */ /* Sanity checks */
@@ -1893,20 +1894,20 @@ errout_with_lock:
* *
****************************************************************************/ ****************************************************************************/
int smartfs_rename(struct inode *mountpt, const char *oldrelpath, int smartfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
const char *newrelpath) FAR const char *newrelpath)
{ {
struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
int ret; int ret;
struct smartfs_entry_s oldentry; struct smartfs_entry_s oldentry;
uint16_t oldparentdirsector; uint16_t oldparentdirsector;
const char *oldfilename; FAR const char *oldfilename;
struct smartfs_entry_s newentry; struct smartfs_entry_s newentry;
uint16_t newparentdirsector; uint16_t newparentdirsector;
const char *newfilename; FAR const char *newfilename;
mode_t mode; mode_t mode;
uint16_t type; uint16_t type;
struct smartfs_entry_header_s *direntry; FAR struct smartfs_entry_header_s *direntry;
struct smart_read_write_s readwrite; struct smart_read_write_s readwrite;
/* Sanity checks */ /* Sanity checks */
@@ -1970,7 +1971,7 @@ int smartfs_rename(struct inode *mountpt, const char *oldrelpath,
readwrite.logsector = oldentry.dsector; readwrite.logsector = oldentry.dsector;
readwrite.offset = 0; readwrite.offset = 0;
readwrite.count = fs->fs_llformat.availbytes; readwrite.count = fs->fs_llformat.availbytes;
readwrite.buffer = (uint8_t *) fs->fs_rwbuffer; readwrite.buffer = (FAR uint8_t *)fs->fs_rwbuffer;
ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_READSECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
{ {
@@ -1979,7 +1980,7 @@ int smartfs_rename(struct inode *mountpt, const char *oldrelpath,
goto errout_with_lock; goto errout_with_lock;
} }
direntry = (struct smartfs_entry_header_s *) direntry = (FAR struct smartfs_entry_header_s *)
&fs->fs_rwbuffer[oldentry.doffset]; &fs->fs_rwbuffer[oldentry.doffset];
#if CONFIG_SMARTFS_ERASEDSTATE == 0xff #if CONFIG_SMARTFS_ERASEDSTATE == 0xff
direntry->flags &= ~SMARTFS_DIRENT_ACTIVE; direntry->flags &= ~SMARTFS_DIRENT_ACTIVE;
@@ -1991,7 +1992,7 @@ int smartfs_rename(struct inode *mountpt, const char *oldrelpath,
readwrite.offset = oldentry.doffset; readwrite.offset = oldentry.doffset;
readwrite.count = sizeof(direntry->flags); readwrite.count = sizeof(direntry->flags);
readwrite.buffer = (uint8_t *) &direntry->flags; readwrite.buffer = (FAR uint8_t *)&direntry->flags;
ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long)&readwrite); ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long)&readwrite);
if (ret < 0) if (ret < 0)
{ {
@@ -2085,7 +2086,7 @@ static int smartfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
FAR struct stat *buf) FAR struct stat *buf)
{ {
FAR struct smartfs_mountpt_s *fs; FAR struct smartfs_mountpt_s *fs;
FAR struct smartfs_entry_s entry; struct smartfs_entry_s entry;
FAR const char *filename; FAR const char *filename;
uint16_t parentdirsector; uint16_t parentdirsector;
int ret; int ret;
+15 -10
View File
@@ -51,8 +51,8 @@ typedef struct eventfd_waiter_sem_s
struct eventfd_priv_s struct eventfd_priv_s
{ {
mutex_t lock; /* Enforces device exclusive access */ mutex_t lock; /* Enforces device exclusive access */
eventfd_waiter_sem_t *rdsems; /* List of blocking readers */ FAR eventfd_waiter_sem_t *rdsems; /* List of blocking readers */
eventfd_waiter_sem_t *wrsems; /* List of blocking writers */ FAR eventfd_waiter_sem_t *wrsems; /* List of blocking writers */
eventfd_t counter; /* eventfd counter */ eventfd_t counter; /* eventfd counter */
unsigned int minor; /* eventfd minor number */ unsigned int minor; /* eventfd minor number */
uint8_t crefs; /* References counts on eventfd (max: 255) */ uint8_t crefs; /* References counts on eventfd (max: 255) */
@@ -84,7 +84,7 @@ static int eventfd_do_poll(FAR struct file *filep, FAR struct pollfd *fds,
#endif #endif
static int eventfd_blocking_io(FAR struct eventfd_priv_s *dev, static int eventfd_blocking_io(FAR struct eventfd_priv_s *dev,
eventfd_waiter_sem_t *sem, FAR eventfd_waiter_sem_t *sem,
FAR eventfd_waiter_sem_t **slist); FAR eventfd_waiter_sem_t **slist);
static unsigned int eventfd_get_unique_minor(void); static unsigned int eventfd_get_unique_minor(void);
@@ -237,7 +237,7 @@ static int eventfd_do_close(FAR struct file *filep)
} }
static int eventfd_blocking_io(FAR struct eventfd_priv_s *dev, static int eventfd_blocking_io(FAR struct eventfd_priv_s *dev,
eventfd_waiter_sem_t *sem, FAR eventfd_waiter_sem_t *sem,
FAR eventfd_waiter_sem_t **slist) FAR eventfd_waiter_sem_t **slist)
{ {
int ret; int ret;
@@ -252,14 +252,15 @@ static int eventfd_blocking_io(FAR struct eventfd_priv_s *dev,
if (ret < 0) if (ret < 0)
{ {
FAR eventfd_waiter_sem_t *cur_sem;
/* Interrupted wait, unregister semaphore /* Interrupted wait, unregister semaphore
* TODO ensure that lock wait does not fail (ECANCELED) * TODO ensure that lock wait does not fail (ECANCELED)
*/ */
nxmutex_lock(&dev->lock); nxmutex_lock(&dev->lock);
eventfd_waiter_sem_t *cur_sem = *slist; cur_sem = *slist;
if (cur_sem == sem) if (cur_sem == sem)
{ {
*slist = sem->next; *slist = sem->next;
@@ -288,6 +289,7 @@ static ssize_t eventfd_do_read(FAR struct file *filep, FAR char *buffer,
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct eventfd_priv_s *dev = inode->i_private; FAR struct eventfd_priv_s *dev = inode->i_private;
FAR eventfd_waiter_sem_t *cur_sem;
ssize_t ret; ssize_t ret;
if (len < sizeof(eventfd_t) || buffer == NULL) if (len < sizeof(eventfd_t) || buffer == NULL)
@@ -305,13 +307,14 @@ static ssize_t eventfd_do_read(FAR struct file *filep, FAR char *buffer,
if (dev->counter == 0) if (dev->counter == 0)
{ {
eventfd_waiter_sem_t sem;
if (filep->f_oflags & O_NONBLOCK) if (filep->f_oflags & O_NONBLOCK)
{ {
nxmutex_unlock(&dev->lock); nxmutex_unlock(&dev->lock);
return -EAGAIN; return -EAGAIN;
} }
eventfd_waiter_sem_t sem;
nxsem_init(&sem.sem, 0, 0); nxsem_init(&sem.sem, 0, 0);
do do
{ {
@@ -348,7 +351,7 @@ static ssize_t eventfd_do_read(FAR struct file *filep, FAR char *buffer,
/* Notify all waiting writers that counter have been decremented */ /* Notify all waiting writers that counter have been decremented */
eventfd_waiter_sem_t *cur_sem = dev->wrsems; cur_sem = dev->wrsems;
while (cur_sem != NULL) while (cur_sem != NULL)
{ {
nxsem_post(&cur_sem->sem); nxsem_post(&cur_sem->sem);
@@ -366,6 +369,7 @@ static ssize_t eventfd_do_write(FAR struct file *filep,
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct eventfd_priv_s *dev = inode->i_private; FAR struct eventfd_priv_s *dev = inode->i_private;
FAR eventfd_waiter_sem_t *cur_sem;
ssize_t ret; ssize_t ret;
eventfd_t new_counter; eventfd_t new_counter;
@@ -386,6 +390,8 @@ static ssize_t eventfd_do_write(FAR struct file *filep,
if (new_counter < dev->counter) if (new_counter < dev->counter)
{ {
eventfd_waiter_sem_t sem;
/* Overflow detected */ /* Overflow detected */
if (filep->f_oflags & O_NONBLOCK) if (filep->f_oflags & O_NONBLOCK)
@@ -394,7 +400,6 @@ static ssize_t eventfd_do_write(FAR struct file *filep,
return -EAGAIN; return -EAGAIN;
} }
eventfd_waiter_sem_t sem;
nxsem_init(&sem.sem, 0, 0); nxsem_init(&sem.sem, 0, 0);
do do
{ {
@@ -423,7 +428,7 @@ static ssize_t eventfd_do_write(FAR struct file *filep,
/* Notify all of the waiting readers */ /* Notify all of the waiting readers */
eventfd_waiter_sem_t *cur_sem = dev->rdsems; cur_sem = dev->rdsems;
while (cur_sem != NULL) while (cur_sem != NULL)
{ {
nxsem_post(&cur_sem->sem); nxsem_post(&cur_sem->sem);
+10 -7
View File
@@ -63,7 +63,7 @@ typedef struct timerfd_waiter_sem_s
struct timerfd_priv_s struct timerfd_priv_s
{ {
mutex_t lock; /* Enforces device exclusive access */ mutex_t lock; /* Enforces device exclusive access */
timerfd_waiter_sem_t *rdsems; /* List of blocking readers */ FAR timerfd_waiter_sem_t *rdsems; /* List of blocking readers */
int clock; /* Clock to use as the timing base */ int clock; /* Clock to use as the timing base */
int delay; /* If non-zero, used to reset repetitive int delay; /* If non-zero, used to reset repetitive
* timers */ * timers */
@@ -98,7 +98,7 @@ static int timerfd_poll(FAR struct file *filep, FAR struct pollfd *fds,
#endif #endif
static int timerfd_blocking_io(FAR struct timerfd_priv_s *dev, static int timerfd_blocking_io(FAR struct timerfd_priv_s *dev,
timerfd_waiter_sem_t *sem, FAR timerfd_waiter_sem_t *sem,
FAR timerfd_waiter_sem_t **slist); FAR timerfd_waiter_sem_t **slist);
static unsigned int timerfd_get_unique_minor(void); static unsigned int timerfd_get_unique_minor(void);
@@ -268,7 +268,7 @@ static int timerfd_close(FAR struct file *filep)
} }
static int timerfd_blocking_io(FAR struct timerfd_priv_s *dev, static int timerfd_blocking_io(FAR struct timerfd_priv_s *dev,
timerfd_waiter_sem_t *sem, FAR timerfd_waiter_sem_t *sem,
FAR timerfd_waiter_sem_t **slist) FAR timerfd_waiter_sem_t **slist)
{ {
int ret; int ret;
@@ -283,14 +283,15 @@ static int timerfd_blocking_io(FAR struct timerfd_priv_s *dev,
if (ret < 0) if (ret < 0)
{ {
FAR timerfd_waiter_sem_t *cur_sem;
/* Interrupted wait, unregister semaphore /* Interrupted wait, unregister semaphore
* TODO ensure that lock wait does not fail (ECANCELED) * TODO ensure that lock wait does not fail (ECANCELED)
*/ */
nxmutex_lock(&dev->lock); nxmutex_lock(&dev->lock);
timerfd_waiter_sem_t *cur_sem = *slist; cur_sem = *slist;
if (cur_sem == sem) if (cur_sem == sem)
{ {
*slist = sem->next; *slist = sem->next;
@@ -337,13 +338,14 @@ static ssize_t timerfd_read(FAR struct file *filep, FAR char *buffer,
if (timerfd_get_counter(dev) == 0) if (timerfd_get_counter(dev) == 0)
{ {
timerfd_waiter_sem_t sem;
if (filep->f_oflags & O_NONBLOCK) if (filep->f_oflags & O_NONBLOCK)
{ {
nxmutex_unlock(&dev->lock); nxmutex_unlock(&dev->lock);
return -EAGAIN; return -EAGAIN;
} }
timerfd_waiter_sem_t sem;
nxsem_init(&sem.sem, 0, 0); nxsem_init(&sem.sem, 0, 0);
do do
{ {
@@ -448,6 +450,7 @@ out:
static void timerfd_timeout_work(FAR void *arg) static void timerfd_timeout_work(FAR void *arg)
{ {
FAR struct timerfd_priv_s *dev = (FAR struct timerfd_priv_s *)arg; FAR struct timerfd_priv_s *dev = (FAR struct timerfd_priv_s *)arg;
FAR timerfd_waiter_sem_t *cur_sem;
int ret; int ret;
ret = nxmutex_lock(&dev->lock); ret = nxmutex_lock(&dev->lock);
@@ -465,7 +468,7 @@ static void timerfd_timeout_work(FAR void *arg)
/* Notify all of the waiting readers */ /* Notify all of the waiting readers */
timerfd_waiter_sem_t *cur_sem = dev->rdsems; cur_sem = dev->rdsems;
while (cur_sem != NULL) while (cur_sem != NULL)
{ {
nxsem_post(&cur_sem->sem); nxsem_post(&cur_sem->sem);
+1 -1
View File
@@ -109,7 +109,7 @@ struct nxterm_state_s
{ {
FAR const struct nxterm_operations_s *ops; /* Window operations */ FAR const struct nxterm_operations_s *ops; /* Window operations */
FAR void *handle; /* The window handle */ FAR void *handle; /* The window handle */
FAR struct nxterm_window_s wndo; /* Describes the window and font */ struct nxterm_window_s wndo; /* Describes the window and font */
mutex_t lock; /* Forces mutually exclusive access */ mutex_t lock; /* Forces mutually exclusive access */
#ifdef CONFIG_DEBUG_GRAPHICS #ifdef CONFIG_DEBUG_GRAPHICS
pid_t holder; /* Deadlock avoidance */ pid_t holder; /* Deadlock avoidance */
+2 -2
View File
@@ -128,8 +128,8 @@ struct dac_ops_s
struct dac_dev_s struct dac_dev_s
{ {
const struct dac_ops_s *ad_ops; /* Arch-specific operations */ FAR const struct dac_ops_s *ad_ops; /* Arch-specific operations */
void *ad_priv; /* Used by the arch-specific logic */ FAR void *ad_priv; /* Used by the arch-specific logic */
uint8_t ad_ocount; /* The number of times the device has uint8_t ad_ocount; /* The number of times the device has
* been opened */ * been opened */
uint8_t ad_nchannel; /* Number of dac channel */ uint8_t ad_nchannel; /* Number of dac channel */
+2 -2
View File
@@ -129,7 +129,7 @@ struct rwbuffer_s
#ifdef CONFIG_DRVR_WRITEBUFFER #ifdef CONFIG_DRVR_WRITEBUFFER
mutex_t wrlock; /* Enforces exclusive access to the write buffer */ mutex_t wrlock; /* Enforces exclusive access to the write buffer */
struct work_s work; /* Delayed work to flush buffer after a delay with no activity */ struct work_s work; /* Delayed work to flush buffer after a delay with no activity */
uint8_t *wrbuffer; /* Allocated write buffer */ FAR uint8_t *wrbuffer; /* Allocated write buffer */
uint16_t wrnblocks; /* Number of blocks in write buffer */ uint16_t wrnblocks; /* Number of blocks in write buffer */
off_t wrblockstart; /* First block in write buffer */ off_t wrblockstart; /* First block in write buffer */
#endif #endif
@@ -138,7 +138,7 @@ struct rwbuffer_s
#ifdef CONFIG_DRVR_READAHEAD #ifdef CONFIG_DRVR_READAHEAD
mutex_t rhlock; /* Enforces exclusive access to the write buffer */ mutex_t rhlock; /* Enforces exclusive access to the write buffer */
uint8_t *rhbuffer; /* Allocated read-ahead buffer */ FAR uint8_t *rhbuffer; /* Allocated read-ahead buffer */
uint16_t rhnblocks; /* Number of blocks in read-ahead buffer */ uint16_t rhnblocks; /* Number of blocks in read-ahead buffer */
off_t rhblockstart; /* First block in read-ahead buffer */ off_t rhblockstart; /* First block in read-ahead buffer */
#endif #endif