Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: imx: don't access the pin function radix tree directly

The radix tree containing pin function descriptors should not be
accessed directly by drivers. There are dedicated functions for it. I
suppose this driver does it so that the memory containing the function
description is not duplicated but we're going to address that shortly so
convert it to using generic pinctrl APIs.

Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Bartosz Golaszewski and committed by
Linus Walleij
ea22f777 bd6f4a91

+18 -23
+18 -23
drivers/pinctrl/freescale/pinctrl-imx.c
··· 580 580 u32 index) 581 581 { 582 582 struct pinctrl_dev *pctl = ipctl->pctl; 583 - struct function_desc *func; 583 + struct pinfunction *func; 584 584 struct group_desc *grp; 585 585 const char **group_names; 586 + int ret; 586 587 u32 i; 587 588 588 589 dev_dbg(pctl->dev, "parse function(%d): %pOFn\n", index, np); 589 590 590 - func = pinmux_generic_get_function(pctl, index); 591 + func = devm_kzalloc(ipctl->dev, sizeof(*func), GFP_KERNEL); 591 592 if (!func) 592 - return -EINVAL; 593 + return -ENOMEM; 593 594 594 595 /* Initialise function */ 595 - func->func.name = np->name; 596 - func->func.ngroups = of_get_child_count(np); 597 - if (func->func.ngroups == 0) { 596 + func->name = np->name; 597 + func->ngroups = of_get_child_count(np); 598 + if (func->ngroups == 0) { 598 599 dev_info(ipctl->dev, "no groups defined in %pOF\n", np); 599 600 return -EINVAL; 600 601 } 601 602 602 - group_names = devm_kcalloc(ipctl->dev, func->func.ngroups, 603 - sizeof(*func->func.groups), GFP_KERNEL); 603 + group_names = devm_kcalloc(ipctl->dev, func->ngroups, 604 + sizeof(*func->groups), GFP_KERNEL); 604 605 if (!group_names) 605 606 return -ENOMEM; 606 607 i = 0; 607 608 for_each_child_of_node_scoped(np, child) 608 609 group_names[i++] = child->name; 609 - func->func.groups = group_names; 610 + func->groups = group_names; 611 + 612 + ret = pinmux_generic_add_pinfunction(pctl, func, NULL); 613 + if (ret < 0) 614 + return ret; 610 615 611 616 i = 0; 612 617 for_each_child_of_node_scoped(np, child) { ··· 620 615 return -ENOMEM; 621 616 622 617 mutex_lock(&ipctl->mutex); 618 + /* 619 + * FIXME: This should use pinctrl_generic_add_group() and not 620 + * access the private radix tree directly. 621 + */ 623 622 radix_tree_insert(&pctl->pin_group_tree, 624 623 ipctl->group_index++, grp); 625 624 mutex_unlock(&ipctl->mutex); ··· 677 668 return -EINVAL; 678 669 } 679 670 } 680 - 681 - for (i = 0; i < nfuncs; i++) { 682 - struct function_desc *function; 683 - 684 - function = devm_kzalloc(&pdev->dev, sizeof(*function), 685 - GFP_KERNEL); 686 - if (!function) 687 - return -ENOMEM; 688 - 689 - mutex_lock(&ipctl->mutex); 690 - radix_tree_insert(&pctl->pin_function_tree, i, function); 691 - mutex_unlock(&ipctl->mutex); 692 - } 693 - pctl->num_functions = nfuncs; 694 671 695 672 ipctl->group_index = 0; 696 673 if (flat_funcs) {