Skip to content

Commit

Permalink
device: property: add helpers to count items in string arrays
Browse files Browse the repository at this point in the history
Instead of doing the following:

    count = device_property_read_string_array(dev, propname, NULL, 0);

Let's provide inline helpers with hardcoded arguments for counting
strings in property arrays.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
Bartosz Golaszewski committed Sep 14, 2020
1 parent 8d4a85b commit 6b6ff4a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/linux/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ static inline int device_property_count_u64(struct device *dev, const char *prop
return device_property_read_u64_array(dev, propname, NULL, 0);
}

static inline int device_property_string_array_count(struct device *dev,
const char *propname)
{
return device_property_read_string_array(dev, propname, NULL, 0);
}

static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
const char *propname)
{
Expand Down Expand Up @@ -224,6 +230,13 @@ static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
}

static inline int
fwnode_property_string_array_count(const struct fwnode_handle *fwnode,
const char *propname)
{
return fwnode_property_read_string_array(fwnode, propname, NULL, 0);
}

struct software_node;

/**
Expand Down

0 comments on commit 6b6ff4a

Please sign in to comment.