mirror of
https://github.com/apache/nuttx.git
synced 2026-10-10 07:40:27 +00:00
drivers/input, drivers/ioexpander: nxstyle
No functional change; the next commit touches both files. Signed-off-by: Royyan Zahir <royzah@gmail.com>
This commit is contained in:
parent
24368b8008
commit
bcff4ae00d
2 changed files with 83 additions and 78 deletions
|
|
@ -565,102 +565,103 @@ static int btn_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
ret = -EINVAL;
|
||||
switch (cmd)
|
||||
{
|
||||
/* Command: BTNIOC_SUPPORTED
|
||||
* Description: Report the set of button events supported by the
|
||||
* hardware;
|
||||
* Argument: A pointer to writeable integer value in which to return
|
||||
* the set of supported buttons.
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
/* Command: BTNIOC_SUPPORTED
|
||||
* Description: Report the set of button events supported by the
|
||||
* hardware;
|
||||
* Argument: A pointer to writeable integer value in which to return
|
||||
* the set of supported buttons.
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
case BTNIOC_SUPPORTED:
|
||||
{
|
||||
FAR btn_buttonset_t *supported =
|
||||
(FAR btn_buttonset_t *)((uintptr_t)arg);
|
||||
case BTNIOC_SUPPORTED:
|
||||
{
|
||||
FAR btn_buttonset_t *supported =
|
||||
(FAR btn_buttonset_t *)((uintptr_t)arg);
|
||||
|
||||
if (supported)
|
||||
{
|
||||
lower = priv->bu_lower;
|
||||
DEBUGASSERT(lower && lower->bl_supported);
|
||||
if (supported)
|
||||
{
|
||||
lower = priv->bu_lower;
|
||||
DEBUGASSERT(lower && lower->bl_supported);
|
||||
|
||||
*supported = lower->bl_supported(lower);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
*supported = lower->bl_supported(lower);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Command: BTNIOC_POLLEVENTS
|
||||
* Description: Specify the set of button events that can cause a poll()
|
||||
* to awaken. The default is all button depressions and
|
||||
* all button releases (all supported buttons);
|
||||
* Argument: A read-only pointer to an instance of struct
|
||||
* btn_pollevents_s
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
/* Command: BTNIOC_POLLEVENTS
|
||||
* Description: Specify the set of button events that can cause a
|
||||
* poll() to awaken. The default is all button
|
||||
* depressions and all button releases (all supported
|
||||
* buttons);
|
||||
* Argument: A read-only pointer to an instance of struct
|
||||
* btn_pollevents_s
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
case BTNIOC_POLLEVENTS:
|
||||
{
|
||||
FAR struct btn_pollevents_s *pollevents =
|
||||
(FAR struct btn_pollevents_s *)((uintptr_t)arg);
|
||||
case BTNIOC_POLLEVENTS:
|
||||
{
|
||||
FAR struct btn_pollevents_s *pollevents =
|
||||
(FAR struct btn_pollevents_s *)((uintptr_t)arg);
|
||||
|
||||
if (pollevents)
|
||||
{
|
||||
/* Save the poll events */
|
||||
if (pollevents)
|
||||
{
|
||||
/* Save the poll events */
|
||||
|
||||
opriv->bo_pollevents.bp_press = pollevents->bp_press;
|
||||
opriv->bo_pollevents.bp_release = pollevents->bp_release;
|
||||
opriv->bo_pollevents.bp_press = pollevents->bp_press;
|
||||
opriv->bo_pollevents.bp_release = pollevents->bp_release;
|
||||
|
||||
/* Enable/disable interrupt handling */
|
||||
/* Enable/disable interrupt handling */
|
||||
|
||||
btn_enable(priv);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
btn_enable(priv);
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Command: BTNIOC_REGISTER
|
||||
* Description: Register to receive a signal whenever there is a change
|
||||
* in any of the discrete buttone inputs. This feature,
|
||||
* of course, depends upon interrupt GPIO support from the
|
||||
* platform.
|
||||
* Argument: A read-only pointer to an instance of struct
|
||||
* btn_notify_s
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
/* Command: BTNIOC_REGISTER
|
||||
* Description: Register to receive a signal whenever there is a change
|
||||
* in any of the discrete buttone inputs. This feature,
|
||||
* of course, depends upon interrupt GPIO support from the
|
||||
* platform.
|
||||
* Argument: A read-only pointer to an instance of struct
|
||||
* btn_notify_s
|
||||
* Return: Zero (OK) on success. Minus one will be returned on
|
||||
* failure with the errno value set appropriately.
|
||||
*/
|
||||
|
||||
case BTNIOC_REGISTER:
|
||||
{
|
||||
case BTNIOC_REGISTER:
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
FAR struct btn_notify_s *notify =
|
||||
(FAR struct btn_notify_s *)((uintptr_t)arg);
|
||||
FAR struct btn_notify_s *notify =
|
||||
(FAR struct btn_notify_s *)((uintptr_t)arg);
|
||||
|
||||
if (notify)
|
||||
{
|
||||
/* Save the notification events */
|
||||
if (notify)
|
||||
{
|
||||
/* Save the notification events */
|
||||
|
||||
opriv->bo_notify.bn_press = notify->bn_press;
|
||||
opriv->bo_notify.bn_release = notify->bn_release;
|
||||
opriv->bo_notify.bn_event = notify->bn_event;
|
||||
opriv->bo_pid = nxsched_getpid();
|
||||
opriv->bo_notify.bn_press = notify->bn_press;
|
||||
opriv->bo_notify.bn_release = notify->bn_release;
|
||||
opriv->bo_notify.bn_event = notify->bn_event;
|
||||
opriv->bo_pid = nxsched_getpid();
|
||||
|
||||
/* Enable/disable interrupt handling */
|
||||
/* Enable/disable interrupt handling */
|
||||
|
||||
btn_enable(priv);
|
||||
ret = OK;
|
||||
}
|
||||
btn_enable(priv);
|
||||
ret = OK;
|
||||
}
|
||||
#else
|
||||
ret = -ENOSYS;
|
||||
ret = -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
iinfo("ERROR: Unrecognized command: %d\n", cmd);
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
default:
|
||||
iinfo("ERROR: Unrecognized command: %d\n", cmd);
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
|
|
|||
|
|
@ -786,6 +786,7 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
case GPIOC_READ:
|
||||
{
|
||||
FAR bool *ptr = (FAR bool *)((uintptr_t)arg);
|
||||
|
||||
DEBUGASSERT(ptr != NULL);
|
||||
|
||||
filep->f_priv = (FAR void *)dev->int_count;
|
||||
|
|
@ -805,6 +806,7 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
FAR enum gpio_pintype_e *ptr =
|
||||
(FAR enum gpio_pintype_e *)((uintptr_t)arg);
|
||||
|
||||
DEBUGASSERT(ptr != NULL);
|
||||
|
||||
*ptr = (enum gpio_pintype_e)dev->gp_pintype;
|
||||
|
|
@ -1027,9 +1029,10 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
* false to unmask the interrupt.
|
||||
*/
|
||||
|
||||
case GPIOC_IRQ_SETMASK:
|
||||
case GPIOC_IRQ_SETMASK:
|
||||
{
|
||||
bool mask = (bool)arg;
|
||||
|
||||
DEBUGASSERT(dev->gp_ops->go_setmask != NULL);
|
||||
ret = dev->gp_ops->go_setmask(dev, mask);
|
||||
break;
|
||||
|
|
@ -1258,6 +1261,7 @@ int gpio_pin_register_byname(FAR struct gpio_dev_s *dev,
|
|||
int gpio_pin_unregister(FAR struct gpio_dev_s *dev, int minor)
|
||||
{
|
||||
char devname[16];
|
||||
|
||||
snprintf(devname, sizeof(devname), "gpio%u", (unsigned int)minor);
|
||||
return gpio_pin_unregister_byname(dev, devname);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue