Thread (26 messages) 26 messages, 9 authors, 2023-01-11

Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2022-11-23 13:46:46
Also in: alsa-devel, linux-acpi, linux-block, linux-devicetree, linux-i2c, linux-i3c, linux-media, linux-serial, linux-usb, lkml, platform-driver-x86

On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
On 11/23/22 13:25, Greg Kroah-Hartman wrote:
quoted
The uevent() callback in struct device_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.
[...]
quoted
-static inline struct ssam_device *to_ssam_device(struct device *d)
+static inline struct ssam_device *to_ssam_device(const struct device *d)
  {
  	return container_of(d, struct ssam_device, dev);
  }
I am slightly conflicted about this change as that now more or less
implicitly drops the const. So I'm wondering if it wouldn't be better to
either create a function specifically for const pointers or to just
open-code it in the instance above.

I guess we could also convert this to a macro. Then at least there
wouldn't be an explicit and potentially misleading const-conversion
indicated in the function signature.
This is an intermediate step as far as I know since moving container_of to
recognize const is a bit noisy right now. I guess you can find a discussion
on the topic between Greg and Sakari.

-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help