Skip to content

Commit dc918c3

Browse files
committed
pinctrl: amd: Fix hibernation support with CONFIG_SUSPEND unset
After recent changes, pinctrl-amd will not support hibernation when CONFIG_HIBERNATION is set and CONFIG_SUSPEND isn't because it will not register amd_gpio_pm_ops then. Address this by restoring dependencies on CONFIG_PM_SLEEP where necessary for hibernation support. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent b841c1d commit dc918c3

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

drivers/pinctrl/pinctrl-amd.c

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -894,26 +894,7 @@ static void amd_gpio_irq_init(struct amd_gpio *gpio_dev)
894894
}
895895
}
896896

897-
#ifdef CONFIG_SUSPEND
898-
static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
899-
{
900-
const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
901-
902-
if (!pd)
903-
return false;
904-
905-
/*
906-
* Only restore the pin if it is actually in use by the kernel (or
907-
* by userspace).
908-
*/
909-
if (pd->mux_owner || pd->gpio_owner ||
910-
gpiochip_line_is_irq(&gpio_dev->gc, pin))
911-
return true;
912-
913-
return false;
914-
}
915-
916-
#ifdef CONFIG_ACPI
897+
#if defined(CONFIG_SUSPEND) && defined(CONFIG_ACPI)
917898
static void amd_gpio_check_pending(void)
918899
{
919900
struct amd_gpio *gpio_dev = pinctrl_dev;
@@ -936,8 +917,40 @@ static void amd_gpio_check_pending(void)
936917
static struct acpi_s2idle_dev_ops pinctrl_amd_s2idle_dev_ops = {
937918
.check = amd_gpio_check_pending,
938919
};
920+
921+
static void amd_gpio_register_s2idle_ops(void)
922+
{
923+
acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
924+
}
925+
926+
static void amd_gpio_unregister_s2idle_ops(void)
927+
{
928+
acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
929+
}
930+
#else
931+
static inline void amd_gpio_register_s2idle_ops(void) {}
932+
static inline void amd_gpio_unregister_s2idle_ops(void) {}
939933
#endif
940934

935+
#ifdef CONFIG_PM_SLEEP
936+
static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
937+
{
938+
const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
939+
940+
if (!pd)
941+
return false;
942+
943+
/*
944+
* Only restore the pin if it is actually in use by the kernel (or
945+
* by userspace).
946+
*/
947+
if (pd->mux_owner || pd->gpio_owner ||
948+
gpiochip_line_is_irq(&gpio_dev->gc, pin))
949+
return true;
950+
951+
return false;
952+
}
953+
941954
static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend)
942955
{
943956
struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
@@ -1213,9 +1226,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
12131226

12141227
platform_set_drvdata(pdev, gpio_dev);
12151228
acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
1216-
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
1217-
acpi_register_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
1218-
#endif
1229+
amd_gpio_register_s2idle_ops();
12191230

12201231
dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
12211232
return ret;
@@ -1234,9 +1245,7 @@ static void amd_gpio_remove(struct platform_device *pdev)
12341245

12351246
gpiochip_remove(&gpio_dev->gc);
12361247
acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev);
1237-
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
1238-
acpi_unregister_lps0_dev(&pinctrl_amd_s2idle_dev_ops);
1239-
#endif
1248+
amd_gpio_unregister_s2idle_ops();
12401249
}
12411250

12421251
#ifdef CONFIG_ACPI
@@ -1253,7 +1262,7 @@ static struct platform_driver amd_gpio_driver = {
12531262
.driver = {
12541263
.name = "amd_gpio",
12551264
.acpi_match_table = ACPI_PTR(amd_gpio_acpi_match),
1256-
#ifdef CONFIG_SUSPEND
1265+
#ifdef CONFIG_PM_SLEEP
12571266
.pm = &amd_gpio_pm_ops,
12581267
#endif
12591268
},

0 commit comments

Comments
 (0)