Skip to content

Commit 24efcdf

Browse files
arndbjwrdegoede
authored andcommitted
platform/x86/amd: pmc: remove CONFIG_SUSPEND checks
The amd_pmc_write_stb() function was previously hidden in an ifdef to avoid a warning when CONFIG_SUSPEND is disabled, but now there is an additional caller: drivers/platform/x86/amd/pmc.c: In function 'amd_pmc_stb_debugfs_open_v2': drivers/platform/x86/amd/pmc.c:256:8: error: implicit declaration of function 'amd_pmc_write_stb'; did you mean 'amd_pmc_read_stb'? [-Werror=implicit-function-declaration] 256 | ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC); | ^~~~~~~~~~~~~~~~~ | amd_pmc_read_stb There is now an easier way to handle this using DEFINE_SIMPLE_DEV_PM_OPS() to replace all the #ifdefs, letting gcc drop any of the unused functions silently. Fixes: b0d4bb9 ("platform/x86/amd: pmc: Write dummy postcode into the STB DRAM") Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Hans de Goede <[email protected]>
1 parent fe15c26 commit 24efcdf

File tree

1 file changed

+9
-21
lines changed
  • drivers/platform/x86/amd

1 file changed

+9
-21
lines changed

drivers/platform/x86/amd/pmc.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");
171171
static struct amd_pmc_dev pmc;
172172
static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
173173
static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
174-
#ifdef CONFIG_SUSPEND
175174
static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
176-
#endif
177175

178176
static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
179177
{
@@ -386,7 +384,6 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table
386384
return 0;
387385
}
388386

389-
#ifdef CONFIG_SUSPEND
390387
static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
391388
{
392389
struct smu_metrics table;
@@ -400,7 +397,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
400397
dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n",
401398
table.timein_s0i3_lastcapture);
402399
}
403-
#endif
404400

405401
static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
406402
{
@@ -673,7 +669,6 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg,
673669
return rc;
674670
}
675671

676-
#ifdef CONFIG_SUSPEND
677672
static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev)
678673
{
679674
switch (dev->cpu_id) {
@@ -861,9 +856,7 @@ static int __maybe_unused amd_pmc_suspend_handler(struct device *dev)
861856
return 0;
862857
}
863858

864-
static SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);
865-
866-
#endif
859+
static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);
867860

868861
static const struct pci_device_id pmc_pci_ids[] = {
869862
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },
@@ -905,7 +898,6 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
905898
return 0;
906899
}
907900

908-
#ifdef CONFIG_SUSPEND
909901
static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
910902
{
911903
int err;
@@ -926,7 +918,6 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)
926918

927919
return 0;
928920
}
929-
#endif
930921

931922
static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf)
932923
{
@@ -1017,11 +1008,11 @@ static int amd_pmc_probe(struct platform_device *pdev)
10171008
}
10181009

10191010
platform_set_drvdata(pdev, dev);
1020-
#ifdef CONFIG_SUSPEND
1021-
err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
1022-
if (err)
1023-
dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
1024-
#endif
1011+
if (IS_ENABLED(CONFIG_SUSPEND)) {
1012+
err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
1013+
if (err)
1014+
dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
1015+
}
10251016

10261017
amd_pmc_dbgfs_register(dev);
10271018
return 0;
@@ -1035,9 +1026,8 @@ static int amd_pmc_remove(struct platform_device *pdev)
10351026
{
10361027
struct amd_pmc_dev *dev = platform_get_drvdata(pdev);
10371028

1038-
#ifdef CONFIG_SUSPEND
1039-
acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
1040-
#endif
1029+
if (IS_ENABLED(CONFIG_SUSPEND))
1030+
acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
10411031
amd_pmc_dbgfs_unregister(dev);
10421032
pci_dev_put(dev->rdev);
10431033
mutex_destroy(&dev->lock);
@@ -1061,9 +1051,7 @@ static struct platform_driver amd_pmc_driver = {
10611051
.name = "amd_pmc",
10621052
.acpi_match_table = amd_pmc_acpi_ids,
10631053
.dev_groups = pmc_groups,
1064-
#ifdef CONFIG_SUSPEND
1065-
.pm = &amd_pmc_pm,
1066-
#endif
1054+
.pm = pm_sleep_ptr(&amd_pmc_pm),
10671055
},
10681056
.probe = amd_pmc_probe,
10691057
.remove = amd_pmc_remove,

0 commit comments

Comments
 (0)