[PATCH] imx-drm: imx-hdmi: move memory and resource allocation into probe function

Thierry Reding thierry.reding at gmail.com
Wed May 14 14:55:51 PDT 2014


On Wed, May 14, 2014 at 11:24:14PM +0200, Philipp Zabel wrote:
> Move memory allocation and resource acquisition from the bind function into
> the probe function. This calls the devres managed functions once instead of
> possibly multiple times in the bind function and avoids leaking memory (as
> long as the hdmi platform device stays bound).
> 
> While at it, request the irq only after the interrupt handler mutes are
> set up, to avoid spurious interrupts.
> 
> Signed-off-by: Philipp Zabel <philipp.zabel at gmail.com>
> ---
>  drivers/staging/imx-drm/imx-hdmi.c | 163 +++++++++++++++++++------------------
>  1 file changed, 83 insertions(+), 80 deletions(-)

Very nice. I like it. One comment below, though it's unrelated to what
you're trying to achieve here. It's primarily a note to myself.

> diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c
[...]
>  static int imx_hdmi_platform_probe(struct platform_device *pdev)
>  {
[...]
> +	ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
> +	if (ddc_node) {
> +		hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
> +		if (!hdmi->ddc)
> +			dev_dbg(hdmi->dev, "failed to read ddc node\n");
> +
> +		of_node_put(ddc_node);
> +	} else {
> +		dev_dbg(hdmi->dev, "no ddc property found\n");
> +	}

This seems to be emerging as a common pattern. Perhaps we should add a
common helper for this.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20140514/e583b378/attachment.sig>


More information about the dri-devel mailing list