From patchwork Mon Feb 8 19:27:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 8254301 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BA2189F6DA for ; Mon, 8 Feb 2016 19:27:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1F37203DA for ; Mon, 8 Feb 2016 19:27:27 +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 D986F203B7 for ; Mon, 8 Feb 2016 19:27:26 +0000 (UTC) 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 1aSrT3-0001pt-3S; Mon, 08 Feb 2016 19:27:25 +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 1aSrT1-0001pn-R0 for tpmdd-devel@lists.sourceforge.net; Mon, 08 Feb 2016 19:27:23 +0000 X-ACL-Warn: Received: from e36.co.us.ibm.com ([32.97.110.154]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1aSrT0-0002QL-T2 for tpmdd-devel@lists.sourceforge.net; Mon, 08 Feb 2016 19:27:23 +0000 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Feb 2016 12:27:17 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Feb 2016 12:27:14 -0700 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: stefanb@linux.vnet.ibm.com X-IBM-RcptTo: tpmdd-devel@lists.sourceforge.net Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id B026B3E40030 for ; Mon, 8 Feb 2016 12:27:13 -0700 (MST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u18JRD8d26673372 for ; Mon, 8 Feb 2016 12:27:13 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u18JRCvq015919 for ; Mon, 8 Feb 2016 12:27:13 -0700 Received: from dhcp-9-2-140-43.watson.ibm.com (dhcp-9-2-140-28.watson.ibm.com [9.2.140.28]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u18JRBM8015717; Mon, 8 Feb 2016 12:27:12 -0700 From: Stefan Berger To: tpmdd-devel@lists.sourceforge.net Date: Mon, 8 Feb 2016 14:27:04 -0500 Message-Id: <1454959628-30582-2-git-send-email-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1454959628-30582-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1454959628-30582-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16020819-0021-0000-0000-000016DADB98 X-Spam-Score: -0.2 (/) X-Headers-End: 1aSrT0-0002QL-T2 Cc: dhowells@redhat.com, dwmw2@infradead.org Subject: [tpmdd-devel] [PATCH v5 1/5] Implement tpm_chip_free 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.2 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 Implement the public function tpm_chip_free to undo tpmm_chip_alloc. Signed-off-by: Stefan Berger --- drivers/char/tpm/tpm-chip.c | 14 ++++++++++---- drivers/char/tpm/tpm.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index fbd75c5..361cee8 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -59,6 +59,15 @@ struct tpm_chip *tpm_chip_find_get(int chip_num) } EXPORT_SYMBOL_GPL(tpm_chip_find_get); +void tpm_chip_free(struct tpm_chip *chip) +{ + spin_lock(&driver_lock); + clear_bit(chip->dev_num, dev_mask); + spin_unlock(&driver_lock); + kfree(chip); +} +EXPORT_SYMBOL_GPL(tpm_chip_free); + /** * tpm_dev_release() - free chip memory and the device number * @dev: the character device for the TPM chip @@ -69,10 +78,7 @@ static void tpm_dev_release(struct device *dev) { struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev); - spin_lock(&driver_lock); - clear_bit(chip->dev_num, dev_mask); - spin_unlock(&driver_lock); - kfree(chip); + tpm_chip_free(chip); } /** diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index a4257a3..440a167 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -515,6 +515,7 @@ extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long, struct tpm_chip *tpm_chip_find_get(int chip_num); extern struct tpm_chip *tpmm_chip_alloc(struct device *dev, const struct tpm_class_ops *ops); +extern void tpm_chip_free(struct tpm_chip *chip); extern int tpm_chip_register(struct tpm_chip *chip); extern void tpm_chip_unregister(struct tpm_chip *chip);