Subject: Re: [PATCH RFC 3/7] [POWERPC] CPM2: implement GPIO API

From: Jochen Friedrich <[email-masked]>
Date: Wed, 12 Dec 2007 16:49:46 +0100

Hi Anton,

> +int gpio_direction_input(unsigned int gpio)
> +{
> +	unsigned long flags;
> +	int port = gpio / 32;
> +	int pin = gpio % 32;
> +
> +	spin_lock_irqsave(&cpm2_port_locks[port], flags);
> +
> +	cpm2_set_pin(port, pin, CPM_PIN_INPUT | CPM_PIN_GPIO);

> +int gpio_direction_output(unsigned int gpio, int value)
> +{
> +	struct cpm2_ioports __iomem *iop =
> +		(struct cpm2_ioports __iomem *)&cpm2_immr->im_ioport;
> +	int port = gpio / 32;
> +	int pin = gpio % 32;
> +	unsigned long flags;
> +
> +	pin = 1 << (31 - pin);
> +
> +	spin_lock_irqsave(&cpm2_port_locks[port], flags);
> +
> +	cpm2_set_pin(port, pin, CPM_PIN_OUTPUT | CPM_PIN_GPIO);

You seem to do the pin -> bitmask conversation twice in gpio_direction_output().

cpm2_set_pin() must be executed before pin = 1 << (31 - pin);

Thanks,
Jochen