From patchwork Mon May 15 17:34:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman X-Patchwork-Id: 762660 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 3wRSQD4Nfxz9s2s for ; Tue, 16 May 2017 03:35:00 +1000 (AEST) 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 1dAJtW-0001AL-RE; Mon, 15 May 2017 17:34:54 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dAJtV-0001AF-8o for tpmdd-devel@lists.sourceforge.net; Mon, 15 May 2017 17:34:53 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of google.com designates 209.85.192.173 as permitted sender) client-ip=209.85.192.173; envelope-from=joshz@google.com; helo=mail-pf0-f173.google.com; Received: from mail-pf0-f173.google.com ([209.85.192.173]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dAJtU-0000hY-BO for tpmdd-devel@lists.sourceforge.net; Mon, 15 May 2017 17:34:53 +0000 Received: by mail-pf0-f173.google.com with SMTP id e193so66474706pfh.0 for ; Mon, 15 May 2017 10:34:52 -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=n/L/hBqxjPs8aH6JB7GgUxfa2GlHZDW/whzACqip8DY=; b=BZWjWmux5V2AS6uYj7lwISZL+Euj1TNCFjsp7nBvWqVmOLGZWic1lQzkS74BuXhzsP qxyFCpafJ3o7zdbTbjiCOi2VjNXS0Y/KG9eSz1N7kdfIXrweEtHryEQTXF5SgUg9vOZE qbL5oQOiu2b6joDhgaTo7r/9VCCAovJ0bY5senZFc3cVqi81MVRcFrIAffn1T/Y+WNLD p2R5EPcPuZLRQM0AxS8yV70Dm92jtlKeWvR0Qj7W8Su97lfjLLPZ6r6sOvEcpI9ehk+U X2o4vU3UCQMBf7u1sbS1NAa/v0sPCb3wJiofB6cuJRSQvy1vM2ZeQEtUKrpLa8j80EHu nnew== X-Gm-Message-State: AODbwcCFf9bVKo9f8drPkmK26MHNRXrmMoX+NczOGpFkxpiyhaNYBR+R VuP5EdaM2eIjyDYi X-Received: by 10.98.65.26 with SMTP id o26mr7578457pfa.228.1494869686495; Mon, 15 May 2017 10:34:46 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.119.30.20]) by smtp.googlemail.com with ESMTPSA id n85sm21726722pfi.101.2017.05.15.10.34.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 May 2017 10:34:45 -0700 (PDT) From: Josh Zimmerman To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Date: Mon, 15 May 2017 10:34:38 -0700 Message-Id: <20170515173438.13420-1-joshz@google.com> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog X-Spam-Score: -1.4 (-) 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 [209.85.192.173 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.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1dAJtU-0000hY-BO Cc: tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [PATCH v3] 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. Usage example: 'tpm: Issue a TPM2_Shutdown for TPM2 devices.' (see https://patchwork.kernel.org/patch/9724919/ for v2). Signed-off-by: Josh Zimmerman ----- v2: Add Signed-off-by. v3: Remove logically separate change. Acked-by: Greg Kroah-Hartman --- drivers/base/core.c | 5 +++++ include/linux/device.h | 2 ++ 2 files changed, 7 insertions(+) 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..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);