struct cal_camerarx *phy[CAL_NUM_CSI2_PORTS];
struct cal_ctx *ctx[CAL_NUM_CONTEXT];
+
+ struct v4l2_device v4l2_dev;
};
/*
* There is one cal_ctx structure for each camera core context.
*/
struct cal_ctx {
- struct v4l2_device v4l2_dev;
struct v4l2_ctrl_handler ctrl_handler;
struct video_device vdev;
struct v4l2_async_notifier notifier;
vfd = &ctx->vdev;
*vfd = cal_videodev;
- vfd->v4l2_dev = &ctx->v4l2_dev;
+ vfd->v4l2_dev = &ctx->cal->v4l2_dev;
vfd->queue = q;
/* Initialize the control handler. */
}
ctx->notifier.ops = &cal_async_ops;
- ret = v4l2_async_notifier_register(&ctx->v4l2_dev,
+ ret = v4l2_async_notifier_register(&ctx->cal->v4l2_dev,
&ctx->notifier);
if (ret) {
ctx_err(ctx, "Error registering async notifier\n");
/* save the cal_dev * for future ref */
ctx->cal = cal;
- snprintf(ctx->v4l2_dev.name, sizeof(ctx->v4l2_dev.name),
- "%s-%03d", CAL_MODULE_NAME, inst);
- ret = v4l2_device_register(&cal->pdev->dev, &ctx->v4l2_dev);
- if (ret)
- return NULL;
-
/* Make sure Camera Core H/W register area is available */
ctx->phy = cal->phy[inst];
ctx->cport = inst;
ret = of_cal_create_instance(ctx, inst);
- if (ret) {
- ret = -EINVAL;
- goto unreg_dev;
- }
- return ctx;
+ if (ret)
+ return NULL;
-unreg_dev:
- v4l2_device_unregister(&ctx->v4l2_dev);
- return NULL;
+ return ctx;
}
static const struct of_device_id cal_of_match[] = {
return PTR_ERR(cal->phy[i]);
}
+ /* Register the V4L2 device. */
+ ret = v4l2_device_register(&pdev->dev, &cal->v4l2_dev);
+ if (ret) {
+ cal_err(cal, "Failed to register V4L2 device\n");
+ return ret;
+ }
+
/* Create contexts. */
for (i = 0; i < cal->data->num_csi2_phy; ++i)
cal->ctx[i] = cal_ctx_create(cal, i);
if (!cal->ctx[0] && !cal->ctx[1]) {
cal_err(cal, "Neither port is configured, no point in staying up\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto error_v4l2;
}
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
pm_runtime_enable(&pdev->dev);
ret = pm_runtime_get_sync(&pdev->dev);
if (ret)
- goto runtime_disable;
+ goto error_pm_runtime;
cal_get_hwinfo(cal);
pm_runtime_put_sync(&pdev->dev);
return 0;
-runtime_disable:
+error_pm_runtime:
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
pm_runtime_disable(&pdev->dev);
v4l2_async_notifier_unregister(&ctx->notifier);
v4l2_async_notifier_cleanup(&ctx->notifier);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_device_unregister(&ctx->v4l2_dev);
}
}
+error_v4l2:
+ v4l2_device_unregister(&cal->v4l2_dev);
return ret;
}
v4l2_async_notifier_unregister(&ctx->notifier);
v4l2_async_notifier_cleanup(&ctx->notifier);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_device_unregister(&ctx->v4l2_dev);
video_unregister_device(&ctx->vdev);
}
}
+ v4l2_device_unregister(&cal->v4l2_dev);
+
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);