drivers/ioexpander/gpio_lower_half.c: Remove limitation when pintype > GPIO_INTERRUPT_PIN.
This commit is contained in:
parent
91ef2ec394
commit
ead2c26be8
@ -389,7 +389,7 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
*/
|
||||
|
||||
case GPIOC_REGISTER:
|
||||
if (arg && dev->gp_pintype == GPIO_INTERRUPT_PIN)
|
||||
if (arg && dev->gp_pintype >= GPIO_INTERRUPT_PIN)
|
||||
{
|
||||
pid = getpid();
|
||||
flags = spin_lock_irqsave();
|
||||
@ -439,7 +439,7 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
*/
|
||||
|
||||
case GPIOC_UNREGISTER:
|
||||
if (dev->gp_pintype == GPIO_INTERRUPT_PIN)
|
||||
if (dev->gp_pintype >= GPIO_INTERRUPT_PIN)
|
||||
{
|
||||
pid = getpid();
|
||||
flags = spin_lock_irqsave();
|
||||
@ -558,7 +558,7 @@ int gpio_pin_register(FAR struct gpio_dev_s *dev, int minor)
|
||||
}
|
||||
break;
|
||||
|
||||
case GPIO_INTERRUPT_PIN:
|
||||
default:
|
||||
{
|
||||
DEBUGASSERT(dev->gp_ops->go_read != NULL &&
|
||||
dev->gp_ops->go_attach != NULL &&
|
||||
@ -575,9 +575,6 @@ int gpio_pin_register(FAR struct gpio_dev_s *dev, int minor)
|
||||
fmt = "/dev/gpint%u";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snprintf(devname, 16, fmt, (unsigned int)minor);
|
||||
@ -620,14 +617,11 @@ void gpio_pin_unregister(FAR struct gpio_dev_s *dev, int minor)
|
||||
}
|
||||
break;
|
||||
|
||||
case GPIO_INTERRUPT_PIN:
|
||||
default:
|
||||
{
|
||||
fmt = "/dev/gpint%u";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(devname, 16, fmt, (unsigned int)minor);
|
||||
|
@ -395,7 +395,7 @@ int gpio_lower_half(FAR struct ioexpander_dev_s *ioe, unsigned int pin,
|
||||
* interrupting pin types.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(pintype != GPIO_INTERRUPT_PIN);
|
||||
DEBUGASSERT(pintype < GPIO_INTERRUPT_PIN);
|
||||
#endif
|
||||
|
||||
/* Allocate an new instance of the GPIO lower half driver */
|
||||
@ -412,18 +412,16 @@ int gpio_lower_half(FAR struct ioexpander_dev_s *ioe, unsigned int pin,
|
||||
priv->pin = (uint8_t)pin;
|
||||
priv->ioe = ioe;
|
||||
gpio = &priv->gpio;
|
||||
gpio->gp_pintype = (uint8_t)pintype;
|
||||
gpio->gp_ops = &g_gplh_ops;
|
||||
|
||||
if (pintype == GPIO_OUTPUT_PIN)
|
||||
/* Set pintype */
|
||||
|
||||
ret = gplh_setpintype(gpio, pintype);
|
||||
if (ret < 0)
|
||||
{
|
||||
IOEXP_SETDIRECTION(ioe, pin, IOEXPANDER_DIRECTION_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
IOEXP_SETDIRECTION(ioe, pin, IOEXPANDER_DIRECTION_IN);
|
||||
IOEXP_SETOPTION(ioe, pin, IOEXPANDER_OPTION_INTCFG,
|
||||
(FAR void *)g_gplh_inttype[pintype]);
|
||||
gpioerr("ERROR: gplh_setpintype() failed: %d\n", ret);
|
||||
kmm_free(priv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Register the GPIO driver */
|
||||
|
Loading…
Reference in New Issue
Block a user