[PATCH v2 1/3] media: ti: cal: Use str_up_down()

Ricardo Ribalda posted 3 patches 2 months ago
There is a newer version of this series
[PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by Ricardo Ribalda 2 months ago
The str_up_down() helper simplifies the code and fixes the following cocci
warning:

drivers/media/platform/ti/cal/cal-camerarx.c:194:3-9: opportunity for str_up_down(enable)

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/ti/cal/cal-camerarx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c
index 42dfe08b765f..ba8c4743f539 100644
--- a/drivers/media/platform/ti/cal/cal-camerarx.c
+++ b/drivers/media/platform/ti/cal/cal-camerarx.c
@@ -191,7 +191,7 @@ static void cal_camerarx_power(struct cal_camerarx *phy, bool enable)
 
 	if (i == 10)
 		phy_err(phy, "Failed to power %s complexio\n",
-			enable ? "up" : "down");
+			str_up_down(enable);
 }
 
 static void cal_camerarx_wait_reset(struct cal_camerarx *phy)

-- 
2.46.1.824.gd892dcdcdd-goog
Re: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by kernel test robot 2 months ago
Hi Ricardo,

kernel test robot noticed the following build errors:

[auto build test ERROR on 075dbe9f6e3c21596c5245826a4ee1f1c1676eb8]

