From patchwork Thu Apr 21 22:04:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8904161 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 CE3139F39A for ; Thu, 21 Apr 2016 22:05:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2A51200C6 for ; Thu, 21 Apr 2016 22:05:11 +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 CF2D22034A for ; Thu, 21 Apr 2016 22:05:10 +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 1atMij-0000R7-Nm; Thu, 21 Apr 2016 22:05:09 +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 1atMii-0000Qy-AY for tpmdd-devel@lists.sourceforge.net; Thu, 21 Apr 2016 22:05:08 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.45 as permitted sender) client-ip=74.125.82.45; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f45.google.com; Received: from mail-wm0-f45.google.com ([74.125.82.45]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1atMih-00027U-FK for tpmdd-devel@lists.sourceforge.net; Thu, 21 Apr 2016 22:05:08 +0000 Received: by mail-wm0-f45.google.com with SMTP id v188so261468798wme.1 for ; Thu, 21 Apr 2016 15:05:07 -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=hU9oVBaaP7Y45fzVAxED8J1Zeeqt4emzGsXOaB74iNM=; b=O33HsPFpG4+mUBnyRS2nfII7d49LHl2h1DW290Qy/itoQT86U7ta+5BFr8A0ofqFWU t+g0Ve3ghOHnV2++0M2RbpEMcAxDYrQvyiV/A5XjJFWw+4wrQnl7x1ek9VfUb+U7dSHC dpdWizL8x/z0RzmV3vVAoQKnwpITKdGUQUuBrU9mhe5jwhaazIKuIXER5XXXH+vfdaHi 3plGzzS9Bc9SX/dUpVtzdhV4SKbzKoOe0CnVhXSytAN6xWzU0V4K3nVzRfvdn/f0UTaW E3ZsYyA6r6N3x/jrenfVAKz26cBguQzCOD9J+gJRyv8aCkUAKBet4XXOGCwwhMF2suTU YTgg== X-Gm-Message-State: AOPr4FWp278PHEuPCHx8VlrMm5y94X3nhc1DtH2lQ4JtQNqW0FezwFjrbiFoEgdzyBHyOA== X-Received: by 10.28.236.156 with SMTP id h28mr232046wmi.25.1461276301531; Thu, 21 Apr 2016 15:05:01 -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 m14sm144521wmc.4.2016.04.21.15.05.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Apr 2016 15:05:00 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Fri, 22 Apr 2016 00:04:42 +0200 Message-Id: <1461276283-2453-8-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461276283-2453-1-git-send-email-christophe-h.ricard@st.com> References: <1461276283-2453-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1atMih-00027U-FK 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 v5 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 76899d8..b426934 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -142,6 +142,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,