boards/samv7: add lower level IOCTL handler to sam_gpio_enc driver

SAMv7 encoder driver with GPIO pins was written without IOCTL support.
While this driver does not require any lower level IOCTLs for its
functionality the upper layer fails on assertion when unknown command
can not be send to lower layer. This commit adds IOCTL handler that
always returns -ENOTTY as no commands are supported.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc 2023-06-19 14:33:09 +02:00 committed by Xiang Xiao
parent 425cc89989
commit 5b90ae9c72

View File

@ -76,6 +76,8 @@ static int sam_gpio_enc_position(struct qe_lowerhalf_s *lower, int32_t *pos);
static int sam_gpio_enc_setup(struct qe_lowerhalf_s *lower);
static int sam_gpio_enc_shutdown(struct qe_lowerhalf_s *lower);
static int sam_gpio_enc_reset(struct qe_lowerhalf_s *lower);
static int sam_gpio_enc_ioctl(struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
@ -88,7 +90,7 @@ static const struct qe_ops_s g_qecallbacks =
.position = sam_gpio_enc_position,
.setposmax = NULL,
.reset = sam_gpio_enc_reset,
.ioctl = NULL,
.ioctl = sam_gpio_enc_ioctl,
};
static struct sam_qeconfig_s sam_gpio_enc_config =
@ -300,6 +302,14 @@ static int sam_gpio_enc_shutdown(struct qe_lowerhalf_s *lower)
return OK;
}
/****************************************************************************
* Name: sam_gpio_enc_reset
*
* Description:
* Reset the position measurement to base position.
*
****************************************************************************/
static int sam_gpio_enc_reset(struct qe_lowerhalf_s *lower)
{
struct sam_gpio_enc_lowerhalf_s *priv =
@ -312,6 +322,23 @@ static int sam_gpio_enc_reset(struct qe_lowerhalf_s *lower)
return OK;
}
/****************************************************************************
* Name: sam_gpio_enc_ioctl
*
* Description:
* This method is called when IOCTL command can not be handled by upper
* half of the driver.
*
****************************************************************************/
static int sam_gpio_enc_ioctl(struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg)
{
/* No commands supported. */
return -ENOTTY;
}
/****************************************************************************
* Public Functions
****************************************************************************/