staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
Subsystems (4)
PATCH v2 1/1 staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
Fixes the following Coccinelle warning reported by string_choices.cocci:
opportunity for str_on_off(on)
---
Changes in v2:
- Include "media" in the subject line.
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +3 -2
@@ -13,6 +13,7 @@#include <linux/gpio/consumer.h> #include <linux/gpio.h> #include <linux/platform_device.h> +#include <linux/string_choices.h> #include "../../include/linux/atomisp_platform.h" #include "../../include/linux/atomisp_gmin_platform.h"
@@ -917,7 +918,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on)return 0 ;dev_dbg (subdev->dev,"Setting power state to %s\n" , - on ?"on" :"off" ); +str_on_off (on));if (on) ret = acpi_device_set_power(adev,
@@ -930,7 +931,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) gs->clock_on = on; else dev_err(subdev->dev, "Couldn't set power state to %s\n", - on ? "on" : "off"); + str_on_off(on));return ret; }
Signature · 1 line
2.53.0
Sakari Ailus
reviewerHi Nick,
Quoted 8 lines · Nick Spooner
Fixes the following Coccinelle warning reported by
string_choices.cocci:opportunity for
str_on_off(on)Signed-off-by Nick Spooner <[email protected]>---
Changes in v2:
- Include "media" in the subject line.
If there's only such a change that you'd do right after submitting a patch, please wait some time for other review comments first.
Quoted 17 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-0@@ -13,6 +13,7 @@#include <linux/gpio/consumer.h> #include <linux/gpio.h> #include <linux/platform_device.h> +#include <linux/string_choices.h> #include "../../include/linux/atomisp_platform.h" #include "../../include/linux/atomisp_gmin_platform.h"
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) · line 921
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1@@ -917,7 +918,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on)return 0 ;dev_dbg (subdev->dev,"Setting power state to %s\n" , - on ?"on" :"off" ); +str_on_off (on));
This fits on the previous line.
Quoted 12 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1if (on) ret = acpi_device_set_power(adev,@@ -930,7 +931,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) gs->clock_on = on; else dev_err(subdev->dev, "Couldn't set power state to %s\n", - on ? "on" : "off"); + str_on_off(on));return ret; }
Signature · 3 lines
Regards, Sakari Ailus
Quoted 25 lines · On Thu, 23 Apr 2026 13:47:27 -0600 Nick Spooner <[email protected]>…
Fixes the following Coccinelle warning reported by
string_choices.cocci:opportunity for
str_on_off(on)Signed-off-by Nick Spooner <[email protected]>---
Changes in v2:
- Include "media" in the subject line.drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-0@@ -13,6 +13,7 @@#include <linux/gpio/consumer.h> #include <linux/gpio.h> #include <linux/platform_device.h> +#include <linux/string_choices.h> #include "../../include/linux/atomisp_platform.h" #include "../../include/linux/atomisp_gmin_platform.h"
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) · line 921
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1@@ -917,7 +918,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on)return 0 ;dev_dbg (subdev->dev,"Setting power state to %s\n" , - on ?"on" :"off" ); +str_on_off (on));
While someone went to the trouble of adding the 'helper' and the Coccinelle warning; I'm not really convinced it actually improves the code. It doesn't even do &"off\0on"[on_off * 4] - which might be an excuse for a helper.
David
Quoted 12 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1if (on) ret = acpi_device_set_power(adev,@@ -930,7 +931,7 @@ static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) gs->clock_on = on; else dev_err(subdev->dev, "Couldn't set power state to %s\n", - on ? "on" : "off"); + str_on_off(on));return ret; }
Quoted 2 lines · David Laight
On Thu, 23 Apr 2026 13:47:27 -0600
Nick Spooner <[email protected]> wrote:
...
Quoted 8 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) · line 921
Quoted 3 lines
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1dev_dbg (subdev->dev,"Setting power state to %s\n" , - on ?"on" :"off" ); +str_on_off (on));While someone went to the trouble of adding the 'helper' and the Coccinelle warning; I'm not really convinced it actually improves the code. It doesn't even do &"off\0on"[on_off * 4] - which might be an excuse for a helper.
The point of the helper mainly not about the code optimisation, it's all about making unified tokens when printing stuff (same for dates, times, escaped strings, et cetera). Btw, the code like &"off\0on"[on_off * 4] is unreadable trick. And I dunno if compiler/linker will be able to pack these string literals as currently done in case several of str_FOO_BAR() [with the same FOO_BAR] are in the same compilation unit.
Signature · 2 lines
With Best Regards, Andy Shevchenko