If no match is found for a hwmod class, omap_hwmod_for_each_by_class()
currently does not spit out any error messages. To make debugging
issues related to non-existent hwmod classes simpler make this function
print an error message in case no match is found for the supplied hwmod
class.

Signed-off-by: Vaibhav Bedia <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6ca8e51..90e2306 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -3480,7 +3480,8 @@ int omap_hwmod_read_hardreset(struct omap_hwmod *oh, 
const char *name)
  * If the callback function returns something other than
  * zero, the iterator is terminated, and the callback function's return
  * value is passed back to the caller.  Returns 0 upon success, -EINVAL
- * if @classname or @fn are NULL, or passes back the error code from @fn.
+ * if @classname or @fn are NULL or no match is found for @classname,
+ * or passes back the error code from @fn.
  */
 int omap_hwmod_for_each_by_class(const char *classname,
                                 int (*fn)(struct omap_hwmod *oh,
@@ -3489,6 +3490,7 @@ int omap_hwmod_for_each_by_class(const char *classname,
 {
        struct omap_hwmod *temp_oh;
        int ret = 0;
+       bool found = false;
 
        if (!classname || !fn)
                return -EINVAL;
@@ -3498,6 +3500,7 @@ int omap_hwmod_for_each_by_class(const char *classname,
 
        list_for_each_entry(temp_oh, &omap_hwmod_list, node) {
                if (!strcmp(temp_oh->class->name, classname)) {
+                       found = true;
                        pr_debug("omap_hwmod: %s: %s: calling callback fn\n",
                                 __func__, temp_oh->name);
                        ret = (*fn)(temp_oh, user);
@@ -3506,6 +3509,12 @@ int omap_hwmod_for_each_by_class(const char *classname,
                }
        }
 
+       if (!found) {
+               pr_err("omap_hwmod: %s: no match for class %s\n",
+                       __func__, classname);
+               return -EINVAL;
+       }
+
        if (ret)
                pr_debug("omap_hwmod: %s: iterator terminated early: %d\n",
                         __func__, ret);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to