From patchwork Sun Jun 25 21:53:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman via tpmdd-devel X-Patchwork-Id: 780537 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 3wwmD33fClz9s4q for ; Mon, 26 Jun 2017 07:53:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.b="AW7VRxN4"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.b="MA+rK4ob"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sf.net header.i=@sf.net header.b="OwpLGmc9"; dkim=neutral (0-bit key) header.d=google.com header.i=@google.com header.b="DVO5PxfI"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References:In-Reply-To:Message-Id:Date:To; bh=so6GWRZVUSxXHI3Vhj2sU+3B5+f/dqt5TZfml1ndvCM=; b=AW7VRxN4nQ3BcAD/wzcdOcnwYzQ5nifYMGrfnZ6NVbh783Efb6e+o9Hdjv4H5Bpl1APUWNiRjb1z1K+gtak5TUSL7BnH9wvRm2q6G/MYh29jgVR2DryBN8kdp6okZ/S4b2TPkIUknXNFLRcu7nXFmM5Rwa4y8Gvyk93AptUO/Io=; 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 1dPFTa-0003lg-67; Sun, 25 Jun 2017 21:53:50 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dPFTY-0003la-QQ for tpmdd-devel@lists.sourceforge.net; Sun, 25 Jun 2017 21:53:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=R4UhTLWCBBhqSHXCYumqDJsCyYjlW3g8jD/9bi9uPTw=; b=MA+rK4obg1ANwyET74jm4X2PS8xPVN9tHc/bPxbCyQuI2IQH/V9DCFUplsUPa9PuqhJTC+H79djUHuJJ8UKcfteX9H4oniRYNaGs260hrZL+uAul5sPQlheBqVh9U/Bp4jZXvL07M9GGd6d9hZ4nCgumEuRlQcQMzrjGU3LrpF8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=R4UhTLWCBBhqSHXCYumqDJsCyYjlW3g8jD/9bi9uPTw=; b=OwpLGmc9+EDL7yIqGfPEWs5RMy2ayLiHUXTB3WkUUIr5qFu3G5BJhe8ji4quWKl0exemUtldSFSQQUcmfi9JLZk2di2siKOlANEhIBHi/gONf1Fsh2OpcqnQIldOjyUfj6GbsKTE1rKSeYwNn3h2n4HJ5z8Gk7MdFV0efxdgzws=; Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of google.com designates 74.125.83.49 as permitted sender) client-ip=74.125.83.49; envelope-from=joshz@google.com; helo=mail-pg0-f49.google.com; Received: from mail-pg0-f49.google.com ([74.125.83.49]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dPFTW-0000mc-RC for tpmdd-devel@lists.sourceforge.net; Sun, 25 Jun 2017 21:53:48 +0000 Received: by mail-pg0-f49.google.com with SMTP id f127so40183408pgc.0 for ; Sun, 25 Jun 2017 14:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R4UhTLWCBBhqSHXCYumqDJsCyYjlW3g8jD/9bi9uPTw=; b=DVO5PxfIbnzGY2YrRS4C96B8haWS72m+Z2JYDJBCUqYYKshaJermaZwWkICweoHdHW odATIFQgufA+nBwF/7QlFJ/pf/hTpBWjRNPam9jSW+rhl7+tRa/1nZwz6cxL5j36bQc6 vgopvtP0XBbPqFLutFY2r2A+IZRndPhaw5yGbhCsorepLhR1Ll161mhWDq6N3zykXh2A TkCU9mnvfcamcbPqMhJmOAOLdhvneWXgI3i3kYgYVCi5anZUDEQmEChaeYbNYCqv2dx9 9xFLQwusMStYQmIhK24GE/Nn0z0Zw/+s7haIMCQioHtBdzsKUKUEugG55P3ZiO9ktks0 k4QQ== 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:in-reply-to :references; bh=R4UhTLWCBBhqSHXCYumqDJsCyYjlW3g8jD/9bi9uPTw=; b=oiVoI1XPwu0uJBXrtTOEZ9/00v4FT02C329hr01nmbtxDTaL91t0UykNAiwKncP+Ew fJqeWDUX7SEGctynlHLWByH/DeJiabovyUCjxIYKIn7WQjafhUgFSmFOARnvoE/wts0b e71zLWZ7sIciX9T6PGEiYtLnAT30EFSYlgKO1fkuyIjFL6/+oATYoSFKmVIIq+Xrxwmc o4BQFIu1iO1IKpsymkMKufa2jnZ2tgJhLfkz84K4R5S0hHb0OySVvWDzi5UpSzncZ1i8 L9gENM0+EitT8Jri2YMHeH3XrOc649k2L+0PgY2pYncMQKMlb2wUrrvPrn2iz8VeG4GY Z0CQ== X-Gm-Message-State: AKS2vOyN+/f6R08AuJePUphFPbC8qAhy4/Xba6ngBFj5lnIWgq6L5iiv hKK8aOiPGlV23aff X-Received: by 10.99.50.135 with SMTP id y129mr18767451pgy.238.1498427621042; Sun, 25 Jun 2017 14:53:41 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.66.174.26]) by smtp.googlemail.com with ESMTPSA id s64sm25692458pfd.77.2017.06.25.14.53.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 14:53:40 -0700 (PDT) To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, jmorris@namei.org Date: Sun, 25 Jun 2017 14:53:23 -0700 Message-Id: <20170625215324.17467-2-joshz@google.com> X-Mailer: git-send-email 2.13.1.611.g7e3b11ae1-goog In-Reply-To: <20170625215324.17467-1-joshz@google.com> References: <20170625215324.17467-1-joshz@google.com> X-Spam-Score: -1.6 (-) 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 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.83.49 listed in list.dnswl.org] -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 X-Headers-End: 1dPFTW-0000mc-RC Subject: [tpmdd-devel] [PATCH v7 1/2] Add "shutdown" to "struct class". X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Josh Zimmerman via tpmdd-devel From: Josh Zimmerman via tpmdd-devel Reply-To: Josh Zimmerman 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. Signed-off-by: Josh Zimmerman Acked-by: Greg Kroah-Hartman Cc: stable@vger.kernel.org Fixes: 74d6b3ceaa17 ("tpm: fix suspend/resume paths for TPM 2.0") --- v2: Add Signed-off-by. v3: Remove logically separate change. v4: Add "acked-by" and "cc". v5: Execute only one of the class/bus/driver's shutdown functions. v6: (None in this patch, all were in the other of this patch series) v7: Re-ordered this patch and the other. drivers/base/core.c | 6 +++++- include/linux/device.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index bbecaf9293be..d3228cb7d12f 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2667,7 +2667,11 @@ void device_shutdown(void) pm_runtime_get_noresume(dev); pm_runtime_barrier(dev); - if (dev->bus && dev->bus->shutdown) { + if (dev->class && dev->class->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->class->shutdown(dev); + } else if (dev->bus && dev->bus->shutdown) { if (initcall_debug) dev_info(dev, "shutdown\n"); dev->bus->shutdown(dev); diff --git a/include/linux/device.h b/include/linux/device.h index 9ef518af5515..f240baac2001 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);