On Wed, Jan 29, 2020 at 09:23:38AM -0800, Sowjanya Komatineni wrote:
On 1/29/20 3:13 AM, Thierry Reding wrote:[...]
On Tue, Jan 28, 2020 at 10:23:20AM -0800, Sowjanya Komatineni wrote:
[...]diff --git a/drivers/staging/media/tegra/host1x-video.c b/drivers/staging/media/tegra/host1x-video.c
host1x_device_init() already takes care of undoing what it did onhost1x_device_init can fail if any of its client ops init fails.+ media_device_init(&cam->media_dev);There should be no need to call host1x_device_exit() when
+ ret = media_device_register(&cam->media_dev);
+ if (ret < 0) {
+ dev_err(cam->dev, "failed to register media device: %d\n", ret);
+ return ret;
+ }
+
+ cam->v4l2_dev.mdev = &cam->media_dev;
+ ret = v4l2_device_register(cam->dev, &cam->v4l2_dev);
+ if (ret < 0) {
+ dev_err(cam->dev, "V4L2 device registration failed: %d\n", ret);
+ goto register_error;
+ }
+
+ dev_set_drvdata(&dev->dev, cam);
+
+ ret = host1x_device_init(dev);
+ if (ret < 0)
+ goto dev_exit;
+
+ return 0;
+
+dev_exit:
+ host1x_device_exit(dev);
host1x_device_init() failed because the latter already takes care of
undoing whatever it did already.
So, calling host1x_device_exit here to undo the things done in other
successful client init ops.
failure. Also, it makes sure to only undo what had already been done,
rather than tear down every client, even if it hadn't been initialized
yet when the failure happened. The latter is what would happen if you
called host1x_device_exit() to cleanup at this point.
Thierry