Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/surface: aggregator: Make to_ssam_device_driver() respect constness

Make to_ssam_device_driver() a bit safer by replacing container_of()
with container_of_const() to respect the constness of the passed in
pointer, instead of silently discarding any const specifications. This
change also makes it more similar to to_ssam_device(), which already
uses container_of_const().

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20230525205041.2774947-1-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Maximilian Luz and committed by
Hans de Goede
ed08d937 3279decb

+1 -5
+1 -5
include/linux/surface_aggregator/device.h
··· 243 243 * Return: Returns the pointer to the &struct ssam_device_driver wrapping the 244 244 * given device driver @d. 245 245 */ 246 - static inline 247 - struct ssam_device_driver *to_ssam_device_driver(struct device_driver *d) 248 - { 249 - return container_of(d, struct ssam_device_driver, driver); 250 - } 246 + #define to_ssam_device_driver(d) container_of_const(d, struct ssam_device_driver, driver) 251 247 252 248 const struct ssam_device_id *ssam_device_id_match(const struct ssam_device_id *table, 253 249 const struct ssam_device_uid uid);