struct v4l2_subdev *sd結構體?
struct v4l2_subdev {
#if defined(CONFIG_MEDIA_CONTROLLER)struct media_entity entity;
#endifstruct list_head list;struct module *owner;bool owner_v4l2_dev;u32 flags;struct v4l2_device *v4l2_dev;const struct v4l2_subdev_ops *ops;const struct v4l2_subdev_internal_ops *internal_ops;struct v4l2_ctrl_handler *ctrl_handler;char name[V4L2_SUBDEV_NAME_SIZE];u32 grp_id;void *dev_priv;void *host_priv;struct video_device *devnode;struct device *dev;struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;struct v4l2_async_notifier *subdev_notifier;struct v4l2_subdev_platform_data *pdata;
};
sd->ops
if(sd->ops == NULL){DEBUG_CORE("sd->ops NULL");break;}
然后看看?v4l2_subdev_ops 的定義
static const struct v4l2_subdev_ops ov5645_subdev_ops = {.core = &ov5645_core_ops,.video = &ov5645_video_ops,.pad = &ov5645_subdev_pad_ops,
};
if(sd->ops->core == NULL){DEBUG_CORE("sd->ops->core NULL");break;}
最后判斷ioctl是否為空
if(sd->ops->core->ioctl == NULL){DEBUG_CORE("sd->ops->core NULL");break;}sd->ops->core->ioctl(sd, ctrl->id, &ctrl->val);
小結
最后把 v4l2_subdev_call(sd, core, ioctl, ctrl->id,ctrl->val);
轉換為了?sd->ops->core->ioctl(sd, ctrl->id, &ctrl->val);
轉換這個主要是為了空指針檢查。解決問題了以后,還是用原來的宏就行了。