url:    https://github.com/intel-lab-lkp/linux/commits/Ricardo-Ribalda/media-ti-cal-Use-str_up_down/20240927-180438
base:   075dbe9f6e3c21596c5245826a4ee1f1c1676eb8
patch link:    https://lore.kernel.org/r/20240927-cocci-6-12-v2-1-1c6ad931959b%40chromium.org
patch subject: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
config: i386-buildonly-randconfig-003-20240928 (https://download.01.org/0day-ci/archive/20240928/202409281015.ZcDlYBGw-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240928/202409281015.ZcDlYBGw-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409281015.ZcDlYBGw-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> drivers/media/platform/ti/cal/cal-camerarx.c:193:3: error: unterminated function-like macro invocation
     193 |                 phy_err(phy, "Failed to power %s complexio\n",
         |                 ^
   drivers/media/platform/ti/cal/cal.h:278:9: note: macro 'phy_err' defined here
     278 | #define phy_err(phy, fmt, arg...)                                       \
         |         ^
>> drivers/media/platform/ti/cal/cal-camerarx.c:897:2: error: expected expression
     897 | }
         |  ^
>> drivers/media/platform/ti/cal/cal-camerarx.c:897:2: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
   drivers/media/platform/ti/cal/cal-camerarx.c:192:2: note: previous statement is here
     192 |         if (i == 10)
         |         ^
>> drivers/media/platform/ti/cal/cal-camerarx.c:897:2: error: expected '}'
     897 | }
         |  ^
   drivers/media/platform/ti/cal/cal-camerarx.c:169:1: note: to match this '{'
     169 | {
         | ^
   1 warning and 3 errors generated.


vim +193 drivers/media/platform/ti/cal/cal-camerarx.c

af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  167  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  168  static void cal_camerarx_power(struct cal_camerarx *phy, bool enable)
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  169  {
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  170  	u32 target_state;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  171  	unsigned int i;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  172  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  173  	target_state = enable ? CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ON :
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  174  		       CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_OFF;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  175  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  176  	cal_write_field(phy->cal, CAL_CSI2_COMPLEXIO_CFG(phy->instance),
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  177  			target_state, CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_MASK);
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  178  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  179  	for (i = 0; i < 10; i++) {
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  180  		u32 current_state;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  181  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  182  		current_state = cal_read_field(phy->cal,
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  183  					       CAL_CSI2_COMPLEXIO_CFG(phy->instance),
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  184  					       CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_MASK);
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  185  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  186  		if (current_state == target_state)
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  187  			break;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  188  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  189  		usleep_range(1000, 1100);
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  190  	}
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  191  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  192  	if (i == 10)
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06 @193  		phy_err(phy, "Failed to power %s complexio\n",
368e80f16a6aff drivers/media/platform/ti/cal/cal-camerarx.c Ricardo Ribalda  2024-09-27  194  			str_up_down(enable);
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  195  }
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  196  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by kernel test robot 2 months ago
Hi Ricardo,

kernel test robot noticed the following build errors:

[auto build test ERROR on 075dbe9f6e3c21596c5245826a4ee1f1c1676eb8]

url:    https://github.com/intel-lab-lkp/linux/commits/Ricardo-Ribalda/media-ti-cal-Use-str_up_down/20240927-180438
base:   075dbe9f6e3c21596c5245826a4ee1f1c1676eb8
patch link:    https://lore.kernel.org/r/20240927-cocci-6-12-v2-1-1c6ad931959b%40chromium.org
patch subject: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
config: arc-randconfig-002-20240928 (https://download.01.org/0day-ci/archive/20240928/202409281008.pouaXQCm-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240928/202409281008.pouaXQCm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409281008.pouaXQCm-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/media/platform/ti/cal/cal-camerarx.c: In function 'cal_camerarx_power':
>> drivers/media/platform/ti/cal/cal-camerarx.c:897:2: error: unterminated argument list invoking macro "phy_err"
     897 | }
         |  ^
>> drivers/media/platform/ti/cal/cal-camerarx.c:193:17: error: 'phy_err' undeclared (first use in this function)
     193 |                 phy_err(phy, "Failed to power %s complexio\n",
         |                 ^~~~~~~
   drivers/media/platform/ti/cal/cal-camerarx.c:193:17: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/media/platform/ti/cal/cal-camerarx.c:193:24: error: expected ';' at end of input
     193 |                 phy_err(phy, "Failed to power %s complexio\n",
         |                        ^
         |                        ;
   ......
   drivers/media/platform/ti/cal/cal-camerarx.c:192:9: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
     192 |         if (i == 10)
         |         ^~
   drivers/media/platform/ti/cal/cal-camerarx.c:192:9: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory
>> drivers/media/platform/ti/cal/cal-camerarx.c:193:17: error: expected declaration or statement at end of input
     193 |                 phy_err(phy, "Failed to power %s complexio\n",
         |                 ^~~~~~~
   drivers/media/platform/ti/cal/cal-camerarx.c: At top level:
>> drivers/media/platform/ti/cal/cal-camerarx.c:168:13: warning: 'cal_camerarx_power' defined but not used [-Wunused-function]
     168 | static void cal_camerarx_power(struct cal_camerarx *phy, bool enable)
         |             ^~~~~~~~~~~~~~~~~~
>> drivers/media/platform/ti/cal/cal-camerarx.c:133:13: warning: 'cal_camerarx_config' defined but not used [-Wunused-function]
     133 | static void cal_camerarx_config(struct cal_camerarx *phy, s64 link_freq)
         |             ^~~~~~~~~~~~~~~~~~~
>> drivers/media/platform/ti/cal/cal-camerarx.c:108:13: warning: 'cal_camerarx_enable' defined but not used [-Wunused-function]
     108 | static void cal_camerarx_enable(struct cal_camerarx *phy)
         |             ^~~~~~~~~~~~~~~~~~~
>> drivers/media/platform/ti/cal/cal-camerarx.c:80:13: warning: 'cal_camerarx_lane_config' defined but not used [-Wunused-function]
      80 | static void cal_camerarx_lane_config(struct cal_camerarx *phy)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/platform/ti/cal/cal-camerarx.c:48:12: warning: 'cal_camerarx_get_ext_link_freq' defined but not used [-Wunused-function]
      48 | static s64 cal_camerarx_get_ext_link_freq(struct cal_camerarx *phy)
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/phy_err +897 drivers/media/platform/ti/cal/cal-camerarx.c

af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  886  
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  887  void cal_camerarx_destroy(struct cal_camerarx *phy)
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  888  {
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  889  	if (!phy)
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  890  		return;
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06  891  
5acc3e22c25359 drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-12-07  892  	v4l2_device_unregister_subdev(&phy->subdev);
e7bbe653fd9a76 drivers/media/platform/ti/cal/cal-camerarx.c Tomi Valkeinen   2023-06-19  893  	v4l2_subdev_cleanup(&phy->subdev);
5acc3e22c25359 drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-12-07  894  	media_entity_cleanup(&phy->subdev.entity);
27f86b9bff79e1 drivers/media/platform/ti-vpe/cal-camerarx.c Tomi Valkeinen   2021-06-14  895  	of_node_put(phy->source_ep_node);
27f86b9bff79e1 drivers/media/platform/ti-vpe/cal-camerarx.c Tomi Valkeinen   2021-06-14  896  	of_node_put(phy->source_node);
af30d4f36ef35d drivers/media/platform/ti-vpe/cal-camerarx.c Laurent Pinchart 2020-07-06 @897  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by Andy Shevchenko 2 months ago
On Fri, Sep 27, 2024 at 1:02 PM Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> The str_up_down() helper simplifies the code and fixes the following cocci
> warning:
>
> drivers/media/platform/ti/cal/cal-camerarx.c:194:3-9: opportunity for str_up_down(enable)

...

>         if (i == 10)
>                 phy_err(phy, "Failed to power %s complexio\n",
> -                       enable ? "up" : "down");
> +                       str_up_down(enable);

You never tested this, do not bother to send untested material, please!

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by Ricardo Ribalda 2 months ago
Hi Andy

On Fri, 27 Sept 2024 at 12:10, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Fri, Sep 27, 2024 at 1:02 PM Ricardo Ribalda <ribalda@chromium.org> wrote:
> >
> > The str_up_down() helper simplifies the code and fixes the following cocci
> > warning:
> >
> > drivers/media/platform/ti/cal/cal-camerarx.c:194:3-9: opportunity for str_up_down(enable)
>
> ...
>
> >         if (i == 10)
> >                 phy_err(phy, "Failed to power %s complexio\n",
> > -                       enable ? "up" : "down");
> > +                       str_up_down(enable);
>
> You never tested this, do not bother to send untested material, please!

Do you mean tested in real hardware or compile test it?

I did test it:
https://gitlab.freedesktop.org/linux-media/users/ribalda/-/commits/test-newlinus

But obviously we are not building that file :S. Let me figure out why
did this happened

Sorry for the noise

>
> --
> With Best Regards,
> Andy Shevchenko



-- 
Ricardo Ribalda
Re: [PATCH v2 1/3] media: ti: cal: Use str_up_down()
Posted by Andy Shevchenko 2 months ago
On Fri, Sep 27, 2024 at 1:16 PM Ricardo Ribalda <ribalda@chromium.org> wrote:
> On Fri, 27 Sept 2024 at 12:10, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Fri, Sep 27, 2024 at 1:02 PM Ricardo Ribalda <ribalda@chromium.org> wrote:

...

> > >         if (i == 10)
> > >                 phy_err(phy, "Failed to power %s complexio\n",
> > > -                       enable ? "up" : "down");
> > > +                       str_up_down(enable);
> >
> > You never tested this, do not bother to send untested material, please!
>
> Do you mean tested in real hardware or compile test it?

Obviously both as one can't be done without the other.

-- 
With Best Regards,
Andy Shevchenko