Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8158b48 authored by Sakari Ailus's avatar Sakari Ailus Committed by Rafael J. Wysocki
Browse files

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: 3708184a "device property: Move FW type specific functionality to FW specific files"
Fixes: 2294b3af "device property: Introduce fwnode_device_is_available()"
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6a71d8d7
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -253,10 +253,10 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
{
{
	bool ret;
	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) &&
	if (ret == false && !IS_ERR_OR_NULL(fwnode) &&
	    !IS_ERR_OR_NULL(fwnode->secondary))
	    !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);
					 propname);
	return ret;
	return ret;
}
}
@@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
 */
 */
bool fwnode_device_is_available(struct fwnode_handle *fwnode)
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);
EXPORT_SYMBOL_GPL(fwnode_device_is_available);


+4 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,10 @@ struct fwnode_operations {
	(fwnode ? (fwnode_has_op(fwnode, op) ?				\
	(fwnode ? (fwnode_has_op(fwnode, op) ?				\
		   (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
		   (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
	 -EINVAL)
	 -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, ...)		\
#define fwnode_call_ptr_op(fwnode, op, ...)		\
	(fwnode_has_op(fwnode, op) ?			\
	(fwnode_has_op(fwnode, op) ?			\
	 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)
	 (fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)