mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	gpio: adnp: use new line value setter callbacks
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Link: https://lore.kernel.org/r/20250306-gpiochip-set-conversion-v2-2-a76e72e21425@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
		
							parent
							
								
									c7fe19ed39
								
							
						
					
					
						commit
						21c853ad93
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -80,7 +80,7 @@ static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset)
 | 
				
			||||||
	return (value & BIT(pos)) ? 1 : 0;
 | 
						return (value & BIT(pos)) ? 1 : 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value)
 | 
					static int __adnp_gpio_set(struct adnp *adnp, unsigned int offset, int value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned int reg = offset >> adnp->reg_shift;
 | 
						unsigned int reg = offset >> adnp->reg_shift;
 | 
				
			||||||
	unsigned int pos = offset & 7;
 | 
						unsigned int pos = offset & 7;
 | 
				
			||||||
| 
						 | 
					@ -89,23 +89,23 @@ static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = adnp_read(adnp, GPIO_PLR(adnp) + reg, &val);
 | 
						err = adnp_read(adnp, GPIO_PLR(adnp) + reg, &val);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (value)
 | 
						if (value)
 | 
				
			||||||
		val |= BIT(pos);
 | 
							val |= BIT(pos);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		val &= ~BIT(pos);
 | 
							val &= ~BIT(pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	adnp_write(adnp, GPIO_PLR(adnp) + reg, val);
 | 
						return adnp_write(adnp, GPIO_PLR(adnp) + reg, val);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 | 
					static int adnp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct adnp *adnp = gpiochip_get_data(chip);
 | 
						struct adnp *adnp = gpiochip_get_data(chip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	guard(mutex)(&adnp->i2c_lock);
 | 
						guard(mutex)(&adnp->i2c_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__adnp_gpio_set(adnp, offset, value);
 | 
						return __adnp_gpio_set(adnp, offset, value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 | 
					static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 | 
				
			||||||
| 
						 | 
					@ -430,7 +430,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios,
 | 
				
			||||||
	chip->direction_input = adnp_gpio_direction_input;
 | 
						chip->direction_input = adnp_gpio_direction_input;
 | 
				
			||||||
	chip->direction_output = adnp_gpio_direction_output;
 | 
						chip->direction_output = adnp_gpio_direction_output;
 | 
				
			||||||
	chip->get = adnp_gpio_get;
 | 
						chip->get = adnp_gpio_get;
 | 
				
			||||||
	chip->set = adnp_gpio_set;
 | 
						chip->set_rv = adnp_gpio_set;
 | 
				
			||||||
	chip->can_sleep = true;
 | 
						chip->can_sleep = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (IS_ENABLED(CONFIG_DEBUG_FS))
 | 
						if (IS_ENABLED(CONFIG_DEBUG_FS))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue