Re: [PATCH v3 2/2] v4l: mt9v032: Add OF support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Laurent,

On Wed, Mar 18, 2015 at 03:32:28PM +0200, Laurent Pinchart wrote:
...
> > > @@ -876,10 +879,59 @@ static const struct regmap_config
> > > mt9v032_regmap_config = {> 
> > >   * Driver initialization and probing
> > >   */
> > > 
> > > +static struct mt9v032_platform_data *
> > > +mt9v032_get_pdata(struct i2c_client *client)
> > > +{
> > > +	struct mt9v032_platform_data *pdata;
> > > +	struct v4l2_of_endpoint endpoint;
> > > +	struct device_node *np;
> > > +	struct property *prop;
> > > +
> > > +	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
> > > +		return client->dev.platform_data;
> > > +
> > > +	np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
> > > +	if (!np)
> > > +		return NULL;
> > > +
> > > +	if (v4l2_of_parse_endpoint(np, &endpoint) < 0)
> > > +		goto done;
> > > +
> > > +	pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
> > > +	if (!pdata)
> > > +		goto done;
> > > +
> > > +	prop = of_find_property(np, "link-frequencies", NULL);
> > > +	if (prop) {
> > > +		size_t size = prop->length / 8;
> > > +		u64 *link_freqs;
> > > +
> > > +		link_freqs = devm_kzalloc(&client->dev,
> > > +					  size * sizeof(*link_freqs),
> > 
> > You could simply use prop->length here. I think that'd look nicer.
> 
> How about devm_kcalloc(&client->dev, size, sizeof(*link_freqs)) as this is 
> allocating an array ?

That's certainly fine as well, I think. Feel free to divide prop->length by
sizeof(*link_freqs) instead of plain 8.

-- 
Sakari Ailus
e-mail: sakari.ailus@xxxxxx	XMPP: sailus@xxxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux