gpio/generic: initialize basic_mmio_gpio shadow variables properly
Subsystems (3)
PATCH v2 1/1 gpio/generic: initialize basic_mmio_gpio shadow variables properly
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add missing initialization of basic_mmio_gpio shadow variables) manged to fix in gpio-mxc driver, so that other platform specific drivers do not suffer from the same problem over and over again.
Changes since v1:
* Turn the last parameter "bool big_endian" into "unsigned long flags" and give those really quirky hardwares a chance to tell that reg_set and reg_dir are unreadable.
--- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-generic.c | 9 +++++++-- drivers/gpio/gpio-mxc.c | 2 +- drivers/gpio/gpio-mxs.c | 2 +- drivers/gpio/gpio-sodaville.c | 2 +- include/linux/basic_mmio_gpio.h | 6 +++++- 6 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpio/gpio-ep93xx.c +1 -1
@@ -325,7 +325,7 @@ static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev,void __iomem *dir = mmio_base + bank->dir;int err; - err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL , false); + err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL ,0 );if (err)return err;
drivers/gpio/gpio-generic.c +7 -2
@@ -364,7 +364,7 @@ EXPORT_SYMBOL_GPL(bgpio_remove);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian) +unsigned long flags) {int ret;
@@ -385,7 +385,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,if (ret)return ret; - ret =bgpio_setup_accessors (dev, bgc, big_endian); + ret =bgpio_setup_accessors (dev, bgc, flags &BGPIOF_BIG_ENDIAN );if (ret)return ret;
@@ -394,6 +394,11 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,return ret; bgc->data = bgc->read_reg (bgc->reg_dat); +if (bgc->gc.set == bgpio_set_set && + !(flags &BGPIOF_UNREADABLE_REG_SET )) + bgc->data = bgc->read_reg (bgc->reg_set); +if (bgc->reg_dir && !(flags &BGPIOF_UNREADABLE_REG_DIR )) + bgc->dir = bgc->read_reg (bgc->reg_dir);return ret; }
drivers/gpio/gpio-mxc.c +1 -1
@@ -417,7 +417,7 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +GPIO_PSR , port->base +GPIO_DR ,NULL , - port->base +GPIO_GDIR ,NULL , false); + port->base +GPIO_GDIR ,NULL ,0 );if (err) goto out_iounmap;
drivers/gpio/gpio-mxs.c +1 -1
@@ -285,7 +285,7 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +PINCTRL_DIN (port), port->base +PINCTRL_DOUT (port),NULL , - port->base +PINCTRL_DOE (port),NULL , false); + port->base +PINCTRL_DOE (port),NULL ,0 );if (err)return err;
drivers/gpio/gpio-sodaville.c +1 -1
@@ -224,7 +224,7 @@ static int __devinit sdv_gpio_probe(struct pci_dev *pdev, ret =bgpio_init (&sd->bgpio, &pdev->dev,4 , sd->gpio_pub_base +GPINR , sd->gpio_pub_base +GPOUTR , -NULL , sd->gpio_pub_base +GPOER ,NULL , false); +NULL , sd->gpio_pub_base +GPOER ,NULL ,0 );if (ret) goto unmap; sd->bgpio.gc.ngpio =SDV_NUM_PUB_GPIOS ;
include/linux/basic_mmio_gpio.h +5 -1
@@ -67,6 +67,10 @@ int bgpio_remove(struct bgpio_chip *bgc);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian); +unsigned long flags); + +#define BGPIOF_BIG_ENDIAN BIT(0) +#define BGPIOF_UNREADABLE_REG_SET BIT(1)/* reg_set is unreadable */ +#define BGPIOF_UNREADABLE_REG_DIR BIT(2)/* reg_dir is unreadable */ #endif /* __BASIC_MMIO_GPIO_H */
Signature · 1 line
1.7.5.4
PATCH RESEND v2 1/1 gpio/generic: initialize basic_mmio_gpio shadow variables properly
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add missing initialization of basic_mmio_gpio shadow variables) manged to fix in gpio-mxc driver, so that other platform specific drivers do not suffer from the same problem over and over again.
Changes since v1:
* Turn the last parameter of bgpio_init() "bool big_endian" into "unsigned long flags" and give those really quirky hardwares a chance to tell that reg_set and reg_dir are unreadable.
---
Resend to have bgpio_pdev_probe adapt bgpio_init parameter change.
drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-generic.c | 16 +++++++++++----- drivers/gpio/gpio-mxc.c | 2 +- drivers/gpio/gpio-mxs.c | 2 +- drivers/gpio/gpio-sodaville.c | 2 +- include/linux/basic_mmio_gpio.h | 6 +++++- 6 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpio/gpio-ep93xx.c +1 -1
@@ -325,7 +325,7 @@ static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev,void __iomem *dir = mmio_base + bank->dir;int err; - err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL , false); + err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL ,0 );if (err)return err;
drivers/gpio/gpio-generic.c +11 -5
@@ -364,7 +364,7 @@ EXPORT_SYMBOL_GPL(bgpio_remove);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian) +unsigned long flags) {int ret;
@@ -385,7 +385,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,if (ret)return ret; - ret =bgpio_setup_accessors (dev, bgc, big_endian); + ret =bgpio_setup_accessors (dev, bgc, flags &BGPIOF_BIG_ENDIAN );if (ret)return ret;
@@ -394,6 +394,11 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,return ret; bgc->data = bgc->read_reg (bgc->reg_dat); +if (bgc->gc.set == bgpio_set_set && + !(flags &BGPIOF_UNREADABLE_REG_SET )) + bgc->data = bgc->read_reg (bgc->reg_set); +if (bgc->reg_dir && !(flags &BGPIOF_UNREADABLE_REG_DIR )) + bgc->dir = bgc->read_reg (bgc->reg_dir);return ret; }
@@ -449,7 +454,7 @@ static int __devinit bgpio_pdev_probe(struct platform_device *pdev)void __iomem *dirout;void __iomem *dirin;unsigned long sz; -bool be; +unsigned long flags;int err;struct bgpio_chip *bgc;struct bgpio_pdata *pdata =dev_get_platdata (dev);
@@ -480,13 +485,14 @@ static int __devinit bgpio_pdev_probe(struct platform_device *pdev)if (err)return err; - be = !strcmp (platform_get_device_id (pdev)->name,"basic-mmio-gpio-be" ); + flags = !strcmp (platform_get_device_id (pdev)->name, +"basic-mmio-gpio-be" ); bgc =devm_kzalloc (&pdev->dev,sizeof (*bgc),GFP_KERNEL );if (!bgc)return -ENOMEM ; - err =bgpio_init (bgc, dev, sz, dat, set, clr, dirout, dirin, be); + err =bgpio_init (bgc, dev, sz, dat, set, clr, dirout, dirin, flags);if (err)return err;
drivers/gpio/gpio-mxc.c +1 -1
@@ -417,7 +417,7 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +GPIO_PSR , port->base +GPIO_DR ,NULL , - port->base +GPIO_GDIR ,NULL , false); + port->base +GPIO_GDIR ,NULL ,0 );if (err) goto out_iounmap;
drivers/gpio/gpio-mxs.c +1 -1
@@ -285,7 +285,7 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +PINCTRL_DIN (port), port->base +PINCTRL_DOUT (port),NULL , - port->base +PINCTRL_DOE (port),NULL , false); + port->base +PINCTRL_DOE (port),NULL ,0 );if (err)return err;
drivers/gpio/gpio-sodaville.c +1 -1
@@ -224,7 +224,7 @@ static int __devinit sdv_gpio_probe(struct pci_dev *pdev, ret =bgpio_init (&sd->bgpio, &pdev->dev,4 , sd->gpio_pub_base +GPINR , sd->gpio_pub_base +GPOUTR , -NULL , sd->gpio_pub_base +GPOER ,NULL , false); +NULL , sd->gpio_pub_base +GPOER ,NULL ,0 );if (ret) goto unmap; sd->bgpio.gc.ngpio =SDV_NUM_PUB_GPIOS ;
include/linux/basic_mmio_gpio.h +5 -1
@@ -67,6 +67,10 @@ int bgpio_remove(struct bgpio_chip *bgc);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian); +unsigned long flags); + +#define BGPIOF_BIG_ENDIAN BIT(0) +#define BGPIOF_UNREADABLE_REG_SET BIT(1)/* reg_set is unreadable */ +#define BGPIOF_UNREADABLE_REG_DIR BIT(2)/* reg_dir is unreadable */ #endif /* __BASIC_MMIO_GPIO_H */
Signature · 1 line
1.7.5.4
Grant Likely
AppliedQuoted 11 lines · Shawn Guo
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add missing initialization of
basic_mmio_gpioshadow variables) manged to fix in gpio-mxc driver, so that other platform specific drivers do not suffer from the same problem over and over again.Changes since v1:
* Turn the last parameter "boolbig_endian" into "unsigned long flags" and give those really quirky hardwares a chance to tell thatreg_setandreg_dirare unreadable.Signed-off-by Shawn Guo <[email protected]>
Applied, thanks.
g.
Quoted 114 lines
--- drivers/gpio/gpio-ep93xx.c | 2 +- drivers/gpio/gpio-generic.c | 9 +++++++-- drivers/gpio/gpio-mxc.c | 2 +- drivers/gpio/gpio-mxs.c | 2 +- drivers/gpio/gpio-sodaville.c | 2 +- include/linux/basic_mmio_gpio.h | 6 +++++- 6 files changed, 16 insertions(+), 7 deletions(-)drivers/gpio/gpio-ep93xx.c +1
-1@@ -325,7 +325,7 @@ static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev,void __iomem *dir = mmio_base + bank->dir;int err; - err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL , false); + err =bgpio_init (bgc, dev,1 , data,NULL ,NULL , dir,NULL ,0 );if (err)return err;drivers/gpio/gpio-generic.c +7
-2@@ -364,7 +364,7 @@ EXPORT_SYMBOL_GPL(bgpio_remove);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian) +unsigned long flags) {int ret;@@ -385,7 +385,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,if (ret)return ret; - ret =bgpio_setup_accessors (dev, bgc, big_endian); + ret =bgpio_setup_accessors (dev, bgc, flags &BGPIOF_BIG_ENDIAN );if (ret)return ret;@@ -394,6 +394,11 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,return ret; bgc->data = bgc->read_reg (bgc->reg_dat); +if (bgc->gc.set == bgpio_set_set && + !(flags &BGPIOF_UNREADABLE_REG_SET )) + bgc->data = bgc->read_reg (bgc->reg_set); +if (bgc->reg_dir && !(flags &BGPIOF_UNREADABLE_REG_DIR )) + bgc->dir = bgc->read_reg (bgc->reg_dir);return ret; }drivers/gpio/gpio-mxc.c +1
-1@@ -417,7 +417,7 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +GPIO_PSR , port->base +GPIO_DR ,NULL , - port->base +GPIO_GDIR ,NULL , false); + port->base +GPIO_GDIR ,NULL ,0 );if (err) goto out_iounmap;drivers/gpio/gpio-mxs.c +1
-1@@ -285,7 +285,7 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev) err =bgpio_init (&port->bgc, &pdev->dev,4 , port->base +PINCTRL_DIN (port), port->base +PINCTRL_DOUT (port),NULL , - port->base +PINCTRL_DOE (port),NULL , false); + port->base +PINCTRL_DOE (port),NULL ,0 );if (err)return err;drivers/gpio/gpio-sodaville.c +1
-1@@ -224,7 +224,7 @@ static int __devinit sdv_gpio_probe(struct pci_dev *pdev, ret =bgpio_init (&sd->bgpio, &pdev->dev,4 , sd->gpio_pub_base +GPINR , sd->gpio_pub_base +GPOUTR , -NULL , sd->gpio_pub_base +GPOER ,NULL , false); +NULL , sd->gpio_pub_base +GPOER ,NULL ,0 );if (ret) goto unmap; sd->bgpio.gc.ngpio =SDV_NUM_PUB_GPIOS ;include/linux/basic_mmio_gpio.h +5
-1@@ -67,6 +67,10 @@ int bgpio_remove(struct bgpio_chip *bgc);int bgpio_init (struct bgpio_chip *bgc,struct device *dev,unsigned long sz,void __iomem *dat,void __iomem *set,void __iomem *clr,void __iomem *dirout,void __iomem *dirin, -bool big_endian); +unsigned long flags); + +#define BGPIOF_BIG_ENDIAN BIT(0) +#define BGPIOF_UNREADABLE_REG_SET BIT(1)/* reg_set is unreadable */ +#define BGPIOF_UNREADABLE_REG_DIR BIT(2)/* reg_dir is unreadable */ #endif /* __BASIC_MMIO_GPIO_H */ Signature · 1 line
1.7.5.4
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd.
Quoted 6 lines · Grant Likely
Quoted 5 lines · Shawn Guo
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add missing initialization of
basic_mmio_gpioshadow variables) manged to fix in gpio-mxc driver, so that other platform specific drivers do not suffer from the same problem over and over again.
Quoted 9 lines
Quoted 6 lines
Changes since v1:
* Turn the last parameter "boolbig_endian" into "unsigned long flags" and give those really quirky hardwares a chance to tell thatreg_setandreg_dirare unreadable.Signed-off-by Shawn Guo <[email protected]>Applied, thanks.
Grant,
Can you please pick up the RESEND version of the patch, which had bgpio_pdev_probe adapt bgpio_init parameter change too?
Signature · 2 lines
Regards, Shawn
Quoted 12 lines · Shawn Guo
Quoted 11 lines · Grant Likely
Quoted 10 lines · Shawn Guo
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add missing initialization of
basic_mmio_gpioshadow variables) manged to fix in gpio-mxc driver, so that other platform specific drivers do not suffer from the same problem over and over again.Changes since v1:
* Turn the last parameter "boolbig_endian" into "unsigned long flags" ? and give those really quirky hardwares a chance to tell thatreg_set? andreg_dirare unreadable.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Shawn Guo <[email protected]>Applied, thanks.
Grant,
Can you please pick up the RESEND version of the patch, which had
bgpio_pdev_probeadaptbgpio_initparameter change too?
I did even though I replied to the original.. You can check my gpio/next branch to be sure.
g.