Skip to content

Commit

Permalink
of: dynamic: Constify parameter in of_changeset_add_prop_string_array()
Browse files Browse the repository at this point in the history
The str_array parameter has no reason to be an un-const array.
Indeed, elements of the 'str_array' array are not changed by the code.

Constify the 'str_array' array parameter.
With this const qualifier added, the following construction is allowed:
  static const char * const tab_str[] = { "string1", "string2" };
  of_changeset_add_prop_string_array(..., tab_str, ARRAY_SIZE(tab_str));

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20240527161450.326615-14-herve.codina@bootlin.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
  • Loading branch information
Herve Codina authored and Rob Herring (Arm) committed Jul 8, 2024
1 parent 38da7fa commit 6badc62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/of/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ EXPORT_SYMBOL_GPL(of_changeset_add_prop_string);
int of_changeset_add_prop_string_array(struct of_changeset *ocs,
struct device_node *np,
const char *prop_name,
const char **str_array, size_t sz)
const char * const *str_array, size_t sz)
{
struct property prop;
int i, ret;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ int of_changeset_add_prop_string(struct of_changeset *ocs,
int of_changeset_add_prop_string_array(struct of_changeset *ocs,
struct device_node *np,
const char *prop_name,
const char **str_array, size_t sz);
const char * const *str_array, size_t sz);
int of_changeset_add_prop_u32_array(struct of_changeset *ocs,
struct device_node *np,
const char *prop_name,
Expand Down

0 comments on commit 6badc62

Please sign in to comment.