rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iosys_map: Make dst a const in iosys_map_memcpy_to()
@ 2025-10-16 20:24 Lyude Paul
  2025-10-17  7:45 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Lyude Paul @ 2025-10-16 20:24 UTC (permalink / raw)
  To: Thomas Zimmermann, dri-devel, linux-kernel
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich,
	open list:RUST:Keyword:b(?i:rust)b

A drive-by fix I discovered when writing up bindings for iosys_mem for
rust: while iosys_map_memcpy_to() does modify the memory pointed to by the
iosys_map, it doesn't modify the actual iosys_map struct at all.

As such, let's add a const qualifier to this function.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 include/linux/iosys-map.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 3e85afe794c0a..0ececbba04b3a 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -278,7 +278,7 @@ static inline void iosys_map_clear(struct iosys_map *map)
  * system memory. Depending on the buffer's location, the helper picks the
  * correct method of accessing the memory.
  */
-static inline void iosys_map_memcpy_to(struct iosys_map *dst, size_t dst_offset,
+static inline void iosys_map_memcpy_to(const struct iosys_map *dst, size_t dst_offset,
 				       const void *src, size_t len)
 {
 	if (dst->is_iomem)

base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iosys_map: Make dst a const in iosys_map_memcpy_to()
  2025-10-16 20:24 [PATCH] iosys_map: Make dst a const in iosys_map_memcpy_to() Lyude Paul
@ 2025-10-17  7:45 ` Thomas Zimmermann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Zimmermann @ 2025-10-17  7:45 UTC (permalink / raw)
  To: Lyude Paul, dri-devel, linux-kernel
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich,
	open list:RUST:Keyword:b(?i:rust)b

Hi

Am 16.10.25 um 22:24 schrieb Lyude Paul:
> A drive-by fix I discovered when writing up bindings for iosys_mem for
> rust: while iosys_map_memcpy_to() does modify the memory pointed to by the
> iosys_map, it doesn't modify the actual iosys_map struct at all.
>
> As such, let's add a const qualifier to this function.

As far as I'm concerned, the non-const is intentional. Because it's the 
destination, so expect it to be written. Thus passing arguments that are 
already const is most likely an error. And because I'd like to keep the 
option of doing something more complicated within iosys_map (e.g., some 
temp memory for handling I/O) and const might get in the way.

Best regads
Thomas

>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> ---
>   include/linux/iosys-map.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
> index 3e85afe794c0a..0ececbba04b3a 100644
> --- a/include/linux/iosys-map.h
> +++ b/include/linux/iosys-map.h
> @@ -278,7 +278,7 @@ static inline void iosys_map_clear(struct iosys_map *map)
>    * system memory. Depending on the buffer's location, the helper picks the
>    * correct method of accessing the memory.
>    */
> -static inline void iosys_map_memcpy_to(struct iosys_map *dst, size_t dst_offset,
> +static inline void iosys_map_memcpy_to(const struct iosys_map *dst, size_t dst_offset,
>   				       const void *src, size_t len)
>   {
>   	if (dst->is_iomem)
>
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-17  7:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 20:24 [PATCH] iosys_map: Make dst a const in iosys_map_memcpy_to() Lyude Paul
2025-10-17  7:45 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).