OSDN Git Service

sh-pfc: Replace first_gpio and last_gpio with nr_gpios
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 28 Nov 2012 16:51:00 +0000 (17:51 +0100)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Fri, 15 Mar 2013 12:33:36 +0000 (13:33 +0100)
The SoC information first_gpio field is always equal to 0, and the
last_gpio field is the index of the last entry in the pinmux_gpios
array. Replace the first_gpio and last_gpio fields by a nr_gpios field,
and initialize it to ARRAY_SIZE(pinmux_gpios).

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
20 files changed:
drivers/pinctrl/sh-pfc/core.c
drivers/pinctrl/sh-pfc/gpio.c
drivers/pinctrl/sh-pfc/pfc-r8a7740.c
drivers/pinctrl/sh-pfc/pfc-r8a7779.c
drivers/pinctrl/sh-pfc/pfc-sh7203.c
drivers/pinctrl/sh-pfc/pfc-sh7264.c
drivers/pinctrl/sh-pfc/pfc-sh7269.c
drivers/pinctrl/sh-pfc/pfc-sh7372.c
drivers/pinctrl/sh-pfc/pfc-sh73a0.c
drivers/pinctrl/sh-pfc/pfc-sh7720.c
drivers/pinctrl/sh-pfc/pfc-sh7722.c
drivers/pinctrl/sh-pfc/pfc-sh7723.c
drivers/pinctrl/sh-pfc/pfc-sh7724.c
drivers/pinctrl/sh-pfc/pfc-sh7734.c
drivers/pinctrl/sh-pfc/pfc-sh7757.c
drivers/pinctrl/sh-pfc/pfc-sh7785.c
drivers/pinctrl/sh-pfc/pfc-sh7786.c
drivers/pinctrl/sh-pfc/pfc-shx3.c
drivers/pinctrl/sh-pfc/pinctrl.c
drivers/pinctrl/sh-pfc/sh_pfc.h

index 970ddff..1b86a90 100644 (file)
@@ -260,7 +260,7 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc)
        struct pinmux_data_reg *drp;
        int k;
 
-       for (k = pfc->info->first_gpio; k <= pfc->info->last_gpio; k++)
+       for (k = 0; k < pfc->info->nr_gpios; k++)
                sh_pfc_setup_data_reg(pfc, k);
 
        k = 0;
index a535075..f46f069 100644 (file)
@@ -130,12 +130,10 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip)
        gc->set = sh_gpio_set;
        gc->to_irq = sh_gpio_to_irq;
 
-       WARN_ON(pfc->info->first_gpio != 0); /* needs testing */
-
        gc->label = pfc->info->name;
        gc->owner = THIS_MODULE;
-       gc->base = pfc->info->first_gpio;
-       gc->ngpio = (pfc->info->last_gpio - pfc->info->first_gpio) + 1;
+       gc->base = 0;
+       gc->ngpio = pfc->info->nr_gpios;
 }
 
 int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
@@ -157,9 +155,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
 
        pfc->gpio = chip;
 
-       pr_info("%s handling gpio %d -> %d\n",
-               pfc->info->name, pfc->info->first_gpio,
-               pfc->info->last_gpio);
+       pr_info("%s handling gpio 0 -> %u\n",
+               pfc->info->name, pfc->info->nr_gpios - 1);
 
        return 0;
 }
