From patchwork Fri Apr 22 22:11:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8915861 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 688569F372 for ; Fri, 22 Apr 2016 22:11:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 964452021B for ; Fri, 22 Apr 2016 22:11:55 +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 889A12020F for ; Fri, 22 Apr 2016 22:11:54 +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 1atjIn-0006cT-Dz; Fri, 22 Apr 2016 22:11:53 +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 1atjIl-0006c8-OC for tpmdd-devel@lists.sourceforge.net; Fri, 22 Apr 2016 22:11:51 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.66 as permitted sender) client-ip=74.125.82.66; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f66.google.com; Received: from mail-wm0-f66.google.com ([74.125.82.66]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1atjIk-0008Ar-KA for tpmdd-devel@lists.sourceforge.net; Fri, 22 Apr 2016 22:11:51 +0000 Received: by mail-wm0-f66.google.com with SMTP id r12so7341412wme.0 for ; Fri, 22 Apr 2016 15:11:50 -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=P3HSCBJb3S8hOBbldSFsIsDXqD5G+AKwBExHBd86rx0=; b=R3z3mCdvNYDjLFcTZJhZc+/WZYYDMp4Zp0kltwCrtitSFly6dnnrpKcCT5ha0Jgod4 ktohFWO0VAjLcoCn659Y5XUUzq4YY3OV67FDj52HAXU/fjDqyPoohgj9GCnIkex/9Jdk NUEItTHt/xbtS5BnYsfOplaF5Ba0i6/OMN3QkUMP2Gz+amO6WSElze7q40vzdb6f5lyc tk+8Mu0NdKvq3tgYtWfNClkbJUzxM5flakTy7YHp8uD4gJ3M5dSlYKNHJzZWwspPVcZ/ /0XGl8W7uu7a7NKjyKay6caQbZ1q025yBIPkFvy2MiAylMrVvbr/ZSLA5IyIVcvDaoiT Th0g== X-Gm-Message-State: AOPr4FX35RoXiG77wslWvgAQF13CLeKYu9fMIdPgtR7vEKK0I8pt9cEUIewhPoorwn0eZA== X-Received: by 10.28.94.5 with SMTP id s5mr6127046wmb.26.1461363104655; Fri, 22 Apr 2016 15:11:44 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id us3sm10028438wjc.41.2016.04.22.15.11.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Apr 2016 15:11:43 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sat, 23 Apr 2016 00:11:24 +0200 Message-Id: <1461363085-9908-8-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461363085-9908-1-git-send-email-christophe-h.ricard@st.com> References: <1461363085-9908-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1atjIk-0008Ar-KA Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v6 7/8] tpm: Use read/write_bytes for drivers without more specialized methods 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, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 Some drivers might need to implement only functions for transferring an arbitrary number of bytes. Provides a generic functions for handling of word or dword transfers to be dump into driver functions pointers. Signed-off-by: Alexander Steffen Signed-off-by: Christophe Ricard --- drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++++ drivers/char/tpm/tpm_tis_core.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index f4e05ac..fd9c6a5 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -854,6 +854,36 @@ int tpm_tis_resume(struct device *dev) EXPORT_SYMBOL_GPL(tpm_tis_resume); #endif +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result) +{ + int rc; + + rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), (u8 *)result); + if (!rc) + *result = le16_to_cpu(*result); + return rc; +} +EXPORT_SYMBOL_GPL(tpm_tis_common_read16); + +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result) +{ + int rc; + + rc = data->phy_ops->read_bytes(data, addr, sizeof(u32), (u8 *)result); + if (!rc) + *result = le32_to_cpu(*result); + return rc; +} +EXPORT_SYMBOL_GPL(tpm_tis_common_read32); + +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value) +{ + value = cpu_to_le32(value); + return data->phy_ops->write_bytes(data, addr, sizeof(u32), + (u8 *)&value); +} +EXPORT_SYMBOL_GPL(tpm_tis_common_write32); + MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); MODULE_DESCRIPTION("TPM Driver"); MODULE_VERSION("2.0"); diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index 91aa305..bdc7899 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -141,6 +141,10 @@ static inline int tpm_write32(struct tpm_tis_data *data, u32 addr, u32 value) return data->phy_ops->write32(data, addr, value); } +int tpm_tis_common_read16(struct tpm_tis_data *data, u32 addr, u16 *result); +int tpm_tis_common_read32(struct tpm_tis_data *data, u32 addr, u32 *result); +int tpm_tis_common_write32(struct tpm_tis_data *data, u32 addr, u32 value); + void tpm_tis_remove(struct tpm_chip *chip); int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, const struct tpm_tis_phy_ops *phy_ops,