struct v4l2_async_notifier *notifier = &bridge->notifier;
struct media_pad *pads = bridge->pads;
struct device *dev = csi2_dev->dev;
+ bool notifier_registered = false;
int ret;
mutex_init(&bridge->lock);
notifier->ops = &sun6i_mipi_csi2_notifier_ops;
ret = sun6i_mipi_csi2_bridge_source_setup(csi2_dev);
- if (ret)
+ if (ret && ret != -ENODEV)
goto error_v4l2_notifier_cleanup;
- ret = v4l2_async_subdev_nf_register(subdev, notifier);
- if (ret < 0)
- goto error_v4l2_notifier_cleanup;
+ /* Only register the notifier when a sensor is connected. */
+ if (ret != -ENODEV) {
+ ret = v4l2_async_subdev_nf_register(subdev, notifier);
+ if (ret < 0)
+ goto error_v4l2_notifier_cleanup;
+
+ notifier_registered = true;
+ }
/* V4L2 Subdev */
return 0;
error_v4l2_notifier_unregister:
- v4l2_async_nf_unregister(notifier);
+ if (notifier_registered)
+ v4l2_async_nf_unregister(notifier);
error_v4l2_notifier_cleanup:
v4l2_async_nf_cleanup(notifier);