driver/touchscreen: add custom open/close
Add custom open/close for lower to init/deinit device. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
27e2f51d2e
commit
9f6666b75b
2 changed files with 41 additions and 0 deletions
|
|
@ -149,6 +149,11 @@ static int touch_open(FAR struct file *filep)
|
|||
|
||||
filep->f_priv = openpriv;
|
||||
nxmutex_unlock(&upper->lock);
|
||||
if (lower->open)
|
||||
{
|
||||
return lower->open(lower);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +166,7 @@ static int touch_close(FAR struct file *filep)
|
|||
FAR struct touch_openpriv_s *openpriv = filep->f_priv;
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct touch_upperhalf_s *upper = inode->i_private;
|
||||
FAR struct touch_lowerhalf_s *lower = upper->lower;
|
||||
int ret;
|
||||
|
||||
ret = nxmutex_lock(&upper->lock);
|
||||
|
|
@ -181,6 +187,11 @@ static int touch_close(FAR struct file *filep)
|
|||
kmm_free(openpriv);
|
||||
|
||||
nxmutex_unlock(&upper->lock);
|
||||
if (lower->close)
|
||||
{
|
||||
return lower->close(lower);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,36 @@ struct touch_lowerhalf_s
|
|||
|
||||
CODE ssize_t (*write)(FAR struct touch_lowerhalf_s *lower,
|
||||
FAR const char *buffer, size_t buflen);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: open
|
||||
*
|
||||
* Description:
|
||||
* Users can use this interface to implement custom open().
|
||||
*
|
||||
* Arguments:
|
||||
* lower - The instance of lower half of touchscreen device.
|
||||
*
|
||||
* Return Value:
|
||||
* Zero(OK) on success; a negated errno value on failure.
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*open)(FAR struct touch_lowerhalf_s *lower);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: close
|
||||
*
|
||||
* Description:
|
||||
* Users can use this interface to implement custom close().
|
||||
*
|
||||
* Arguments:
|
||||
* lower - The instance of lower half of touchscreen device.
|
||||
*
|
||||
* Return Value:
|
||||
* Zero(OK) on success; a negated errno value on failure.
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*close)(FAR struct touch_lowerhalf_s *lower);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue