diff options
Diffstat (limited to 'drivers/gpio/gpiolib.c')
| -rw-r--r-- | drivers/gpio/gpiolib.c | 17 | 
1 files changed, 13 insertions, 4 deletions
| diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a18f00fc1bb8..3346abd29b52 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -233,7 +233,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)  		for (i = 0; i != chip->ngpio; ++i) {  			struct gpio_desc *gpio = &chip->desc[i]; -			if (!gpio->name) +			if (!gpio->name || !name)  				continue;  			if (!strcmp(gpio->name, name)) { @@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc)  	chip = desc->chip;  	offset = gpio_chip_hwgpio(desc);  	value = chip->get ? chip->get(chip, offset) : -EIO; -	value = value < 0 ? value : !!value; +	/* +	 * FIXME: fix all drivers to clamp to [0,1] or return negative, +	 * then change this to: +	 * value = value < 0 ? value : !!value; +	 * so we can properly propagate error codes. +	 */ +	value = !!value;  	trace_gpio_value(desc_to_gpio(desc), 1, value);  	return value;  } @@ -1868,12 +1874,15 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,  	/* Then from plain _CRS GPIOs */  	if (IS_ERR(desc)) { +		if (!acpi_can_fallback_to_crs(adev, con_id)) +			return ERR_PTR(-ENOENT); +  		desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info);  		if (IS_ERR(desc))  			return desc;  	} -	if (info.active_low) +	if (info.polarity == GPIO_ACTIVE_LOW)  		*flags |= GPIO_ACTIVE_LOW;  	return desc; @@ -2211,7 +2220,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,  		desc = acpi_node_get_gpiod(fwnode, propname, 0, &info);  		if (!IS_ERR(desc)) -			active_low = info.active_low; +			active_low = info.polarity == GPIO_ACTIVE_LOW;  	}  	if (IS_ERR(desc)) | 
