GPIO driver: Add an IOCTL to unregister a signal handler
This commit is contained in:
parent
0f9fb09a53
commit
9685fd8c99
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue