Re: [RFCv2 5/8] [media] si4713: add device tree support

Sebastian Reichel
2014-11-10T20:58:23Z

[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]