From patchwork Thu Jun 1 16:33:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman X-Patchwork-Id: 769818 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 3wdtGL5qjbz9ryv for ; Fri, 2 Jun 2017 02:34:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.b="a2G17qfS"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sf.net header.i=@sf.net header.b="ggLkuVdR"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="g21u1D/Q"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dGT37-0004WR-3r; Thu, 01 Jun 2017 16:34:13 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dGT34-0004WI-Ve for tpmdd-devel@lists.sourceforge.net; Thu, 01 Jun 2017 16:34:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From:MIME-Version; bh=XyVwhVT+OqIAt61cVqQFpaMuNO4XOk/ebsbmnS50VoY=; b=a2G17qfSSPvH81v/OEatWlbEKpk9nfY8KkyBHiM3ygx4BmUQzSezusBoa+2vD56Es2fD/5Ndg+DocBYZruJfGyIlgN4/JfI6OLd+Zldt3OeryIZC6p51rpshDrVOCXRC5xZmU2Rd03pnGmfG9ZOGfc6om9pOUWyQHs9ku4ACPbI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From:MIME-Version; bh=XyVwhVT+OqIAt61cVqQFpaMuNO4XOk/ebsbmnS50VoY=; b=ggLkuVdR2f9QEo4fcH7sbzFpB8Z5uRWF7m4ksg4G6eWTifcNC1sNABXXVn9r/MdeyJHef+6nRIAl3WwG45PlHHH/HBFK6srAMOanNCeUWaFQgBueOJkMFPn6WGGWZma0v8hb5X/Vw4r9Q1LHI036Td3WL69r6aNQ4JHE3iqul3Q=; Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of google.com designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; envelope-from=joshz@google.com; helo=mail-qk0-f179.google.com; Received: from mail-qk0-f179.google.com ([209.85.220.179]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dGT34-0002m7-21 for tpmdd-devel@lists.sourceforge.net; Thu, 01 Jun 2017 16:34:10 +0000 Received: by mail-qk0-f179.google.com with SMTP id d14so40712064qkb.1 for ; Thu, 01 Jun 2017 09:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=XyVwhVT+OqIAt61cVqQFpaMuNO4XOk/ebsbmnS50VoY=; b=g21u1D/QMdjJMR0zyODgHLmSTEN7fFRZ/CohJ9pW/3Qb/zj3BF1SkCghZLmOoHDTwu hBWGjVDkHLiZVdc04u9ccnRFKxtONhuMPnzNHPiM2FgBugv5pxwGklQ40ITES1lh2xs+ iai3tFV2wCefmufeFcgwEHn2E07RnrvjSdC7I/2uwAqWH4EgXO655+Gjhz5W7z5TiMMX vsJ+zaaeAfc27LSjOdzHBqq2luKSA5WVgc8kSOo1xAvmP7GLR8MZWFj6PxRYmXkZXnsX U9XatRDcqQN1t0wLqwWhaRGrTFviLvaAWGYgEU4tQKPlHzM0LkBBEEP2wq6c/m+6LaG0 /JjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XyVwhVT+OqIAt61cVqQFpaMuNO4XOk/ebsbmnS50VoY=; b=rDJdzNX5mpSmA7ufegtOhg6CtdwtvrHi5ghYKj84cYgzBsnKhwpDBneawGQMeOvS// l2SToz4EL31MEmfvDYCzOeFAOThnLwEkDQAHKo3Ksh9dd8dZzAXQC3bRbvg6+B+SYnV1 hUIn7+80F99bPL7fW0Z24rZzIEo8Fa+d2kvBu/Y/QgCywbOqVRKvTKV5dWOdejzy2IaV gNfqcPiY2w46L9vvoceaQmL8RxS1ChOcAymTUpEIvT+hGdImB4N9xO84vGvzWFxGuUNY SGviceDOCZzuv2i0fdJe5kYIHjXEnFMwEqB/qTwEPeJZsad8RDL94i+1IaNZ9p1kZ/su 3UCQ== X-Gm-Message-State: AODbwcAnOaEnIQfG8f+3Kpwf5WV0kPe/lnV86eezYFvNxk29+TAONFNK RLAC6k3MEEOanQaq0RsC2YgLPmKBqkJw6r9ylw== X-Received: by 10.55.166.137 with SMTP id p131mr2817671qke.132.1496334844229; Thu, 01 Jun 2017 09:34:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.82.180 with HTTP; Thu, 1 Jun 2017 09:33:43 -0700 (PDT) From: Josh Zimmerman Date: Thu, 1 Jun 2017 09:33:43 -0700 Message-ID: To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, jmorris@namei.org 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 [209.85.220.179 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 [209.85.220.179 listed in dnsbl.sorbs.net] X-Headers-End: 1dGT34-0002m7-21 Subject: [tpmdd-devel] [PATCH v5 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: , 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(-) 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); 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