aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2017-07-11 11:20:20 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-07-12 07:32:46 -0400
commite8158b486d5f3f55cf372c5a32b42f263bf7f123 (patch)
treeccec68fe1452a4df5f30da226623aa6dc5e9e7ec
parent6a71d8d77795e0f7d887baa95bfc0d1d2bc74899 (diff)
device property: Introduce fwnode_call_bool_op() for ops that return bool
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>
-rw-r--r--drivers/base/property.c6
-rw-r--r--include/linux/fwnode.h4
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 692007e5a94b..edf02c1b5845 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -253,10 +253,10 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
253{ 253{
254 bool ret; 254 bool ret;
255 255
256 ret = fwnode_call_int_op(fwnode, property_present, propname); 256 ret = fwnode_call_bool_op(fwnode, property_present, propname);
257 if (ret == false && !IS_ERR_OR_NULL(fwnode) && 257 if (ret == false && !IS_ERR_OR_NULL(fwnode) &&
258 !IS_ERR_OR_NULL(fwnode->secondary)) 258 !IS_ERR_OR_NULL(fwnode->secondary))
259 ret = fwnode_call_int_op(fwnode->secondary, property_present, 259 ret = fwnode_call_bool_op(fwnode->secondary, property_present,
260 propname); 260 propname);
261 return ret; 261 return ret;
262} 262}
@@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
1027 */ 1027 */
1028bool fwnode_device_is_available(struct fwnode_handle *fwnode) 1028bool fwnode_device_is_available(struct fwnode_handle *fwnode)
1029{ 1029{
1030 return fwnode_call_int_op(fwnode, device_is_available); 1030 return fwnode_call_bool_op(fwnode, device_is_available);
1031} 1031}
1032EXPORT_SYMBOL_GPL(fwnode_device_is_available); 1032EXPORT_SYMBOL_GPL(fwnode_device_is_available);
1033 1033
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 9ab375419189..50893a1646cf 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -99,6 +99,10 @@ struct fwnode_operations {
99 (fwnode ? (fwnode_has_op(fwnode, op) ? \ 99 (fwnode ? (fwnode_has_op(fwnode, op) ? \
100 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \ 100 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
101 -EINVAL) 101 -EINVAL)
102#define fwnode_call_bool_op(fwnode, op, ...) \
103 (fwnode ? (fwnode_has_op(fwnode, op) ? \
104 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : false) : \
105 false)
102#define fwnode_call_ptr_op(fwnode, op, ...) \ 106#define fwnode_call_ptr_op(fwnode, op, ...) \
103 (fwnode_has_op(fwnode, op) ? \ 107 (fwnode_has_op(fwnode, op) ? \
104 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL) 108 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)