Skip to content

Commit e7fef85

Browse files
Mani-SadhasivamBartosz Golaszewski
authored andcommitted
serdev: Convert to_serdev_*() helpers to macros and use container_of_const()
If these helpers receive the 'const struct device' pointer, then the const qualifier will get dropped, leading to below warning: warning: passing argument 1 of ‘to_serdev_device_driver’ discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] This is not an issue as of now, but with the future commits adding serdev device based driver matching, this warning will get triggered. Hence, convert these helpers to macros so that the qualifier get preserved and also use container_of_const() as container_of() is deprecated. Tested-by: Hans de Goede <johannes.goede@oss.qualcomm.com> # ThinkPad T14s gen6 (arm64) Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com> Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Link: https://patch.msgid.link/20260326-pci-m2-e-v7-1-43324a7866e6@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 6de23f8 commit e7fef85

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

include/linux/serdev.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ struct serdev_device {
4949
struct mutex write_lock;
5050
};
5151

52-
static inline struct serdev_device *to_serdev_device(struct device *d)
53-
{
54-
return container_of(d, struct serdev_device, dev);
55-
}
52+
#define to_serdev_device(d) container_of_const(d, struct serdev_device, dev)
5653

5754
/**
5855
* struct serdev_device_driver - serdev slave device driver
@@ -68,10 +65,7 @@ struct serdev_device_driver {
6865
void (*shutdown)(struct serdev_device *);
6966
};
7067

71-
static inline struct serdev_device_driver *to_serdev_device_driver(struct device_driver *d)
72-
{
73-
return container_of(d, struct serdev_device_driver, driver);
74-
}
68+
#define to_serdev_device_driver(d) container_of_const(d, struct serdev_device_driver, driver)
7569

7670
enum serdev_parity {
7771
SERDEV_PARITY_NONE,
@@ -112,10 +106,7 @@ struct serdev_controller {
112106
const struct serdev_controller_ops *ops;
113107
};
114108

115-
static inline struct serdev_controller *to_serdev_controller(struct device *d)
116-
{
117-
return container_of(d, struct serdev_controller, dev);
118-
}
109+
#define to_serdev_controller(d) container_of_const(d, struct serdev_controller, dev)
119110

120111
static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev)
121112
{

0 commit comments

Comments
 (0)