lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YTB0vegl2YFfaWzM@kroah.com>
Date:   Thu, 2 Sep 2021 08:52:45 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Cai Huoqing <caihuoqing@...du.com>
Cc:     rafael@...nel.org, patrice.chotard@...s.st.com, mchehab@...nel.org,
        ryder.lee@...iatek.com, jianjun.wang@...iatek.com,
        lorenzo.pieralisi@....com, robh@...nel.org, kw@...ux.com,
        bhelgaas@...gle.com, matthias.bgg@...il.com,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-media@...r.kernel.org, linux-pci@...r.kernel.org,
        linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v2 1/3] driver core: platform: Add the helper function
 devm_platform_get_and_ioremap_resource_byname()

On Thu, Sep 02, 2021 at 02:37:00PM +0800, Cai Huoqing wrote:
> Since provide the helper function devm_platform_ioremap_resource_byname()
> which is wrap platform_get_resource_byname() and devm_ioremap_resource().
> But sometimes, many drivers still need to use the resource variables
> obtained by platform_get_resource(). In these cases, provide this helper
> function devm_platform_get_and_ioremap_resource_byname().
> 
> Signed-off-by: Cai Huoqing <caihuoqing@...du.com>
> ---
> v1->v2: Resend this patch as part of a patch series that uses
> 	the new function. 
> 
>  drivers/base/platform.c         | 30 ++++++++++++++++++++++++++----
>  include/linux/platform_device.h |  3 +++
>  2 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 652531f67135..34bb581338d9 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -124,6 +124,31 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
>  }
>  EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
>  
> +/**
> + * devm_platform_get_and_ioremap_resource_byname - call devm_ioremap_resource() for a
> + *						   platform device and get resource
> + *
> + * @pdev: platform device to use both for memory resource lookup as well as
> + *        resource management
> + * @name: name of the resource
> + * @res: optional output parameter to store a pointer to the obtained resource.
> + *
> + * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code
> + * on failure.
> + */
> +void __iomem *
> +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev,
> +					      const char *name, struct resource **res)
> +{
> +	struct resource *r;
> +
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> +	if (res)
> +		*res = r;

You forgot to check the return value of this call :(

Which means you did not test this?  Why not?

But step back, _WHY_ is this needed at all?  How deep are we going to
get with the "devm_platform_get_and_do_this_and_that_and_that" type
functions here?

You show 2 users of this call, and they save what, 1-2 lines of code
here?

What is the real need for this?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