Skip to content

Commit f2b388d

Browse files
hcodinarobherring
authored andcommitted
of: dynamic: Introduce of_changeset_add_prop_bool()
APIs to add some properties in a changeset exist but nothing to add a DT boolean property (i.e. a property without any values). Fill this lack with of_changeset_add_prop_bool(). Signed-off-by: Herve Codina <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent aa5545a commit f2b388d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/of/dynamic.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,3 +1047,28 @@ int of_changeset_add_prop_u32_array(struct of_changeset *ocs,
10471047
return of_changeset_add_prop_helper(ocs, np, &prop);
10481048
}
10491049
EXPORT_SYMBOL_GPL(of_changeset_add_prop_u32_array);
1050+
1051+
/**
1052+
* of_changeset_add_prop_bool - Add a boolean property (i.e. a property without
1053+
* any values) to a changeset.
1054+
*
1055+
* @ocs: changeset pointer
1056+
* @np: device node pointer
1057+
* @prop_name: name of the property to be added
1058+
*
1059+
* Create a boolean property and add it to a changeset.
1060+
*
1061+
* Return: 0 on success, a negative error value in case of an error.
1062+
*/
1063+
int of_changeset_add_prop_bool(struct of_changeset *ocs, struct device_node *np,
1064+
const char *prop_name)
1065+
{
1066+
struct property prop;
1067+
1068+
prop.name = (char *)prop_name;
1069+
prop.length = 0;
1070+
prop.value = NULL;
1071+
1072+
return of_changeset_add_prop_helper(ocs, np, &prop);
1073+
}
1074+
EXPORT_SYMBOL_GPL(of_changeset_add_prop_bool);

include/linux/of.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,9 @@ static inline int of_changeset_add_prop_u32(struct of_changeset *ocs,
16521652
return of_changeset_add_prop_u32_array(ocs, np, prop_name, &val, 1);
16531653
}
16541654

1655+
int of_changeset_add_prop_bool(struct of_changeset *ocs, struct device_node *np,
1656+
const char *prop_name);
1657+
16551658
#else /* CONFIG_OF_DYNAMIC */
16561659
static inline int of_reconfig_notifier_register(struct notifier_block *nb)
16571660
{

0 commit comments

Comments
 (0)