[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2667885.kq9SiOBOqS@avalon>
Date: Tue, 30 Apr 2013 13:45:31 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Sascha Hauer <s.hauer@...gutronix.de>
Cc: Prabhakar Lad <prabhakar.csengg@...il.com>,
LMML <linux-media@...r.kernel.org>,
Hans Verkuil <hans.verkuil@...co.com>,
Mauro Carvalho Chehab <mchehab@...hat.com>,
Guennadi Liakhovetski <g.liakhovetski@....de>,
Sylwester Nawrocki <s.nawrocki@...sung.com>,
Sakari Ailus <sakari.ailus@....fi>,
Grant Likely <grant.likely@...retlab.ca>,
Rob Herring <rob.herring@...xeda.com>,
Rob Landley <rob@...dley.net>,
devicetree-discuss@...ts.ozlabs.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC] media: i2c: mt9p031: add OF support
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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists