#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
+static int v4l2_async_notifier_call_bound(struct v4l2_async_notifier *n,
+ struct v4l2_subdev *subdev,
+ struct v4l2_async_subdev *asd)
+{
+ if (!n->ops || !n->ops->bound)
+ return 0;
+
+ return n->ops->bound(n, subdev, asd);
+}
+
+static void v4l2_async_notifier_call_unbind(struct v4l2_async_notifier *n,
+ struct v4l2_subdev *subdev,
+ struct v4l2_async_subdev *asd)
+{
+ if (!n->ops || !n->ops->unbind)
+ return;
+
+ n->ops->unbind(n, subdev, asd);
+}
+
+static int v4l2_async_notifier_call_complete(struct v4l2_async_notifier *n)
+{
+ if (!n->ops || !n->ops->complete)
+ return 0;
+
+ return n->ops->complete(n);
+}
+
static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
{
#if IS_ENABLED(CONFIG_I2C)
{
int ret;
- if (notifier->ops->bound) {
- ret = notifier->ops->bound(notifier, sd, asd);
- if (ret < 0)
- return ret;
- }
+ ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+ if (ret < 0)
+ return ret;
ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
if (ret < 0) {
- if (notifier->ops->unbind)
- notifier->ops->unbind(notifier, sd, asd);
+ v4l2_async_notifier_call_unbind(notifier, sd, asd);
return ret;
}
struct v4l2_subdev *sd, *tmp;
list_for_each_entry_safe(sd, tmp, ¬ifier->done, async_list) {
- if (notifier->ops->unbind)
- notifier->ops->unbind(notifier, sd, sd->asd);
+ v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
v4l2_async_cleanup(sd);
list_move(&sd->async_list, &subdev_list);
}
}
- if (list_empty(¬ifier->waiting) && notifier->ops->complete) {
- ret = notifier->ops->complete(notifier);
+ if (list_empty(¬ifier->waiting)) {
+ ret = v4l2_async_notifier_call_complete(notifier);
if (ret)
goto err_complete;
}
if (ret)
goto err_unlock;
- if (!list_empty(¬ifier->waiting) || !notifier->ops->complete)
+ if (!list_empty(¬ifier->waiting))
goto out_unlock;
- ret = notifier->ops->complete(notifier);
+ ret = v4l2_async_notifier_call_complete(notifier);
if (ret)
goto err_cleanup;
return 0;
err_cleanup:
- if (notifier->ops->unbind)
- notifier->ops->unbind(notifier, sd, sd->asd);
+ v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
v4l2_async_cleanup(sd);
err_unlock:
list_add(&sd->asd->list, ¬ifier->waiting);
- if (notifier->ops->unbind)
- notifier->ops->unbind(notifier, sd, sd->asd);
+ v4l2_async_notifier_call_unbind(notifier, sd, sd->asd);
}
v4l2_async_cleanup(sd);