[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141110205814.GA2591@earth.universe>
Date: Mon, 10 Nov 2014 21:58:14 +0100
From: Sebastian Reichel <sre@...nel.org>
To: Sakari Ailus <sakari.ailus@....fi>
Cc: Hans Verkuil <hans.verkuil@...co.com>, linux-media@...r.kernel.org,
Tony Lindgren <tony@...mide.com>,
Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>, linux-omap@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [RFCv2 5/8] [media] si4713: add device tree support
Hi Sakari,
On Tue, Nov 04, 2014 at 11:47:14PM +0200, Sakari Ailus wrote:
> Nice set of patches! Thanks! :-)
Thanks :)
> > [...]
> > struct si4713_device *sdev;
> > - struct si4713_platform_data *pdata = client->dev.platform_data;
> > struct v4l2_ctrl_handler *hdl;
> > - int rval, i;
> > + struct si4713_platform_data *pdata = client->dev.platform_data;
> > + struct device_node *np = client->dev.of_node;
> > + int rval;
> > +
>
> Why empty line here?
>
> It's not a bad practice to declare short temporary variables etc. as last.
Fixed in PATCHv3.
> > + struct radio_si4713_platform_data si4713_pdev_pdata;
> > + struct platform_device *si4713_pdev;
> >
> > sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL);
> > if (!sdev) {
> > @@ -1608,8 +1612,31 @@ static int si4713_probe(struct i2c_client *client,
> > goto free_ctrls;
> > }
> >
> > + if ((pdata && pdata->is_platform_device) || np) {
> > + si4713_pdev = platform_device_alloc("radio-si4713", -1);
>
> You could declare si4713_pdev here since you're not using it elsewhere.
It has been used in the put_main_pdev jump label at the bottom
outside of the scope and all access will happen out of the scope
after the refactoring you suggested below.
> > + if (!si4713_pdev)
> > + goto put_main_pdev;
> > +
> > + si4713_pdev_pdata.subdev = client;
> > + rval = platform_device_add_data(si4713_pdev, &si4713_pdev_pdata,
> > + sizeof(si4713_pdev_pdata));
> > + if (rval)
> > + goto put_main_pdev;
> > +
> > + rval = platform_device_add(si4713_pdev);
> > + if (rval)
> > + goto put_main_pdev;
> > +
> > + sdev->pd = si4713_pdev;
> > + } else {
> > + sdev->pd = NULL;
>
> sdev->pd is NULL already here. You could simply return in if () and
> proceed to create the platform device if need be.
Right. I simplified the code accordingly in PATCHv3.
> Speaking of which --- I wonder if there are other than historical
> reasons to create the platform device. I guess that's out of the scope
> of the set anyway.
I think this was done, so that the usb device can export its own
control functions.
> > [...]
> >
> > + if (sdev->pd)
> > + platform_device_unregister(sdev->pd);
>
> platform_device_unregister() may be safely called with NULL argument.
Ok. Changed in PATCHv3.
> > [...]
-- Sebastian
Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)
Powered by blists - more mailing lists