mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-01 04:53:09 -04:00
gpio: Use of_property_present()
Use of_property_present() to test for property presence rather than of_find_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_find_property() leaks the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20240731191312.1710417-3-robh@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
ac93ca125b
commit
b034a90b27
@@ -1058,13 +1058,13 @@ static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
|
||||
int index = 0, ret, trim;
|
||||
const char *name;
|
||||
static const char group_names_propname[] = "gpio-ranges-group-names";
|
||||
struct property *group_names;
|
||||
bool has_group_names;
|
||||
|
||||
np = dev_of_node(&chip->gpiodev->dev);
|
||||
if (!np)
|
||||
return 0;
|
||||
|
||||
group_names = of_find_property(np, group_names_propname, NULL);
|
||||
has_group_names = of_property_present(np, group_names_propname);
|
||||
|
||||
for (;; index++) {
|
||||
ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
|
||||
@@ -1085,7 +1085,7 @@ static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
|
||||
|
||||
if (pinspec.args[2]) {
|
||||
/* npins != 0: linear range */
|
||||
if (group_names) {
|
||||
if (has_group_names) {
|
||||
of_property_read_string_index(np,
|
||||
group_names_propname,
|
||||
index, &name);
|
||||
@@ -1123,7 +1123,7 @@ static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!group_names) {
|
||||
if (!has_group_names) {
|
||||
pr_err("%pOF: GPIO group range requested but no %s property.\n",
|
||||
np, group_names_propname);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user