]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
device: property: add helpers to count items in string arrays
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 9 Sep 2020 08:54:24 +0000 (10:54 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Mon, 14 Sep 2020 08:53:43 +0000 (10:53 +0200)
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>
include/linux/property.h

index 9f805c442819532a894a7c6a7e52efccec29ebca..75c178055bc972f2751556433a20eb69b2981a18 100644 (file)
@@ -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)
 {
@@ -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;
 
 /**