Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: xilinx: add runtime PM support

Added Runtime power management support to the xilinx phy driver and using
DEFINE_RUNTIME_DEV_PM_OPS new macros allows the compiler to remove the
unused dev_pm_ops structure and related functions if !CONFIG_PM without
the need to mark the functions __maybe_unused.

Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
Link: https://lore.kernel.org/r/20230613140250.3018947-2-piyush.mehta@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Piyush Mehta and committed by
Vinod Koul
b3db66f6 bd36b1ba

+28 -7
+28 -7
drivers/phy/xilinx/phy-zynqmp.c
··· 20 20 #include <linux/of.h> 21 21 #include <linux/phy/phy.h> 22 22 #include <linux/platform_device.h> 23 + #include <linux/pm_runtime.h> 23 24 #include <linux/slab.h> 24 25 25 26 #include <dt-bindings/phy/phy.h> ··· 821 820 * Power Management 822 821 */ 823 822 824 - static int __maybe_unused xpsgtr_suspend(struct device *dev) 823 + static int xpsgtr_runtime_suspend(struct device *dev) 825 824 { 826 825 struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev); 827 826 unsigned int i; ··· 836 835 return 0; 837 836 } 838 837 839 - static int __maybe_unused xpsgtr_resume(struct device *dev) 838 + static int xpsgtr_runtime_resume(struct device *dev) 840 839 { 841 840 struct xpsgtr_dev *gtr_dev = dev_get_drvdata(dev); 842 841 unsigned int icm_cfg0, icm_cfg1; ··· 877 876 return err; 878 877 } 879 878 880 - static const struct dev_pm_ops xpsgtr_pm_ops = { 881 - SET_SYSTEM_SLEEP_PM_OPS(xpsgtr_suspend, xpsgtr_resume) 882 - }; 883 - 879 + static DEFINE_RUNTIME_DEV_PM_OPS(xpsgtr_pm_ops, xpsgtr_runtime_suspend, 880 + xpsgtr_runtime_resume, NULL); 884 881 /* 885 882 * Probe & Platform Driver 886 883 */ ··· 1004 1005 ret = PTR_ERR(provider); 1005 1006 goto err_clk_put; 1006 1007 } 1008 + 1009 + pm_runtime_set_active(gtr_dev->dev); 1010 + pm_runtime_enable(gtr_dev->dev); 1011 + 1012 + ret = pm_runtime_resume_and_get(gtr_dev->dev); 1013 + if (ret < 0) { 1014 + pm_runtime_disable(gtr_dev->dev); 1015 + goto err_clk_put; 1016 + } 1017 + 1007 1018 return 0; 1008 1019 1009 1020 err_clk_put: ··· 1021 1012 clk_disable_unprepare(gtr_dev->clk[i]); 1022 1013 1023 1014 return ret; 1015 + } 1016 + 1017 + static int xpsgtr_remove(struct platform_device *pdev) 1018 + { 1019 + struct xpsgtr_dev *gtr_dev = platform_get_drvdata(pdev); 1020 + 1021 + pm_runtime_disable(gtr_dev->dev); 1022 + pm_runtime_put_noidle(gtr_dev->dev); 1023 + pm_runtime_set_suspended(gtr_dev->dev); 1024 + 1025 + return 0; 1024 1026 } 1025 1027 1026 1028 static const struct of_device_id xpsgtr_of_match[] = { ··· 1043 1023 1044 1024 static struct platform_driver xpsgtr_driver = { 1045 1025 .probe = xpsgtr_probe, 1026 + .remove = xpsgtr_remove, 1046 1027 .driver = { 1047 1028 .name = "xilinx-psgtr", 1048 1029 .of_match_table = xpsgtr_of_match, 1049 - .pm = &xpsgtr_pm_ops, 1030 + .pm = pm_ptr(&xpsgtr_pm_ops), 1050 1031 }, 1051 1032 }; 1052 1033