!54 重写代码,将嵌套的结构体成员指向与强转分层,使代码更清晰

Merge pull request !54 from JING/drv
This commit is contained in:
openharmony_ci
2021-05-21 18:38:41 +08:00
committed by Gitee
@@ -38,7 +38,8 @@ uint32_t TouchPoll(struct file *filep, InputDevice *inputDev, poll_table *wait);
static int32_t InputDevIoctl(struct file *filep, int32_t cmd, unsigned long arg)
{
int32_t ret;
InputDevice *inputdev = (InputDevice *)((struct drv_data*)filep->f_vnode->data)->priv;
struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data;
InputDevice *inputdev = (InputDevice *)drvData->priv;
if (inputdev == NULL) {
return HDF_FAILURE;
}
@@ -57,7 +58,8 @@ static int32_t InputDevIoctl(struct file *filep, int32_t cmd, unsigned long arg)
static int32_t InputDevOpen(struct file *filep)
{
InputDevice *inputdev = (InputDevice *)((struct drv_data*)filep->f_vnode->data)->priv;
struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data;
InputDevice *inputdev = (InputDevice *)drvData->priv;
if (inputdev == NULL) {
HDF_LOGE("%s: filep is null", __func__);
return HDF_FAILURE;
@@ -67,7 +69,8 @@ static int32_t InputDevOpen(struct file *filep)
static int32_t InputDevClose(struct file *filep)
{
InputDevice *inputdev = (InputDevice *)((struct drv_data*)filep->f_vnode->data)->priv;
struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data;
InputDevice *inputdev = (InputDevice *)drvData->priv;
if (inputdev == NULL) {
HDF_LOGE("%s: inputdev is null", __func__);
return HDF_FAILURE;
@@ -79,7 +82,8 @@ static int32_t InputDevClose(struct file *filep)
static int32_t InputDevPoll(struct file *filep, poll_table *wait)
{
uint32_t pollMask = 0;
InputDevice *inputdev = (InputDevice *)(InputDevice *)((struct drv_data*)filep->f_vnode->data)->priv;
struct drv_data *drvData = (struct drv_data *)filep->f_vnode->data;
InputDevice *inputdev = (InputDevice *)drvData->priv;
switch (inputdev->devType) {
case INDEV_TYPE_TOUCH:
pollMask = TouchPoll(filep, inputdev, wait);