From patchwork Mon Mar 16 22:21:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Huewe X-Patchwork-Id: 6026191 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 493F5BF90F for ; Mon, 16 Mar 2015 22:16:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BE622041D for ; Mon, 16 Mar 2015 22:16:21 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D5D92041B for ; Mon, 16 Mar 2015 22:16:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YXdJ4-0000Oq-DZ; Mon, 16 Mar 2015 22:16:18 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YXdJ3-0000Oh-98 for tpmdd-devel@lists.sourceforge.net; Mon, 16 Mar 2015 22:16:17 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmx.de designates 212.227.17.21 as permitted sender) client-ip=212.227.17.21; envelope-from=peterhuewe@gmx.de; helo=mout.gmx.net; Received: from mout.gmx.net ([212.227.17.21]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1YXdJ1-00062B-VP for tpmdd-devel@lists.sourceforge.net; Mon, 16 Mar 2015 22:16:17 +0000 Received: from localhost.localdomain ([84.56.20.217]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0M3u86-1ZNwm41fH8-00rbf0; Mon, 16 Mar 2015 23:16:06 +0100 From: Peter Huewe To: Peter Huewe , Marcel Selhorst Date: Mon, 16 Mar 2015 23:21:24 +0100 Message-Id: <1426544484-31863-1-git-send-email-peterhuewe@gmx.de> X-Mailer: git-send-email 2.0.5 X-Provags-ID: V03:K0:ZdN7QlwkCS1X+bvgczvxsCPzgK8jXU8SwpSudDf2iJgw8OnQ5lP RiO9ysY76jmrT4J5WuCOZBakeDUdrYEPAFljK6WbCrN4I+0usvMvRQPvckPtNH4r7ylfkcI bzIpgGdh3roQEmXwF9xbadtdWvP8PXogzKK4i8NxwDJ4vs76qigTl7fe5UtfsL81mjCGxnk 8CtIdP3VR2eptttSn8SeA== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: -0.8 (/) X-Headers-End: 1YXdJ1-00062B-VP Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [tpmdd-devel] [PATCH] tpm/tpm_infineon: Use struct dev_pm_ops for power management X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HK_RANDOM_ENVFROM, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Marcel Selhorst --- drivers/char/tpm/tpm_infineon.c | 34 +++++++++------------------------- 1 file 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) } } -static int tpm_inf_pnp_suspend(struct pnp_dev *dev, pm_message_t pm_state) -{ - struct tpm_chip *chip = pnp_get_drvdata(dev); - int rc; - if (chip) { - u8 savestate[] = { - 0, 193, /* TPM_TAG_RQU_COMMAND */ - 0, 0, 0, 10, /* blob length (in bytes) */ - 0, 0, 0, 152 /* TPM_ORD_SaveState */ - }; - dev_info(&dev->dev, "saving TPM state\n"); - rc = tpm_inf_send(chip, savestate, sizeof(savestate)); - if (rc < 0) { - dev_err(&dev->dev, "error while saving TPM state\n"); - return rc; - } - } - return 0; -} - -static int tpm_inf_pnp_resume(struct pnp_dev *dev) +#ifdef CONFIG_PM_SLEEP +static int tpm_inf_resume(struct device *dev) { /* Re-configure TPM after suspending */ tpm_config_out(ENABLE_REGISTER_PAIR, TPM_INF_ADDR); @@ -625,16 +606,19 @@ static int tpm_inf_pnp_resume(struct pnp_dev *dev) tpm_config_out(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); /* disable RESET, LP and IRQC */ tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); - return tpm_pm_resume(&dev->dev); + return tpm_pm_resume(dev); } +#endif +static SIMPLE_DEV_PM_OPS(tpm_inf_pm, tpm_pm_suspend, tpm_inf_resume); static struct pnp_driver tpm_inf_pnp_driver = { .name = "tpm_inf_pnp", .id_table = tpm_inf_pnp_tbl, .probe = tpm_inf_pnp_probe, - .suspend = tpm_inf_pnp_suspend, - .resume = tpm_inf_pnp_resume, - .remove = tpm_inf_pnp_remove + .remove = tpm_inf_pnp_remove, + .driver = { + .pm = &tpm_inf_pm, + } }; static int __init init_inf(void)