backlight: lcd: Constify lcd_ops
authorKrzysztof Kozlowski <krzk@kernel.org>
Wed, 24 Apr 2024 06:33:27 +0000 (08:33 +0200)
committerLee Jones <lee@kernel.org>
Fri, 3 May 2024 09:44:42 +0000 (10:44 +0100)
'struct lcd_ops' passed in lcd_device_register() is not modified by core
backlight code, so it can be made const for code safety.  This allows
drivers to also define the structure as const.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240424-video-backlight-lcd-ops-v2-1-1aaa82b07bc6@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/lcd.c
include/linux/lcd.h

index 77c5cb2a44e25d7eb798162f8b6dc25c0e60e233..ba3e37b5b584727bf97549c834e8bc60b7eaa8d4 100644 (file)
@@ -188,7 +188,7 @@ ATTRIBUTE_GROUPS(lcd_device);
  * or a pointer to the newly allocated device.
  */
 struct lcd_device *lcd_device_register(const char *name, struct device *parent,
-               void *devdata, struct lcd_ops *ops)
+               void *devdata, const struct lcd_ops *ops)
 {
        struct lcd_device *new_ld;
        int rc;
@@ -276,7 +276,7 @@ static int devm_lcd_device_match(struct device *dev, void *res, void *data)
  */
 struct lcd_device *devm_lcd_device_register(struct device *dev,
                const char *name, struct device *parent,
-               void *devdata, struct lcd_ops *ops)
+               void *devdata, const struct lcd_ops *ops)
 {
        struct lcd_device **ptr, *lcd;
 
index 238fb1dfed98d9b16dd85789c25e3326fa8e30d9..68703a51dc5394a652c8f61a2960ded21c337797 100644 (file)
@@ -61,7 +61,7 @@ struct lcd_device {
           points to something in the body of that driver, it is also invalid. */
        struct mutex ops_lock;
        /* If this is NULL, the backing module is unloaded */
-       struct lcd_ops *ops;
+       const struct lcd_ops *ops;
        /* Serialise access to set_power method */
        struct mutex update_lock;
        /* The framebuffer notifier block */
@@ -102,10 +102,10 @@ static inline void lcd_set_power(struct lcd_device *ld, int power)
 }
 
 extern struct lcd_device *lcd_device_register(const char *name,
-       struct device *parent, void *devdata, struct lcd_ops *ops);
+       struct device *parent, void *devdata, const struct lcd_ops *ops);
 extern struct lcd_device *devm_lcd_device_register(struct device *dev,
        const char *name, struct device *parent,
-       void *devdata, struct lcd_ops *ops);
+       void *devdata, const struct lcd_ops *ops);
 extern void lcd_device_unregister(struct lcd_device *ld);
 extern void devm_lcd_device_unregister(struct device *dev,
        struct lcd_device *ld);