mirror of
https://gitee.com/openharmony/kernel_linux
synced 2025-04-06 09:02:31 +00:00
pinctrl: core: create nolock version of pinctrl_find_gpio_range_from_pin
pinctrl_find_gpio_range_from_pin takes the pctldev->mutex but so does pinconf_pins_show and this will cause a deadlock if pinctrl_find_gpio_range_from_pin is used in .pin_config_get callback. Create a nolock version of pinctrl_find_gpio_range_from_pin to allow pin to gpio lookup to be used from pinconf_pins_show. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
5e9a207547
commit
b18537cd8e
@ -481,6 +481,30 @@ int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, const char *pin_group,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pinctrl_get_group_pins);
|
EXPORT_SYMBOL_GPL(pinctrl_get_group_pins);
|
||||||
|
|
||||||
|
struct pinctrl_gpio_range *
|
||||||
|
pinctrl_find_gpio_range_from_pin_nolock(struct pinctrl_dev *pctldev,
|
||||||
|
unsigned int pin)
|
||||||
|
{
|
||||||
|
struct pinctrl_gpio_range *range;
|
||||||
|
|
||||||
|
/* Loop over the ranges */
|
||||||
|
list_for_each_entry(range, &pctldev->gpio_ranges, node) {
|
||||||
|
/* Check if we're in the valid range */
|
||||||
|
if (range->pins) {
|
||||||
|
int a;
|
||||||
|
for (a = 0; a < range->npins; a++) {
|
||||||
|
if (range->pins[a] == pin)
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
} else if (pin >= range->pin_base &&
|
||||||
|
pin < range->pin_base + range->npins)
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pinctrl_find_gpio_range_from_pin_nolock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinctrl_find_gpio_range_from_pin() - locate the GPIO range for a pin
|
* pinctrl_find_gpio_range_from_pin() - locate the GPIO range for a pin
|
||||||
* @pctldev: the pin controller device to look in
|
* @pctldev: the pin controller device to look in
|
||||||
@ -493,22 +517,9 @@ pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev,
|
|||||||
struct pinctrl_gpio_range *range;
|
struct pinctrl_gpio_range *range;
|
||||||
|
|
||||||
mutex_lock(&pctldev->mutex);
|
mutex_lock(&pctldev->mutex);
|
||||||
/* Loop over the ranges */
|
range = pinctrl_find_gpio_range_from_pin_nolock(pctldev, pin);
|
||||||
list_for_each_entry(range, &pctldev->gpio_ranges, node) {
|
|
||||||
/* Check if we're in the valid range */
|
|
||||||
if (range->pins) {
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < range->npins; a++) {
|
|
||||||
if (range->pins[a] == pin)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} else if (pin >= range->pin_base &&
|
|
||||||
pin < range->pin_base + range->npins)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
range = NULL;
|
|
||||||
out:
|
|
||||||
mutex_unlock(&pctldev->mutex);
|
mutex_unlock(&pctldev->mutex);
|
||||||
|
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pinctrl_find_gpio_range_from_pin);
|
EXPORT_SYMBOL_GPL(pinctrl_find_gpio_range_from_pin);
|
||||||
|
@ -182,6 +182,10 @@ static inline struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev,
|
|||||||
return radix_tree_lookup(&pctldev->pin_desc_tree, pin);
|
return radix_tree_lookup(&pctldev->pin_desc_tree, pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern struct pinctrl_gpio_range *
|
||||||
|
pinctrl_find_gpio_range_from_pin_nolock(struct pinctrl_dev *pctldev,
|
||||||
|
unsigned int pin);
|
||||||
|
|
||||||
int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
|
int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
|
||||||
bool dup);
|
bool dup);
|
||||||
void pinctrl_unregister_map(struct pinctrl_map const *map);
|
void pinctrl_unregister_map(struct pinctrl_map const *map);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user