diff mbox series

[1/4] media: platform: rzg2l-cru: rzg2l-csi2: Switch to RUNTIME_PM_OPS()

Message ID 20240123115821.292787-2-biju.das.jz@bp.renesas.com (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series RZ/G2L CSI/CRU Improvements | expand

Commit Message

Biju Das Jan. 23, 2024, 11:58 a.m. UTC
SET_RUNTIME_PM_OPS() are deprecated and require __maybe_unused
protection against unused function warnings. The usage of pm_ptr() and
RUNTIME_PM_OPS() allows the compiler to see the functions, thus
suppressing the warning. Thus drop the __maybe_unused markings.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart Jan. 23, 2024, 3:29 p.m. UTC | #1
Hi Biju,

Thank you for the patch.

On Tue, Jan 23, 2024 at 11:58:18AM +0000, Biju Das wrote:
> SET_RUNTIME_PM_OPS() are deprecated

Not that I particularly care about SET_RUNTIME_PM_OPS, but I'm not aware
of it being deprecated. Has that been announced somewhere ?

> and require __maybe_unused
> protection against unused function warnings. The usage of pm_ptr() and
> RUNTIME_PM_OPS() allows the compiler to see the functions, thus
> suppressing the warning. Thus drop the __maybe_unused markings.

Have you tried to compile this with CONFIG_PM disabled, and confirmed
the compiler doesn't generate any warning ?

> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> index d20f4eff93a4..c4609da9bf1a 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> @@ -834,7 +834,7 @@ static void rzg2l_csi2_remove(struct platform_device *pdev)
>  	pm_runtime_disable(&pdev->dev);
>  }
>  
> -static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device *dev)
> +static int rzg2l_csi2_pm_runtime_suspend(struct device *dev)
>  {
>  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
>  
> @@ -843,7 +843,7 @@ static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device *dev)
> +static int rzg2l_csi2_pm_runtime_resume(struct device *dev)
>  {
>  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
>  
> @@ -851,7 +851,7 @@ static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device *dev)
>  }
>  
>  static const struct dev_pm_ops rzg2l_csi2_pm_ops = {
> -	SET_RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend, rzg2l_csi2_pm_runtime_resume, NULL)
> +	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend, rzg2l_csi2_pm_runtime_resume, NULL)

While at it, I would wrap the line to

	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
		       rzg2l_csi2_pm_runtime_resume, NULL)

Up to you.

