Skip to content

Commit ab17de6

Browse files
Evenxfgregkh
authored andcommitted
HID: intel_ish-hid: ipc: register more pm callbacks to support hibernation
commit ebeaa36 upstream. Current ISH driver only registers suspend/resume PM callbacks which don't support hibernation (suspend to disk). Basically after hiberation, the ISH can't resume properly and user may not see sensor events (for example: screen rotation may not work). User will not see a crash or panic or anything except the following message in log: hid-sensor-hub 001F:8086:22D8.0001: timeout waiting for response from ISHTP device So this patch adds support for S4/hiberbation to ISH by using the SIMPLE_DEV_PM_OPS() MACRO instead of struct dev_pm_ops directly. The suspend and resume functions will now be used for both suspend to RAM and hibernation. If power management is disabled, SIMPLE_DEV_PM_OPS will do nothing, the suspend and resume related functions won't be used, so mark them as __maybe_unused to clarify that this is the intended behavior, and remove #ifdefs for power management. Cc: [email protected] Signed-off-by: Even Xu <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e3e6bd6 commit ab17de6

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ static void ish_remove(struct pci_dev *pdev)
204204
kfree(ishtp_dev);
205205
}
206206

207-
#ifdef CONFIG_PM
208-
static struct device *ish_resume_device;
207+
static struct device __maybe_unused *ish_resume_device;
209208

210209
/* 50ms to get resume response */
211210
#define WAIT_FOR_RESUME_ACK_MS 50
@@ -219,7 +218,7 @@ static struct device *ish_resume_device;
219218
* in that case a simple resume message is enough, others we need
220219
* a reset sequence.
221220
*/
222-
static void ish_resume_handler(struct work_struct *work)
221+
static void __maybe_unused ish_resume_handler(struct work_struct *work)
223222
{
224223
struct pci_dev *pdev = to_pci_dev(ish_resume_device);
225224
struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -261,7 +260,7 @@ static void ish_resume_handler(struct work_struct *work)
261260
*
262261
* Return: 0 to the pm core
263262
*/
264-
static int ish_suspend(struct device *device)
263+
static int __maybe_unused ish_suspend(struct device *device)
265264
{
266265
struct pci_dev *pdev = to_pci_dev(device);
267266
struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -287,7 +286,7 @@ static int ish_suspend(struct device *device)
287286
return 0;
288287
}
289288

290-
static DECLARE_WORK(resume_work, ish_resume_handler);
289+
static __maybe_unused DECLARE_WORK(resume_work, ish_resume_handler);
291290
/**
292291
* ish_resume() - ISH resume callback
293292
* @device: device pointer
@@ -296,7 +295,7 @@ static DECLARE_WORK(resume_work, ish_resume_handler);
296295
*
297296
* Return: 0 to the pm core
298297
*/
299-
static int ish_resume(struct device *device)
298+
static int __maybe_unused ish_resume(struct device *device)
300299
{
301300
struct pci_dev *pdev = to_pci_dev(device);
302301
struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -310,21 +309,14 @@ static int ish_resume(struct device *device)
310309
return 0;
311310
}
312311

313-
static const struct dev_pm_ops ish_pm_ops = {
314-
.suspend = ish_suspend,
315-
.resume = ish_resume,
316-
};
317-
#define ISHTP_ISH_PM_OPS (&ish_pm_ops)
318-
#else
319-
#define ISHTP_ISH_PM_OPS NULL
320-
#endif /* CONFIG_PM */
312+
static SIMPLE_DEV_PM_OPS(ish_pm_ops, ish_suspend, ish_resume);
321313

322314
static struct pci_driver ish_driver = {
323315
.name = KBUILD_MODNAME,
324316
.id_table = ish_pci_tbl,
325317
.probe = ish_probe,
326318
.remove = ish_remove,
327-
.driver.pm = ISHTP_ISH_PM_OPS,
319+
.driver.pm = &ish_pm_ops,
328320
};
329321

330322
module_pci_driver(ish_driver);

0 commit comments

Comments
 (0)