[PATCH 14/23] resource: Mark res given to resource_assigned() as const

Ilpo Järvinen posted 23 patches 1 month, 3 weeks ago
[PATCH 14/23] resource: Mark res given to resource_assigned() as const
Posted by Ilpo Järvinen 1 month, 3 weeks ago
The caller may hold a const struct resource which will trigger an
unnecessary warning when calling resource_assigned() as it will not
modify res in anyway.

Mark resource_assigned()'s struct resource *res parameter const to
avoid the compiler warning.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 include/linux/ioport.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 9afa30f9346f..60ca6a49839c 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -338,7 +338,7 @@ static inline bool resource_union(const struct resource *r1, const struct resour
  * Check if this resource is added to a resource tree or detached. Caller is
  * responsible for not racing assignment.
  */
-static inline bool resource_assigned(struct resource *res)
+static inline bool resource_assigned(const struct resource *res)
 {
 	return res->parent;
 }
-- 
2.39.5

Re: [PATCH 14/23] resource: Mark res given to resource_assigned() as const
Posted by Ilpo Järvinen 1 month, 3 weeks ago
On Fri, 19 Dec 2025, Ilpo Järvinen wrote:

> The caller may hold a const struct resource which will trigger an
> unnecessary warning when calling resource_assigned() as it will not
> modify res in anyway.
> 
> Mark resource_assigned()'s struct resource *res parameter const to
> avoid the compiler warning.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

An afterthought right after sending, I should have Cc'ed Dan & Jonathan 
to this so adding them now.

-- 
 i.


> ---
>  include/linux/ioport.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index 9afa30f9346f..60ca6a49839c 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -338,7 +338,7 @@ static inline bool resource_union(const struct resource *r1, const struct resour
>   * Check if this resource is added to a resource tree or detached. Caller is
>   * responsible for not racing assignment.
>   */
> -static inline bool resource_assigned(struct resource *res)
> +static inline bool resource_assigned(const struct resource *res)
>  {
>  	return res->parent;
>  }
>