From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>,
LMML <linux-media@vger.kernel.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Sakari Ailus <sakari.ailus@iki.fi>,
Grant Likely <grant.likely@secretlab.ca>,
Rob Herring <rob.herring@calxeda.com>,
Rob Landley <rob@landley.net>,
devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] media: i2c: mt9p031: add OF support
Date: Tue, 30 Apr 2013 13:45:31 +0200 [thread overview]
Message-ID: <2667885.kq9SiOBOqS@avalon> (raw)
In-Reply-To: <20130430061625.GC16843@pengutronix.de>
Hi Sascha,
On Tuesday 30 April 2013 08:16:25 Sascha Hauer wrote:
> On Mon, Apr 29, 2013 at 01:30:01PM +0530, Prabhakar Lad wrote:
> > From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> >
> > add OF support for the mt9p031 sensor driver.
> >
> > +static struct mt9p031_platform_data
> > + *mt9p031_get_pdata(struct i2c_client *client)
> > +
> > +{
> > + if (!client->dev.platform_data && client->dev.of_node) {
> > + struct device_node *np;
> > + struct mt9p031_platform_data *pdata;
> > + int ret;
> > +
> > + np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
> > + if (!np)
> > + return NULL;
> > +
> > + pdata = devm_kzalloc(&client->dev,
> > + sizeof(struct mt9p031_platform_data),
> > + GFP_KERNEL);
> > + if (!pdata) {
> > + pr_warn("mt9p031 failed allocate memeory\n");
> > + return NULL;
> > + }
> > + ret = of_property_read_u32(np, "reset", &pdata->reset);
> > + if (ret == -EINVAL)
> > + pdata->reset = -1;
> > + else if (ret == -ENODATA)
> > + return NULL;
> > +
> > + if (of_property_read_u32(np, "ext_freq", &pdata->ext_freq))
> > + return NULL;
> > +
> > + if (of_property_read_u32(np, "target_freq",
> > + &pdata->target_freq))
> > + return NULL;
> > +
> > + return pdata;
> > + }
>
> I don't know how the others see this, but IMO it would be cleaner to
> first add a duplicate of the members of pdata in struct mt9p031 and then
> initialize them either from pdata or from devicetree data. The
> (artificial) creation of platform_data for the devicetree case adds a
> new level of indirection. This may not be a problem here, but there are
> cases where there is no 1:1 transcription between pdata and devicetree
> possible.
I have no strong opinion on this. In the mt9p031 case it won't matter much,
but it's probably a good idea in general.
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2013-04-30 11:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-29 8:00 [PATCH RFC] media: i2c: mt9p031: add OF support Prabhakar Lad
2013-04-29 8:21 ` Sascha Hauer
2013-04-29 11:11 ` Prabhakar Lad
[not found] ` <CA+V-a8uM61Rzqa2y9b6FZVin2FWHg6o9kO7fqHupqq2dcBT3SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-04-29 11:17 ` Laurent Pinchart
2013-04-29 11:17 ` Laurent Pinchart
2013-04-29 11:35 ` Laurent Pinchart
2013-04-29 11:48 ` Prabhakar Lad
2013-04-29 14:12 ` Laurent Pinchart
2013-04-30 6:16 ` Sascha Hauer
2013-04-30 11:45 ` Laurent Pinchart [this message]
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=2667885.kq9SiOBOqS@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=g.liakhovetski@gmx.de \
--cc=grant.likely@secretlab.ca \
--cc=hans.verkuil@cisco.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=prabhakar.csengg@gmail.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=s.hauer@pengutronix.de \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@iki.fi \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.