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 970ddff2b0b6a4eea4abfc3e262ade40f7e8f4a0..1b86a906a97b1f16fa0295a03184757874aef15e 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 a535075c8b69f0aee1380ebc4fca94810dae5a69..f46f06997b99569ea8b559942b6423c3ed05ade0 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 214788c4a606180755e8e6f02c97afb4059fa163..c189a86fe8d3f3adc0d1e3b9377a5d40d74954b4 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 13feaa0c0eb703e49960d2f62e35264ea8e91cbd..16ec97a31b38387bbe92177d9dfab13758552900 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 22be49b3bd382fbc51e202f6ba5e59740851fdd9..6cc67017e8febed58cb18bceffed8280275ec9c3 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 ebe9c7ceb575ba3294b346c3e775d81e427dc4d8..c2ecc65ff25293f651619850d4bd8c2a16f6657f 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 87cb6933e02bbeff1bb04f74e9a70584ef10516e..2013f4fa24f2f7fdf9261609a77c66e87178bdf1 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 d44e7f02069b2779e082c52d55a7db6661e1cad6..332cf34a867fd4cc8ab33674ee8883e5bd5983e5 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 232731bcdd228ec43fc52a6189e456cb6372a058..d5ee0f7680af4f1d990f1a9458d77fd9b08fe3ca 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 e2e4520a14c40eae6120f285d918e38343564244..8646237e9dffaae641d32e6980d7318b67a0dbe7 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 225fa96b6a21328419c2d7d46dd0bcce497b9bc0..194ae3de5a05df61ad2b73be9e151323efdca3f1 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 49fd5c82e3cfe8e732c1296cc690e035e9fc4d9a..f31aa4f6b165d1ac349100732fa671b737df43fd 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 054b700a7e011531d34553ea51f169305b3d962d..64b69b709f0f944171ed80e88d14dfa7cbc7bb0c 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 23d76d262c3204a431892bc8f575f930036b8cd9..d67a572de822f55f3a41bff2bd5a4618230e92e8 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 ffbd8b7ee72e5b9783ecc52a075c75eff82563f1..7fc1310faf9c7b8ccaea1bd1ec6f4d41ffc90716 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 2e9d7cbec783ccea01195622d30d0b2fee3bc73a..4bde4b56de587e6279ee45dc9091cd63c4795e94 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 c9d8f500a6d35d578890d4b98c5018d916b84ffd..9a42d25312d95c33802592158f44eaf4c138db73 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 04e89407aecdc8a03209e367aab68c76672d75e2..b23f5f9a84296e8e48a69f824c42fe2a9f36d209 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 4ce2753cb2df03e52e2058c1743d7ec0537b28a7..908b5362b1cde21d1c50f73da4dc3237e6bd5161 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 13049c4c8d309b3430c45ed15150676191e6acf0..67fe91b051cbccbabb032611ca969df31eea3cc7 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;