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

Simon Glass
2021-11-05T02:06:35Z

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
>