lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130430061625.GC16843@pengutronix.de>
Date:	Tue, 30 Apr 2013 08:16:25 +0200
From:	Sascha Hauer <s.hauer@...gutronix.de>
To:	Prabhakar Lad <prabhakar.csengg@...il.com>
Cc:	LMML <linux-media@...r.kernel.org>,
	Hans Verkuil <hans.verkuil@...co.com>,
	Laurent Pinchart <laurent.pinchart@...asonboard.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,

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@...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.

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