Re: Re: [RFC PATCH v1 4/5] media: tegra: Add Tegra Video input driver for Tegra210

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux