From patchwork Thu Jan 14 16:01:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 8033891 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 C26F19F744 for ; Thu, 14 Jan 2016 16:02:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17F502042B for ; Thu, 14 Jan 2016 16:02:49 +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 6451820459 for ; Thu, 14 Jan 2016 16:02:42 +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 1aJkMC-0003jw-3Q; Thu, 14 Jan 2016 16:02:40 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aJkMA-0003jp-NK for tpmdd-devel@lists.sourceforge.net; Thu, 14 Jan 2016 16:02:38 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of us.ibm.com designates 129.33.205.208 as permitted sender) client-ip=129.33.205.208; envelope-from=stefanb@us.ibm.com; helo=e18.ny.us.ibm.com; Received: from e18.ny.us.ibm.com ([129.33.205.208]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1aJkM8-0003RN-QG for tpmdd-devel@lists.sourceforge.net; Thu, 14 Jan 2016 16:02:38 +0000 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Jan 2016 11:02:31 -0500 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Jan 2016 11:02:29 -0500 X-IBM-Helo: d01dlp01.pok.ibm.com X-IBM-MailFrom: stefanb@us.ibm.com X-IBM-RcptTo: tpmdd-devel@lists.sourceforge.net Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 9E75B38C8063 for ; Thu, 14 Jan 2016 11:02:27 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0EG2Rs524510684 for ; Thu, 14 Jan 2016 16:02:27 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0EG2Q5i016123 for ; Thu, 14 Jan 2016 11:02:26 -0500 Received: from sbct-3.watson.ibm.com (sbct-3.watson.ibm.com [9.2.141.158]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0EG21A1011081; Thu, 14 Jan 2016 11:02:02 -0500 From: Stefan Berger To: tpmdd-devel@lists.sourceforge.net Date: Thu, 14 Jan 2016 11:01:56 -0500 Message-Id: <1452787318-29610-3-git-send-email-stefanb@us.ibm.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1452787318-29610-1-git-send-email-stefanb@us.ibm.com> References: <1452787318-29610-1-git-send-email-stefanb@us.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16011416-0045-0000-0000-000003111BBE X-Spam-Score: -1.5 (-) X-Headers-End: 1aJkM8-0003RN-QG Cc: dhowells@redhat.com, dwmw2@infradead.org Subject: [tpmdd-devel] [RFC PATCH 2/4] Allow to provide a name pattern of the device 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=-6.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 From: Stefan Berger Introduce tpmm_chip_alloc_pattern that takes an additional parameter of the device's name pattern. All existing devices use "tpm%d". Signed-off-by: Stefan Berger --- drivers/char/tpm/tpm-chip.c | 28 ++++++++++++++++++++++++---- drivers/char/tpm/tpm.h | 6 +++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index f2da376..d98fcd9 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -76,17 +76,20 @@ static void tpm_dev_release(struct device *dev) } /** - * tpmm_chip_alloc() - allocate a new struct tpm_chip instance + * tpmm_chip_alloc_pattern() - allocate a new struct tpm_chip instance + * and use the given pattern for naming the device * @dev: device to which the chip is associated * @ops: struct tpm_class_ops instance + * @pattern: name pattern of the device * * Allocates a new struct tpm_chip instance and assigns a free * device number for it. Caller does not have to worry about * freeing the allocated resources. When the devices is removed * devres calls tpmm_chip_remove() to do the job. */ -struct tpm_chip *tpmm_chip_alloc(struct device *dev, - const struct tpm_class_ops *ops) +struct tpm_chip *tpmm_chip_alloc_pattern(struct device *dev, + const struct tpm_class_ops *ops, + const char *pattern) { struct tpm_chip *chip; @@ -111,7 +114,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, set_bit(chip->dev_num, dev_mask); - scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num); + scnprintf(chip->devname, sizeof(chip->devname), pattern, chip->dev_num); chip->pdev = dev; @@ -139,6 +142,23 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, return chip; } +EXPORT_SYMBOL_GPL(tpmm_chip_alloc_pattern); + +/** + * tpmm_chip_alloc() - allocate a new struct tpm_chip instance + * @dev: device to which the chip is associated + * @ops: struct tpm_class_ops instance + * + * Allocates a new struct tpm_chip instance and assigns a free + * device number for it. Caller does not have to worry about + * freeing the allocated resources. When the devices is removed + * devres calls tpmm_chip_remove() to do the job. + */ +struct tpm_chip *tpmm_chip_alloc(struct device *dev, + const struct tpm_class_ops *ops) +{ + return tpmm_chip_alloc_pattern(dev, ops, "tpm%d"); +} EXPORT_SYMBOL_GPL(tpmm_chip_alloc); static int tpm_dev_add_device(struct tpm_chip *chip) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index dfa755b..c95b26e 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -181,7 +181,7 @@ struct tpm_chip { unsigned int flags; int dev_num; /* /dev/tpm# */ - char devname[7]; + char devname[10]; unsigned long is_open; /* only one allowed */ int time_expired; @@ -517,6 +517,10 @@ 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 struct tpm_chip *tpmm_chip_alloc_pattern( + struct device *dev, + const struct tpm_class_ops *ops, + const char *pattern); extern int tpm_chip_register(struct tpm_chip *chip); extern void tpm_chip_unregister(struct tpm_chip *chip);