Skip to content

Commit e8158b4

Browse files
Sakari Ailusrafaeljw
authored andcommitted
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: 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>
1 parent 6a71d8d commit e8158b4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

drivers/base/property.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
253253
{
254254
bool ret;
255255

256-
ret = fwnode_call_int_op(fwnode, property_present, propname);
256+
ret = fwnode_call_bool_op(fwnode, property_present, propname);
257257
if (ret == false && !IS_ERR_OR_NULL(fwnode) &&
258258
!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,
260260
propname);
261261
return ret;
262262
}
@@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
10271027
*/
10281028
bool fwnode_device_is_available(struct fwnode_handle *fwnode)
10291029
{
1030-
return fwnode_call_int_op(fwnode, device_is_available);
1030+
return fwnode_call_bool_op(fwnode, device_is_available);
10311031
}
10321032
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
10331033

include/linux/fwnode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ struct fwnode_operations {
9999
(fwnode ? (fwnode_has_op(fwnode, op) ? \
100100
(fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
101101
-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)
102106
#define fwnode_call_ptr_op(fwnode, op, ...) \
103107
(fwnode_has_op(fwnode, op) ? \
104108
(fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)

0 commit comments

Comments
 (0)