All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Cai Huoqing <caihuoqing@baidu.com>
Cc: rafael@kernel.org, patrice.chotard@foss.st.com,
	mchehab@kernel.org, ryder.lee@mediatek.com,
	jianjun.wang@mediatek.com, lorenzo.pieralisi@arm.com,
	robh@kernel.org, kw@linux.com, bhelgaas@google.com,
	matthias.bgg@gmail.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 1/3] driver core: platform: Add the helper function devm_platform_get_and_ioremap_resource_byname()
Date: Thu, 2 Sep 2021 08:52:45 +0200	[thread overview]
Message-ID: <YTB0vegl2YFfaWzM@kroah.com> (raw)
In-Reply-To: <20210902063702.32066-2-caihuoqing@baidu.com>

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@baidu.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

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Cai Huoqing <caihuoqing@baidu.com>
Cc: rafael@kernel.org, patrice.chotard@foss.st.com,
	mchehab@kernel.org, ryder.lee@mediatek.com,
	jianjun.wang@mediatek.com, lorenzo.pieralisi@arm.com,
	robh@kernel.org, kw@linux.com, bhelgaas@google.com,
	matthias.bgg@gmail.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 1/3] driver core: platform: Add the helper function devm_platform_get_and_ioremap_resource_byname()
Date: Thu, 2 Sep 2021 08:52:45 +0200	[thread overview]
Message-ID: <YTB0vegl2YFfaWzM@kroah.com> (raw)
In-Reply-To: <20210902063702.32066-2-caihuoqing@baidu.com>

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@baidu.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

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Cai Huoqing <caihuoqing@baidu.com>
Cc: rafael@kernel.org, patrice.chotard@foss.st.com,
	mchehab@kernel.org, ryder.lee@mediatek.com,
	jianjun.wang@mediatek.com, lorenzo.pieralisi@arm.com,
	robh@kernel.org, kw@linux.com, bhelgaas@google.com,
	matthias.bgg@gmail.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, linux-pci@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 1/3] driver core: platform: Add the helper function devm_platform_get_and_ioremap_resource_byname()
Date: Thu, 2 Sep 2021 08:52:45 +0200	[thread overview]
Message-ID: <YTB0vegl2YFfaWzM@kroah.com> (raw)
In-Reply-To: <20210902063702.32066-2-caihuoqing@baidu.com>

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@baidu.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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-09-02  6:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02  6:36 [PATCH v2 0/3] drivers: Add the helper function devm_platform_get_and_ioremap_resource_byname() Cai Huoqing
2021-09-02  6:36 ` Cai Huoqing
2021-09-02  6:36 ` Cai Huoqing
2021-09-02  6:37 ` [PATCH v2 1/3] driver core: platform: " Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing
2021-09-02  6:52   ` Greg KH [this message]
2021-09-02  6:52     ` Greg KH
2021-09-02  6:52     ` Greg KH
2021-09-02  8:05     ` Cai Huoqing
2021-09-02  8:05       ` Cai Huoqing
2021-09-02  8:05       ` Cai Huoqing
2021-09-02  8:25       ` Greg KH
2021-09-02  8:25         ` Greg KH
2021-09-02  8:25         ` Greg KH
2021-09-02  6:37 ` [PATCH v2 2/3] media: sti/c8sectpfe: Make use of " Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing
2021-09-02  6:37 ` [PATCH v2 3/3] PCI: mediatek-gen3: " Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing
2021-09-02  6:37   ` Cai Huoqing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YTB0vegl2YFfaWzM@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bhelgaas@google.com \
    --cc=caihuoqing@baidu.com \
    --cc=jianjun.wang@mediatek.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=ryder.lee@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.