]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
device property: Introduce fwnode_call_bool_op() for ops that return bool
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 11 Jul 2017 15:20:20 +0000 (18:20 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 12 Jul 2017 11:32:46 +0000 (13:32 +0200)
fwnode_call_int_op() isn't suitable for calling ops that return bool
since it effectively causes the result returned to the user to be
true when an op hasn't been defined or the fwnode is NULL.

Address this by introducing fwnode_call_bool_op() for calling ops
that return bool.

Fixes: 3708184afc77 "device property: Move FW type specific functionality to FW specific files"
Fixes: 2294b3af05e9 "device property: Introduce fwnode_device_is_available()"
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c
include/linux/fwnode.h

index 692007e5a94b10437a537440cc0b5a4f236772fd..edf02c1b5845968bb94844f51057c6f414b83d64 100644 (file)
@@ -253,10 +253,10 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
 {
        bool ret;
 
-       ret = fwnode_call_int_op(fwnode, property_present, propname);
+       ret = fwnode_call_bool_op(fwnode, property_present, propname);
        if (ret == false && !IS_ERR_OR_NULL(fwnode) &&
            !IS_ERR_OR_NULL(fwnode->secondary))
-               ret = fwnode_call_int_op(fwnode->secondary, property_present,
+               ret = fwnode_call_bool_op(fwnode->secondary, property_present,
                                         propname);
        return ret;
 }
@@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
  */
 bool fwnode_device_is_available(struct fwnode_handle *fwnode)
 {
-       return fwnode_call_int_op(fwnode, device_is_available);
+       return fwnode_call_bool_op(fwnode, device_is_available);
 }
 EXPORT_SYMBOL_GPL(fwnode_device_is_available);
 
index 9ab37541918929d5d1db6b409615df305f07c727..50893a1646cf3b4cfeeab523caabed50aa119311 100644 (file)
@@ -99,6 +99,10 @@ struct fwnode_operations {
        (fwnode ? (fwnode_has_op(fwnode, op) ?                          \
                   (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
         -EINVAL)
+#define fwnode_call_bool_op(fwnode, op, ...)                           \
+       (fwnode ? (fwnode_has_op(fwnode, op) ?                          \
+                  (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : false) : \
+        false)
 #define fwnode_call_ptr_op(fwnode, op, ...)            \
        (fwnode_has_op(fwnode, op) ?                    \
         (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)