2021-01-07 13:30:44

by Daniel Scally

[permalink] [raw]
Subject: [PATCH v5 03/15] device property: Return true in fwnode_device_is_available for NULL ops

Some types of fwnode_handle do not implement the device_is_available()
check, such as those created by software_nodes. There isn't really a
meaningful way to check for the availability of a device that doesn't
actually exist, so if the check isn't implemented just assume that the
"device" is present.

Suggested-by: Laurent Pinchart <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Signed-off-by: Daniel Scally <[email protected]>
---
Changes in v5:

- Changed the commit subject

drivers/base/property.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 35b95c6ac0c6..0bf5260f14c6 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -837,9 +837,15 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
/**
* fwnode_device_is_available - check if a device is available for use
* @fwnode: Pointer to the fwnode of the device.
+ *
+ * For fwnode node types that don't implement the .device_is_available()
+ * operation, this function returns true.
*/
bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
{
+ if (!fwnode_has_op(fwnode, device_is_available))
+ return true;
+
return fwnode_call_bool_op(fwnode, device_is_available);
}
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
--
2.25.1


2021-01-07 13:51:07

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v5 03/15] device property: Return true in fwnode_device_is_available for NULL ops

On Thu, Jan 07, 2021 at 01:28:26PM +0000, Daniel Scally wrote:
> Some types of fwnode_handle do not implement the device_is_available()
> check, such as those created by software_nodes. There isn't really a
> meaningful way to check for the availability of a device that doesn't
> actually exist, so if the check isn't implemented just assume that the
> "device" is present.
>
> Suggested-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Andy Shevchenko <[email protected]>
> Acked-by: Sakari Ailus <[email protected]>
> Signed-off-by: Daniel Scally <[email protected]>

Reviewed-by: Heikki Krogerus <[email protected]>

> ---
> Changes in v5:
>
> - Changed the commit subject
>
> drivers/base/property.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 35b95c6ac0c6..0bf5260f14c6 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -837,9 +837,15 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
> /**
> * fwnode_device_is_available - check if a device is available for use
> * @fwnode: Pointer to the fwnode of the device.
> + *
> + * For fwnode node types that don't implement the .device_is_available()
> + * operation, this function returns true.
> */
> bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
> {
> + if (!fwnode_has_op(fwnode, device_is_available))
> + return true;
> +
> return fwnode_call_bool_op(fwnode, device_is_available);
> }
> EXPORT_SYMBOL_GPL(fwnode_device_is_available);
> --
> 2.25.1

thanks,

--
heikki

2021-01-10 15:11:52

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v5 03/15] device property: Return true in fwnode_device_is_available for NULL ops

On Thu, Jan 07, 2021 at 01:28:26PM +0000, Daniel Scally wrote:
> Some types of fwnode_handle do not implement the device_is_available()
> check, such as those created by software_nodes. There isn't really a
> meaningful way to check for the availability of a device that doesn't
> actually exist, so if the check isn't implemented just assume that the
> "device" is present.
>
> Suggested-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Reviewed-by: Andy Shevchenko <[email protected]>
> Acked-by: Sakari Ailus <[email protected]>
> Signed-off-by: Daniel Scally <[email protected]>
> ---
> Changes in v5:
>
> - Changed the commit subject
>

Acked-by: Greg Kroah-Hartman <[email protected]>