diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 0da348c2fec..ac1bfde49f1 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,7 @@ struct mtdconfig_struct_s { FAR struct mtd_dev_s *mtd; /* Contained MTD interface */ - sem_t exclsem; /* Supports mutual exclusion */ + mutex_t lock; /* Supports mutual exclusion */ uint32_t blocksize; /* Size of blocks in contained MTD */ uint32_t erasesize; /* Size of erase block in contained MTD */ size_t nblocks; /* Number of blocks available */ @@ -1004,7 +1005,7 @@ errout: * Name: mtdconfig_open ****************************************************************************/ -static int mtdconfig_open(FAR struct file *filep) +static int mtdconfig_open(FAR struct file *filep) { FAR struct inode *inode = filep->f_inode; FAR struct mtdconfig_struct_s *dev = inode->i_private; @@ -1012,7 +1013,7 @@ static int mtdconfig_open(FAR struct file *filep) /* Get exclusive access to the device */ - ret = nxsem_wait(&dev->exclsem); + ret = nxmutex_lock(&dev->lock); if (ret < 0) { ferr("ERROR: nxsem_wait failed: %d\n", ret); @@ -1036,7 +1037,7 @@ static int mtdconfig_close(FAR struct file *filep) /* Release exclusive access to the device */ - nxsem_post(&dev->exclsem); + nxmutex_unlock(&dev->lock); return OK; } @@ -1774,7 +1775,7 @@ int mtdconfig_register(FAR struct mtd_dev_s *mtd) goto errout; } - nxsem_init(&dev->exclsem, 0, 1); + nxmutex_init(&dev->lock); register_driver("/dev/config", &mtdconfig_fops, 0666, dev); } @@ -1806,7 +1807,7 @@ int mtdconfig_unregister(void) inode = file.f_inode; dev = (FAR struct mtdconfig_struct_s *)inode->i_private; - nxsem_destroy(&dev->exclsem); + nxmutex_destroy(&dev->lock); kmm_free(dev); file_close(&file);