[PATCH] kernel/resource: Simplify API __devm_release_region() implementation

Zijun Hu posted 1 patch 1 month, 1 week ago
kernel/resource.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] kernel/resource: Simplify API __devm_release_region() implementation
Posted by Zijun Hu 1 month, 1 week ago
From: Zijun Hu <quic_zijuhu@quicinc.com>

Simplify __devm_release_region() implementation by dedicated
API devres_release() which have below advantages than current
__release_region() + devres_destroy():

It is simpler if __devm_release_region() is undoing what
__devm_request_region() did, otherwise, it can avoid wrong and
undesired __release_region().

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
linux-next tree has similar fixes as shown below:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0ee4dcafda9576910559f0471a3d6891daf9ab92
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
---
 kernel/resource.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index b730bd28b422..8d619c449a73 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1673,8 +1673,7 @@ void __devm_release_region(struct device *dev, struct resource *parent,
 {
 	struct region_devres match_data = { parent, start, n };
 
-	__release_region(parent, start, n);
-	WARN_ON(devres_destroy(dev, devm_region_release, devm_region_match,
+	WARN_ON(devres_release(dev, devm_region_release, devm_region_match,
 			       &match_data));
 }
 EXPORT_SYMBOL(__devm_release_region);

---
base-commit: 9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
change-id: 20241017-release_region_fix-2aa7f93367e0

Best regards,
-- 
Zijun Hu <quic_zijuhu@quicinc.com>
Re: [PATCH] kernel/resource: Simplify API __devm_release_region() implementation
Posted by Zijun Hu 1 week, 5 days ago
On 2024/10/17 23:34, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Simplify __devm_release_region() implementation by dedicated
> API devres_release() which have below advantages than current
> __release_region() + devres_destroy():
> 
> It is simpler if __devm_release_region() is undoing what
> __devm_request_region() did, otherwise, it can avoid wrong and
> undesired __release_region().
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> linux-next tree has similar fixes as shown below:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0ee4dcafda9576910559f0471a3d6891daf9ab92
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
> ---
>  kernel/resource.c | 3 +--

Hi Andrew,

There are no maintainer or supporter for kernel/resource.c according to
get_maintainer.pl.

could you please code review for this patch?

>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/resource.c b/kernel/resource.c
> index b730bd28b422..8d619c449a73 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1673,8 +1673,7 @@ void __devm_release_region(struct device *dev, struct resource *parent,
>  {
>  	struct region_devres match_data = { parent, start, n };
>  
> -	__release_region(parent, start, n);
> -	WARN_ON(devres_destroy(dev, devm_region_release, devm_region_match,
> +	WARN_ON(devres_release(dev, devm_region_release, devm_region_match,
>  			       &match_data));
>  }
>  EXPORT_SYMBOL(__devm_release_region);
> 
> ---
> base-commit: 9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
> change-id: 20241017-release_region_fix-2aa7f93367e0
> 
> Best regards,
Re: [PATCH] kernel/resource: Simplify API __devm_release_region() implementation
Posted by Andrew Morton 1 week, 4 days ago
On Wed, 13 Nov 2024 22:07:22 +0800 Zijun Hu <zijun_hu@icloud.com> wrote:

> On 2024/10/17 23:34, Zijun Hu wrote:
> > From: Zijun Hu <quic_zijuhu@quicinc.com>
> > 
> > Simplify __devm_release_region() implementation by dedicated
> > API devres_release() which have below advantages than current
> > __release_region() + devres_destroy():
> > 
> > It is simpler if __devm_release_region() is undoing what
> > __devm_request_region() did, otherwise, it can avoid wrong and
> > undesired __release_region().
> > 
> > Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> > ---
> > linux-next tree has similar fixes as shown below:
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0ee4dcafda9576910559f0471a3d6891daf9ab92
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
> > ---
> >  kernel/resource.c | 3 +--
> 
> Hi Andrew,
> 
> There are no maintainer or supporter for kernel/resource.c according to
> get_maintainer.pl.
> 
> could you please code review for this patch?

Yup, thanks, I'll toss it onto the pile for consideration after
6.13-rc1.
Re: [PATCH] kernel/resource: Simplify API __devm_release_region() implementation
Posted by Zijun Hu 2 weeks, 5 days ago
On 2024/10/17 23:34, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Simplify __devm_release_region() implementation by dedicated
> API devres_release() which have below advantages than current
> __release_region() + devres_destroy():
> 
> It is simpler if __devm_release_region() is undoing what
> __devm_request_region() did, otherwise, it can avoid wrong and
> undesired __release_region().
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> linux-next tree has similar fixes as shown below:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0ee4dcafda9576910559f0471a3d6891daf9ab92
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9bd133f05b1dca5ca4399a76d04d0f6f4d454e44

gentle ping (^^) (^^)
sorry for this noise.

linux-next has one more similar fix as below:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2396eefa075a31884d3336e1e94db47a0bd2a456

> ---
>  kernel/resource.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/resource.c b/kernel/resource.c
> index b730bd28b422..8d619c449a73 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1673,8 +1673,7 @@ void __devm_release_region(struct device *dev, struct resource *parent,
>  {
>  	struct region_devres match_data = { parent, start, n };
>  
> -	__release_region(parent, start, n);
> -	WARN_ON(devres_destroy(dev, devm_region_release, devm_region_match,
> +	WARN_ON(devres_release(dev, devm_region_release, devm_region_match,
>  			       &match_data));
>  }
>  EXPORT_SYMBOL(__devm_release_region);
> 
> ---
> base-commit: 9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
> change-id: 20241017-release_region_fix-2aa7f93367e0
> 
> Best regards,