[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200130122055.GA2584455@ulmo>
Date: Thu, 30 Jan 2020 13:20:55 +0100
From: Thierry Reding <thierry.reding@...il.com>
To: Sowjanya Komatineni <skomatineni@...dia.com>
Cc: jonathanh@...dia.com, frankc@...dia.com, hverkuil@...all.nl,
linux-media@...r.kernel.org, devicetree@...r.kernel.org,
linux-clk@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: Re: [RFC PATCH v1 4/5] media: tegra: Add Tegra Video input
driver for Tegra210
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
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists