From patchwork Fri May 12 23:38:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman X-Patchwork-Id: 761879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3wPmdg2Zvtz9s7w for ; Sat, 13 May 2017 09:39:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d9K9B-0008St-VK; Fri, 12 May 2017 23:38:57 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d9K9A-0008Sg-Ov for tpmdd-devel@lists.sourceforge.net; Fri, 12 May 2017 23:38:56 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of google.com designates 74.125.83.53 as permitted sender) client-ip=74.125.83.53; envelope-from=joshz@google.com; helo=mail-pg0-f53.google.com; Received: from mail-pg0-f53.google.com ([74.125.83.53]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1d9K98-0001cU-P1 for tpmdd-devel@lists.sourceforge.net; Fri, 12 May 2017 23:38:56 +0000 Received: by mail-pg0-f53.google.com with SMTP id u187so36508854pgb.0 for ; Fri, 12 May 2017 16:38:54 -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=S5ZXM2UwQ10SiDpO3K6pREbS8PXwJ3fmq+IcchvKA40=; b=uQOvDVR4l3H/NTmkyQGYbD3xDHIxmBqYDjufi9vAYSaLg73wjf4o/hfmhZHuJndrqc AL0n2o9vvBc8MUcZ8WEOuNDgS+ELFBt7Irv2WUjhcowYOs4CJHzcw8GayEIUUbPxJT7L K9I1GAxQmc9ONB3H5Ezktwpo1I53dp45uXYow6mQSuBwQQwUAxzJV48n9YtpyfiGqGnn sQ45khHAWmd8+C+yEVRWh62Q902PD1LYcT4a2B2uy5MFbYl0kg83XHxy2vJatGXXxR5L KEdaJC3+MKZCUQR0Csrb1OJSZqyHBqcNsTAOu76ASiqbjFoa47PWQJazMadXUySe1zOS VqDw== X-Gm-Message-State: AODbwcDn95yHuadx0gwUC+I5AwNJHdgmc92ZeaJbEukNMQQAWjx3yQqX LKQZ29efr7PpzgMj X-Received: by 10.99.167.71 with SMTP id w7mr7087252pgo.138.1494632328954; Fri, 12 May 2017 16:38:48 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.119.30.20]) by smtp.googlemail.com with ESMTPSA id h71sm8167020pfe.85.2017.05.12.16.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 May 2017 16:38:48 -0700 (PDT) From: Josh Zimmerman To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Date: Fri, 12 May 2017 16:38:31 -0700 Message-Id: <20170512233831.25449-1-joshz@google.com> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog X-Spam-Score: -1.1 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.83.53 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [74.125.83.53 listed in dnsbl.sorbs.net] X-Headers-End: 1d9K98-0001cU-P1 Cc: tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [PATCH v2] 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 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.) Signed-off-by: Josh Zimmerman --- 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. */