diff options
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r-- | drivers/pinctrl/core.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 569bdb3ef104..894cd5e103da 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -189,7 +189,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev, | |||
189 | pindesc->pctldev = pctldev; | 189 | pindesc->pctldev = pctldev; |
190 | 190 | ||
191 | /* Copy basic pin info */ | 191 | /* Copy basic pin info */ |
192 | if (pindesc->name) { | 192 | if (name) { |
193 | pindesc->name = name; | 193 | pindesc->name = name; |
194 | } else { | 194 | } else { |
195 | pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number); | 195 | pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number); |
@@ -510,10 +510,12 @@ static struct dentry *debugfs_root; | |||
510 | 510 | ||
511 | static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) | 511 | static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) |
512 | { | 512 | { |
513 | static struct dentry *device_root; | 513 | struct dentry *device_root; |
514 | 514 | ||
515 | device_root = debugfs_create_dir(dev_name(pctldev->dev), | 515 | device_root = debugfs_create_dir(dev_name(pctldev->dev), |
516 | debugfs_root); | 516 | debugfs_root); |
517 | pctldev->device_root = device_root; | ||
518 | |||
517 | if (IS_ERR(device_root) || !device_root) { | 519 | if (IS_ERR(device_root) || !device_root) { |
518 | pr_warn("failed to create debugfs directory for %s\n", | 520 | pr_warn("failed to create debugfs directory for %s\n", |
519 | dev_name(pctldev->dev)); | 521 | dev_name(pctldev->dev)); |
@@ -529,6 +531,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) | |||
529 | pinconf_init_device_debugfs(device_root, pctldev); | 531 | pinconf_init_device_debugfs(device_root, pctldev); |
530 | } | 532 | } |
531 | 533 | ||
534 | static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev) | ||
535 | { | ||
536 | debugfs_remove_recursive(pctldev->device_root); | ||
537 | } | ||
538 | |||
532 | static void pinctrl_init_debugfs(void) | 539 | static void pinctrl_init_debugfs(void) |
533 | { | 540 | { |
534 | debugfs_root = debugfs_create_dir("pinctrl", NULL); | 541 | debugfs_root = debugfs_create_dir("pinctrl", NULL); |
@@ -553,6 +560,10 @@ static void pinctrl_init_debugfs(void) | |||
553 | { | 560 | { |
554 | } | 561 | } |
555 | 562 | ||
563 | static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev) | ||
564 | { | ||
565 | } | ||
566 | |||
556 | #endif | 567 | #endif |
557 | 568 | ||
558 | /** | 569 | /** |
@@ -572,40 +583,40 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | |||
572 | if (pctldesc->name == NULL) | 583 | if (pctldesc->name == NULL) |
573 | return NULL; | 584 | return NULL; |
574 | 585 | ||
586 | pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL); | ||
587 | if (pctldev == NULL) | ||
588 | return NULL; | ||
589 | |||
590 | /* Initialize pin control device struct */ | ||
591 | pctldev->owner = pctldesc->owner; | ||
592 | pctldev->desc = pctldesc; | ||
593 | pctldev->driver_data = driver_data; | ||
594 | INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL); | ||
595 | spin_lock_init(&pctldev->pin_desc_tree_lock); | ||
596 | INIT_LIST_HEAD(&pctldev->gpio_ranges); | ||
597 | mutex_init(&pctldev->gpio_ranges_lock); | ||
598 | pctldev->dev = dev; | ||
599 | |||
575 | /* If we're implementing pinmuxing, check the ops for sanity */ | 600 | /* If we're implementing pinmuxing, check the ops for sanity */ |
576 | if (pctldesc->pmxops) { | 601 | if (pctldesc->pmxops) { |
577 | ret = pinmux_check_ops(pctldesc->pmxops); | 602 | ret = pinmux_check_ops(pctldev); |
578 | if (ret) { | 603 | if (ret) { |
579 | pr_err("%s pinmux ops lacks necessary functions\n", | 604 | pr_err("%s pinmux ops lacks necessary functions\n", |
580 | pctldesc->name); | 605 | pctldesc->name); |
581 | return NULL; | 606 | goto out_err; |
582 | } | 607 | } |
583 | } | 608 | } |
584 | 609 | ||
585 | /* If we're implementing pinconfig, check the ops for sanity */ | 610 | /* If we're implementing pinconfig, check the ops for sanity */ |
586 | if (pctldesc->confops) { | 611 | if (pctldesc->confops) { |
587 | ret = pinconf_check_ops(pctldesc->confops); | 612 | ret = pinconf_check_ops(pctldev); |
588 | if (ret) { | 613 | if (ret) { |
589 | pr_err("%s pin config ops lacks necessary functions\n", | 614 | pr_err("%s pin config ops lacks necessary functions\n", |
590 | pctldesc->name); | 615 | pctldesc->name); |
591 | return NULL; | 616 | goto out_err; |
592 | } | 617 | } |
593 | } | 618 | } |
594 | 619 | ||
595 | pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL); | ||
596 | if (pctldev == NULL) | ||
597 | return NULL; | ||
598 | |||
599 | /* Initialize pin control device struct */ | ||
600 | pctldev->owner = pctldesc->owner; | ||
601 | pctldev->desc = pctldesc; | ||
602 | pctldev->driver_data = driver_data; | ||
603 | INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL); | ||
604 | spin_lock_init(&pctldev->pin_desc_tree_lock); | ||
605 | INIT_LIST_HEAD(&pctldev->gpio_ranges); | ||
606 | mutex_init(&pctldev->gpio_ranges_lock); | ||
607 | pctldev->dev = dev; | ||
608 | |||
609 | /* Register all the pins */ | 620 | /* Register all the pins */ |
610 | pr_debug("try to register %d pins on %s...\n", | 621 | pr_debug("try to register %d pins on %s...\n", |
611 | pctldesc->npins, pctldesc->name); | 622 | pctldesc->npins, pctldesc->name); |
@@ -641,6 +652,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev) | |||
641 | if (pctldev == NULL) | 652 | if (pctldev == NULL) |
642 | return; | 653 | return; |
643 | 654 | ||
655 | pinctrl_remove_device_debugfs(pctldev); | ||
644 | pinmux_unhog_maps(pctldev); | 656 | pinmux_unhog_maps(pctldev); |
645 | /* TODO: check that no pinmuxes are still active? */ | 657 | /* TODO: check that no pinmuxes are still active? */ |
646 | mutex_lock(&pinctrldev_list_mutex); | 658 | mutex_lock(&pinctrldev_list_mutex); |