index 214788c..c189a86 100644 (file)
@@ -2597,10 +2597,9 @@ struct sh_pfc_soc_info r8a7740_pinmux_info = {
        .function       = { PINMUX_FUNCTION_BEGIN,
                            PINMUX_FUNCTION_END },
 
-       .first_gpio     = GPIO_PORT0,
-       .last_gpio      = GPIO_FN_TRACEAUD_FROM_MEMC,
-
        .gpios          = pinmux_gpios,
+       .nr_gpios       = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs       = pinmux_config_regs,
        .data_regs      = pinmux_data_regs,
 
index 13feaa0..16ec97a 100644 (file)
@@ -2612,10 +2612,9 @@ struct sh_pfc_soc_info r8a7779_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_GP_0_0,
-       .last_gpio = GPIO_FN_SCK4_B,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 22be49b..6cc6701 100644 (file)
@@ -1580,10 +1580,9 @@ struct sh_pfc_soc_info sh7203_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PA7,
-       .last_gpio = GPIO_FN_LCD_DATA0,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index ebe9c7c..c2ecc65 100644 (file)
@@ -2119,10 +2119,9 @@ struct sh_pfc_soc_info sh7264_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PA3,
-       .last_gpio = GPIO_FN_LCD_M_DISP,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 87cb693..2013f4f 100644 (file)
@@ -2822,10 +2822,9 @@ struct sh_pfc_soc_info sh7269_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PA1,
-       .last_gpio = GPIO_FN_LCD_M_DISP,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index d44e7f0..332cf34 100644 (file)
@@ -1643,10 +1643,9 @@ struct sh_pfc_soc_info sh7372_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PORT0,
-       .last_gpio = GPIO_FN_SDENC_DV_CLKI,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 232731b..d5ee0f7 100644 (file)
@@ -2779,10 +2779,9 @@ struct sh_pfc_soc_info sh73a0_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PORT0,
-       .last_gpio = GPIO_FN_FSIAISLD_PU,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index e2e4520..8646237 100644 (file)
@@ -1223,10 +1223,9 @@ struct sh_pfc_soc_info sh7720_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PTA7,
-       .last_gpio = GPIO_FN_STATUS1,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 225fa96..194ae3d 100644 (file)
@@ -1767,10 +1767,9 @@ struct sh_pfc_soc_info sh7722_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PTA7,
-       .last_gpio = GPIO_FN_KEYOUT5_IN5,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 49fd5c8..f31aa4f 100644 (file)
@@ -1891,10 +1891,9 @@ struct sh_pfc_soc_info sh7723_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PTA7,
-       .last_gpio = GPIO_FN_IDEA0,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 054b700..64b69b7 100644 (file)
@@ -2213,10 +2213,9 @@ struct sh_pfc_soc_info sh7724_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PTA7,
-       .last_gpio = GPIO_FN_INTC_IRQ0,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 23d76d2..d67a572 100644 (file)
@@ -2463,10 +2463,9 @@ struct sh_pfc_soc_info sh7734_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_GP_0_0,
-       .last_gpio = GPIO_FN_ST_CLKOUT,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index ffbd8b7..7fc1310 100644 (file)
@@ -2270,10 +2270,9 @@ struct sh_pfc_soc_info sh7757_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PTA0,
-       .last_gpio = GPIO_FN_ON_DQ0,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 2e9d7cb..4bde4b5 100644 (file)
@@ -1292,10 +1292,9 @@ struct sh_pfc_soc_info sh7785_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PA7,
-       .last_gpio = GPIO_FN_IRQOUT,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index c9d8f50..9a42d25 100644 (file)
@@ -825,10 +825,9 @@ struct sh_pfc_soc_info sh7786_pinmux_info = {
        .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
        .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
-       .first_gpio = GPIO_PA7,
-       .last_gpio = GPIO_FN_IRL4,
-
        .gpios = pinmux_gpios,
+       .nr_gpios = ARRAY_SIZE(pinmux_gpios),
+
        .cfg_regs = pinmux_config_regs,
        .data_regs = pinmux_data_regs,
 
index 04e8940..b23f5f9 100644 (file)
@@ -572,9 +572,8 @@ struct sh_pfc_soc_info shx3_pinmux_info = {
        .output         = { PINMUX_OUTPUT_BEGIN,   PINMUX_OUTPUT_END },
        .mark           = { PINMUX_MARK_BEGIN,     PINMUX_MARK_END },
        .function       = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
-       .first_gpio     = GPIO_PA7,
-       .last_gpio      = GPIO_FN_STATUS0,
        .gpios          = shx3_pinmux_gpios,
+       .nr_gpios       = ARRAY_SIZE(shx3_pinmux_gpios),
        .gpio_data      = shx3_pinmux_data,
        .gpio_data_size = ARRAY_SIZE(shx3_pinmux_data),
        .cfg_regs       = shx3_pinmux_config_regs,
index 4ce2753..908b536 100644 (file)
@@ -336,7 +336,7 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
 {
        int i;
 
-       pmx->nr_pads = pfc->info->last_gpio - pfc->info->first_gpio + 1;
+       pmx->nr_pads = pfc->info->nr_gpios;
 
        pmx->pads = devm_kzalloc(pfc->dev, sizeof(*pmx->pads) * pmx->nr_pads,
                                 GFP_KERNEL);
@@ -345,17 +345,11 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
                return -ENOMEM;
        }
 
-       /*
-        * We don't necessarily have a 1:1 mapping between pin and linux
-        * GPIO number, as the latter maps to the associated enum_id.
-        * Care needs to be taken to translate back to pin space when
-        * dealing with any pin configurations.
-        */
        for (i = 0; i < pmx->nr_pads; i++) {
                struct pinctrl_pin_desc *pin = pmx->pads + i;
                struct pinmux_gpio *gpio = pfc->info->gpios + i;
 
-               pin->number = pfc->info->first_gpio + i;
+               pin->number = i;
                pin->name = gpio->name;
 
                /* XXX */
@@ -421,9 +415,9 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 
        pmx->range.name = DRV_NAME,
        pmx->range.id = 0;
-       pmx->range.npins = pfc->info->last_gpio - pfc->info->first_gpio + 1;
-       pmx->range.base = pfc->info->first_gpio;
-       pmx->range.pin_base = pfc->info->first_gpio;
+       pmx->range.npins = pfc->info->nr_gpios;
+       pmx->range.base = 0;
+       pmx->range.pin_base = 0;
 
        pinctrl_add_gpio_range(pmx->pctl, &pmx->range);
 
index 13049c4..67fe91b 100644 (file)
@@ -99,9 +99,9 @@ struct sh_pfc_soc_info {
        struct pinmux_range mark;
        struct pinmux_range function;
 
-       unsigned first_gpio, last_gpio;
-
        struct pinmux_gpio *gpios;
+       unsigned int nr_gpios;
+
        struct pinmux_cfg_reg *cfg_regs;
        struct pinmux_data_reg *data_regs;