From patchwork Sat Apr 16 06:35:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8861141 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB913BF29F for ; Sat, 16 Apr 2016 06:36:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E931320279 for ; Sat, 16 Apr 2016 06:36:08 +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 8B73F20268 for ; Sat, 16 Apr 2016 06:36:07 +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 1arJpu-00014b-0h; Sat, 16 Apr 2016 06:36:06 +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 1arJps-00014G-M5 for tpmdd-devel@lists.sourceforge.net; Sat, 16 Apr 2016 06:36:04 +0000 Received-SPF: pass (sog-mx-1.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-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1arJpr-0001ft-RB for tpmdd-devel@lists.sourceforge.net; Sat, 16 Apr 2016 06:36:04 +0000 Received: by mail-wm0-f45.google.com with SMTP id v188so55886518wme.1 for ; Fri, 15 Apr 2016 23:36:03 -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=jaFJ7L3WzmX/GEZt5aBtg79/5OroGuzN19RRrE+buLA=; b=MUmNaS4xn2l7KxUQHwPSau4JKpDFsC9U/GVarbVVpTl8W+NsGJwHpd4Z8OSzChB7+n pfEcAxAY1uLqITFibfahPvkhsnF0xZT6eOyOWKlZYnCR1CGsBqCRnrN/k7Mi8jCcTO7j DxIaIFkHrHvyfRAEJJo4d/CAmBopDzf4+6qhBID+PuX9hXhg49JWVkbamecUrsDJxtKl C0Xva0qcwmZnWQyWh7yoXF4WLFvpnxHTENIMbuAgQYNfH4FikDU8Ihd0Zb3Ok3RnuKmv 5cRpQUAGLV9kEZA7nOEqvNhpF6Gg5YBEFgyQOxqit2qUJ3z82evMXHbgKgw8kSUHGNDs Y6Yw== X-Gm-Message-State: AOPr4FVI/FjrL0BjuNb4zVFjj5JMj8VspqEW+3fpGJhNrVJpkKm1Wmg/eK9b2PQ32bWnOg== X-Received: by 10.28.152.133 with SMTP id a127mr7937561wme.60.1460788557791; Fri, 15 Apr 2016 23:35:57 -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 wr2sm52541996wjc.49.2016.04.15.23.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Apr 2016 23:35:56 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sat, 16 Apr 2016 08:35:36 +0200 Message-Id: <1460788542-2455-7-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460788542-2455-1-git-send-email-christophe-h.ricard@st.com> References: <1460788542-2455-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1arJpr-0001ft-RB 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 v3 06/12] 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.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index 9dd6b41..4074c98 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -60,6 +60,18 @@ static inline int tpm_read8(struct tpm_chip *chip, u32 addr, u8 *result) return priv->phy_ops->read_bytes(chip, addr, 1, result); } +static inline int tpm_tis_common_read16(struct tpm_chip *chip, u32 addr, + u16 *result) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + int rc; + + rc = priv->phy_ops->read_bytes(chip, addr, sizeof(u16), (u8 *)result); + if (!rc) + *result = le16_to_cpu(*result); + return rc; +} + static inline int tpm_read16(struct tpm_chip *chip, u32 addr, u16 *result) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); @@ -67,6 +79,18 @@ static inline int tpm_read16(struct tpm_chip *chip, u32 addr, u16 *result) return priv->phy_ops->read16(chip, addr, result); } +static inline int tpm_tis_common_read32(struct tpm_chip *chip, u32 addr, + u32 *result) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + int rc; + + rc = priv->phy_ops->read_bytes(chip, addr, sizeof(u32), (u8 *)result); + if (!rc) + *result = le32_to_cpu(*result); + return rc; +} + static inline int tpm_read32(struct tpm_chip *chip, u32 addr, u32 *result) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); @@ -89,6 +113,16 @@ static inline int tpm_write8(struct tpm_chip *chip, u32 addr, u8 value) return priv->phy_ops->write_bytes(chip, addr, 1, &value); } +static inline int tpm_tis_common_write32(struct tpm_chip *chip, u32 addr, + u32 value) +{ + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); + + value = cpu_to_le32(value); + return priv->phy_ops->write_bytes(chip, addr, sizeof(u32), + (u8 *)&value); +} + static inline int tpm_write32(struct tpm_chip *chip, u32 addr, u32 value) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);