lkml.org 
[lkml]   [2014]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-11-10 22:41    [W:0.096 / U:1.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site