gpio: more gpio_chip setter conversions
Subsystems (11)
cover gpio: more gpio_chip setter conversions
This is another round of GPIO driver conversions to using the int-returning value setter callbacks.
---
Bartosz Golaszewski (15):
gpio: bcm-kona: use lock guards
gpio: bcm-kona: use new line value setter callbacks
gpio: bd71815: use new line value setter callbacks
gpio: bd71828: use new line value setter callbacks
gpio: bd9571mwv: use new line value setter callbacks
gpio: bt8xx: allow to build the module with COMPILE_TEST=y
gpio: bt8xx: use lock guards
gpio: bt8xx: use new line value setter callbacks
gpio: cgbc: use new line value setter callbacks
gpio: creg-snps: use new line value setter callbacks
gpio: cros-ec: use new line value setter callbacks
gpio: crystalcove: use new line value setter callbacks
gpio: cs5535: use new line value setter callbacks
gpio: da9052: use new line value setter callbacks
gpio: da9055: use new line value setter callbacks
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-bcm-kona.c | 69 +++++++++++++---------------------------- drivers/gpio/gpio-bd71815.c | 15 ++++----- drivers/gpio/gpio-bd71828.c | 15 ++++----- drivers/gpio/gpio-bd9571mwv.c | 8 ++--- drivers/gpio/gpio-bt8xx.c | 48 ++++++++++------------------ drivers/gpio/gpio-cgbc.c | 24 ++++++++------ drivers/gpio/gpio-creg-snps.c | 10 +++--- drivers/gpio/gpio-cros-ec.c | 13 +++----- drivers/gpio/gpio-crystalcove.c | 12 +++---- drivers/gpio/gpio-cs5535.c | 6 ++-- drivers/gpio/gpio-da9052.c | 34 +++++++------------- drivers/gpio/gpio-da9055.c | 14 +++------ 13 files changed, 107 insertions(+), 163 deletions(-)
---
base-commit: 21c853ad93097619c7966542e838c54c37f57c90
change-id: 20250310-gpiochip-set-conversion-4ce7e56df55f
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH 1/15 gpio: bcm-kona: use lock guards
From: Bartosz Golaszewski <[email protected]>
Reduce the code complexity by using automatic lock guards with the raw spinlock.
--- drivers/gpio/gpio-bcm-kona.c | 64 +++++++++++++------------------------------- 1 file changed, 18 insertions(+), 46 deletions(-)
drivers/gpio/gpio-bcm-kona.c +18 -46
@@ -7,6 +7,7 @@*/ #include <linux/bitops.h> +#include <linux/cleanup.h> #include <linux/err.h> #include <linux/gpio/driver.h> #include <linux/init.h>
@@ -100,7 +101,6 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio, unsigned gpio) {u32 val; -unsigned long flags;int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);struct bcm_kona_gpio_bank *bank = &kona_gpio->banks[bank_id];
@@ -112,13 +112,11 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio, }if (--bank->gpio_unlock_count[bit] ==0 ) { -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (kona_gpio->reg_base +GPIO_PWD_STATUS (bank_id)); val |=BIT (bit);bcm_kona_gpio_write_lock_regs (kona_gpio->reg_base, bank_id, val); - -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); } }
@@ -126,19 +124,16 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, unsigned gpio) {u32 val; -unsigned long flags;int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);struct bcm_kona_gpio_bank *bank = &kona_gpio->banks[bank_id];if (bank->gpio_unlock_count[bit] ==0 ) { -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (kona_gpio->reg_base +GPIO_PWD_STATUS (bank_id)); val &= ~BIT (bit);bcm_kona_gpio_write_lock_regs (kona_gpio->reg_base, bank_id, val); - -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); } ++bank->gpio_unlock_count[bit];
@@ -161,24 +156,21 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val, reg_offset; -unsigned long flags; kona_gpio =gpiochip_get_data (chip); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); + +guard (raw_spinlock_irqsave)(&kona_gpio->lock);/* this function only applies to output pin */ if (bcm_kona_gpio_get_dir (chip, gpio) ==GPIO_LINE_DIRECTION_IN ) - goto out; +return ; reg_offset = value ?GPIO_OUT_SET (bank_id) :GPIO_OUT_CLEAR (bank_id); val =readl (reg_base + reg_offset); val |=BIT (bit);writel (val, reg_base + reg_offset); - -out: -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); }static int bcm_kona_gpio_get (struct gpio_chip *chip,unsigned gpio)
@@ -188,11 +180,11 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val, reg_offset; -unsigned long flags; kona_gpio =gpiochip_get_data (chip); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); + +guard (raw_spinlock_irqsave)(&kona_gpio->lock);if (bcm_kona_gpio_get_dir (chip, gpio) ==GPIO_LINE_DIRECTION_IN ) reg_offset =GPIO_IN_STATUS (bank_id);
@@ -202,8 +194,6 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)/* read the GPIO bank status */ val =readl (reg_base + reg_offset); -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); -/* return the specified bit status */ return !!(val &BIT (bit)); }
@@ -228,19 +218,17 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)struct bcm_kona_gpio *kona_gpio;void __iomem *reg_base;u32 val; -unsigned long flags; kona_gpio =gpiochip_get_data (chip); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); + +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_CONTROL (gpio)); val &= ~GPIO_GPCTR0_IOTR_MASK ; val |=GPIO_GPCTR0_IOTR_CMD_INPUT ;writel (val, reg_base +GPIO_CONTROL (gpio)); -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); -return 0 ; }
@@ -252,11 +240,11 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip,int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val, reg_offset; -unsigned long flags; kona_gpio =gpiochip_get_data (chip); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); + +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_CONTROL (gpio)); val &= ~GPIO_GPCTR0_IOTR_MASK ;
@@ -268,8 +256,6 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, val |=BIT (bit);writel (val, reg_base + reg_offset); -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); -return 0 ; }
@@ -289,7 +275,6 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio,struct bcm_kona_gpio *kona_gpio;void __iomem *reg_base;u32 val, res; -unsigned long flags; kona_gpio =gpiochip_get_data (chip); reg_base = kona_gpio->reg_base;
@@ -312,7 +297,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, }/* spin lock for read-modify-write of the GPIO register */ -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_CONTROL (gpio)); val &= ~GPIO_GPCTR0_DBR_MASK ;
@@ -327,8 +312,6 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio,writel (val, reg_base +GPIO_CONTROL (gpio)); -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); -return 0 ; }
@@ -367,17 +350,15 @@ static void bcm_kona_gpio_irq_ack(struct irq_data *d)int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val; -unsigned long flags; kona_gpio =irq_data_get_irq_chip_data (d); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); + +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_INT_STATUS (bank_id)); val |=BIT (bit);writel (val, reg_base +GPIO_INT_STATUS (bank_id)); - -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); }static void bcm_kona_gpio_irq_mask (struct irq_data *d)
@@ -388,19 +369,16 @@ static void bcm_kona_gpio_irq_mask(struct irq_data *d)int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val; -unsigned long flags; kona_gpio =irq_data_get_irq_chip_data (d); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_INT_MASK (bank_id)); val |=BIT (bit);writel (val, reg_base +GPIO_INT_MASK (bank_id));gpiochip_disable_irq (&kona_gpio->gpio_chip, gpio); - -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); }static void bcm_kona_gpio_irq_unmask (struct irq_data *d)
@@ -411,19 +389,16 @@ static void bcm_kona_gpio_irq_unmask(struct irq_data *d)int bank_id =GPIO_BANK (gpio);int bit =GPIO_BIT (gpio);u32 val; -unsigned long flags; kona_gpio =irq_data_get_irq_chip_data (d); reg_base = kona_gpio->reg_base; -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_INT_MSKCLR (bank_id)); val |=BIT (bit);writel (val, reg_base +GPIO_INT_MSKCLR (bank_id));gpiochip_enable_irq (&kona_gpio->gpio_chip, gpio); - -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); }static int bcm_kona_gpio_irq_set_type (struct irq_data *d,unsigned int type)
@@ -433,7 +408,6 @@ static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type)unsigned gpio = d->hwirq;u32 lvl_type;u32 val; -unsigned long flags; kona_gpio =irq_data_get_irq_chip_data (d); reg_base = kona_gpio->reg_base;
@@ -459,15 +433,13 @@ static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type)return -EINVAL ; } -raw_spin_lock_irqsave (&kona_gpio->lock, flags); +guard (raw_spinlock_irqsave)(&kona_gpio->lock); val =readl (reg_base +GPIO_CONTROL (gpio)); val &= ~GPIO_GPCTR0_ITR_MASK ; val |= lvl_type <<GPIO_GPCTR0_ITR_SHIFT ;writel (val, reg_base +GPIO_CONTROL (gpio)); -raw_spin_unlock_irqrestore (&kona_gpio->lock, flags); -return 0 ; }
Signature · 1 line
2.45.2
PATCH 2/15 gpio: bcm-kona: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-bcm-kona.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpio/gpio-bcm-kona.c +6 -3
@@ -149,7 +149,8 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)return val ?GPIO_LINE_DIRECTION_IN :GPIO_LINE_DIRECTION_OUT ; } -static void bcm_kona_gpio_set (struct gpio_chip *chip,unsigned gpio,int value) +static int bcm_kona_gpio_set (struct gpio_chip *chip,unsigned int gpio, +int value) {struct bcm_kona_gpio *kona_gpio;void __iomem *reg_base;
@@ -164,13 +165,15 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)/* this function only applies to output pin */ if (bcm_kona_gpio_get_dir (chip, gpio) ==GPIO_LINE_DIRECTION_IN ) -return ; +return 0 ; reg_offset = value ?GPIO_OUT_SET (bank_id) :GPIO_OUT_CLEAR (bank_id); val =readl (reg_base + reg_offset); val |=BIT (bit);writel (val, reg_base + reg_offset); + +return 0 ; }static int bcm_kona_gpio_get (struct gpio_chip *chip,unsigned gpio)
@@ -336,7 +339,7 @@ static const struct gpio_chip template_chip = { .direction_input = bcm_kona_gpio_direction_input, .get = bcm_kona_gpio_get, .direction_output = bcm_kona_gpio_direction_output, - .set = bcm_kona_gpio_set, + .set_rv = bcm_kona_gpio_set, .set_config = bcm_kona_gpio_set_config, .to_irq = bcm_kona_gpio_to_irq, .base = 0,
Signature · 1 line
2.45.2
PATCH 3/15 gpio: bd71815: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-bd71815.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpio/gpio-bd71815.c +6 -9
@@ -37,21 +37,18 @@ static int bd71815gpo_get(struct gpio_chip *chip, unsigned int offset)return (val >> offset) &1 ; } -static void bd71815gpo_set (struct gpio_chip *chip,unsigned int offset, -int value) +static int bd71815gpo_set (struct gpio_chip *chip,unsigned int offset, +int value) {struct bd71815_gpio *bd71815 =gpiochip_get_data (chip); -int ret, bit; +int bit; bit =BIT (offset);if (value) - ret =regmap_set_bits (bd71815->regmap,BD71815_REG_GPO , bit); -else - ret =regmap_clear_bits (bd71815->regmap,BD71815_REG_GPO , bit); +return regmap_set_bits (bd71815->regmap,BD71815_REG_GPO , bit); -if (ret) -dev_warn (bd71815->dev,"failed to toggle GPO\n" ); +return regmap_clear_bits (bd71815->regmap,BD71815_REG_GPO , bit); } static int bd71815_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -88,7 +85,7 @@ static const struct gpio_chip bd71815gpo_chip = { .owner = THIS_MODULE, .get = bd71815gpo_get, .get_direction = bd71815gpo_direction_get, - .set = bd71815gpo_set, + .set_rv = bd71815gpo_set, .set_config = bd71815_gpio_set_config, .can_sleep = true, };
Signature · 1 line
2.45.2
Re: [PATCH 03/15] gpio: bd71815: use new line value setter callbacks
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
struct
gpio_chipnow has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.Signed-off-by Bartosz Golaszewski <[email protected]>
Thanks!
Quoted 45 lines
--- drivers/gpio/gpio-bd71815.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)drivers/gpio/gpio-bd71815.c +6
-9@@ -37,21 +37,18 @@ static int bd71815gpo_get(struct gpio_chip *chip, unsigned int offset)return (val >> offset) &1 ; } -static void bd71815gpo_set (struct gpio_chip *chip,unsigned int offset, -int value) +static int bd71815gpo_set (struct gpio_chip *chip,unsigned int offset, +int value) {struct bd71815_gpio *bd71815 =gpiochip_get_data (chip); -int ret, bit; +int bit; bit =BIT (offset);if (value) - ret =regmap_set_bits (bd71815->regmap,BD71815_REG_GPO , bit); -else - ret =regmap_clear_bits (bd71815->regmap,BD71815_REG_GPO , bit); +return regmap_set_bits (bd71815->regmap,BD71815_REG_GPO , bit); -if (ret) -dev_warn (bd71815->dev,"failed to toggle GPO\n" ); +return regmap_clear_bits (bd71815->regmap,BD71815_REG_GPO , bit); } static int bd71815_gpio_set_config(struct gpio_chip *chip, unsigned int offset,@@ -88,7 +85,7 @@ static const struct gpio_chip bd71815gpo_chip = { .owner = THIS_MODULE, .get = bd71815gpo_get, .get_direction = bd71815gpo_direction_get, - .set = bd71815gpo_set, + .set_rv = bd71815gpo_set, .set_config = bd71815_gpio_set_config, .can_sleep = true, };
PATCH 4/15 gpio: bd71828: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-bd71828.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpio/gpio-bd71828.c +6 -9
@@ -16,10 +16,9 @@ struct bd71828_gpio {struct gpio_chip gpio; }; -static void bd71828_gpio_set (struct gpio_chip *chip,unsigned int offset, -int value) +static int bd71828_gpio_set (struct gpio_chip *chip,unsigned int offset, +int value) { -int ret;struct bd71828_gpio *bdgpio =gpiochip_get_data (chip);u8 val = (value) ?BD71828_GPIO_OUT_HI :BD71828_GPIO_OUT_LO ;
@@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset,* we are dealing with - then we are done */ if (offset ==HALL_GPIO_OFFSET ) -return ; +return 0 ; - ret =regmap_update_bits (bdgpio->regmap,GPIO_OUT_REG (offset), -BD71828_GPIO_OUT_MASK , val); -if (ret) -dev_err (bdgpio->dev,"Could not set gpio to %d\n" , value); +return regmap_update_bits (bdgpio->regmap,GPIO_OUT_REG (offset), +BD71828_GPIO_OUT_MASK , val); }static int bd71828_gpio_get (struct gpio_chip *chip,unsigned int offset)
@@ -112,7 +109,7 @@ static int bd71828_probe(struct platform_device *pdev) bdgpio->gpio.set_config = bd71828_gpio_set_config; bdgpio->gpio.can_sleep = true; bdgpio->gpio.get = bd71828_gpio_get; - bdgpio->gpio.set = bd71828_gpio_set; + bdgpio->gpio.set_rv = bd71828_gpio_set; bdgpio->gpio.base =-1 ;/*
Signature · 1 line
2.45.2
Matti Vaittinen
maintainerRe: [PATCH 04/15] gpio: bd71828: use new line value setter callbacks
Quoted 29 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
struct
gpio_chipnow has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpio-bd71828.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)drivers/gpio/gpio-bd71828.c +2
-3@@ -16,10 +16,9 @@ struct bd71828_gpio {struct gpio_chip gpio; }; -static void bd71828_gpio_set (struct gpio_chip *chip,unsigned int offset, -int value) +static int bd71828_gpio_set (struct gpio_chip *chip,unsigned int offset, +int value) { -int ret;struct bd71828_gpio *bdgpio =gpiochip_get_data (chip);u8 val = (value) ?BD71828_GPIO_OUT_HI :BD71828_GPIO_OUT_LO ;
drivers/gpio/gpio-bd71828.c static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, · line 30
Quoted 5 lines
drivers/gpio/gpio-bd71828.c +1
-1@@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset,* we are dealing with - then we are done */ if (offset ==HALL_GPIO_OFFSET ) -return ; +return 0 ;
Should this be -EINVAL (or, can this check be just dropped?) Value of an input pin is tried to be set.
Quoted 20 lines
drivers/gpio/gpio-bd71828.c +3
-5- ret =regmap_update_bits (bdgpio->regmap,GPIO_OUT_REG (offset), -BD71828_GPIO_OUT_MASK , val); -if (ret) -dev_err (bdgpio->dev,"Could not set gpio to %d\n" , value); +return regmap_update_bits (bdgpio->regmap,GPIO_OUT_REG (offset), +BD71828_GPIO_OUT_MASK , val); }static int bd71828_gpio_get (struct gpio_chip *chip,unsigned int offset)@@ -112,7 +109,7 @@ static int bd71828_probe(struct platform_device *pdev) bdgpio->gpio.set_config = bd71828_gpio_set_config; bdgpio->gpio.can_sleep = true; bdgpio->gpio.get = bd71828_gpio_get; - bdgpio->gpio.set = bd71828_gpio_set; + bdgpio->gpio.set_rv = bd71828_gpio_set; bdgpio->gpio.base =-1 ;/*
Re: [PATCH 04/15] gpio: bd71828: use new line value setter callbacks
Quoted 11 lines · Matti Vaittinen
drivers/gpio/gpio-bd71828.c static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, · line 30
Quoted 7 lines
drivers/gpio/gpio-bd71828.c +1
-1@@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset,* we are dealing with - then we are done */ if (offset ==HALL_GPIO_OFFSET ) -return ; +return 0 ;Should this be
-EINVAL(or, can this check be just dropped?) Value of an input pin is tried to be set.
I don't want to break existing users but I did notice that and figured that we should rather check this in core GPIO code not each individual driver.
I put that on my TODO list.
Bart
Re: [PATCH 04/15] gpio: bd71828: use new line value setter callbacks
Quoted 14 lines · Bartosz Golaszewski
Quoted 11 lines · Matti Vaittinen
drivers/gpio/gpio-bd71828.c static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset, · line 30
Quoted 7 lines
drivers/gpio/gpio-bd71828.c +1
-1@@ -28,12 +27,10 @@ static void bd71828_gpio_set(struct gpio_chip *chip, unsigned int offset,* we are dealing with - then we are done */ if (offset ==HALL_GPIO_OFFSET ) -return ; +return 0 ;Should this be
-EINVAL(or, can this check be just dropped?) Value of an input pin is tried to be set.
Quoted 3 lines
I don't want to break existing users but I did notice that and figured that we should rather check this in core GPIO code not each individual driver.
Makes sense :) Thanks!
In that case,
Quoted 4 lines
I put that on my TODO list.
Bart
PATCH 5/15 gpio: bd9571mwv: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-bd9571mwv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-bd9571mwv.c +4 -4
@@ -72,13 +72,13 @@ static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset)return val &BIT (offset); } -static void bd9571mwv_gpio_set (struct gpio_chip *chip,unsigned int offset, +static int bd9571mwv_gpio_set (struct gpio_chip *chip,unsigned int offset,int value) {struct bd9571mwv_gpio *gpio =gpiochip_get_data (chip); -regmap_update_bits (gpio->regmap,BD9571MWV_GPIO_OUT , -BIT (offset), value ?BIT (offset) :0 ); +return regmap_update_bits (gpio->regmap,BD9571MWV_GPIO_OUT , +BIT (offset), value ?BIT (offset) :0 ); }static const struct gpio_chip template_chip = {
@@ -88,7 +88,7 @@ static const struct gpio_chip template_chip = { .direction_input = bd9571mwv_gpio_direction_input, .direction_output = bd9571mwv_gpio_direction_output, .get = bd9571mwv_gpio_get, - .set = bd9571mwv_gpio_set, + .set_rv = bd9571mwv_gpio_set, .base = -1, .ngpio = 2, .can_sleep = true,
Signature · 1 line
2.45.2
Re: [PATCH 05/15] gpio: bd9571mwv: use new line value setter callbacks
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
struct
gpio_chipnow has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.Signed-off-by Bartosz Golaszewski <[email protected]>
Thanks!
Quoted 35 lines
--- drivers/gpio/gpio-bd9571mwv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpio/gpio-bd9571mwv.c +4
-4@@ -72,13 +72,13 @@ static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset)return val &BIT (offset); } -static void bd9571mwv_gpio_set (struct gpio_chip *chip,unsigned int offset, +static int bd9571mwv_gpio_set (struct gpio_chip *chip,unsigned int offset,int value) {struct bd9571mwv_gpio *gpio =gpiochip_get_data (chip); -regmap_update_bits (gpio->regmap,BD9571MWV_GPIO_OUT , -BIT (offset), value ?BIT (offset) :0 ); +return regmap_update_bits (gpio->regmap,BD9571MWV_GPIO_OUT , +BIT (offset), value ?BIT (offset) :0 ); }static const struct gpio_chip template_chip = {@@ -88,7 +88,7 @@ static const struct gpio_chip template_chip = { .direction_input = bd9571mwv_gpio_direction_input, .direction_output = bd9571mwv_gpio_direction_output, .get = bd9571mwv_gpio_get, - .set = bd9571mwv_gpio_set, + .set_rv = bd9571mwv_gpio_set, .base = -1, .ngpio = 2, .can_sleep = true,
PATCH 6/15 gpio: bt8xx: allow to build the module with COMPILE_TEST=y
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
--- drivers/gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +1 -1
@@ -1671,7 +1671,7 @@ config GPIO_AMD8111 config GPIO_BT8XX tristate "BT8XX GPIO abuser" - depends on VIDEO_BT848=n + depends on VIDEO_BT848=n || COMPILE_TEST help The BT8xx frame grabber chip has 24 GPIO pins that can be abused as a cheap PCI GPIO card.
Signature · 1 line
2.45.2
PATCH 7/15 gpio: bt8xx: use lock guards
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Reduce the code complexity by using automatic lock guards with the spinlock.
--- drivers/gpio/gpio-bt8xx.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-)
drivers/gpio/gpio-bt8xx.c +14 -29
@@ -31,6 +31,7 @@*/ +#include <linux/cleanup.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/spinlock.h>
@@ -69,10 +70,9 @@ MODULE_PARM_DESC(gpiobase, "The GPIO number base. -1 means dynamic, which is thestatic int bt8xxgpio_gpio_direction_input (struct gpio_chip *gpio,unsigned nr) {struct bt8xxgpio *bg =gpiochip_get_data (gpio); -unsigned long flags;u32 outen, data; -spin_lock_irqsave (&bg->lock, flags); +guard (spinlock_irqsave)(&bg->lock); data =bgread (BT848_GPIO_DATA ); data &= ~(1 << nr);
@@ -82,20 +82,17 @@ static int bt8xxgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) outen &= ~(1 << nr);bgwrite (outen,BT848_GPIO_OUT_EN ); -spin_unlock_irqrestore (&bg->lock, flags); -return 0 ; }static int bt8xxgpio_gpio_get (struct gpio_chip *gpio,unsigned nr) {struct bt8xxgpio *bg =gpiochip_get_data (gpio); -unsigned long flags;u32 val; -spin_lock_irqsave (&bg->lock, flags); +guard (spinlock_irqsave)(&bg->lock); + val =bgread (BT848_GPIO_DATA ); -spin_unlock_irqrestore (&bg->lock, flags);return !!(val & (1 << nr)); }
@@ -104,10 +101,9 @@ static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) {struct bt8xxgpio *bg =gpiochip_get_data (gpio); -unsigned long flags;u32 outen, data; -spin_lock_irqsave (&bg->lock, flags); +guard (spinlock_irqsave)(&bg->lock); outen =bgread (BT848_GPIO_OUT_EN ); outen |= (1 << nr);
@@ -120,8 +116,6 @@ static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio, data &= ~(1 << nr);bgwrite (data,BT848_GPIO_DATA ); -spin_unlock_irqrestore (&bg->lock, flags); -return 0 ; }
@@ -129,10 +123,9 @@ static void bt8xxgpio_gpio_set(struct gpio_chip *gpio, unsigned nr, int val) {struct bt8xxgpio *bg =gpiochip_get_data (gpio); -unsigned long flags;u32 data; -spin_lock_irqsave (&bg->lock, flags); +guard (spinlock_irqsave)(&bg->lock); data =bgread (BT848_GPIO_DATA );if (val)
@@ -140,8 +133,6 @@ static void bt8xxgpio_gpio_set(struct gpio_chip *gpio,else data &= ~(1 << nr);bgwrite (data,BT848_GPIO_DATA ); - -spin_unlock_irqrestore (&bg->lock, flags); }static void bt8xxgpio_gpio_setup (struct bt8xxgpio *bg)
@@ -236,18 +227,15 @@ static void bt8xxgpio_remove(struct pci_dev *pdev)static int bt8xxgpio_suspend (struct pci_dev *pdev,pm_message_t state) {struct bt8xxgpio *bg =pci_get_drvdata (pdev); -unsigned long flags; -spin_lock_irqsave (&bg->lock, flags); + scoped_guard(spinlock_irqsave, &bg->lock) { + bg->saved_outen =bgread (BT848_GPIO_OUT_EN ); + bg->saved_data =bgread (BT848_GPIO_DATA ); - bg->saved_outen =bgread (BT848_GPIO_OUT_EN ); - bg->saved_data =bgread (BT848_GPIO_DATA ); - -bgwrite (0 ,BT848_INT_MASK ); -bgwrite (~0x0 ,BT848_INT_STAT ); -bgwrite (0x0 ,BT848_GPIO_OUT_EN ); - -spin_unlock_irqrestore (&bg->lock, flags); +bgwrite (0 ,BT848_INT_MASK ); +bgwrite (~0x0 ,BT848_INT_STAT ); +bgwrite (0x0 ,BT848_GPIO_OUT_EN ); + }pci_save_state (pdev);pci_disable_device (pdev);
@@ -259,7 +247,6 @@ static int bt8xxgpio_suspend(struct pci_dev *pdev, pm_message_t state)static int bt8xxgpio_resume (struct pci_dev *pdev) {struct bt8xxgpio *bg =pci_get_drvdata (pdev); -unsigned long flags;int err;pci_set_power_state (pdev,PCI_D0 );
@@ -268,7 +255,7 @@ static int bt8xxgpio_resume(struct pci_dev *pdev)return err;pci_restore_state (pdev); -spin_lock_irqsave (&bg->lock, flags); +guard (spinlock_irqsave)(&bg->lock);bgwrite (0 ,BT848_INT_MASK );bgwrite (0 ,BT848_GPIO_DMA_CTL );
@@ -277,8 +264,6 @@ static int bt8xxgpio_resume(struct pci_dev *pdev)bgwrite (bg->saved_data & bg->saved_outen,BT848_GPIO_DATA ); -spin_unlock_irqrestore (&bg->lock, flags); - return 0; }#else
Signature · 1 line
2.45.2
PATCH 8/15 gpio: bt8xx: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-bt8xx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpio/gpio-bt8xx.c +4 -3
@@ -119,8 +119,7 @@ static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio,return 0 ; } -static void bt8xxgpio_gpio_set (struct gpio_chip *gpio, -unsigned nr,int val) +static int bt8xxgpio_gpio_set (struct gpio_chip *gpio,unsigned int nr,int val) {struct bt8xxgpio *bg =gpiochip_get_data (gpio);u32 data;
@@ -133,6 +132,8 @@ static void bt8xxgpio_gpio_set(struct gpio_chip *gpio,else data &= ~(1 << nr);bgwrite (data,BT848_GPIO_DATA ); + +return 0 ; }static void bt8xxgpio_gpio_setup (struct bt8xxgpio *bg)
@@ -144,7 +145,7 @@ static void bt8xxgpio_gpio_setup(struct bt8xxgpio *bg) c->direction_input = bt8xxgpio_gpio_direction_input; c->get = bt8xxgpio_gpio_get; c->direction_output = bt8xxgpio_gpio_direction_output; - c->set = bt8xxgpio_gpio_set; + c->set_rv = bt8xxgpio_gpio_set; c->dbg_show =NULL ; c->base = modparam_gpiobase; c->ngpio =BT8XXGPIO_NR_GPIOS ;
Signature · 1 line
2.45.2
PATCH 9/15 gpio: cgbc: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-cgbc.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/gpio/gpio-cgbc.c +14 -10
@@ -51,8 +51,8 @@ static int cgbc_gpio_get(struct gpio_chip *chip, unsigned int offset)return (int )(val & (u8 )BIT (offset)); } -static void __cgbc_gpio_set (struct gpio_chip *chip, -unsigned int offset,int value) +static int __cgbc_gpio_set (struct gpio_chip *chip,unsigned int offset, +int value) {struct cgbc_gpio_data *gpio =gpiochip_get_data (chip);struct cgbc_device_data *cgbc = gpio->cgbc;
@@ -61,23 +61,23 @@ static void __cgbc_gpio_set(struct gpio_chip *chip, ret =cgbc_gpio_cmd (cgbc,CGBC_GPIO_CMD_GET , (offset >7 ) ?1 :0 ,0 , &val);if (ret) -return ; +return ret;if (value) val |=BIT (offset %8 );else val &= ~(BIT (offset %8 )); -cgbc_gpio_cmd (cgbc,CGBC_GPIO_CMD_SET , (offset >7 ) ?1 :0 , val, &val); +return cgbc_gpio_cmd (cgbc,CGBC_GPIO_CMD_SET , (offset >7 ) ?1 :0 , val, &val); } -static void cgbc_gpio_set (struct gpio_chip *chip, -unsigned int offset,int value) +static int cgbc_gpio_set (struct gpio_chip *chip,unsigned int offset,int value) {struct cgbc_gpio_data *gpio =gpiochip_get_data (chip); - scoped_guard(mutex, &gpio->lock) -__cgbc_gpio_set (chip, offset, value); +guard (mutex)(&gpio->lock); + +return __cgbc_gpio_set (chip, offset, value); } static int cgbc_gpio_direction_set(struct gpio_chip *chip,
@@ -116,10 +116,14 @@ static int cgbc_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int value) {struct cgbc_gpio_data *gpio =gpiochip_get_data (chip); +int ret;guard (mutex)(&gpio->lock); -__cgbc_gpio_set (chip, offset, value); + ret =__cgbc_gpio_set (chip, offset, value); +if (ret) +return ret; +return cgbc_gpio_direction_set (chip, offset,GPIO_LINE_DIRECTION_OUT ); }
@@ -167,7 +171,7 @@ static int cgbc_gpio_probe(struct platform_device *pdev) chip->direction_output = cgbc_gpio_direction_output; chip->get_direction = cgbc_gpio_get_direction; chip->get = cgbc_gpio_get; - chip->set = cgbc_gpio_set; + chip->set_rv = cgbc_gpio_set; chip->ngpio =CGBC_GPIO_NGPIO ; ret =devm_mutex_init (dev, &gpio->lock);
Signature · 1 line
2.45.2
PATCH 10/15 gpio: creg-snps: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-creg-snps.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpio/gpio-creg-snps.c +5 -5
@@ -27,7 +27,7 @@ struct creg_gpio {const struct creg_layout *layout; }; -static void creg_gpio_set (struct gpio_chip *gc,unsigned int offset,int val) +static int creg_gpio_set (struct gpio_chip *gc,unsigned int offset,int val) {struct creg_gpio *hcg =gpiochip_get_data (gc);const struct creg_layout *layout = hcg->layout;
@@ -47,13 +47,13 @@ static void creg_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) reg |= (value << reg_shift);writel (reg, hcg->regs);spin_unlock_irqrestore (&hcg->lock, flags); + +return 0 ; }static int creg_gpio_dir_out (struct gpio_chip *gc,unsigned int offset,int val) { -creg_gpio_set (gc, offset, val); - -return 0 ; +return creg_gpio_set (gc, offset, val); } static int creg_gpio_validate_pg(struct device *dev, struct creg_gpio *hcg,
@@ -167,7 +167,7 @@ static int creg_gpio_probe(struct platform_device *pdev) hcg->gc.label =dev_name (dev); hcg->gc.base =-1 ; hcg->gc.ngpio = ngpios; - hcg->gc.set = creg_gpio_set; + hcg->gc.set_rv = creg_gpio_set; hcg->gc.direction_output = creg_gpio_dir_out; ret =devm_gpiochip_add_data (dev, &hcg->gc, hcg);
Signature · 1 line
2.45.2
PATCH 11/15 gpio: cros-ec: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-cros-ec.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpio/gpio-cros-ec.c +5 -8
@@ -24,24 +24,21 @@static const char cros_ec_gpio_prefix[] ="EC:" ;/* Setting gpios is only supported when the system is unlocked */ -static void cros_ec_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val) +static int cros_ec_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val) {const char *name = gc->names[gpio] +strlen (cros_ec_gpio_prefix);struct cros_ec_device *cros_ec =gpiochip_get_data (gc);struct ec_params_gpio_set params = { .val = val, }; -int ret;ssize_t copied; copied =strscpy (params.name, name,sizeof (params.name));if (copied <0 ) -return ; +return copied; - ret =cros_ec_cmd (cros_ec,0 ,EC_CMD_GPIO_SET , ¶ms, -sizeof (params),NULL ,0 ); -if (ret <0 ) -dev_err (gc->parent,"error setting gpio%d (%s) on EC: %d\n" , gpio, name, ret); +return cros_ec_cmd (cros_ec,0 ,EC_CMD_GPIO_SET , ¶ms, +sizeof (params),NULL ,0 ); }static int cros_ec_gpio_get (struct gpio_chip *gc,unsigned int gpio)
@@ -191,7 +188,7 @@ static int cros_ec_gpio_probe(struct platform_device *pdev) gc->can_sleep = true; gc->label =dev_name (dev); gc->base =-1 ; - gc->set = cros_ec_gpio_set; + gc->set_rv = cros_ec_gpio_set; gc->get = cros_ec_gpio_get; gc->get_direction = cros_ec_gpio_get_direction;
Signature · 1 line
2.45.2
Re: [PATCH 11/15] gpio: cros-ec: use new line value setter callbacks
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
struct
gpio_chipnow has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.Signed-off-by Bartosz Golaszewski <[email protected]>
PATCH 12/15 gpio: crystalcove: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-crystalcove.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-crystalcove.c +6 -6
@@ -168,18 +168,18 @@ static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)return val &0x1 ; } -static void crystalcove_gpio_set (struct gpio_chip *chip,unsigned int gpio,int value) +static int crystalcove_gpio_set (struct gpio_chip *chip,unsigned int gpio,int value) {struct crystalcove_gpio *cg =gpiochip_get_data (chip);int reg =to_reg (gpio,CTRL_OUT );if (reg <0 ) -return ; +return 0 ;if (value) -regmap_update_bits (cg->regmap, reg,1 ,1 ); -else -regmap_update_bits (cg->regmap, reg,1 ,0 ); +return regmap_update_bits (cg->regmap, reg,1 ,1 ); + +return regmap_update_bits (cg->regmap, reg,1 ,0 ); }static int crystalcove_irq_type (struct irq_data *data,unsigned int type)
@@ -349,7 +349,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev) cg->chip.direction_input = crystalcove_gpio_dir_in; cg->chip.direction_output = crystalcove_gpio_dir_out; cg->chip.get = crystalcove_gpio_get; - cg->chip.set = crystalcove_gpio_set; + cg->chip.set_rv = crystalcove_gpio_set; cg->chip.base =-1 ; cg->chip.ngpio =CRYSTALCOVE_VGPIO_NUM ; cg->chip.can_sleep = true;
Signature · 1 line
2.45.2
PATCH 13/15 gpio: cs5535: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-cs5535.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/gpio-cs5535.c +4 -2
@@ -232,12 +232,14 @@ static int chip_gpio_get(struct gpio_chip *chip, unsigned offset)return cs5535_gpio_isset (offset,GPIO_READ_BACK ); } -static void chip_gpio_set (struct gpio_chip *chip,unsigned offset,int val) +static int chip_gpio_set (struct gpio_chip *chip,unsigned int offset,int val) {if (val)cs5535_gpio_set (offset,GPIO_OUTPUT_VAL );else cs5535_gpio_clear (offset,GPIO_OUTPUT_VAL ); + +return 0 ; }static int chip_direction_input (struct gpio_chip *c,unsigned offset)
@@ -294,7 +296,7 @@ static struct cs5535_gpio_chip cs5535_gpio_chip = { .request = chip_gpio_request, .get = chip_gpio_get, - .set = chip_gpio_set, + .set_rv = chip_gpio_set, .direction_input = chip_direction_input, .direction_output = chip_direction_output,
Signature · 1 line
2.45.2
PATCH 14/15 gpio: da9052: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-da9052.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
drivers/gpio/gpio-da9052.c +12 -22
@@ -89,30 +89,20 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) } } -static void da9052_gpio_set (struct gpio_chip *gc,unsigned offset,int value) +static int da9052_gpio_set (struct gpio_chip *gc,unsigned int offset,int value) {struct da9052_gpio *gpio =gpiochip_get_data (gc); -int ret; -if (da9052_gpio_port_odd (offset)) { - ret =da9052_reg_update (gpio->da9052, (offset >>1 ) + -DA9052_GPIO_0_1_REG , -DA9052_GPIO_ODD_PORT_MODE , - value <<DA9052_GPIO_ODD_SHIFT ); -if (ret !=0 ) -dev_err (gpio->da9052->dev, -"Failed to updated gpio odd reg,%d" , - ret); - }else { - ret =da9052_reg_update (gpio->da9052, (offset >>1 ) + -DA9052_GPIO_0_1_REG , -DA9052_GPIO_EVEN_PORT_MODE , - value <<DA9052_GPIO_EVEN_SHIFT ); -if (ret !=0 ) -dev_err (gpio->da9052->dev, -"Failed to updated gpio even reg,%d" , - ret); - } +if (da9052_gpio_port_odd (offset)) +return da9052_reg_update (gpio->da9052, (offset >>1 ) + +DA9052_GPIO_0_1_REG , +DA9052_GPIO_ODD_PORT_MODE , + value <<DA9052_GPIO_ODD_SHIFT ); + +return da9052_reg_update (gpio->da9052, + (offset >>1 ) +DA9052_GPIO_0_1_REG , +DA9052_GPIO_EVEN_PORT_MODE , + value <<DA9052_GPIO_EVEN_SHIFT ); }static int da9052_gpio_direction_input (struct gpio_chip *gc,unsigned offset)
@@ -182,7 +172,7 @@ static const struct gpio_chip reference_gp = { .label = "da9052-gpio", .owner = THIS_MODULE, .get = da9052_gpio_get, - .set = da9052_gpio_set, + .set_rv = da9052_gpio_set, .direction_input = da9052_gpio_direction_input, .direction_output = da9052_gpio_direction_output, .to_irq = da9052_gpio_to_irq,
Signature · 1 line
2.45.2
PATCH 15/15 gpio: da9055: use new line value setter callbacks
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them.
--- drivers/gpio/gpio-da9055.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpio/gpio-da9055.c +5 -9
@@ -59,14 +59,12 @@ static int da9055_gpio_get(struct gpio_chip *gc, unsigned offset) } -static void da9055_gpio_set (struct gpio_chip *gc,unsigned offset,int value) +static int da9055_gpio_set (struct gpio_chip *gc,unsigned int offset,int value) {struct da9055_gpio *gpio =gpiochip_get_data (gc); -da9055_reg_update (gpio->da9055, -DA9055_REG_GPIO_MODE0_2 , -1 << offset, - value << offset); +return da9055_reg_update (gpio->da9055,DA9055_REG_GPIO_MODE0_2 , +1 << offset, value << offset); }static int da9055_gpio_direction_input (struct gpio_chip *gc,unsigned offset)
@@ -102,9 +100,7 @@ static int da9055_gpio_direction_output(struct gpio_chip *gc,if (ret <0 )return ret; -da9055_gpio_set (gc, offset, value); - -return 0 ; +return da9055_gpio_set (gc, offset, value); }static int da9055_gpio_to_irq (struct gpio_chip *gc,u32 offset)
@@ -120,7 +116,7 @@ static const struct gpio_chip reference_gp = { .label = "da9055-gpio", .owner = THIS_MODULE, .get = da9055_gpio_get, - .set = da9055_gpio_set, + .set_rv = da9055_gpio_set, .direction_input = da9055_gpio_direction_input, .direction_output = da9055_gpio_direction_output, .to_irq = da9055_gpio_to_irq,
Signature · 1 line
2.45.2
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 4 lines · Bartosz Golaszewski
This is another round of GPIO driver conversions to using the int-returning value setter callbacks.
Applied, thanks!
[01/15] gpio: bcm-kona: use lock guards
commit: cd7d117a297149b61871d441fa1a8146c55c435d
[02/15] gpio: bcm-kona: use new line value setter callbacks
commit: d5cc72803b146c811b01f9a5b91e97337adf5784
[03/15] gpio: bd71815: use new line value setter callbacks
commit: 7bd2bb7901a67f6b14c913596acb471351f500a5
[04/15] gpio: bd71828: use new line value setter callbacks
commit: 8a050f738d41d337fb73ef582916328dc5bd73e1
[05/15] gpio: bd9571mwv: use new line value setter callbacks
commit: fe7667f2085ee7d66a6a34e6bf6830be7e641b52
[06/15] gpio: bt8xx: allow to build the module with COMPILE_TEST=y
commit: c948feeadba290e989b049913576b3d30ba02235
[07/15] gpio: bt8xx: use lock guards
commit: b9a557d05a7dde42b1e3652751eea6c06091402e
[08/15] gpio: bt8xx: use new line value setter callbacks
commit: 19c39c53752ae0b5cbf7577bcdf7c13d1c146e65
[09/15] gpio: cgbc: use new line value setter callbacks
commit: 1e69c7532a188a84b4cb535944fd7d60393a1fc8
[10/15] gpio: creg-snps: use new line value setter callbacks
commit: 68f5b74e0db7ab57885ad4ec05f7418cac8f4063
[11/15] gpio: cros-ec: use new line value setter callbacks
commit: 2661dc2de18617ac827aa9b50cb145bf5a185896
[12/15] gpio: crystalcove: use new line value setter callbacks
commit: 96498b83b3ded5f01207775d681374d62111d548
[13/15] gpio: cs5535: use new line value setter callbacks
commit: 588dfcdb162855b954f92fce73a12e3fa86ded01
[14/15] gpio: da9052: use new line value setter callbacks
commit: 489c19cee3b9fd58e7967dbc4e54cdf212b073a0
[15/15] gpio: da9055: use new line value setter callbacks
commit: 2eb5dc9a4b0d193b27289281faa05aadab978b41Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>