diff mbox series

[1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS

Message ID 20230417091027.966146-2-d-gole@ti.com (mailing list archive)
State New, archived
Headers show
Series Fix PM Hooks in the Cadence Quad SPI Driver | expand

Commit Message

Dhruva Gole April 17, 2023, 9:10 a.m. UTC
Using this macro makes the code more readable.
It also inits the members of dev_pm_ops in the following manner
without us explicitly needing to:

.suspend = cqspi_suspend, \
.resume = cqspi_resume, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,

Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
Signed-off-by: Dhruva Gole <d-gole@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Mark Brown April 18, 2023, 12:52 p.m. UTC | #1
On Mon, Apr 17, 2023 at 02:40:26PM +0530, Dhruva Gole wrote:

> -static const struct dev_pm_ops cqspi__dev_pm_ops = {
> -	.suspend = cqspi_suspend,
> -	.resume = cqspi_resume,
> -};
> +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
>  
>  #define CQSPI_DEV_PM_OPS	(&cqspi__dev_pm_ops)
>  #else

These days you should use DEFINE_SIMPLE_DEV_PM_OPS() instead.
Dhruva Gole April 18, 2023, 2:17 p.m. UTC | #2
Hi Mark, Thanks for going through my patch.

On 4/18/2023 6:22 PM, Mark Brown wrote:
> On Mon, Apr 17, 2023 at 02:40:26PM +0530, Dhruva Gole wrote:
>
>> -static const struct dev_pm_ops cqspi__dev_pm_ops = {
>> -	.suspend = cqspi_suspend,
>> -	.resume = cqspi_resume,
>> -};
>> +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
>>  
>>  #define CQSPI_DEV_PM_OPS	(&cqspi__dev_pm_ops)
>>  #else
> These days you should use DEFINE_SIMPLE_DEV_PM_OPS() instead.


Sure, I can respin this series with this macro instead,

https://elixir.bootlin.com/linux/v6.1/source/include/linux/pm.h#L399

So essentially it will look like,

static DEFINE_SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);


Are there any other improvements you'd like me to make in my next revision of this series?
Mark Brown April 18, 2023, 4:19 p.m. UTC | #3
On Tue, Apr 18, 2023 at 07:47:57PM +0530, Gole, Dhruva wrote:

> Are there any other improvements you'd like me to make in my next revision of this series?

That was it.  I think I queued patch 2 already.
diff mbox series

Patch

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 79ab7e309644..d47e954fe809 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1829,10 +1829,7 @@  static int cqspi_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops cqspi__dev_pm_ops = {
-	.suspend = cqspi_suspend,
-	.resume = cqspi_resume,
-};
+static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);
 
 #define CQSPI_DEV_PM_OPS	(&cqspi__dev_pm_ops)
 #else