From: Sascha Hauer <s.hauer@pengutronix.de>
To: Prabhakar Lad <prabhakar.csengg@gmail.com>
Cc: LMML <linux-media@vger.kernel.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.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 08:16:25 +0200 [thread overview]
Message-ID: <20130430061625.GC16843@pengutronix.de> (raw)
In-Reply-To: <1367222401-26649-1-git-send-email-prabhakar.csengg@gmail.com>
Hi,
One more point for your devicetree conversions,
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.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2013-04-30 6:16 UTC|newest]
Thread overview: 9+ 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:35 ` Laurent Pinchart
2013-04-29 11:48 ` Prabhakar Lad
2013-04-29 14:12 ` Laurent Pinchart
2013-04-30 6:16 ` Sascha Hauer [this message]
2013-04-30 11:45 ` Laurent Pinchart
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=20130430061625.GC16843@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=g.liakhovetski@gmx.de \
--cc=grant.likely@secretlab.ca \
--cc=hans.verkuil@cisco.com \
--cc=laurent.pinchart@ideasonboard.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.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 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).