BCH driver should forward ioctl commands to the contained block driver

This commit is contained in:
Gregory Nutt 2015-11-09 11:47:25 -06:00
parent 2ab0832c26
commit 896834002a
3 changed files with 33 additions and 11 deletions

View File

@ -11074,3 +11074,6 @@
* arch/arm/src/samv7: The QSPI FLASH driver is now functional. This
driver operates in the memory-mapped, Serial Memory Mode (SMM)
(2015-11-07).
* drivers/bch: Block-to-character (BCH) driver should forward ioctl()
calls to the contained block driver (2015-11-09).

View File

@ -61,18 +61,18 @@
struct bchlib_s
{
struct inode *inode; /* I-node of the block driver */
sem_t sem; /* For atomic accesses to this structure */
size_t nsectors; /* Number of sectors supported by the device */
size_t sector; /* The current sector in the buffer */
uint16_t sectsize; /* The size of one sector on the device */
uint8_t refs; /* Number of references */
bool dirty; /* Data has been written to the buffer */
bool readonly; /* true: Only read operations are supported */
FAR uint8_t *buffer; /* One sector buffer */
FAR struct inode *inode; /* I-node of the block driver */
sem_t sem; /* For atomic accesses to this structure */
size_t nsectors; /* Number of sectors supported by the device */
size_t sector; /* The current sector in the buffer */
uint16_t sectsize; /* The size of one sector on the device */
uint8_t refs; /* Number of references */
bool dirty; /* Data has been written to the buffer */
bool readonly; /* true: Only read operations are supported */
FAR uint8_t *buffer; /* One sector buffer */
#if defined(CONFIG_BCH_ENCRYPTION)
uint8_t key[CONFIG_BCH_ENCRYPTION_KEY_SIZE]; /* Encryption key */
uint8_t key[CONFIG_BCH_ENCRYPTION_KEY_SIZE]; /* Encryption key */
#endif
};

View File

@ -302,6 +302,8 @@ static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
DEBUGASSERT(inode && inode->i_private);
bch = (FAR struct bchlib_s *)inode->i_private;
/* Is this a request to get the private data structure */
if (cmd == DIOC_GETPRIV)
{
FAR struct bchlib_s **bchr = (FAR struct bchlib_s **)((uintptr_t)arg);
@ -319,7 +321,10 @@ static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
bchlib_semgive(bch);
}
#if defined(CONFIG_BCH_ENCRYPTION)
#ifdef CONFIG_BCH_ENCRYPTION
/* Is this a request to set the encryption key? */
else if (cmd == DIOC_SETKEY)
{
memcpy(bch->key, (FAR void *)arg, CONFIG_BCH_ENCRYPTION_KEY_SIZE);
@ -327,6 +332,20 @@ static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
#endif
/* Otherwise, pass the IOCTL command on to the contained block driver */
else
{
FAR struct inode *bchinode = bch->inode;
/* Does the block driver support the ioctl method? */
if (bchinode->u.i_bops->ioctl != NULL)
{
ret = bchinode->u.i_bops->ioctl(bchinode, cmd, arg);
}
}
return ret;
}