diff mbox series

[v2,07/12] sysinfo: Make .detect() non-mandatory

Message ID 20211103232332.2737-8-kabel@kernel.org
State Changes Requested
Delegated to: Simon Glass
Headers show
Series Board specific runtime determined default env | expand

Commit Message

Marek Behún Nov. 3, 2021, 11:23 p.m. UTC
From: Marek Behún <marek.behun@nic.cz>

Make it so that if the .detect() method is not implemented, the sysinfo
is considered to be present.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/sysinfo/sysinfo-uclass.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Simon Glass Nov. 5, 2021, 2:02 a.m. UTC | #1
On Wed, 3 Nov 2021 at 17:23, Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Make it so that if the .detect() method is not implemented, the sysinfo
> is considered to be present.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/sysinfo/sysinfo-uclass.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Need to update sysinfo.h docs for the detect() method, I think.


>
> diff --git a/drivers/sysinfo/sysinfo-uclass.c b/drivers/sysinfo/sysinfo-uclass.c
> index 71f9ad105a..d945f073c5 100644
> --- a/drivers/sysinfo/sysinfo-uclass.c
> +++ b/drivers/sysinfo/sysinfo-uclass.c
> @@ -25,10 +25,7 @@ int sysinfo_detect(struct udevice *dev)
>         struct sysinfo_priv *priv = dev_get_uclass_priv(dev);
>         struct sysinfo_ops *ops = sysinfo_get_ops(dev);
>
> -       if (!ops->detect)
> -               return -ENOSYS;
> -
> -       ret = ops->detect(dev);
> +       ret = ops->detect ? ops->detect(dev) : 0;
>         if (!ret)
>                 priv->detected = true;
>
> --
> 2.32.0
>
diff mbox series

Patch

diff --git a/drivers/sysinfo/sysinfo-uclass.c b/drivers/sysinfo/sysinfo-uclass.c
index 71f9ad105a..d945f073c5 100644
--- a/drivers/sysinfo/sysinfo-uclass.c
+++ b/drivers/sysinfo/sysinfo-uclass.c
@@ -25,10 +25,7 @@  int sysinfo_detect(struct udevice *dev)
 	struct sysinfo_priv *priv = dev_get_uclass_priv(dev);
 	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
 
-	if (!ops->detect)
-		return -ENOSYS;
-
-	ret = ops->detect(dev);
+	ret = ops->detect ? ops->detect(dev) : 0;
 	if (!ret)
 		priv->detected = true;