aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/i2c/tpm/tis.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2019-11-29 11:47:47 +0100
committerPatrick Georgi <pgeorgi@google.com>2019-12-02 10:44:38 +0000
commitc9b13594eb8d425e54a126b5c10e3f6fbc41528b (patch)
treef120705f6eb4ddf6dd008e73bdbbd34ae17fbdc9 /src/drivers/i2c/tpm/tis.c
parentae64f22e8d5707ef715ad4bd01b6181653a3f9ca (diff)
src/: Remove g_ prefixes and _g suffixes from variables
These were often used to distinguish CAR_GLOBAL variables that weren't directly usable. Since we're getting rid of this special case, also get rid of the marker. This change was created using coccinelle and the following script: @match@ type T; identifier old =~ "^(g_.*|.*_g)$"; @@ old @script:python global_marker@ old << match.old; new; @@ new = old if old[0:2] == "g_": new = new[2:] if new[-2:] == "_g": new = new[:-2] coccinelle.new = new @@ identifier match.old, global_marker.new; @@ - old + new @@ type T; identifier match.old, global_marker.new; @@ - T old; + T new; @@ type T; identifier match.old, global_marker.new; @@ - T old + T new = ...; There were some manual fixups: Some code still uses the global/local variable naming scheme, so keep g_* there, and some variable names weren't completely rewritten. Change-Id: I4936ff9780a0d3ed9b8b539772bc48887f8d5eed Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37358 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Diffstat (limited to 'src/drivers/i2c/tpm/tis.c')
-rw-r--r--src/drivers/i2c/tpm/tis.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c
index d791a56af5..8b07bb78dd 100644
--- a/src/drivers/i2c/tpm/tis.c
+++ b/src/drivers/i2c/tpm/tis.c
@@ -26,7 +26,7 @@
#include "tpm.h"
/* global structure for tpm chip data */
-static struct tpm_chip g_chip;
+static struct tpm_chip chip;
#define TPM_CMD_COUNT_BYTE 2
#define TPM_CMD_ORDINAL_BYTE 6
@@ -35,15 +35,15 @@ int tis_open(void)
{
int rc;
- if (g_chip.is_open) {
+ if (chip.is_open) {
printk(BIOS_DEBUG, "tis_open() called twice.\n");
return -1;
}
- rc = tpm_vendor_init(&g_chip, CONFIG_DRIVER_TPM_I2C_BUS,
+ rc = tpm_vendor_init(&chip, CONFIG_DRIVER_TPM_I2C_BUS,
CONFIG_DRIVER_TPM_I2C_ADDR);
if (rc < 0)
- g_chip.is_open = 0;
+ chip.is_open = 0;
if (rc)
return -1;
@@ -53,9 +53,9 @@ int tis_open(void)
int tis_close(void)
{
- if (g_chip.is_open) {
- tpm_vendor_cleanup(&g_chip);
- g_chip.is_open = 0;
+ if (chip.is_open) {
+ tpm_vendor_cleanup(&chip);
+ chip.is_open = 0;
}
return 0;
@@ -76,7 +76,7 @@ static ssize_t tpm_transmit(const uint8_t *sbuf, size_t sbufsiz, void *rbuf,
memcpy(&count, sbuf + TPM_CMD_COUNT_BYTE, sizeof(count));
count = be32_to_cpu(count);
- if (!g_chip.vendor.send || !g_chip.vendor.status || !g_chip.vendor.cancel)
+ if (!chip.vendor.send || !chip.vendor.status || !chip.vendor.cancel)
return -1;
if (count == 0) {
@@ -89,8 +89,8 @@ static ssize_t tpm_transmit(const uint8_t *sbuf, size_t sbufsiz, void *rbuf,
return -1;
}
- ASSERT(g_chip.vendor.send);
- rc = g_chip.vendor.send(&g_chip, (uint8_t *) sbuf, count);
+ ASSERT(chip.vendor.send);
+ rc = chip.vendor.send(&chip, (uint8_t *) sbuf, count);
if (rc < 0) {
printk(BIOS_DEBUG, "tpm_transmit: tpm_send error\n");
goto out;
@@ -98,14 +98,14 @@ static ssize_t tpm_transmit(const uint8_t *sbuf, size_t sbufsiz, void *rbuf,
int timeout = 2 * 60 * 1000; /* two minutes timeout */
while (timeout) {
- ASSERT(g_chip.vendor.status);
- uint8_t status = g_chip.vendor.status(&g_chip);
- if ((status & g_chip.vendor.req_complete_mask) ==
- g_chip.vendor.req_complete_val) {
+ ASSERT(chip.vendor.status);
+ uint8_t status = chip.vendor.status(&chip);
+ if ((status & chip.vendor.req_complete_mask) ==
+ chip.vendor.req_complete_val) {
goto out_recv;
}
- if (status == g_chip.vendor.req_canceled) {
+ if (status == chip.vendor.req_canceled) {
printk(BIOS_DEBUG,
"tpm_transmit: Operation Canceled\n");
rc = -1;
@@ -115,15 +115,15 @@ static ssize_t tpm_transmit(const uint8_t *sbuf, size_t sbufsiz, void *rbuf,
timeout--;
}
- ASSERT(g_chip.vendor.cancel);
- g_chip.vendor.cancel(&g_chip);
+ ASSERT(chip.vendor.cancel);
+ chip.vendor.cancel(&chip);
printk(BIOS_DEBUG, "tpm_transmit: Operation Timed out\n");
rc = -1; //ETIME;
goto out;
out_recv:
- rc = g_chip.vendor.recv(&g_chip, (uint8_t *) rbuf, rbufsiz);
+ rc = chip.vendor.recv(&chip, (uint8_t *) rbuf, rbufsiz);
if (rc < 0)
printk(BIOS_DEBUG, "tpm_transmit: tpm_recv: error %d\n", rc);
out: