aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/sh-pfc/pinctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pinctrl/sh-pfc/pinctrl.c')
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c49
1 files changed, 14 insertions, 35 deletions
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 314255d79bff..8649ec3910a3 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -587,22 +587,9 @@ static const struct pinconf_ops sh_pfc_pinconf_ops = {
587/* PFC ranges -> pinctrl pin descs */ 587/* PFC ranges -> pinctrl pin descs */
588static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) 588static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
589{ 589{
590 const struct pinmux_range *ranges;
591 struct pinmux_range def_range;
592 unsigned int nr_ranges;
593 unsigned int nr_pins;
594 unsigned int i; 590 unsigned int i;
595 591
596 if (pfc->info->ranges == NULL) { 592 /* Allocate and initialize the pins and configs arrays. */
597 def_range.begin = 0;
598 def_range.end = pfc->info->nr_pins - 1;
599 ranges = &def_range;
600 nr_ranges = 1;
601 } else {
602 ranges = pfc->info->ranges;
603 nr_ranges = pfc->info->nr_ranges;
604 }
605
606 pmx->pins = devm_kzalloc(pfc->dev, 593 pmx->pins = devm_kzalloc(pfc->dev,
607 sizeof(*pmx->pins) * pfc->info->nr_pins, 594 sizeof(*pmx->pins) * pfc->info->nr_pins,
608 GFP_KERNEL); 595 GFP_KERNEL);
@@ -615,32 +602,24 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
615 if (unlikely(!pmx->configs)) 602 if (unlikely(!pmx->configs))
616 return -ENOMEM; 603 return -ENOMEM;
617 604
618 for (i = 0, nr_pins = 0; i < nr_ranges; ++i) { 605 for (i = 0; i < pfc->info->nr_pins; ++i) {
619 const struct pinmux_range *range = &ranges[i]; 606 const struct sh_pfc_pin *info = &pfc->info->pins[i];
620 unsigned int number; 607 struct sh_pfc_pin_config *cfg = &pmx->configs[i];
608 struct pinctrl_pin_desc *pin = &pmx->pins[i];
621 609
622 for (number = range->begin; number <= range->end; 610 /* If the pin number is equal to -1 all pins are considered */
623 number++, nr_pins++) { 611 pin->number = info->pin != (u16)-1 ? info->pin : i;
624 struct sh_pfc_pin_config *cfg = &pmx->configs[nr_pins]; 612 pin->name = info->name;
625 struct pinctrl_pin_desc *pin = &pmx->pins[nr_pins]; 613 cfg->type = PINMUX_TYPE_NONE;
626 const struct sh_pfc_pin *info =
627 &pfc->info->pins[nr_pins];
628
629 pin->number = number;
630 pin->name = info->name;
631 cfg->type = PINMUX_TYPE_NONE;
632 }
633 } 614 }
634 615
635 pfc->nr_gpio_pins = ranges[nr_ranges-1].end + 1; 616 return 0;
636
637 return nr_ranges;
638} 617}
639 618
640int sh_pfc_register_pinctrl(struct sh_pfc *pfc) 619int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
641{ 620{
642 struct sh_pfc_pinctrl *pmx; 621 struct sh_pfc_pinctrl *pmx;
643 int nr_ranges; 622 int ret;
644 623
645 pmx = devm_kzalloc(pfc->dev, sizeof(*pmx), GFP_KERNEL); 624 pmx = devm_kzalloc(pfc->dev, sizeof(*pmx), GFP_KERNEL);
646 if (unlikely(!pmx)) 625 if (unlikely(!pmx))
@@ -649,9 +628,9 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
649 pmx->pfc = pfc; 628 pmx->pfc = pfc;
650 pfc->pinctrl = pmx; 629 pfc->pinctrl = pmx;
651 630
652 nr_ranges = sh_pfc_map_pins(pfc, pmx); 631 ret = sh_pfc_map_pins(pfc, pmx);
653 if (unlikely(nr_ranges < 0)) 632 if (ret < 0)
654 return nr_ranges; 633 return ret;
655 634
656 pmx->pctl_desc.name = DRV_NAME; 635 pmx->pctl_desc.name = DRV_NAME;
657 pmx->pctl_desc.owner = THIS_MODULE; 636 pmx->pctl_desc.owner = THIS_MODULE;