Skip to content

Commit

Permalink
Update the driver to use the pm_runtime API for runtime_suspend and r…
Browse files Browse the repository at this point in the history
…untime_resume

While they are still technically functional, it is recommended to update the driver to use the pm_runtime API for better power management and compatibility with newer kernels.
  • Loading branch information
ruck314 committed Feb 19, 2024
1 parent 595c193 commit 57078f4
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions petalinux/axistreamdma/files/axistreamdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,22 @@ MODULE_AUTHOR("Ryan Herbst");
MODULE_DESCRIPTION("AXI Stream DMA driver. V3");
MODULE_LICENSE("GPL");

/**
* Rce_DmaNop - No-operation function for DMA device power management.
*
* This function is intended to be used as a placeholder for power management
* operations where no action is needed. It simply returns 0, indicating success,
* and is used for both runtime_suspend and runtime_resume operations in the
* device's power management operations structure.
*
* @dev: The device structure.
* @return: Always returns 0, indicating success.
*/
static int Rce_DmaNop(struct device *dev)
// Optional: Implement your hardware-specific suspend and resume logic
static int Rce_runtime_suspend(struct device *dev)
{
// Suspend actions specific to your device
return 0;
}

static const struct dev_pm_ops Rce_DmaOps = {
.runtime_suspend = Rce_DmaNop,
.runtime_resume = Rce_DmaNop,
static int Rce_runtime_resume(struct device *dev)
{
// Resume actions specific to your device
return 0;
}

static const struct dev_pm_ops Rce_Dma_pm_ops = {
SET_RUNTIME_PM_OPS(Rce_runtime_suspend,
Rce_runtime_resume, NULL)
};

static struct of_device_id Rce_DmaMatch[] = {
Expand All @@ -90,7 +87,7 @@ static struct platform_driver Rce_DmaPdrv = {
.driver = {
.name = MOD_NAME,
.owner = THIS_MODULE,
.pm = &Rce_DmaOps,
.pm = &Rce_Dma_pm_ops,
.of_match_table = of_match_ptr(Rce_DmaMatch),
},
};
Expand Down Expand Up @@ -216,18 +213,15 @@ int Rce_Probe(struct platform_device *pdev) {

// Call common dma init function
if ( Dma_Init(dev) < 0 )
goto cleanup_force_exit;
return -1;

// Increment count only after DMA is initialized successfully
gDmaDevCount++;

return 0;

/* Cleanup after probe failure */
cleanup_force_exit:
return -1;
// Enable runtime PM for this device
pm_runtime_enable(&pdev->dev);


return 0;
}

/**
Expand All @@ -250,6 +244,9 @@ int Rce_Remove(struct platform_device *pdev)

pr_info("%s: Remove: Remove called.\n", MOD_NAME);

// Clean up before removing the device
pm_runtime_disable(&pdev->dev);

// Extract device name suffix
tmpName = pdev->name + 9;

Expand Down

0 comments on commit 57078f4

Please sign in to comment.