Skip to contentSkip to conversation

lib-string-introduce-match_string-helper fix

PATCH New Andy Shevchenko 1 participant 2 messages Feb 8, 2016

Subsystems (4)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/2 lib-string-introduce-match_string-helper fix

Fix return code to be -EINVAL instead of -ENODATA.

---
 lib/string.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/string.c +2 -2
index f2a8fa6..ed83562 100644
@@ -637,7 +637,7 @@ EXPORT_SYMBOL(sysfs_streq);
  * @string:	string to match with
  *
  * Return:
- * index of a @string in the @array if matches, or %-ENODATA otherwise.
+ * index of a @string in the @array if matches, or %-EINVAL otherwise.
  */
 int match_string(const char * const *array, size_t n, const char *string)
 {
@@ -652,7 +652,7 @@ int match_string(const char * const *array, size_t n, const char *string)
 			return index;
 	}
 
-	return -ENODATA;
+	return -EINVAL;
 }
 EXPORT_SYMBOL(match_string);
 
Signature · 1 line
2.7.0
author reviewer
#1 lore raw

PATCH 2/2 device-property-convert-to-use-match_string-helper fix

Since match_string() returns -EINVAL let's convert it to -ENODATA as designed by device property API.

---
 drivers/base/property.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/property.c +2 -0
index f902b55..167f0a9 100644
@@ -665,6 +665,8 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
 		goto out;
 
 	ret = match_string(values, nval, string);
+	if (ret < 0)
+		ret = -ENODATA;
 out:
 	kfree(values);
 	return ret;
Signature · 1 line
2.7.0