diff options
author | Peter Huewe <peterhuewe@gmx.de> | 2015-03-16 17:26:21 -0400 |
---|---|---|
committer | Peter Huewe <peterhuewe@gmx.de> | 2015-03-18 17:43:08 -0400 |
commit | 6b37729bd184fdd44f144c6cc4951b06b55bcf4b (patch) | |
tree | 0ead610ac95b4ea1b90def25a8da2998254c0e1b | |
parent | ce93b4b086b6497bb5809ba706dd9caa39cadbbe (diff) |
tpm/tpm_infineon: Use struct dev_pm_ops for power management
Make the tpm_infineon driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct pnp_driver.
This allows the driver to use tpm_pm_suspend() as its suspend
callback directly, so we can remove the duplicated savestate code.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
-rw-r--r-- | drivers/char/tpm/tpm_infineon.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index 6d492132ad2b..922f60e1e0a0 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c | |||
@@ -591,27 +591,8 @@ static void tpm_inf_pnp_remove(struct pnp_dev *dev) | |||
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | static int tpm_inf_pnp_suspend(struct pnp_dev *dev, pm_message_t pm_state) | 594 | #ifdef CONFIG_PM_SLEEP |
595 | { | 595 | static int tpm_inf_resume(struct device *dev) |
596 | struct tpm_chip *chip = pnp_get_drvdata(dev); | ||
597 | int rc; | ||
598 | if (chip) { | ||
599 | u8 savestate[] = { | ||
600 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | ||
601 | 0, 0, 0, 10, /* blob length (in bytes) */ | ||
602 | 0, 0, 0, 152 /* TPM_ORD_SaveState */ | ||
603 | }; | ||
604 | dev_info(&dev->dev, "saving TPM state\n"); | ||
605 | rc = tpm_inf_send(chip, savestate, sizeof(savestate)); | ||
606 | if (rc < 0) { | ||
607 | dev_err(&dev->dev, "error while saving TPM state\n"); | ||
608 | return rc; | ||
609 | } | ||
610 | } | ||
611 | return 0; | ||
612 | } | ||
613 | |||
614 | static int tpm_inf_pnp_resume(struct pnp_dev *dev) | ||
615 | { | 596 | { |
616 | /* Re-configure TPM after suspending */ | 597 | /* Re-configure TPM after suspending */ |
617 | tpm_config_out(ENABLE_REGISTER_PAIR, TPM_INF_ADDR); | 598 | tpm_config_out(ENABLE_REGISTER_PAIR, TPM_INF_ADDR); |
@@ -625,16 +606,19 @@ static int tpm_inf_pnp_resume(struct pnp_dev *dev) | |||
625 | tpm_config_out(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); | 606 | tpm_config_out(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); |
626 | /* disable RESET, LP and IRQC */ | 607 | /* disable RESET, LP and IRQC */ |
627 | tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); | 608 | tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); |
628 | return tpm_pm_resume(&dev->dev); | 609 | return tpm_pm_resume(dev); |
629 | } | 610 | } |
611 | #endif | ||
612 | static SIMPLE_DEV_PM_OPS(tpm_inf_pm, tpm_pm_suspend, tpm_inf_resume); | ||
630 | 613 | ||
631 | static struct pnp_driver tpm_inf_pnp_driver = { | 614 | static struct pnp_driver tpm_inf_pnp_driver = { |
632 | .name = "tpm_inf_pnp", | 615 | .name = "tpm_inf_pnp", |
633 | .id_table = tpm_inf_pnp_tbl, | 616 | .id_table = tpm_inf_pnp_tbl, |
634 | .probe = tpm_inf_pnp_probe, | 617 | .probe = tpm_inf_pnp_probe, |
635 | .suspend = tpm_inf_pnp_suspend, | 618 | .remove = tpm_inf_pnp_remove, |
636 | .resume = tpm_inf_pnp_resume, | 619 | .driver = { |
637 | .remove = tpm_inf_pnp_remove | 620 | .pm = &tpm_inf_pm, |
621 | } | ||
638 | }; | 622 | }; |
639 | 623 | ||
640 | static int __init init_inf(void) | 624 | static int __init init_inf(void) |