From patchwork Fri May 12 23:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman X-Patchwork-Id: 9724901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E7EEF601E7 for ; Fri, 12 May 2017 23:33:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1BAD28897 for ; Fri, 12 May 2017 23:33:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C56182889F; Fri, 12 May 2017 23:33:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 9CD9428897 for ; Fri, 12 May 2017 23:33:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d9K3Q-0006OT-8E; Fri, 12 May 2017 23:33:00 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d9K3O-0006O5-R1 for tpmdd-devel@lists.sourceforge.net; Fri, 12 May 2017 23:32:58 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of google.com designates 209.85.192.169 as permitted sender) client-ip=209.85.192.169; envelope-from=joshz@google.com; helo=mail-pf0-f169.google.com; Received: from mail-pf0-f169.google.com ([209.85.192.169]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1d9K3N-0007Ry-Ul for tpmdd-devel@lists.sourceforge.net; Fri, 12 May 2017 23:32:58 +0000 Received: by mail-pf0-f169.google.com with SMTP id e193so36717515pfh.0 for ; Fri, 12 May 2017 16:32:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=04FLAjtquDgcpqKkcLHqhir2F+TxX5wdNGBxbjq1Iww=; b=Aeh7Xcn2bKQrRoLs8tbtwT64nv0UfffF9VKeYvEOBLahAO6SrHx9iW9uGJW3UUwpFz tiwVMefL/KplrSn/cMQsscDQokeghYDkEeVqcmiJrV0hMWwid+NbwUTi8u/Sv+JR55e2 BPWn3FzAdHDqIAlvkGMUV2NzTObyBTQvNEC6KOrftEjgVvHBaYl2/lkZPh8Fft1EbisQ LXtdDudObNWXsCuNWrfl5U90UMg6p+Ypi6zaeB4IXc3LNeEZH245Bb56Ag20OlcYyNbn KuriO2ioPWfT4cwxcyTSwH2mZyZAOZi/nIwj6eANEI5pvz4Sd4M3+U3P/uYnuejh5rZO XzTg== X-Gm-Message-State: AODbwcDSoLJrq4wdwK2FVS925JJP6ymgLcE58MHmCqoxdjgZ8QdzBb5J gziSqq4SEakwM8iG X-Received: by 10.99.101.135 with SMTP id z129mr6786312pgb.66.1494631972093; Fri, 12 May 2017 16:32:52 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.119.30.20]) by smtp.googlemail.com with ESMTPSA id p13sm8375641pfl.52.2017.05.12.16.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 May 2017 16:32:51 -0700 (PDT) From: Josh Zimmerman To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Date: Fri, 12 May 2017 16:32:03 -0700 Message-Id: <20170512233203.23659-1-joshz@google.com> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog X-Headers-End: 1d9K3N-0007Ry-Ul Cc: tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [PATCH] Add "shutdown" to "struct class". 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-Virus-Scanned: ClamAV using ClamSMTP The TPM class has some common shutdown code that must be executed for all drivers. This adds some needed functionality for that. (In addition, update a comment to reflect an out-of-date path.) --- drivers/base/core.c | 5 +++++ include/linux/device.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index bbecaf9293be..5c1648875e94 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2667,6 +2667,11 @@ void device_shutdown(void) pm_runtime_get_noresume(dev); pm_runtime_barrier(dev); + if (dev->class && dev->class->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->class->shutdown(dev); + } if (dev->bus && dev->bus->shutdown) { if (initcall_debug) dev_info(dev, "shutdown\n"); diff --git a/include/linux/device.h b/include/linux/device.h index 9ef518af5515..a150f8d3b3f1 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -378,6 +378,7 @@ int subsys_virtual_register(struct bus_type *subsys, * @suspend: Used to put the device to sleep mode, usually to a low power * state. * @resume: Used to bring the device from the sleep mode. + * @shutdown: Called at shut-down time to quiesce the device. * @ns_type: Callbacks so sysfs can detemine namespaces. * @namespace: Namespace of the device belongs to this class. * @pm: The default device power management operations of this class. @@ -407,6 +408,7 @@ struct class { int (*suspend)(struct device *dev, pm_message_t state); int (*resume)(struct device *dev); + int (*shutdown)(struct device *dev); const struct kobj_ns_type_operations *ns_type; const void *(*namespace)(struct device *dev); @@ -1228,7 +1230,7 @@ static inline int devtmpfs_delete_node(struct device *dev) { return 0; } static inline int devtmpfs_mount(const char *mountpoint) { return 0; } #endif -/* drivers/base/power/shutdown.c */ +/* drivers/base/core.c */ extern void device_shutdown(void); /* debugging and troubleshooting/diagnostic helpers. */