From patchwork Fri Jun 16 17:25:31 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: 776880 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 3wq6hy0t9zz9sDF for ; Sat, 17 Jun 2017 03:25:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.b="PZ7gw+U/"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.b="laToeAIO"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sf.net header.i=@sf.net header.b="ADeI7eia"; dkim=neutral (0-bit key) header.d=google.com header.i=@google.com header.b="bDe6dQta"; 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=VE1xjkl0W+kQc5ovUsjsKTverWlHlzhaARMDM/q4rUs=; b=PZ7gw+U//QZHMd/0YJzZcrBb0tNG7qRKzg6SBj20NS7CpuApiaLfXVFwXGCvz9N1cfQKioGSBHxHgpbnvC5q/dmcSV+HQuSDC+gHEviNtXj1GtaBiclqFkV2Lp6/l8DsRiRn90vOPRtdav1S3JGUCx0h3Zws4abScJn8CAOPcpM=; 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 1dLv0G-0005Lw-4d; Fri, 16 Jun 2017 17:25:48 +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 1dLv0E-0005Lp-ON for tpmdd-devel@lists.sourceforge.net; Fri, 16 Jun 2017 17:25:46 +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=e0LIp2TAfj0DNrsdIiz/85z9IwCvroT8l6EHdZgvKio=; b=laToeAIOhIbsnpmgh94914XUhnPWWQjV+CONNWTyDbhYsgg+3982JjsFXq+zG7nX/36am8uNy4AIKgbhqt0MHxhlOukJqt+dkYzkUTiILtXWT2AUfDgnArrQAm8E0gCtlozC6SmkfrU98LXzUIleiNFVZNK22zdYY3eChHvKyL8=; 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=e0LIp2TAfj0DNrsdIiz/85z9IwCvroT8l6EHdZgvKio=; b=ADeI7eiafvlnwxCEGnZU8eI+bdXxhTON6fWheAYnNrAhwV9TaoWCPYoUovjagrHpSnpKbO/trbIvIx3fWosiWfZ9n1PJL1G+ZLV20Gs8dUt8PEFU+9xsxoyZHPtSe9KJ6IjY1F0NF4lUfICZ+lksePecQnn/1wsNOx987Z449Pk=; Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of google.com designates 209.85.192.176 as permitted sender) client-ip=209.85.192.176; envelope-from=joshz@google.com; helo=mail-pf0-f176.google.com; Received: from mail-pf0-f176.google.com ([209.85.192.176]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dLv0C-0002fd-Of for tpmdd-devel@lists.sourceforge.net; Fri, 16 Jun 2017 17:25:46 +0000 Received: by mail-pf0-f176.google.com with SMTP id x63so25203465pff.3 for ; Fri, 16 Jun 2017 10:25:44 -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=e0LIp2TAfj0DNrsdIiz/85z9IwCvroT8l6EHdZgvKio=; b=bDe6dQtagcpFXoD8oyfJHcWSsBfKyxuJBvX2KVzHpKlgf9aha5qd4uYHVQ49gscQi5 rIQewc3kSlWJnnApW32Z7Q/ZoSzUXv5r3clM90QbV3rDcF6vGPC7ZKCiXfvHP/1tQgUZ 95fKhurZIt81lv8bc9QovG2IM+HJoLhsxnQeg6sreUZfkgLtLeYMBJi/H1vosPzNHZNd u3q5ixSvoBqB6Pce3X3afWcSCyPiNTEqzRWKkgCuhRjd3AoDyYrF6ICjyXr1wsxFJMqh X1G5ARA7DfH6SZU2Ru8UMP9DIAs9hXGyOLPE/WUDzhr7BdPz7UQWdjbdM+MBTRajP9JJ 2y+Q== 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=e0LIp2TAfj0DNrsdIiz/85z9IwCvroT8l6EHdZgvKio=; b=Zvmyb2no5bxzielflRqHjhEPS32ZL3OroWZHwuv+8En1nCLd/ZwZ0wK4YesOfVNu0p 0q/jP/hAa+I6gzYOODVi8hQAPkjkuj5FIWqEkEYeEsp9CpO4/gT0y6nWyimZLQXvlhd0 sNfMb6CuhG2d6ZWXz75jr6DZtzwyZSZyqz7SWkXmaInJanJh/NRI2aloP+AnFC6ylBZy ujiWkcF6QY+hX83ZKYGQvwQlIMZuGjXfqPKStH8A/OsTA5Wgi534GBxpe7EdfpYBTRDP yMOTeU7aI8mgDUMSVpi6wSmt00liZgIxmrFKvtYpAaZk0DGPcxexIzj+aXOnyZ3K/5fT OsVA== X-Gm-Message-State: AKS2vOygnEk+vMFPdKPWmpIxJP2ZBbDiurrvGTOFUt+6wwEzDgPtxpxl eaKQfDZ+JmrAB67K X-Received: by 10.84.224.207 with SMTP id k15mr8751664pln.15.1497633939007; Fri, 16 Jun 2017 10:25:39 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.66.174.26]) by smtp.googlemail.com with ESMTPSA id l2sm5823733pfg.6.2017.06.16.10.25.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 10:25:37 -0700 (PDT) To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, jmorris@namei.org Date: Fri, 16 Jun 2017 10:25:31 -0700 Message-Id: <20170616172531.28464-2-joshz@google.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170616172531.28464-1-joshz@google.com> References: <20170616172531.28464-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 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.176 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: 1dLv0C-0002fd-Of Subject: [tpmdd-devel] [PATCH v6 2/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 ----- 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. --- 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 6bb60fb6a30b..9f426954681e 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);