Commit 9c89b4cc authored by Tony Lindgren's avatar Tony Lindgren Committed by Greg Kroah-Hartman

pinctrl: core: Fix warning by removing bogus code

commit 664b7c47 upstream.

Andre Przywara <andre.przywara@arm.com> noticed that we can get the
following warning with -EPROBE_DEFER:

"WARNING: CPU: 1 PID: 89 at drivers/base/dd.c:349
driver_probe_device+0x2ac/0x2e8"

Let's fix the issue by removing the indices as suggested by
Tejun Heo <tj@kernel.org>. All we have to do here is kill the radix
tree.

I probably ended up with the indices after grepping for removal
of all entries using radix_tree_for_each_slot() and the first
match found was gmap_radix_tree_free(). Anyways, no need for
indices here, and we can just do remove all the entries using
radix_tree_for_each_slot() along how the item_kill_tree() test
case does.

Fixes: c7059c5a ("pinctrl: core: Add generic pinctrl functions for managing groups")
Fixes: a76edc89 ("pinctrl: core: Add generic pinctrl functions for managing groups")
Reported-by: default avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
Tested-by: default avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 789aa0c0
...@@ -680,30 +680,16 @@ EXPORT_SYMBOL_GPL(pinctrl_generic_remove_group); ...@@ -680,30 +680,16 @@ EXPORT_SYMBOL_GPL(pinctrl_generic_remove_group);
* pinctrl_generic_free_groups() - removes all pin groups * pinctrl_generic_free_groups() - removes all pin groups
* @pctldev: pin controller device * @pctldev: pin controller device
* *
* Note that the caller must take care of locking. * Note that the caller must take care of locking. The pinctrl groups
* are allocated with devm_kzalloc() so no need to free them here.
*/ */
static void pinctrl_generic_free_groups(struct pinctrl_dev *pctldev) static void pinctrl_generic_free_groups(struct pinctrl_dev *pctldev)
{ {
struct radix_tree_iter iter; struct radix_tree_iter iter;
struct group_desc *group;
unsigned long *indices;
void **slot; void **slot;
int i = 0;
indices = devm_kzalloc(pctldev->dev, sizeof(*indices) *
pctldev->num_groups, GFP_KERNEL);
if (!indices)
return;
radix_tree_for_each_slot(slot, &pctldev->pin_group_tree, &iter, 0) radix_tree_for_each_slot(slot, &pctldev->pin_group_tree, &iter, 0)
indices[i++] = iter.index; radix_tree_delete(&pctldev->pin_group_tree, iter.index);
for (i = 0; i < pctldev->num_groups; i++) {
group = radix_tree_lookup(&pctldev->pin_group_tree,
indices[i]);
radix_tree_delete(&pctldev->pin_group_tree, indices[i]);
devm_kfree(pctldev->dev, group);
}
pctldev->num_groups = 0; pctldev->num_groups = 0;
} }
......
...@@ -826,30 +826,17 @@ EXPORT_SYMBOL_GPL(pinmux_generic_remove_function); ...@@ -826,30 +826,17 @@ EXPORT_SYMBOL_GPL(pinmux_generic_remove_function);
* pinmux_generic_free_functions() - removes all functions * pinmux_generic_free_functions() - removes all functions
* @pctldev: pin controller device * @pctldev: pin controller device
* *
* Note that the caller must take care of locking. * Note that the caller must take care of locking. The pinctrl
* functions are allocated with devm_kzalloc() so no need to free
* them here.
*/ */
void pinmux_generic_free_functions(struct pinctrl_dev *pctldev) void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
{ {
struct radix_tree_iter iter; struct radix_tree_iter iter;
struct function_desc *function;
unsigned long *indices;
void **slot; void **slot;
int i = 0;
indices = devm_kzalloc(pctldev->dev, sizeof(*indices) *
pctldev->num_functions, GFP_KERNEL);
if (!indices)
return;
radix_tree_for_each_slot(slot, &pctldev->pin_function_tree, &iter, 0) radix_tree_for_each_slot(slot, &pctldev->pin_function_tree, &iter, 0)
indices[i++] = iter.index; radix_tree_delete(&pctldev->pin_function_tree, iter.index);
for (i = 0; i < pctldev->num_functions; i++) {
function = radix_tree_lookup(&pctldev->pin_function_tree,
indices[i]);
radix_tree_delete(&pctldev->pin_function_tree, indices[i]);
devm_kfree(pctldev->dev, function);
}
pctldev->num_functions = 0; pctldev->num_functions = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment