[PATCH 1/3] [POWERPC] Implement support for the GPIO LIB API

Stephen Rothwell sfr at canb.auug.org.au
Wed Jan 9 11:20:22 EST 2008


On Tue, 8 Jan 2008 21:45:18 +0300 Anton Vorontsov <avorontsov at ru.mvista.com> wrote:
>
> +int of_mm_gpiochip_add(struct device_node *np,
> +		       const struct of_gpio_chip *of_gc)
> +{
> +	int ret = -ENOMEM;
> +	struct of_mm_gpio_chip *mm_gc;
> +
> +	mm_gc = kzalloc(sizeof(*mm_gc), GFP_KERNEL);
> +	if (!mm_gc)
> +		goto err0;
> +
> +	mm_gc->of_gc = *of_gc;
> +
> +	mm_gc->of_gc.gc.label = kstrdup(np->full_name, GFP_KERNEL);
> +	if (!mm_gc->of_gc.gc.label)
> +		goto err1;
> +
> +	ret = of_get_gpiochip_base(np);
> +	if (ret < 0)
> +		goto err2;
> +
> +	mm_gc->regs = of_iomap(np, 0);
> +	if (!mm_gc->regs) {
> +		ret = -ENOMEM;
> +		goto err1;

Should this be err2?

> +	}
> +
> +	mm_gc->of_gc.gc.base = ret;
> +
> +	np->data = &mm_gc->of_gc;
> +
> +	ret = gpiochip_add(&mm_gc->of_gc.gc);
> +	if (ret)
> +		goto err2;
> +
> +	of_node_get(np);

Why do you this of_node_get(np) when you do not keep a reference to np in
this routine?

-- 
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20080109/8c561b6a/attachment.pgp>


More information about the Linuxppc-dev mailing list