Skip to content

Commit a2e25c8

Browse files
krzklag-linaro
authored andcommitted
backlight: lcd: Constify lcd_ops
'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 <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 4cece76 commit a2e25c8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/video/backlight/lcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ ATTRIBUTE_GROUPS(lcd_device);
188188
* or a pointer to the newly allocated device.
189189
*/
190190
struct lcd_device *lcd_device_register(const char *name, struct device *parent,
191-
void *devdata, struct lcd_ops *ops)
191+
void *devdata, const struct lcd_ops *ops)
192192
{
193193
struct lcd_device *new_ld;
194194
int rc;
@@ -276,7 +276,7 @@ static int devm_lcd_device_match(struct device *dev, void *res, void *data)
276276
*/
277277
struct lcd_device *devm_lcd_device_register(struct device *dev,
278278
const char *name, struct device *parent,
279-
void *devdata, struct lcd_ops *ops)
279+
void *devdata, const struct lcd_ops *ops)
280280
{
281281
struct lcd_device **ptr, *lcd;
282282

include/linux/lcd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct lcd_device {
6161
points to something in the body of that driver, it is also invalid. */
6262
struct mutex ops_lock;
6363
/* If this is NULL, the backing module is unloaded */
64-
struct lcd_ops *ops;
64+
const struct lcd_ops *ops;
6565
/* Serialise access to set_power method */
6666
struct mutex update_lock;
6767
/* The framebuffer notifier block */
@@ -102,10 +102,10 @@ static inline void lcd_set_power(struct lcd_device *ld, int power)
102102
}
103103

104104
extern struct lcd_device *lcd_device_register(const char *name,
105-
struct device *parent, void *devdata, struct lcd_ops *ops);
105+
struct device *parent, void *devdata, const struct lcd_ops *ops);
106106
extern struct lcd_device *devm_lcd_device_register(struct device *dev,
107107
const char *name, struct device *parent,
108-
void *devdata, struct lcd_ops *ops);
108+
void *devdata, const struct lcd_ops *ops);
109109
extern void lcd_device_unregister(struct lcd_device *ld);
110110
extern void devm_lcd_device_unregister(struct device *dev,
111111
struct lcd_device *ld);

0 commit comments

Comments
 (0)