Messages in this thread | | | Subject | Re: Re: Re: [RFC PATCH v1 4/5] media: tegra: Add Tegra Video input driver for Tegra210 | From | Sowjanya Komatineni <> | Date | Thu, 30 Jan 2020 09:02:21 -0800 |
| |
On 1/30/20 4:20 AM, Thierry Reding wrote: > 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 > [...] >>>> + media_device_init(&cam->media_dev); >>>> + 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); >>> There should be no need to call host1x_device_exit() when >>> host1x_device_init() failed because the latter already takes care of >>> undoing whatever it did already. >>> >> host1x_device_init can fail if any of its client ops init fails. >> >> So, calling host1x_device_exit here to undo the things done in other >> successful client init ops. > host1x_device_init() already takes care of undoing what it did on > 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
Sorry, yes I see host1x_device_init calls exit ops on failures .
Will remove it. Thanks Thierry.
| |