>  };
>  
>  static const struct of_device_id rzg2l_csi2_of_table[] = {
> @@ -865,7 +865,7 @@ static struct platform_driver rzg2l_csi2_pdrv = {
>  	.driver	= {
>  		.name = "rzg2l-csi2",
>  		.of_match_table = rzg2l_csi2_of_table,
> -		.pm = &rzg2l_csi2_pm_ops,
> +		.pm = pm_ptr(&rzg2l_csi2_pm_ops),
>  	},
>  };
>
Biju Das Jan. 23, 2024, 6:33 p.m. UTC | #2
Hi Laurent Pinchart,

Thanks for the feedback.

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: Tuesday, January 23, 2024 3:29 PM
> Subject: Re: [PATCH 1/4] media: platform: rzg2l-cru: rzg2l-csi2: Switch to
> RUNTIME_PM_OPS()
> 
> Hi Biju,
> 
> Thank you for the patch.
> 
> On Tue, Jan 23, 2024 at 11:58:18AM +0000, Biju Das wrote:
> > SET_RUNTIME_PM_OPS() are deprecated
> 
> Not that I particularly care about SET_RUNTIME_PM_OPS, but I'm not aware
> of it being deprecated. Has that been announced somewhere ?

I was under the impression from [1], this is new style and old style going to be deprecated.

If it is not the case, I would like to drop this patch.

[1] https://www.spinics.net/lists/stable/msg691416.html

> 
> > and require __maybe_unused
> > protection against unused function warnings. The usage of pm_ptr() and
> > RUNTIME_PM_OPS() allows the compiler to see the functions, thus
> > suppressing the warning. Thus drop the __maybe_unused markings.
> 
> Have you tried to compile this with CONFIG_PM disabled, and confirmed the
> compiler doesn't generate any warning ?

I am not able to compile with CONFIG_PM disabled as it is throwing errors in power management code.

kernel/power/suspend.c: In function ‘suspend_prepare’:
kernel/power/suspend.c:360:10: error: implicit declaration of function ‘pm_notifier_call_chain_robust’; did you mean ‘raw_notifier_call_chain_robust’? [-Werror=implicit-function-declaration]
  360 |  error = pm_notifier_call_chain_robust(PM_SUSPEND_PREPARE, PM_POST_SUSPEND);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |          raw_notifier_call_chain_robust
kernel/power/hibernate.c:325:2: error: implicit declaration of function ‘save_processor_state’ [-Werror=implicit-function-declaration]
  325 |  save_processor_state();
      |  ^~~~~~~~~~~~~~~~~~~~
kernel/power/suspend.c:372:2: error: implicit declaration of function ‘pm_notifier_call_chain’; did you mean ‘raw_notifier_call_chain’? [-Werror=implicit-function-declaration]
  372 |  pm_notifier_call_chain(PM_POST_SUSPEND);
      |  ^~~~~~~~~~~~~~~~~~~~~~
      |  raw_notifier_call_chain
  CC      io_uring/timeout.o
kernel/power/suspend.c: In function ‘suspend_enter’:
kernel/power/suspend.c:405:10: error: implicit declaration of function ‘dpm_suspend_late’; did you mean ‘dpm_suspend_start’? [-Werror=implicit-function-declaration]
  405 |  error = dpm_suspend_late(PMSG_SUSPEND);
      |          ^~~~~~~~~~~~~~~~
      |          dpm_suspend_start 

> 
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> >  drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > index d20f4eff93a4..c4609da9bf1a 100644
> > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > @@ -834,7 +834,7 @@ static void rzg2l_csi2_remove(struct platform_device
> *pdev)
> >  	pm_runtime_disable(&pdev->dev);
> >  }
> >
> > -static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device
> > *dev)
> > +static int rzg2l_csi2_pm_runtime_suspend(struct device *dev)
> >  {
> >  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
> >
> > @@ -843,7 +843,7 @@ static int __maybe_unused
> rzg2l_csi2_pm_runtime_suspend(struct device *dev)
> >  	return 0;
> >  }
> >
> > -static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device
> > *dev)
> > +static int rzg2l_csi2_pm_runtime_resume(struct device *dev)
> >  {
> >  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
> >
> > @@ -851,7 +851,7 @@ static int __maybe_unused
> > rzg2l_csi2_pm_runtime_resume(struct device *dev)  }
> >
> >  static const struct dev_pm_ops rzg2l_csi2_pm_ops = {
> > -	SET_RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> rzg2l_csi2_pm_runtime_resume, NULL)
> > +	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> > +rzg2l_csi2_pm_runtime_resume, NULL)
> 
> While at it, I would wrap the line to
> 
> 	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> 		       rzg2l_csi2_pm_runtime_resume, NULL)
> 
> Up to you.

If it is not a requirement to move to use the modern pm_ops/pm_sleep_ops
then as said in the above I would like to drop this patch.

Cheers,
Biju

