Skip to content

Commit

Permalink
device property: Introduce fwnode_call_bool_op() for ops that return …
Browse files Browse the repository at this point in the history
…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: 3708184 "device property: Move FW type specific functionality to FW specific files"
Fixes: 2294b3a "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>
  • Loading branch information
Sakari Ailus authored and Rafael J. Wysocki committed Jul 12, 2017
1 parent 6a71d8d commit e8158b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/base/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions include/linux/fwnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e8158b4

Please sign in to comment.