Skip to contentSkip to conversation

backlight: ipaq_micro: Make structure micro_bl_props constant

PATCH In review Nishka Dasgupta 2 participants 5 messages Aug 13, 2019 – Sep 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backlight: ipaq_micro: Make structure micro_bl_props constant

Static structure micro_bl_props, having type backlight_properties, is used only once, when it is passed as the last argument to function devm_backlight_device_register(). devm_backlight_device_register() is defined with its last parameter being declared constant. Hence make micro_bl_props itself constant as well.
Issue found with Coccinelle.

---
 drivers/video/backlight/ipaq_micro_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/ipaq_micro_bl.c +1 -1
index 1123f67c12b3..85b16cc82878 100644
@@ -44,7 +44,7 @@ static const struct backlight_ops micro_bl_ops = {
 	.update_status  = micro_bl_update_status,
 };
 
-static struct backlight_properties micro_bl_props = {
+static const struct backlight_properties micro_bl_props = {
 	.type = BACKLIGHT_RAW,
 	.max_brightness = 255,
 	.power = FB_BLANK_UNBLANK,
Signature · 6 lines
2.19.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 6 lines · Nishka Dasgupta

Static structure micro_bl_props, having type backlight_properties, is used only once, when it is passed as the last argument to function devm_backlight_device_register(). devm_backlight_device_register() is defined with its last parameter being declared constant. Hence make micro_bl_props itself constant as well.
Issue found with Coccinelle.

Did you do any review to see if this pattern occurs in other backlight drivers (it looks to me like the same pattern appears in rave-sp-backlight.c... do the tools bring that one out as well).

Daniel.

Quoted 22 lines
---
 drivers/video/backlight/ipaq_micro_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/ipaq_micro_bl.c +1 -1
index 1123f67c12b3..85b16cc82878 100644
@@ -44,7 +44,7 @@ static const struct backlight_ops micro_bl_ops = {
 	.update_status  = micro_bl_update_status,
 };
 
-static struct backlight_properties micro_bl_props = {
+static const struct backlight_properties micro_bl_props = {
 	.type = BACKLIGHT_RAW,
 	.max_brightness = 255,
 	.power = FB_BLANK_UNBLANK,
Signature · 1 line
2.19.1
#2 lore raw
Quoted 11 lines · Daniel Thompson
Quoted 6 lines · Nishka Dasgupta

Static structure micro_bl_props, having type backlight_properties, is used only once, when it is passed as the last argument to function devm_backlight_device_register(). devm_backlight_device_register() is defined with its last parameter being declared constant. Hence make micro_bl_props itself constant as well.
Issue found with Coccinelle.

Did you do any review to see if this pattern occurs in other backlight drivers (it looks to me like the same pattern appears in rave-sp-backlight.c... do the tools bring that one out as well).

Ping?

Daniel.

Quoted 21 lines
Quoted 21 lines
---
 drivers/video/backlight/ipaq_micro_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/ipaq_micro_bl.c +1 -1
index 1123f67c12b3..85b16cc82878 100644
@@ -44,7 +44,7 @@ static const struct backlight_ops micro_bl_ops = {
 	.update_status  = micro_bl_update_status,
 };
 
-static struct backlight_properties micro_bl_props = {
+static const struct backlight_properties micro_bl_props = {
 	.type = BACKLIGHT_RAW,
 	.max_brightness = 255,
 	.power = FB_BLANK_UNBLANK,
Signature · 1 line
2.19.1
#3 lore raw
Quoted 10 lines · Daniel Thompson
Quoted 8 lines · Daniel Thompson
Quoted 6 lines · Nishka Dasgupta

Static structure micro_bl_props, having type backlight_properties, is used only once, when it is passed as the last argument to function devm_backlight_device_register(). devm_backlight_device_register() is defined with its last parameter being declared constant. Hence make micro_bl_props itself constant as well.
Issue found with Coccinelle.

Quoted 5 lines
Quoted 3 lines

Did you do any review to see if this pattern occurs in other backlight drivers (it looks to me like the same pattern appears in rave-sp-backlight.c... do the tools bring that one out as well).

Ping?

Sorry, did my reply not go through?
I had said:
No, the Coccinelle script I'm using doesn't flag any other backlight drivers. It's possible that the script just missed something. Which structure in rave-sp-backlight.c could potentially be made const?

Thanking you,
Nishka

Quoted 18 lines

Daniel.

Quoted 13 lines
Quoted 13 lines
---
 drivers/video/backlight/ipaq_micro_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/ipaq_micro_bl.c +0 -0
index 1123f67c12b3..85b16cc82878 100644
@@ -44,7 +44,7 @@ static const struct backlight_ops micro_bl_ops = {
    .update_status  = micro_bl_update_status,
 };
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/video/backlight/ipaq_micro_bl.c +1 -2
-static struct backlight_properties micro_bl_props = {
+static const struct backlight_properties micro_bl_props = {
    .type = BACKLIGHT_RAW,
    .max_brightness = 255,
    .power = FB_BLANK_UNBLANK,
--

2.19.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/1
#4 lore raw
In reply to Nishka Dasgupta
Quoted 8 lines · Nishka Dasgupta

Static structure micro_bl_props, having type backlight_properties, is used only once, when it is passed as the last argument to function devm_backlight_device_register(). devm_backlight_device_register() is defined with its last parameter being declared constant. Hence make micro_bl_props itself constant as well.
Issue found with Coccinelle.

Quoted 19 lines
---
 drivers/video/backlight/ipaq_micro_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/ipaq_micro_bl.c +1 -1
index 1123f67c12b3..85b16cc82878 100644
@@ -44,7 +44,7 @@ static const struct backlight_ops micro_bl_ops = {
 	.update_status  = micro_bl_update_status,
 };
 
-static struct backlight_properties micro_bl_props = {
+static const struct backlight_properties micro_bl_props = {
 	.type = BACKLIGHT_RAW,
 	.max_brightness = 255,
 	.power = FB_BLANK_UNBLANK,
Signature · 1 line
2.19.1