> 
> >  };
> >
> >  static const struct of_device_id rzg2l_csi2_of_table[] = { @@ -865,7
> > +865,7 @@ static struct platform_driver rzg2l_csi2_pdrv = {
> >  	.driver	= {
> >  		.name = "rzg2l-csi2",
> >  		.of_match_table = rzg2l_csi2_of_table,
> > -		.pm = &rzg2l_csi2_pm_ops,
> > +		.pm = pm_ptr(&rzg2l_csi2_pm_ops),
> >  	},
> >  };
> >
> 
> --
> Regards,
> 
> Laurent Pinchart
Laurent Pinchart Jan. 23, 2024, 10:17 p.m. UTC | #3
On Tue, Jan 23, 2024 at 06:33:57PM +0000, Biju Das wrote:
> > On Tue, Jan 23, 2024 at 11:58:18AM +0000, Biju Das wrote:
> > > SET_RUNTIME_PM_OPS() are deprecated
> > 
> > Not that I particularly care about SET_RUNTIME_PM_OPS, but I'm not aware
> > of it being deprecated. Has that been announced somewhere ?
> 
> I was under the impression from [1], this is new style and old style going to be deprecated.
> 
> If it is not the case, I would like to drop this patch.
> 
> [1] https://www.spinics.net/lists/stable/msg691416.html

I'm not against this change, I was just wondering about the status of
SET_RUNTIME_PM_OPS. If you think using RUNTIME_PM_OPS is better, I have
no problem with that. The commit message should probably state that the
latter is better, instead of saying that SET_RUNTIME_PM_OPS is
deprecated.

> > > and require __maybe_unused
> > > protection against unused function warnings. The usage of pm_ptr() and
> > > RUNTIME_PM_OPS() allows the compiler to see the functions, thus
> > > suppressing the warning. Thus drop the __maybe_unused markings.
> > 
> > Have you tried to compile this with CONFIG_PM disabled, and confirmed the
> > compiler doesn't generate any warning ?
> 
> I am not able to compile with CONFIG_PM disabled as it is throwing errors in power management code.
> 
> kernel/power/suspend.c: In function ‘suspend_prepare’:
> kernel/power/suspend.c:360:10: error: implicit declaration of function ‘pm_notifier_call_chain_robust’; did you mean ‘raw_notifier_call_chain_robust’? [-Werror=implicit-function-declaration]
>   360 |  error = pm_notifier_call_chain_robust(PM_SUSPEND_PREPARE, PM_POST_SUSPEND);
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |          raw_notifier_call_chain_robust
> kernel/power/hibernate.c:325:2: error: implicit declaration of function ‘save_processor_state’ [-Werror=implicit-function-declaration]
>   325 |  save_processor_state();
>       |  ^~~~~~~~~~~~~~~~~~~~
> kernel/power/suspend.c:372:2: error: implicit declaration of function ‘pm_notifier_call_chain’; did you mean ‘raw_notifier_call_chain’? [-Werror=implicit-function-declaration]
>   372 |  pm_notifier_call_chain(PM_POST_SUSPEND);
>       |  ^~~~~~~~~~~~~~~~~~~~~~
>       |  raw_notifier_call_chain
>   CC      io_uring/timeout.o
> kernel/power/suspend.c: In function ‘suspend_enter’:
> kernel/power/suspend.c:405:10: error: implicit declaration of function ‘dpm_suspend_late’; did you mean ‘dpm_suspend_start’? [-Werror=implicit-function-declaration]
>   405 |  error = dpm_suspend_late(PMSG_SUSPEND);
>       |          ^~~~~~~~~~~~~~~~
>       |          dpm_suspend_start 

I'm surprised. Sakari, isn't !CONFIG_PM supposed to be supported ?

> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > >  drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > > b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > > index d20f4eff93a4..c4609da9bf1a 100644
> > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
> > > @@ -834,7 +834,7 @@ static void rzg2l_csi2_remove(struct platform_device
> > *pdev)
> > >  	pm_runtime_disable(&pdev->dev);
> > >  }
> > >
> > > -static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device
> > > *dev)
> > > +static int rzg2l_csi2_pm_runtime_suspend(struct device *dev)
> > >  {
> > >  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
> > >
> > > @@ -843,7 +843,7 @@ static int __maybe_unused
> > rzg2l_csi2_pm_runtime_suspend(struct device *dev)
> > >  	return 0;
> > >  }
> > >
> > > -static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device
> > > *dev)
> > > +static int rzg2l_csi2_pm_runtime_resume(struct device *dev)
> > >  {
> > >  	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
> > >
> > > @@ -851,7 +851,7 @@ static int __maybe_unused
> > > rzg2l_csi2_pm_runtime_resume(struct device *dev)  }
> > >
> > >  static const struct dev_pm_ops rzg2l_csi2_pm_ops = {
> > > -	SET_RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> > rzg2l_csi2_pm_runtime_resume, NULL)
> > > +	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> > > +rzg2l_csi2_pm_runtime_resume, NULL)
> > 
> > While at it, I would wrap the line to
> > 
> > 	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend,
> > 		       rzg2l_csi2_pm_runtime_resume, NULL)
> > 
> > Up to you.
> 
> If it is not a requirement to move to use the modern pm_ops/pm_sleep_ops
> then as said in the above I would like to drop this patch.
> 
> > >  };
> > >
> > >  static const struct of_device_id rzg2l_csi2_of_table[] = { @@ -865,7
> > > +865,7 @@ static struct platform_driver rzg2l_csi2_pdrv = {
> > >  	.driver	= {
> > >  		.name = "rzg2l-csi2",
> > >  		.of_match_table = rzg2l_csi2_of_table,
> > > -		.pm = &rzg2l_csi2_pm_ops,
> > > +		.pm = pm_ptr(&rzg2l_csi2_pm_ops),
> > >  	},
> > >  };
> > >
Biju Das Jan. 24, 2024, 11:39 a.m. UTC | #4
Hi Laurent Pinchart,

Thanks for the feedback.

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: Tuesday, January 23, 2024 10:17 PM
> Subject: Re: [PATCH 1/4] media: platform: rzg2l-cru: rzg2l-csi2: Switch to
> RUNTIME_PM_OPS()
> 
> On Tue, Jan 23, 2024 at 06:33:57PM +0000, Biju Das wrote:
> > > On Tue, Jan 23, 2024 at 11:58:18AM +0000, Biju Das wrote:
> > > > SET_RUNTIME_PM_OPS() are deprecated
> > >
> > > Not that I particularly care about SET_RUNTIME_PM_OPS, but I'm not
> > > aware of it being deprecated. Has that been announced somewhere ?
> >
> > I was under the impression from [1], this is new style and old style
> going to be deprecated.
> >
> > If it is not the case, I would like to drop this patch.
> >
> > [1]
> 
> I'm not against this change, I was just wondering about the status of
> SET_RUNTIME_PM_OPS. If you think using RUNTIME_PM_OPS is better, I have no
> problem with that. The commit message should probably state that the
> latter is better, instead of saying that SET_RUNTIME_PM_OPS is deprecated.


Agreed. Will update the commit message along with the changes you suggested in
Next version.

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index d20f4eff93a4..c4609da9bf1a 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -834,7 +834,7 @@  static void rzg2l_csi2_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device *dev)
+static int rzg2l_csi2_pm_runtime_suspend(struct device *dev)
 {
 	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
 
@@ -843,7 +843,7 @@  static int __maybe_unused rzg2l_csi2_pm_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device *dev)
+static int rzg2l_csi2_pm_runtime_resume(struct device *dev)
 {
 	struct rzg2l_csi2 *csi2 = dev_get_drvdata(dev);
 
@@ -851,7 +851,7 @@  static int __maybe_unused rzg2l_csi2_pm_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rzg2l_csi2_pm_ops = {
-	SET_RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend, rzg2l_csi2_pm_runtime_resume, NULL)
+	RUNTIME_PM_OPS(rzg2l_csi2_pm_runtime_suspend, rzg2l_csi2_pm_runtime_resume, NULL)
 };
 
 static const struct of_device_id rzg2l_csi2_of_table[] = {
@@ -865,7 +865,7 @@  static struct platform_driver rzg2l_csi2_pdrv = {
 	.driver	= {
 		.name = "rzg2l-csi2",
 		.of_match_table = rzg2l_csi2_of_table,
-		.pm = &rzg2l_csi2_pm_ops,
+		.pm = pm_ptr(&rzg2l_csi2_pm_ops),
 	},
 };