From patchwork Sun Aug 23 00:31:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 509774 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 41F2C1402A8 for ; Sun, 23 Aug 2015 10:33:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=NP6S/kvR; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C1CE64B67F; Sun, 23 Aug 2015 02:33:37 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WdbE-mdGKXrl; Sun, 23 Aug 2015 02:33:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 695F34B6CD; Sun, 23 Aug 2015 02:32:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3BB3D4B64D for ; Sun, 23 Aug 2015 02:32:27 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Y71rN_b06xs for ; Sun, 23 Aug 2015 02:32:27 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f173.google.com (mail-io0-f173.google.com [209.85.223.173]) by theia.denx.de (Postfix) with ESMTPS id 05A044B668 for ; Sun, 23 Aug 2015 02:32:19 +0200 (CEST) Received: by iodv127 with SMTP id v127so115807328iod.3 for ; Sat, 22 Aug 2015 17:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=xF5K3YowqobzuKxVrpiQX64RwHOh5dB4x8uC70t+FWk=; b=NP6S/kvRTmxGfxX4fugWHxLIpvvTzFESLzarvu+jSF2va60VHo+y9v1j1Ax3SU4GgW VXSdLurbfBL5wLbF2mFhcrew04v8omhCZIZD+Upy1XBVNiv+QScYyjwRmLytNAG9wN1q NWmWAT0wee1zOYwDV8XXcWg7YQKHQMlcmhfyjde7lyiIsy1zD974gPEhb2rFi32V9KiD mGkbWGqGa1WFMLx8Qi5lbgrebmJ6iaYI1YTM3n8QMUwwxmwOX3kyferWol5VKVJAc3oe DN7vzyUJ3vghTfgDkv3Tr6nH7JFWeizELLm4Paamo+1Wrfn42oyEkDrNKzFUH4JQtLxl 4BIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=xF5K3YowqobzuKxVrpiQX64RwHOh5dB4x8uC70t+FWk=; b=imHXy0xlSnigE+XRZd7k0psNbk+asFyuOtKUZX6xWYZ71V0TFddUCIyvYoYgFVnwQu IINv/qm37O3fraB2IUCUlKZ7s3c8SMwOcHdDn9zhLQKG+MXpZHycS8UD/wk2RGBhS0pS fgPiFHO+E5Qt0KrY2V5vxp5H0hCbOAWZsC7Z0gHFlhLryW3VMwTzHa7+pw9SKi88g4S/ d+wlraidHzZ7e/BO1qNE8+vC+nFOJG/4Sc62AHJzgVlRdpp+W9DiAjBiQ1POyloUGqPA 8FcEpHGDOUIKfxyopKm9rIV4OdlHHWEwhoz5DgvwCOj4KSwjgKUPs4SmX36G57PZvkUc jY7g== X-Gm-Message-State: ALoCoQnbzmaDjYCYXDBDjlh3vQVOUGml3aFamujcYjQ5BjKaeq1FWq5BCf6RFEqS5ZkBE8j1MIc/ X-Received: by 10.107.136.148 with SMTP id s20mr12788499ioi.135.1440289937914; Sat, 22 Aug 2015 17:32:17 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id pl8sm5486088igb.8.2015.08.22.17.32.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2015 17:32:15 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 448372217C9; Sat, 22 Aug 2015 18:32:13 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 22 Aug 2015 18:31:26 -0600 Message-Id: <1440289904-31280-11-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 In-Reply-To: <1440289904-31280-1-git-send-email-sjg@chromium.org> References: <1440289904-31280-1-git-send-email-sjg@chromium.org> Cc: Christophe Ricard Subject: [U-Boot] [PATCH v2 10/28] tpm: tpm_tis_i2c: Merge struct tpm into tpm_chip X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" There are too many structures storing the same sort of information. Move the fields from struct tpm into struct tpm_chip and remove the former struct. Signed-off-by: Simon Glass --- Changes in v2: None drivers/tpm/tpm_tis_i2c.c | 24 +++++++++--------------- drivers/tpm/tpm_tis_i2c.h | 1 + 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c index 81a3bb5..046e282 100644 --- a/drivers/tpm/tpm_tis_i2c.c +++ b/drivers/tpm/tpm_tis_i2c.c @@ -375,12 +375,6 @@ static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = { TPM_MEDIUM, }; -/* TPM configuration */ -struct tpm { - struct udevice *dev; - char inited; -} tpm; - static struct tpm_chip g_chip; /* @@ -976,7 +970,7 @@ static void tpm_close(void) * @param dev Returns a configuration of TPM device * @return 0 if ok, -1 on error */ -static int tpm_decode_config(struct tpm *dev) +static int tpm_decode_config(struct tpm_chip *chip) { const void *blob = gd->fdt_blob; struct udevice *bus; @@ -1021,7 +1015,7 @@ static int tpm_decode_config(struct tpm *dev) * TODO(sjg@chromium.org): Older TPMs will need to use the older method * in iic_tpm_read() so the offset length needs to be 0 here. */ - ret = i2c_get_chip(bus, chip_addr, 1, &dev->dev); + ret = i2c_get_chip(bus, chip_addr, 1, &chip->dev); if (ret) { debug("Cannot find device for node '%s: ret=%d'\n", fdt_get_name(blob, node, NULL), ret); @@ -1033,15 +1027,15 @@ static int tpm_decode_config(struct tpm *dev) int tis_init(void) { - if (tpm.inited) + if (g_chip.inited) return 0; - if (tpm_decode_config(&tpm)) + if (tpm_decode_config(&g_chip)) return -1; debug("%s: done\n", __func__); - tpm.inited = 1; + g_chip.inited = 1; return 0; } @@ -1050,17 +1044,17 @@ int tis_open(void) { int rc; - if (!tpm.inited) + if (!g_chip.inited) return -1; - rc = tpm_open_dev(tpm.dev); + rc = tpm_open_dev(g_chip.dev); return rc; } int tis_close(void) { - if (!tpm.inited) + if (!g_chip.inited) return -1; tpm_close(); @@ -1074,7 +1068,7 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, int len; uint8_t buf[4096]; - if (!tpm.inited) + if (!g_chip.inited) return -1; if (sizeof(buf) < sbuf_size) diff --git a/drivers/tpm/tpm_tis_i2c.h b/drivers/tpm/tpm_tis_i2c.h index 0fec464..161e63b 100644 --- a/drivers/tpm/tpm_tis_i2c.h +++ b/drivers/tpm/tpm_tis_i2c.h @@ -43,6 +43,7 @@ enum i2c_chip_type { }; struct tpm_chip { + bool inited; int is_open; u8 req_complete_mask; u8 req_complete_val;