141-reset-fix-of_reset_control_get.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 7fd7a26b60090a7df15f30ba10b0d39cbbd6a94e Mon Sep 17 00:00:00 2001
  2. From: Alban Bedel <albeu@free.fr>
  3. Date: Tue, 1 Sep 2015 17:28:31 +0200
  4. Subject: [PATCH] reset: Fix of_reset_control_get() for consistent return
  5. values
  6. When of_reset_control_get() is called without connection ID it returns
  7. -ENOENT when the 'resets' property doesn't exists or is an empty entry.
  8. However when a connection ID is given it returns -EINVAL when the 'resets'
  9. property doesn't exists or the requested name can't be found. This is
  10. because the error code returned by of_property_match_string() is just
  11. passed down as an index to of_parse_phandle_with_args(), which then
  12. returns -EINVAL.
  13. To get a consistent return value with both code paths we must return
  14. -ENOENT when of_property_match_string() fails.
  15. Signed-off-by: Alban Bedel <albeu@free.fr>
  16. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
  17. ---
  18. drivers/reset/core.c | 5 ++++-
  19. 1 file changed, 4 insertions(+), 1 deletion(-)
  20. --- a/drivers/reset/core.c
  21. +++ b/drivers/reset/core.c
  22. @@ -215,9 +215,12 @@ struct reset_control *of_reset_control_g
  23. {
  24. int index = 0;
  25. - if (id)
  26. + if (id) {
  27. index = of_property_match_string(node,
  28. "reset-names", id);
  29. + if (index < 0)
  30. + return ERR_PTR(-ENOENT);
  31. + }
  32. return of_reset_control_get_by_index(node, index);
  33. }
  34. EXPORT_SYMBOL_GPL(of_reset_control_get);