[U-Boot] [PATCH 1/1] altera_pio: fix get_value

Simon Goldschmidt simon.k.r.goldschmidt at gmail.com
Sat Jan 5 08:34:16 UTC 2019


Am 04.01.2019 um 19:53 schrieb Marek Vasut:
> On 1/4/19 5:48 PM, Julien BĂ©raud wrote:
>> gpio_get_value should return 0 or 1, not 1 << pin
> 
> Is this documented somewhere ?

I saw it's kind of documented on 'dm_gpio_get_value', but not on struct 
dm_gpio_ops:

"@return GPIO value (0 for inactive, 1 for active) or -ve on error"

Regards,
Simon

> 
>> Signed-off-by: Julien Beraud <julien.beraud at orolia.com>
>> ---
>>   drivers/gpio/altera_pio.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
>> index 59e30979f0..997c32e56d 100644
>> --- a/drivers/gpio/altera_pio.c
>> +++ b/drivers/gpio/altera_pio.c
>> @@ -56,7 +56,7 @@ static int altera_pio_get_value(struct udevice *dev, unsigned pin)
>>   	struct altera_pio_platdata *plat = dev_get_platdata(dev);
>>   	struct altera_pio_regs *const regs = plat->regs;
>>   
>> -	return readl(&regs->data) & (1 << pin);
>> +	return (readl(&regs->data) >> pin) & 1;
> 
> return !!(..condition..);
> 
>>   }
>>   
>>   
>>
> 
> 



More information about the U-Boot mailing list