devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [RFCv2 5/8] [media] si4713: add device tree support
Date: Mon, 10 Nov 2014 21:58:14 +0100	[thread overview]
Message-ID: <20141110205814.GA2591@earth.universe> (raw)
In-Reply-To: <54594962.2090207@iki.fi>

[-- 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 --]

  reply	other threads:[~2014-11-10 20:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 15:06 [RFCv2 0/8] [media] si4713 DT binding Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 1/8] [media] si4713: switch to devm regulator API Sebastian Reichel
     [not found]   ` <1413904027-16767-2-git-send-email-sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-11-11 11:07     ` Mauro Carvalho Chehab
2014-11-11 14:33       ` Sebastian Reichel
2014-11-11 17:59       ` Hans Verkuil
     [not found]         ` <54624E83.1060404-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2014-11-11 22:12           ` Mauro Carvalho Chehab
2014-10-21 15:07 ` [RFCv2 2/8] [media] si4713: switch reset gpio to devm_gpiod API Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 3/8] [media] si4713: use managed memory allocation Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 4/8] [media] si4713: use managed irq request Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 5/8] [media] si4713: add device tree support Sebastian Reichel
     [not found]   ` <1413904027-16767-6-git-send-email-sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-11-04 21:47     ` Sakari Ailus
2014-11-10 20:58       ` Sebastian Reichel [this message]
2014-10-21 15:07 ` [RFCv2 6/8] [media] si4713: add DT binding documentation Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 7/8] ARM: OMAP2: RX-51: update si4713 platform data Sebastian Reichel
2014-10-21 15:07 ` [RFCv2 8/8] [media] si4713: cleanup " Sebastian Reichel
2014-11-07 12:49 ` [RFCv2 0/8] [media] si4713 DT binding Hans Verkuil
2014-11-10 11:06   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141110205814.GA2591@earth.universe \
    --to=sre@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=hans.verkuil@cisco.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).