public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
@ 2026-04-23 19:47 Nick Spooner
  2026-04-23 21:03 ` Sakari Ailus
  2026-04-23 21:41 ` David Laight
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Spooner @ 2026-04-23 19:47 UTC (permalink / raw)
  To: hansg, mchehab, sakari.ailus, andy, gregkh
  Cc: linux-media, linux-kernel, linux-staging, Nick Spooner

Fixes the following Coccinelle warning reported by string_choices.cocci:

	opportunity for str_on_off(on)

Signed-off-by: Nick Spooner <nicholas.spooner@seagate.com>
---
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(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 4026e98c5845..322eca4a3755 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -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;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
  2026-04-23 19:47 [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning Nick Spooner
@ 2026-04-23 21:03 ` Sakari Ailus
  2026-04-23 21:41 ` David Laight
  1 sibling, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2026-04-23 21:03 UTC (permalink / raw)
  To: Nick Spooner
  Cc: hansg, mchehab, andy, gregkh, linux-media, linux-kernel,
	linux-staging

Hi Nick,

On Thu, Apr 23, 2026 at 01:47:27PM -0600, Nick Spooner wrote:
> Fixes the following Coccinelle warning reported by string_choices.cocci:
> 
> 	opportunity for str_on_off(on)
> 
> Signed-off-by: Nick Spooner <nicholas.spooner@seagate.com>
> ---
> 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.

> 
>  drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> index 4026e98c5845..322eca4a3755 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> @@ -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));

This fits on the previous line.

>  
>  	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;
>  }

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
  2026-04-23 19:47 [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning Nick Spooner
  2026-04-23 21:03 ` Sakari Ailus
@ 2026-04-23 21:41 ` David Laight
  2026-04-24  8:44   ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: David Laight @ 2026-04-23 21:41 UTC (permalink / raw)
  To: Nick Spooner
  Cc: hansg, mchehab, sakari.ailus, andy, gregkh, linux-media,
	linux-kernel, linux-staging

On Thu, 23 Apr 2026 13:47:27 -0600
Nick Spooner <nicholas.spooner@seagate.com> wrote:

> Fixes the following Coccinelle warning reported by string_choices.cocci:
> 
> 	opportunity for str_on_off(on)
> 
> Signed-off-by: Nick Spooner <nicholas.spooner@seagate.com>
> ---
> 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(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> index 4026e98c5845..322eca4a3755 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> @@ -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));

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

>  
>  	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;
>  }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning
  2026-04-23 21:41 ` David Laight
@ 2026-04-24  8:44   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-04-24  8:44 UTC (permalink / raw)
  To: David Laight
  Cc: Nick Spooner, hansg, mchehab, sakari.ailus, andy, gregkh,
	linux-media, linux-kernel, linux-staging

On Thu, Apr 23, 2026 at 10:41:13PM +0100, David Laight wrote:
> On Thu, 23 Apr 2026 13:47:27 -0600
> Nick Spooner <nicholas.spooner@seagate.com> wrote:

...

> >  	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.

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.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-24  8:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 19:47 [PATCH v2] staging: media: atomisp: Use str_on_off() to fix Coccinelle warning Nick Spooner
2026-04-23 21:03 ` Sakari Ailus
2026-04-23 21:41 ` David Laight
2026-04-24  8:44   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox