pinctrl: Use new GPIO_LINE_DIRECTION
Subsystems (21)
PATCH 2/2 pinctrl: Use new GPIO_LINE_DIRECTION
Use newly added GPIO defines GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT instead of using hard-coded 1 and 0.
Main benefit is to make it easier to see which values mean IN and which OUT. As a side effect this helps GPIO framework to change the direction defines to something else if ever needed.
Please note that return value from get_direction call on pinctrl-axp209 driver was changed. Previously pinctrl-axp209 might have returned value 2 for direction INPUT.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 5 ++++- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 5 ++++- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 5 ++++- drivers/pinctrl/mediatek/pinctrl-paris.c | 5 ++++- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 7 +++++-- drivers/pinctrl/pinctrl-amd.c | 5 ++++- drivers/pinctrl/pinctrl-at91.c | 5 ++++- drivers/pinctrl/pinctrl-axp209.c | 7 +++++-- drivers/pinctrl/pinctrl-ingenic.c | 14 ++++++++++---- drivers/pinctrl/pinctrl-ocelot.c | 5 ++++- drivers/pinctrl/pinctrl-oxnas.c | 5 ++++- drivers/pinctrl/pinctrl-pic32.c | 5 ++++- drivers/pinctrl/pinctrl-pistachio.c | 5 ++++- drivers/pinctrl/pinctrl-rk805.c | 7 +++++-- drivers/pinctrl/pinctrl-rockchip.c | 5 ++++- drivers/pinctrl/pinctrl-rza1.c | 5 ++++- drivers/pinctrl/pinctrl-rza2.c | 6 +++--- drivers/pinctrl/pinctrl-st.c | 14 +++++++++++--- drivers/pinctrl/pinctrl-stmfx.c | 17 ++++++++++++++--- drivers/pinctrl/pinctrl-sx150x.c | 9 ++++++--- drivers/pinctrl/qcom/pinctrl-msm.c | 4 ++-- drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++-- drivers/pinctrl/vt8500/pinctrl-wmt.c | 6 ++++-- 24 files changed, 119 insertions(+), 41 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +4 -1
@@ -322,7 +322,10 @@ static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offseif (fsel >BCM2835_FSEL_GPIO_OUT )return -EINVAL ; -return (fsel ==BCM2835_FSEL_GPIO_IN ); +if (fsel ==BCM2835_FSEL_GPIO_IN ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static void bcm2835_gpio_set (struct gpio_chip *chip,unsigned offset,int value)
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +4 -1
@@ -357,7 +357,10 @@ static int iproc_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)unsigned int offset =IPROC_GPIO_REG (gpio,IPROC_GPIO_OUT_EN_OFFSET );unsigned int shift =IPROC_GPIO_SHIFT (gpio); -return !(readl (chip->base + offset) &BIT (shift)); +if (readl (chip->base + offset) &BIT (shift)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static void iproc_gpio_set (struct gpio_chip *gc,unsigned gpio,int val)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +4 -1
@@ -804,7 +804,10 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset) pctl->devdata->spec_dir_set (®_addr, offset);regmap_read (pctl->regmap1, reg_addr, &read_val); -return !(read_val & bit); +if (read_val & bit) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int mtk_gpio_get (struct gpio_chip *chip,unsigned offset)
drivers/pinctrl/mediatek/pinctrl-paris.c +4 -1
@@ -699,7 +699,10 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)if (err)return err; -return !value; +if (value) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int mtk_gpio_get (struct gpio_chip *chip,unsigned int gpio)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -1
@@ -403,7 +403,10 @@ static int armada_37xx_gpio_get_direction(struct gpio_chip *chip, mask =BIT (offset);regmap_read (info->regmap, reg, &val); -return !(val & mask); +if (val & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
drivers/pinctrl/nomadik/pinctrl-nomadik.c +5 -2
@@ -850,11 +850,14 @@ static int nmk_gpio_get_dir(struct gpio_chip *chip, unsigned offset)clk_enable (nmk_chip->clk); - dir = !(readl (nmk_chip->addr +NMK_GPIO_DIR ) &BIT (offset)); + dir =readl (nmk_chip->addr +NMK_GPIO_DIR ) &BIT (offset);clk_disable (nmk_chip->clk); -return dir; +if (dir) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int nmk_gpio_make_input (struct gpio_chip *chip,unsigned offset)
drivers/pinctrl/pinctrl-amd.c +4 -1
@@ -46,7 +46,10 @@ static int amd_gpio_get_direction(struct gpio_chip *gc, unsigned offset) pin_reg =readl (gpio_dev->base + offset *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); -return !(pin_reg &BIT (OUTPUT_ENABLE_OFF )); +if (pin_reg &BIT (OUTPUT_ENABLE_OFF )) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int amd_gpio_direction_input (struct gpio_chip *gc,unsigned offset)
drivers/pinctrl/pinctrl-at91.c +4 -1
@@ -1414,7 +1414,10 @@ static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset)u32 osr; osr =readl_relaxed (pio +PIO_OSR ); -return !(osr & mask); +if (osr & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int at91_gpio_direction_input (struct gpio_chip *chip,unsigned offset)
drivers/pinctrl/pinctrl-axp209.c +5 -2
@@ -149,13 +149,16 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip,* going to change the value soon anyway. Default to output. */ if ((val &AXP20X_GPIO_FUNCTIONS ) >2 ) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ;/* * The GPIO directions are the three lowest values. * 2 is input, 0 and 1 are output */ -return val &2 ; +if (val &2 ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; } static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset,
drivers/pinctrl/pinctrl-ingenic.c +10 -4
@@ -1643,13 +1643,19 @@ static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)struct ingenic_pinctrl *jzpc = jzgc->jzpc;unsigned int pin = gc->base + offset; -if (jzpc->version >=ID_JZ4760 ) -return ingenic_get_pin_config (jzpc, pin,JZ4760_GPIO_PAT1 ); +if (jzpc->version >=ID_JZ4760 ) { +if (ingenic_get_pin_config (jzpc, pin,JZ4760_GPIO_PAT1 )) +return GPIO_LINE_DIRECTION_IN ; +return GPIO_LINE_DIRECTION_OUT ; + }if (ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_SELECT )) -return true; +return GPIO_LINE_DIRECTION_IN ; + +if (ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_DIR )) +return GPIO_LINE_DIRECTION_OUT ; -return !ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_DIR ); +return GPIO_LINE_DIRECTION_IN ; }static const struct pinctrl_ops ingenic_pctlops = {
drivers/pinctrl/pinctrl-ocelot.c +4 -1
@@ -604,7 +604,10 @@ static int ocelot_gpio_get_direction(struct gpio_chip *chip,regmap_read (info->map,REG (OCELOT_GPIO_OE , info, offset), &val); -return !(val &BIT (offset %32 )); +if (val &BIT (offset %32 )) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int ocelot_gpio_direction_input(struct gpio_chip *chip,
drivers/pinctrl/pinctrl-oxnas.c +4 -1
@@ -756,7 +756,10 @@ static int oxnas_gpio_get_direction(struct gpio_chip *chip,struct oxnas_gpio_bank *bank =gpiochip_get_data (chip);u32 mask =BIT (offset); -return !(readl_relaxed (bank->reg_base +OUTPUT_EN ) & mask); +if (readl_relaxed (bank->reg_base +OUTPUT_EN ) & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int oxnas_gpio_direction_input(struct gpio_chip *chip,
drivers/pinctrl/pinctrl-pic32.c +4 -1
@@ -1990,7 +1990,10 @@ static int pic32_gpio_get_direction(struct gpio_chip *chip, unsigned offset) {struct pic32_gpio_bank *bank =gpiochip_get_data (chip); -return !!(readl (bank->reg_base +TRIS_REG ) &BIT (offset)); +if (readl (bank->reg_base +TRIS_REG ) &BIT (offset)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static void pic32_gpio_irq_ack (struct irq_data *data)
drivers/pinctrl/pinctrl-pistachio.c +4 -1
@@ -1166,7 +1166,10 @@ static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset) {struct pistachio_gpio_bank *bank =gpiochip_get_data (chip); -return !(gpio_readl (bank,GPIO_OUTPUT_EN ) &BIT (offset)); +if (gpio_readl (bank,GPIO_OUTPUT_EN ) &BIT (offset)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int pistachio_gpio_get (struct gpio_chip *chip,unsigned offset)
drivers/pinctrl/pinctrl-rk805.c +5 -2
@@ -184,7 +184,7 @@ static int rk805_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)/* default output*/ if (!pci->pin_cfg[offset].dir_msk) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ; ret = regmap_read(pci->rk808->regmap, pci->pin_cfg[offset].reg,
@@ -194,7 +194,10 @@ static int rk805_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)return ret; } -return !(val & pci->pin_cfg[offset].dir_msk); +if (val & pci->pin_cfg[offset].dir_msk) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static const struct gpio_chip rk805_gpio_chip = {
drivers/pinctrl/pinctrl-rockchip.c +4 -1
@@ -2211,7 +2211,10 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset) data =readl_relaxed (bank->reg_base +GPIO_SWPORT_DDR );clk_disable (bank->clk); -return !(data &BIT (offset)); +if (data &BIT (offset)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }/*
drivers/pinctrl/pinctrl-rza1.c +4 -1
@@ -777,7 +777,10 @@ static int rza1_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) {struct rza1_port *port =gpiochip_get_data (chip); -return !!rza1_get_bit (port,RZA1_PM_REG , gpio); +if (rza1_get_bit (port,RZA1_PM_REG , gpio)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; } static int rza1_gpio_direction_input(struct gpio_chip *chip,
drivers/pinctrl/pinctrl-rza2.c +3 -3
@@ -135,10 +135,10 @@ static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset) reg16 = (reg16 >> (pin *2 )) &RZA2_PDR_MASK ;if (reg16 ==RZA2_PDR_OUTPUT ) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ;if (reg16 ==RZA2_PDR_INPUT ) -return 1 ; +return GPIO_LINE_DIRECTION_IN ;/* * This GPIO controller has a default Hi-Z state that is not input or
@@ -146,7 +146,7 @@ static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset)*/ rza2_pin_to_gpio (priv->base, offset,1 ); -return 1 ; +return GPIO_LINE_DIRECTION_IN ; } static int rza2_chip_direction_input(struct gpio_chip *chip,
drivers/pinctrl/pinctrl-st.c +11 -3
@@ -746,7 +746,10 @@ static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) function =st_pctl_get_pin_function (&pc, offset);if (function) {st_pinconf_get_direction (&pc, offset, &config); -return !ST_PINCONF_UNPACK_OE (config); +if (ST_PINCONF_UNPACK_OE (config)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }/*
@@ -758,7 +761,10 @@ static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) direction |= ((value >> offset) &0x1 ) << i; } -return (direction ==ST_GPIO_DIRECTION_IN ); +if (direction ==ST_GPIO_DIRECTION_IN ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }/* Pinctrl Groups */
@@ -996,6 +1002,7 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,unsigned int function;int offset =st_gpio_pin (pin_id);char f[16 ]; +int oe;mutex_unlock (&pctldev->mutex); pc =st_get_pio_control (pctldev, pin_id);
@@ -1008,10 +1015,11 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,else snprintf (f,5 ,"GPIO" ); + oe =st_gpio_get_direction (&pc_to_bank (pc)->gpio_chip, offset); seq_printf(s, "[OE:%d,PU:%ld,OD:%ld]\t%s\n" "\t\t[retime:%ld,invclk:%ld,clknotdat:%ld," "de:%ld,rt-clk:%ld,rt-delay:%ld]", - !st_gpio_get_direction(&pc_to_bank(pc)->gpio_chip, offset), + (oe == GPIO_LINE_DIRECTION_OUT), ST_PINCONF_UNPACK_PU(config), ST_PINCONF_UNPACK_OD(config), f,
drivers/pinctrl/pinctrl-stmfx.c +14 -3
@@ -134,10 +134,14 @@ static int stmfx_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) ret =regmap_read (pctl->stmfx->map, reg, &val);/* * On stmfx, gpio pins direction is (0)input, (1)output. -* .get_direction returns 0=out, 1=in */ +if (ret) +return ret; -return ret ? ret : !(val & mask); +if (val & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int stmfx_gpio_direction_input (struct gpio_chip *gc,unsigned int offset)
@@ -223,6 +227,13 @@ static int stmfx_pinconf_get(struct pinctrl_dev *pctldev, dir =stmfx_gpio_get_direction (&pctl->gpio_chip, pin);if (dir <0 )return dir; + +/* +* Currently the gpiolib IN is 1 and OUT is 0 but let's not count +* on it just to be on the safe side also in the future :) +*/ + dir = (dir ==GPIO_LINE_DIRECTION_IN ) ?1 :0 ; + type =stmfx_pinconf_get_type (pctl, pin);if (type <0 )return type;
@@ -360,7 +371,7 @@ static void stmfx_pinconf_dbg_show(struct pinctrl_dev *pctldev,if (val <0 )return ; -if (!dir) { +if (dir ==GPIO_LINE_DIRECTION_OUT ) {seq_printf (s,"output %s " , val ?"high" :"low" );if (type) seq_printf(s, "open drain %s internal pull-up ",
drivers/pinctrl/pinctrl-sx150x.c +6 -3
@@ -391,13 +391,16 @@ static int sx150x_gpio_get_direction(struct gpio_chip *chip,int ret;if (sx150x_pin_is_oscio (pctl, offset)) -return false; +return GPIO_LINE_DIRECTION_OUT ; ret =regmap_read (pctl->regmap, pctl->data->reg_dir, &value);if (ret <0 )return ret; -return !!(value &BIT (offset)); +if (value &BIT (offset)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static int sx150x_gpio_get (struct gpio_chip *chip,unsigned int offset)
@@ -687,7 +690,7 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,if (ret <0 )return ret; -if (ret) +if (ret ==GPIO_LINE_DIRECTION_IN )return -EINVAL ; ret =sx150x_gpio_get (&pctl->gpio, pin);
drivers/pinctrl/qcom/pinctrl-msm.c +2 -2
@@ -485,8 +485,8 @@ static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) val =msm_readl_ctl (pctrl, g); -/* 0 = output, 1 = input */ -return val &BIT (g->oe_bit) ?0 :1 ; +return val &BIT (g->oe_bit) ?GPIO_LINE_DIRECTION_OUT : +GPIO_LINE_DIRECTION_IN ; }static int msm_gpio_get (struct gpio_chip *chip,unsigned offset)
drivers/pinctrl/stm32/pinctrl-stm32.c +2 -2
@@ -283,9 +283,9 @@ static int stm32_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)stm32_pmx_get_mode (bank, pin, &mode, &alt);if ((alt ==0 ) && (mode ==0 )) - ret =1 ; + ret =GPIO_LINE_DIRECTION_IN ;else if ((alt ==0 ) && (mode ==1 )) - ret =0 ; + ret =GPIO_LINE_DIRECTION_OUT ;else ret = -EINVAL ;
drivers/pinctrl/vt8500/pinctrl-wmt.c +4 -2
@@ -486,8 +486,10 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset)u32 val; val =readl_relaxed (data->base + reg_dir); -/* Return 0 == output, 1 == input */ -return !(val &BIT (bit)); +if (val &BIT (bit)) +GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset)
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Quoted 5 lines · Matti Vaittinen
drivers/pinctrl/qcom/pinctrl-msm.c +0
-0
drivers/pinctrl/qcom/pinctrl-msm.c static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) · line 491
Quoted 9 lines
drivers/pinctrl/qcom/pinctrl-msm.c +2
-2@@ -485,8 +485,8 @@ static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) val =msm_readl_ctl (pctrl, g); -/* 0 = output, 1 = input */ -return val &BIT (g->oe_bit) ?0 :1 ; +return val &BIT (g->oe_bit) ?GPIO_LINE_DIRECTION_OUT : +GPIO_LINE_DIRECTION_IN ; }
For pinctrl-msm
Regards,
Bjorn
Quoted 7 lines · Matti Vaittinen
Use newly added GPIO defines
GPIO_LINE_DIRECTION_INandGPIO_LINE_DIRECTION_OUTinstead of using hard-coded 1 and 0.Main benefit is to make it easier to see which values mean IN and which OUT. As a side effect this helps GPIO framework to change the direction defines to something else if ever needed.
Quoted 5 lines
Please note that return value from
get_directioncall on pinctrl-axp209 driver was changed. Previously pinctrl-axp209 might have returned value 2 for direction INPUT.Signed-off-by Matti Vaittinen <[email protected]>
For:
Quoted 2 lines
drivers/pinctrl/pinctrl-rza1.c | 5 ++++- drivers/pinctrl/pinctrl-rza2.c | 6 +++---
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on 70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]
url: https://github.com/0day-ci/linux/commits/Matti-Vaittinen/pinctrl-rza1-remove-unnecerssary-static-inline-function/20191113-114104 base: 70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
In file included from drivers/pinctrl/vt8500/pinctrl-wmt.c:9:0:
drivers/pinctrl/vt8500/pinctrl-wmt.c: In function 'wmt_gpio_get_direction':
include/linux/gpio/driver.h:26:33: warning: statement with no effect [-Wunused-value]
#define GPIO_LINE_DIRECTION_OUT 0
^
>> drivers/pinctrl/vt8500/pinctrl-wmt.c:490:3: note: in expansion of macro 'GPIO_LINE_DIRECTION_OUT'
GPIO_LINE_DIRECTION_OUT;
^~~~~~~~~~~~~~~~~~~~~~~vim +/GPIO_LINE_DIRECTION_OUT +490 drivers/pinctrl/vt8500/pinctrl-wmt.c
479
480 static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
481 {
482 struct wmt_pinctrl_data *data = gpiochip_get_data(chip);
483 u32 bank = WMT_BANK_FROM_PIN(offset);
484 u32 bit = WMT_BIT_FROM_PIN(offset);
485 u32 reg_dir = data->banks[bank].reg_dir;
486 u32 val;
487
488 val = readl_relaxed(data->base + reg_dir);
489 if (val & BIT(bit))
> 490 GPIO_LINE_DIRECTION_OUT;
491
492 return GPIO_LINE_DIRECTION_IN;
493 }
494
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 11 lines · kbuild test robot
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on
70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]480 static int wmt_gpio_get_direction(struct
gpio_chip
*chip, unsigned offset)
481 {
482 structwmt_pinctrl_data*data =
Quoted 9 lines
gpiochip_get_data(chip); 483 u32 bank = WMT_BANK_FROM_PIN(offset); 484 u32 bit = WMT_BIT_FROM_PIN(offset); 485 u32 reg_dir = data->banks[bank].reg_dir; 486 u32 val; 487 488 val = readl_relaxed(data->base + reg_dir); 489 if (val & BIT(bit))Quoted 1 line
490
GPIO_LINE_DIRECTION_OUT;
Right. Return is missing. I think I already fixed this - I guess I sent wrong version... Sorry guys. I'll do v3 with only this return added - and I'll send it to limited amount of recipients as I think most of you guys may not be interested. Probably to Linus W, Geert and GPIO list only. Let me know if you want to see the v3 (or other subsequent patches)
Quoted 10 lines
491 492 return GPIO_LINE_DIRECTION_IN; 493 } 494---
0-DAY kernel test infrastructure Open Source
Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
Quoted 22 lines · Matti
Quoted 11 lines · kbuild test robot
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on
70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]480 static int wmt_gpio_get_direction(struct
gpio_chip
*chip, unsigned offset)
481 {
482 structwmt_pinctrl_data*data =Quoted 9 lines
gpiochip_get_data(chip); 483 u32 bank = WMT_BANK_FROM_PIN(offset); 484 u32 bit = WMT_BIT_FROM_PIN(offset); 485 u32 reg_dir = data->banks[bank].reg_dir; 486 u32 val; 487 488 val = readl_relaxed(data->base + reg_dir); 489 if (val & BIT(bit))Quoted 1 line
490
GPIO_LINE_DIRECTION_OUT;
Quoted 6 lines
Right. Return is missing. I think I already fixed this - I guess I sent wrong version... Sorry guys. I'll do v3 with only this return added - and I'll send it to limited amount of recipients as I think most of you guys may not be interested. Probably to Linus W, Geert and GPIO list only. Let me know if you want to see the v3 (or other subsequent patches)
I think I already merged it, just send a new patch on top fixing the problem.
Yours,
Linus Walleij
Hello Linus,
Quoted 24 lines · Linus Walleij
Quoted 22 lines · Matti
Quoted 20 lines · kbuild test robot
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on
70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]480 static int wmt_gpio_get_direction(struct
gpio_chip
*chip, unsigned offset)
481 {
482 structwmt_pinctrl_data*data =gpiochip_get_data(chip); 483 u32 bank = WMT_BANK_FROM_PIN(offset); 484 u32 bit = WMT_BIT_FROM_PIN(offset); 485 u32 reg_dir = data->banks[bank].reg_dir; 486 u32 val; 487 488 val = readl_relaxed(data->base + reg_dir); 489 if (val & BIT(bit))Quoted 1 line
490
GPIO_LINE_DIRECTION_OUT;
Quoted 3 lines
Quoted 3 lines
Right. Return is missing. I think I already fixed this - I guess I sent
wrong version... Sorry guys. I'll do v3 with only this return added
It appears I didn't send wrong patch. The whole wmt was left uncompiled as the folder was excluded from my build by arch and I didn't spot that. So I'll humbly raise my arm as a sign of an error ;)
Quoted 10 lines
Quoted 7 lines
-
and I'll send it to limited amount of recipients as I think most of you
guys may not be interested. Probably to Linus W, Geert and GPIO list
only. Let me know if you want to see the v3 (or other subsequent patches)I think I already merged it, just send a new patch on top fixing the problem.
Hmmm. I don't think I received notification about the patch being applied... But in that case, please ignore v2 I sent some time ago - I'll do a fix patch on top of the already applied one then. I'll send it out soon(ish).
Br,
Matti
Quoted 14 lines · Linus Walleij
Quoted 11 lines · Matti
On Wed, 2019-11-13 at 14:30 +0800, kbuild test robot wrote:
Right. Return is missing. I think I already fixed this - I guess I sent
wrong version... Sorry guys. I'll do v3 with only this return added -
and I'll send it to limited amount of recipients as I think most of you
guys may not be interested. Probably to Linus W, Geert and GPIO list
only. Let me know if you want to see the v3 (or other subsequent patches)
Quoted 2 lines
I think I already merged it, just send a new patch on top fixing the problem.
Hmm. Are you sure you did merge the pincontrol part already? I don't see it in your GPIO tree, devel or for-next branches. Can you please point me the branch - I already destroyed my original pincontrol commit which had the bug when I created the v2.
Br,
Matti Vaittinen
Quoted 6 lines · Matti
Quoted 2 lines · Linus Walleij
I think I already merged it, just send a new patch on top fixing the problem.
Hmm. Are you sure you did merge the pincontrol part already?
No I confused it for the GPIO part. Sorry!
Please keep iterarating this patch.
Yours,
Linus Walleij
Hi-deeee-Ho Peeps!
Quoted 24 lines · Linus Walleij
Quoted 22 lines · Matti
Quoted 20 lines · kbuild test robot
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on
70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]480 static int wmt_gpio_get_direction(struct
gpio_chip
*chip, unsigned offset)
481 {
482 structwmt_pinctrl_data*data =gpiochip_get_data(chip); 483 u32 bank = WMT_BANK_FROM_PIN(offset); 484 u32 bit = WMT_BIT_FROM_PIN(offset); 485 u32 reg_dir = data->banks[bank].reg_dir; 486 u32 val; 487 488 val = readl_relaxed(data->base + reg_dir); 489 if (val & BIT(bit))Quoted 1 line
490
GPIO_LINE_DIRECTION_OUT;
Quoted 10 lines
Quoted 10 lines
Right. Return is missing. I think I already fixed this - I guess I sent
wrong version... Sorry guys. I'll do v3 with only this return added -
and I'll send it to limited amount of recipients as I think most of you
guys may not be interested. Probably to Linus W, Geert and GPIO list
only. Let me know if you want to see the v3 (or other subsequent patches)
I just noticed this was never merged even though I was sure I sent a fixed version. It took me a while but I guess I managed to dig out the reason...
First I sent v2 with the return missing:
https://lore.kernel.org/linux-gpio/[email protected]/
And then I did indeed send a fixed version:
https://lore.kernel.org/linux-gpio/[email protected]/#Z30drivers:pinctrl:vt8500:pinctrl-wmt.c
...but titled this as v2 too. I guess that's why it never caught correct attention.
I tried rebasing this to current gpio/devel. The pinctrl-ingenic.c had gained trivial conflict - do you want me to get the pinctrl tree and do merging on top of it && resending this or do you want to try applying it?
Sorry for messing with the versions!
Br,
Matti Vaittinen
Quoted 58 lines · Matti Vaittinen
Hi-deeee-Ho Peeps!
Quoted 26 lines · Linus Walleij
Quoted 24 lines · Matti
Quoted 22 lines · kbuild test robot
Hi Matti,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on
70d97e099bb426ecb3ad4bf31e88dbf2ef4b2e4c]480 static int wmt_gpio_get_direction(struct
gpio_chip
*chip, unsigned offset)
481 {
482 structwmt_pinctrl_data*data =gpiochip_get_data(chip); 483 u32 bank = WMT_BANK_FROM_PIN(offset); 484 u32 bit = WMT_BIT_FROM_PIN(offset); 485 u32 reg_dir = data->banks[bank].reg_dir; 486 u32 val; 487 488 val = readl_relaxed(data->base +
reg_dir);
489 if (val & BIT(bit))Quoted 1 line
490
GPIO_LINE_DIRECTION_OUT;Quoted 13 lines
Quoted 5 lines
Right. Return is missing. I think I already fixed this - I guess I
sent
wrong version... Sorry guys. I'll do v3 with only this return addedQuoted 8 lines
-
and I'll send it to limited amount of recipients as I think most of
you
guys may not be interested. Probably to Linus W, Geert and GPIO list
only. Let me know if you want to see the v3 (or other subsequent patches)I just noticed this was never merged even though I was sure I sent a fixed version. It took me a while but I guess I managed to dig out the
reason...First I sent v2 with the return missing:
https://lore.kernel.org/linux-gpio/[email protected]/And then I did indeed send a fixed version:
https://lore.kernel.org/linux-gpio/[email protected]/#Z30drivers:pinctrl:vt8500:pinctrl-wmt.c...but titled this as v2 too. I guess that's why it never caught correct attention.
Quoted 6 lines
I tried rebasing this to current gpio/devel. The
pinctrl-ingenic.chad
gained trivial conflict - do you want me to get the pinctrl tree and do
merging on top of it && resending this or do you want to try applying it?
I decided to do resend as I had the commit sitting there rebased. Sorry for messing this up. v3 is now finally on its way.
Best Regards,
Matti Vaittinen
Hi Matti,
Quoted 23 lines · Matti Vaittinen
Use newly added GPIO defines
GPIO_LINE_DIRECTION_INandGPIO_LINE_DIRECTION_OUTinstead of using hard-coded 1 and 0.Main benefit is to make it easier to see which values mean IN and which OUT. As a side effect this helps GPIO framework to change the direction defines to something else if ever needed.
Please note that return value from
get_directioncall on pinctrl-axp209 driver was changed. Previously pinctrl-axp209 might have returned value 2 for direction INPUT.Signed-off-by Matti Vaittinen <[email protected]>--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 5 ++++- drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 5 ++++- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 5 ++++- drivers/pinctrl/mediatek/pinctrl-paris.c | 5 ++++- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 7 +++++-- drivers/pinctrl/pinctrl-amd.c | 5 ++++- drivers/pinctrl/pinctrl-at91.c | 5 ++++- drivers/pinctrl/pinctrl-axp209.c | 7 +++++-- drivers/pinctrl/pinctrl-ingenic.c | 14 ++++++++++----
Quoted 8 lines
drivers/pinctrl/pinctrl-ocelot.c | 5 ++++- drivers/pinctrl/pinctrl-oxnas.c | 5 ++++- drivers/pinctrl/pinctrl-pic32.c | 5 ++++- drivers/pinctrl/pinctrl-pistachio.c | 5 ++++- drivers/pinctrl/pinctrl-rk805.c | 7 +++++-- drivers/pinctrl/pinctrl-rockchip.c | 5 ++++- drivers/pinctrl/pinctrl-rza1.c | 5 ++++- drivers/pinctrl/pinctrl-rza2.c | 6 +++---
For RZ/A1 RZ/A2:
Thanks
j
Quoted 527 lines
drivers/pinctrl/pinctrl-st.c | 14 +++++++++++--- drivers/pinctrl/pinctrl-stmfx.c | 17 ++++++++++++++--- drivers/pinctrl/pinctrl-sx150x.c | 9 ++++++--- drivers/pinctrl/qcom/pinctrl-msm.c | 4 ++-- drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++-- drivers/pinctrl/vt8500/pinctrl-wmt.c | 6 ++++-- 24 files changed, 119 insertions(+), 41 deletions(-)drivers/pinctrl/bcm/pinctrl-bcm2835.c +4
-1@@ -322,7 +322,10 @@ static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offseif (fsel >BCM2835_FSEL_GPIO_OUT )return -EINVAL ; -return (fsel ==BCM2835_FSEL_GPIO_IN ); +if (fsel ==BCM2835_FSEL_GPIO_IN ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static void bcm2835_gpio_set (struct gpio_chip *chip,unsigned offset,int value)drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +4
-1@@ -357,7 +357,10 @@ static int iproc_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)unsigned int offset =IPROC_GPIO_REG (gpio,IPROC_GPIO_OUT_EN_OFFSET );unsigned int shift =IPROC_GPIO_SHIFT (gpio); -return !(readl (chip->base + offset) &BIT (shift)); +if (readl (chip->base + offset) &BIT (shift)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static void iproc_gpio_set (struct gpio_chip *gc,unsigned gpio,int val)drivers/pinctrl/mediatek/pinctrl-mtk-common.c +4
-1@@ -804,7 +804,10 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned offset) pctl->devdata->spec_dir_set (®_addr, offset);regmap_read (pctl->regmap1, reg_addr, &read_val); -return !(read_val & bit); +if (read_val & bit) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int mtk_gpio_get (struct gpio_chip *chip,unsigned offset)drivers/pinctrl/mediatek/pinctrl-paris.c +4
-1@@ -699,7 +699,10 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)if (err)return err; -return !value; +if (value) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int mtk_gpio_get (struct gpio_chip *chip,unsigned int gpio)drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4
-1@@ -403,7 +403,10 @@ static int armada_37xx_gpio_get_direction(struct gpio_chip *chip, mask =BIT (offset);regmap_read (info->regmap, reg, &val); -return !(val & mask); +if (val & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,drivers/pinctrl/nomadik/pinctrl-nomadik.c +5
-2@@ -850,11 +850,14 @@ static int nmk_gpio_get_dir(struct gpio_chip *chip, unsigned offset)clk_enable (nmk_chip->clk); - dir = !(readl (nmk_chip->addr +NMK_GPIO_DIR ) &BIT (offset)); + dir =readl (nmk_chip->addr +NMK_GPIO_DIR ) &BIT (offset);clk_disable (nmk_chip->clk); -return dir; +if (dir) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int nmk_gpio_make_input (struct gpio_chip *chip,unsigned offset)drivers/pinctrl/pinctrl-amd.c +4
-1@@ -46,7 +46,10 @@ static int amd_gpio_get_direction(struct gpio_chip *gc, unsigned offset) pin_reg =readl (gpio_dev->base + offset *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); -return !(pin_reg &BIT (OUTPUT_ENABLE_OFF )); +if (pin_reg &BIT (OUTPUT_ENABLE_OFF )) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int amd_gpio_direction_input (struct gpio_chip *gc,unsigned offset)drivers/pinctrl/pinctrl-at91.c +4
-1@@ -1414,7 +1414,10 @@ static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset)u32 osr; osr =readl_relaxed (pio +PIO_OSR ); -return !(osr & mask); +if (osr & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int at91_gpio_direction_input (struct gpio_chip *chip,unsigned offset)drivers/pinctrl/pinctrl-axp209.c +5
-2@@ -149,13 +149,16 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip,* going to change the value soon anyway. Default to output. */ if ((val &AXP20X_GPIO_FUNCTIONS ) >2 ) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ;/* * The GPIO directions are the three lowest values. * 2 is input, 0 and 1 are output */ -return val &2 ; +if (val &2 ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; } static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset,drivers/pinctrl/pinctrl-ingenic.c +10
-4@@ -1643,13 +1643,19 @@ static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)struct ingenic_pinctrl *jzpc = jzgc->jzpc;unsigned int pin = gc->base + offset; -if (jzpc->version >=ID_JZ4760 ) -return ingenic_get_pin_config (jzpc, pin,JZ4760_GPIO_PAT1 ); +if (jzpc->version >=ID_JZ4760 ) { +if (ingenic_get_pin_config (jzpc, pin,JZ4760_GPIO_PAT1 )) +return GPIO_LINE_DIRECTION_IN ; +return GPIO_LINE_DIRECTION_OUT ; + }if (ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_SELECT )) -return true; +return GPIO_LINE_DIRECTION_IN ; + +if (ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_DIR )) +return GPIO_LINE_DIRECTION_OUT ; -return !ingenic_get_pin_config (jzpc, pin,JZ4740_GPIO_DIR ); +return GPIO_LINE_DIRECTION_IN ; }static const struct pinctrl_ops ingenic_pctlops = {drivers/pinctrl/pinctrl-ocelot.c +4
-1@@ -604,7 +604,10 @@ static int ocelot_gpio_get_direction(struct gpio_chip *chip,regmap_read (info->map,REG (OCELOT_GPIO_OE , info, offset), &val); -return !(val &BIT (offset %32 )); +if (val &BIT (offset %32 )) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int ocelot_gpio_direction_input(struct gpio_chip *chip,drivers/pinctrl/pinctrl-oxnas.c +4
-1@@ -756,7 +756,10 @@ static int oxnas_gpio_get_direction(struct gpio_chip *chip,struct oxnas_gpio_bank *bank =gpiochip_get_data (chip);u32 mask =BIT (offset); -return !(readl_relaxed (bank->reg_base +OUTPUT_EN ) & mask); +if (readl_relaxed (bank->reg_base +OUTPUT_EN ) & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; } static int oxnas_gpio_direction_input(struct gpio_chip *chip,drivers/pinctrl/pinctrl-pic32.c +4
-1@@ -1990,7 +1990,10 @@ static int pic32_gpio_get_direction(struct gpio_chip *chip, unsigned offset) {struct pic32_gpio_bank *bank =gpiochip_get_data (chip); -return !!(readl (bank->reg_base +TRIS_REG ) &BIT (offset)); +if (readl (bank->reg_base +TRIS_REG ) &BIT (offset)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static void pic32_gpio_irq_ack (struct irq_data *data)drivers/pinctrl/pinctrl-pistachio.c +4
-1@@ -1166,7 +1166,10 @@ static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset) {struct pistachio_gpio_bank *bank =gpiochip_get_data (chip); -return !(gpio_readl (bank,GPIO_OUTPUT_EN ) &BIT (offset)); +if (gpio_readl (bank,GPIO_OUTPUT_EN ) &BIT (offset)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int pistachio_gpio_get (struct gpio_chip *chip,unsigned offset)drivers/pinctrl/pinctrl-rk805.c +5
-2@@ -184,7 +184,7 @@ static int rk805_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)/* default output*/ if (!pci->pin_cfg[offset].dir_msk) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ; ret = regmap_read(pci->rk808->regmap, pci->pin_cfg[offset].reg,@@ -194,7 +194,10 @@ static int rk805_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)return ret; } -return !(val & pci->pin_cfg[offset].dir_msk); +if (val & pci->pin_cfg[offset].dir_msk) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static const struct gpio_chip rk805_gpio_chip = {drivers/pinctrl/pinctrl-rockchip.c +4
-1@@ -2211,7 +2211,10 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset) data =readl_relaxed (bank->reg_base +GPIO_SWPORT_DDR );clk_disable (bank->clk); -return !(data &BIT (offset)); +if (data &BIT (offset)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }/* drivers/pinctrl/pinctrl-rza1.c +4
-1@@ -777,7 +777,10 @@ static int rza1_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) {struct rza1_port *port =gpiochip_get_data (chip); -return !!rza1_get_bit (port,RZA1_PM_REG , gpio); +if (rza1_get_bit (port,RZA1_PM_REG , gpio)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; } static int rza1_gpio_direction_input(struct gpio_chip *chip,drivers/pinctrl/pinctrl-rza2.c +3
-3@@ -135,10 +135,10 @@ static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset) reg16 = (reg16 >> (pin *2 )) &RZA2_PDR_MASK ;if (reg16 ==RZA2_PDR_OUTPUT ) -return 0 ; +return GPIO_LINE_DIRECTION_OUT ;if (reg16 ==RZA2_PDR_INPUT ) -return 1 ; +return GPIO_LINE_DIRECTION_IN ;/* * This GPIO controller has a default Hi-Z state that is not input or @@ -146,7 +146,7 @@ static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset)*/ rza2_pin_to_gpio (priv->base, offset,1 ); -return 1 ; +return GPIO_LINE_DIRECTION_IN ; } static int rza2_chip_direction_input(struct gpio_chip *chip,drivers/pinctrl/pinctrl-st.c +11
-3@@ -746,7 +746,10 @@ static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) function =st_pctl_get_pin_function (&pc, offset);if (function) {st_pinconf_get_direction (&pc, offset, &config); -return !ST_PINCONF_UNPACK_OE (config); +if (ST_PINCONF_UNPACK_OE (config)) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }/* @@ -758,7 +761,10 @@ static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) direction |= ((value >> offset) &0x1 ) << i; } -return (direction ==ST_GPIO_DIRECTION_IN ); +if (direction ==ST_GPIO_DIRECTION_IN ) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }/* Pinctrl Groups */ @@ -996,6 +1002,7 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,unsigned int function;int offset =st_gpio_pin (pin_id);char f[16 ]; +int oe;mutex_unlock (&pctldev->mutex); pc =st_get_pio_control (pctldev, pin_id);@@ -1008,10 +1015,11 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,else snprintf (f,5 ,"GPIO" ); + oe =st_gpio_get_direction (&pc_to_bank (pc)->gpio_chip, offset); seq_printf(s, "[OE:%d,PU:%ld,OD:%ld]\t%s\n" "\t\t[retime:%ld,invclk:%ld,clknotdat:%ld," "de:%ld,rt-clk:%ld,rt-delay:%ld]", - !st_gpio_get_direction(&pc_to_bank(pc)->gpio_chip, offset), + (oe == GPIO_LINE_DIRECTION_OUT), ST_PINCONF_UNPACK_PU(config), ST_PINCONF_UNPACK_OD(config), f,drivers/pinctrl/pinctrl-stmfx.c +14
-3@@ -134,10 +134,14 @@ static int stmfx_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) ret =regmap_read (pctl->stmfx->map, reg, &val);/* * On stmfx, gpio pins direction is (0)input, (1)output. -* .get_direction returns 0=out, 1=in */ +if (ret) +return ret; -return ret ? ret : !(val & mask); +if (val & mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int stmfx_gpio_direction_input (struct gpio_chip *gc,unsigned int offset)@@ -223,6 +227,13 @@ static int stmfx_pinconf_get(struct pinctrl_dev *pctldev, dir =stmfx_gpio_get_direction (&pctl->gpio_chip, pin);if (dir <0 )return dir; + +/* +* Currently the gpiolib IN is 1 and OUT is 0 but let's not count +* on it just to be on the safe side also in the future :) +*/ + dir = (dir ==GPIO_LINE_DIRECTION_IN ) ?1 :0 ; + type =stmfx_pinconf_get_type (pctl, pin);if (type <0 )return type;@@ -360,7 +371,7 @@ static void stmfx_pinconf_dbg_show(struct pinctrl_dev *pctldev,if (val <0 )return ; -if (!dir) { +if (dir ==GPIO_LINE_DIRECTION_OUT ) {seq_printf (s,"output %s " , val ?"high" :"low" );if (type) seq_printf(s, "open drain %s internal pull-up ",drivers/pinctrl/pinctrl-sx150x.c +6
-3@@ -391,13 +391,16 @@ static int sx150x_gpio_get_direction(struct gpio_chip *chip,int ret;if (sx150x_pin_is_oscio (pctl, offset)) -return false; +return GPIO_LINE_DIRECTION_OUT ; ret =regmap_read (pctl->regmap, pctl->data->reg_dir, &value);if (ret <0 )return ret; -return !!(value &BIT (offset)); +if (value &BIT (offset)) +return GPIO_LINE_DIRECTION_IN ; + +return GPIO_LINE_DIRECTION_OUT ; }static int sx150x_gpio_get (struct gpio_chip *chip,unsigned int offset)@@ -687,7 +690,7 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,if (ret <0 )return ret; -if (ret) +if (ret ==GPIO_LINE_DIRECTION_IN )return -EINVAL ; ret =sx150x_gpio_get (&pctl->gpio, pin);drivers/pinctrl/qcom/pinctrl-msm.c +2
-2@@ -485,8 +485,8 @@ static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) val =msm_readl_ctl (pctrl, g); -/* 0 = output, 1 = input */ -return val &BIT (g->oe_bit) ?0 :1 ; +return val &BIT (g->oe_bit) ?GPIO_LINE_DIRECTION_OUT : +GPIO_LINE_DIRECTION_IN ; }static int msm_gpio_get (struct gpio_chip *chip,unsigned offset)drivers/pinctrl/stm32/pinctrl-stm32.c +2
-2@@ -283,9 +283,9 @@ static int stm32_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)stm32_pmx_get_mode (bank, pin, &mode, &alt);if ((alt ==0 ) && (mode ==0 )) - ret =1 ; + ret =GPIO_LINE_DIRECTION_IN ;else if ((alt ==0 ) && (mode ==1 )) - ret =0 ; + ret =GPIO_LINE_DIRECTION_OUT ;else ret = -EINVAL ;drivers/pinctrl/vt8500/pinctrl-wmt.c +4
-3@@ -486,8 +486,10 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset)u32 val; val =readl_relaxed (data->base + reg_dir); -/* Return 0 == output, 1 == input */ -return !(val &BIT (bit)); +if (val &BIT (bit)) +GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; }static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset) --2.21.0
--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
drivers/pinctrl/qcom/pinctrl-msm.c static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) · line 489
Quoted 12 lines · Matti Vaittinen
drivers/pinctrl/qcom/pinctrl-msm.c +2
-2@@ -485,8 +485,8 @@ static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) val =msm_readl_ctl (pctrl, g); -/* 0 = output, 1 = input */ -return val &BIT (g->oe_bit) ?0 :1 ; +return val &BIT (g->oe_bit) ?GPIO_LINE_DIRECTION_OUT : +GPIO_LINE_DIRECTION_IN ;
For pinctrl-msm:
drivers/pinctrl/qcom/pinctrl-msm.c static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) · line 490
Quoted 1 line
drivers/pinctrl/qcom/pinctrl-msm.c +0
-0}
Regards,
Bjorn