From patchwork Fri Apr 15 13:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 8851081 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4FED3BF29F for ; Fri, 15 Apr 2016 13:50:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D3E6202F0 for ; Fri, 15 Apr 2016 13:50:35 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 6121120274 for ; Fri, 15 Apr 2016 13:50:34 +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 1ar48n-0005Uq-5w; Fri, 15 Apr 2016 13:50:33 +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 1ar48l-0005Ue-VR for tpmdd-devel@lists.sourceforge.net; Fri, 15 Apr 2016 13:50:31 +0000 X-ACL-Warn: Received: from e34.co.us.ibm.com ([32.97.110.152]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1ar48k-0000do-2t for tpmdd-devel@lists.sourceforge.net; Fri, 15 Apr 2016 13:50:31 +0000 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Apr 2016 07:50:23 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Apr 2016 07:50:21 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: stefanb@linux.vnet.ibm.com X-IBM-RcptTo: tpmdd-devel@lists.sourceforge.net Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 4DD16C40001 for ; Fri, 15 Apr 2016 07:38:29 -0600 (MDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3FDoKZ938207504 for ; Fri, 15 Apr 2016 13:50:20 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3FDiB6o007466 for ; Fri, 15 Apr 2016 09:44:12 -0400 Received: from dhcp-9-2-140-43.watson.ibm.com (dhcp-9-2-140-54.watson.ibm.com [9.2.140.54]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3FDiA1Y007438; Fri, 15 Apr 2016 09:44:11 -0400 From: Stefan Berger To: tpmdd-devel@lists.sourceforge.net Date: Fri, 15 Apr 2016 09:50:13 -0400 Message-Id: <1460728216-19563-3-git-send-email-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1460728216-19563-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1460728216-19563-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041513-0017-0000-0000-00002301712C X-Spam-Score: -1.0 (-) X-Headers-End: 1ar48k-0000do-2t Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [tpmdd-devel] [PATCH v10 2/5] tpm: Introduce TPM_CHIP_FLAG_VIRTUAL 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-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, HK_RANDOM_ENVFROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce TPM_CHIP_FLAG_VIRTUAL to be used when the chip device has no parent device. Prevent sysfs entries requiring a parent device from being created. Signed-off-by: Stefan Berger Reviewed-by: Jason Gunthorpe --- drivers/char/tpm/tpm-chip.c | 7 +++++-- drivers/char/tpm/tpm.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 7e2c9cf..a12db8e 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -181,6 +181,9 @@ struct tpm_chip *tpm_chip_alloc(struct device *dev, if (rc) goto out; + if (!dev) + chip->flags |= TPM_CHIP_FLAG_VIRTUAL; + cdev_init(&chip->cdev, &tpm_fops); chip->cdev.owner = THIS_MODULE; chip->cdev.kobj.parent = &chip->dev.kobj; @@ -297,7 +300,7 @@ static void tpm_del_legacy_sysfs(struct tpm_chip *chip) { struct attribute **i; - if (chip->flags & TPM_CHIP_FLAG_TPM2) + if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) return; sysfs_remove_link(&chip->dev.parent->kobj, "ppi"); @@ -315,7 +318,7 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip) struct attribute **i; int rc; - if (chip->flags & TPM_CHIP_FLAG_TPM2) + if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) return 0; rc = __compat_only_sysfs_link_entry_to_kobj( diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 508e8e0..ff4e53c 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -138,6 +138,7 @@ enum tpm_chip_flags { TPM_CHIP_FLAG_REGISTERED = BIT(0), TPM_CHIP_FLAG_TPM2 = BIT(1), TPM_CHIP_FLAG_IRQ = BIT(2), + TPM_CHIP_FLAG_VIRTUAL = BIT(3), }; struct tpm_chip {