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: 9727691 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 2803960231 for ; Mon, 15 May 2017 17:34:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 137A828991 for ; Mon, 15 May 2017 17:34:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 085622899F; Mon, 15 May 2017 17:34:57 +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.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_HI 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 76CEC289A0 for ; Mon, 15 May 2017 17:34:56 +0000 (UTC) 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-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 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. 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);