From patchwork Fri Jul 15 01:51:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Pronin X-Patchwork-Id: 9231009 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 39CD160572 for ; Fri, 15 Jul 2016 01:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27F082830A for ; Fri, 15 Jul 2016 01:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CBD628326; Fri, 15 Jul 2016 01:51:55 +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,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 982832830A for ; Fri, 15 Jul 2016 01:51:54 +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 1bNsID-0002ob-7s; Fri, 15 Jul 2016 01:51:53 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bNsIB-0002oT-Jm for tpmdd-devel@lists.sourceforge.net; Fri, 15 Jul 2016 01:51:51 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of chromium.org designates 209.85.192.175 as permitted sender) client-ip=209.85.192.175; envelope-from=apronin@chromium.org; helo=mail-pf0-f175.google.com; Received: from mail-pf0-f175.google.com ([209.85.192.175]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1bNsI5-0007kW-Sh for tpmdd-devel@lists.sourceforge.net; Fri, 15 Jul 2016 01:51:51 +0000 Received: by mail-pf0-f175.google.com with SMTP id c2so35892902pfa.2 for ; Thu, 14 Jul 2016 18:51:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ANmynUytjNfGizntOQoUVzbYh7hdeHdwP1MV6uwcmgU=; b=JndTQ4BtKJ6ZhbLi/B1gwh/nAolQQpuTr3hSG0Z2nfX1TocP0HATuYNQussYvbafjj +jyKv7npPksbCic02LZnHbFIZxt7TeJtIwgSi0BsYI+3mLtSbGZSGX/Od9VakXlV7yHr Ns9fMSETFZTp/s6OONqGP8fjN4r6XlrboSuhZPa+Xob7i7H8u/E+6+7svU2cinCqpBs7 kO5JpL4fPUFJjWcg1KSGQQSI2vXRmDnjzyZPRIKjyBFCRBYcM8w+V+2PF1xwhKV79rtk 6nmhhMmlqkuX3+jLHp1c33e2Je7pVCSOObPx1sYPKmCUvzNC5MIITGuRmcLAE1T754QL cvuw== X-Gm-Message-State: ALyK8tLFFTpwhr5Y2MgP05uNhoJ34fUcuJk/B34uJpoJz+0+rfdN7cvg7yqJZiyQIn4aTX3z X-Received: by 10.98.112.196 with SMTP id l187mr17482370pfc.59.1468547500270; Thu, 14 Jul 2016 18:51:40 -0700 (PDT) Received: from apronin0.mtv.corp.google.com ([172.22.64.136]) by smtp.gmail.com with ESMTPSA id g189sm6789777pfc.46.2016.07.14.18.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jul 2016 18:51:39 -0700 (PDT) From: Andrey Pronin To: Jarkko Sakkinen Date: Thu, 14 Jul 2016 18:51:36 -0700 Message-Id: <1468547496-16215-3-git-send-email-apronin@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1468547496-16215-1-git-send-email-apronin@chromium.org> References: <1468547496-16215-1-git-send-email-apronin@chromium.org> X-Headers-End: 1bNsI5-0007kW-Sh Cc: dianders@chromium.org, linux-kernel@vger.kernel.org, smbarber@chromium.org, tpmdd-devel@lists.sourceforge.net, groeck@chromium.org Subject: [tpmdd-devel] [PATCH 2/2] tpm: support driver-specific sysfs attrs in tpm_tis_core 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 Add attr_group to phy_ops that a driver relying on tpm_tis_core_init can set to have its specific attributes registered in sysfs. Signed-off-by: Andrey Pronin --- drivers/char/tpm/tpm-sysfs.c | 1 - drivers/char/tpm/tpm.h | 8 +++++++- drivers/char/tpm/tpm_tis_core.c | 3 +++ drivers/char/tpm/tpm_tis_core.h | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index 95ce90d..22c9874 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c @@ -304,7 +304,6 @@ void tpm_sysfs_add_device(struct tpm_chip *chip) * is called before ops is null'd and the sysfs core synchronizes this * removal so that no callbacks are running or can run again */ - WARN_ON(chip->groups_cnt != 0); chip->groups[chip->groups_cnt++] = &tpm_dev_group; if (chip->flags & TPM_CHIP_FLAG_TPM2) chip->groups[chip->groups_cnt++] = &tpm2_dev_group; diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 8890df2..8c69649 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -173,7 +173,13 @@ struct tpm_chip { struct dentry **bios_dir; - const struct attribute_group *groups[3]; + /* up to 4 attribute groups: + * - driver-specific + * - common TPM1.2 and TPM2.0 + * - TPM1.2/2.0-specific + * - ppi + */ + const struct attribute_group *groups[5]; unsigned int groups_cnt; #ifdef CONFIG_ACPI acpi_handle acpi_dev_handle; diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 8110b52..6d5d8f4 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -796,6 +796,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, } } + if (priv->phy_ops->attr_group) + chip->groups[chip->groups_cnt++] = priv->phy_ops->attr_group; + return tpm_chip_register(chip); out_err: tpm_tis_remove(chip); diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index 9191aab..4417ed9 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -95,6 +95,7 @@ struct tpm_tis_data { }; struct tpm_tis_phy_ops { + const struct attribute_group *attr_group; int (*read_bytes)(struct tpm_tis_data *data, u32 addr, u16 len, u8 *result); int (*write_bytes)(struct tpm_tis_data *data, u32 addr, u16 len,