GPIO driver: Add an IOCTL to unregister a signal handler

This commit is contained in:
Gregory Nutt 2016-08-01 13:52:27 -06:00
parent 0f9fb09a53
commit 9685fd8c99
2 changed files with 36 additions and 4 deletions

View File

@ -268,6 +268,33 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break;
/* Command: GPIOC_UNREGISTER
* Description: Stop receiving signals for pin interrupts.
* Argument: None.
*/
case GPIOC_UNREGISTER:
if (dev->gp_pintype == GPIO_INTERRUPT_PIN)
{
/* Make sure that the pin interrupt is disabled */
ret = dev->gp_ops->go_enable(dev, false);
if (ret >= 0)
{
/* Detach the handler */
ret = dev->gp_ops->go_attach(dev, NULL);
dev->gp_pid = 0;
dev->gp_signo = 0;
}
}
else
{
ret = -EACCES;
}
break;
/* Unrecognized command */
default:

View File

@ -70,12 +70,17 @@
* depends upon interrupt GPIO support from the platform.
* Argument: The number of signal to be generated when the interrupt
* occurs.
*
* Command: GPIOC_UNREGISTER
* Description: Stop receiving signals for pin interrupts.
* Argument: None.
*/
#define GPIOC_WRITE _GPIOC(1)
#define GPIOC_READ _GPIOC(2)
#define GPIOC_PINTYPE _GPIOC(3)
#define GPIOC_REGISTER _GPIOC(4)
#define GPIOC_WRITE _GPIOC(1)
#define GPIOC_READ _GPIOC(2)
#define GPIOC_PINTYPE _GPIOC(3)
#define GPIOC_REGISTER _GPIOC(4)
#define GPIOC_UNREGISTER _GPIOC(5)
/****************************************************************************
* Public Types