diff options
author | Patrick Georgi <pgeorgi@google.com> | 2019-11-29 11:47:47 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-12-02 10:44:38 +0000 |
commit | c9b13594eb8d425e54a126b5c10e3f6fbc41528b (patch) | |
tree | f120705f6eb4ddf6dd008e73bdbbd34ae17fbdc9 /src/drivers/spi/tpm/tpm.c | |
parent | ae64f22e8d5707ef715ad4bd01b6181653a3f9ca (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/spi/tpm/tpm.c')
-rw-r--r-- | src/drivers/spi/tpm/tpm.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index d3d36c9160..62d1bbae55 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -39,10 +39,10 @@ #define CR50_TIMEOUT_INIT_MS 30000 /* Very long timeout for TPM init */ /* SPI slave structure for TPM device. */ -static struct spi_slave g_spi_slave; +static struct spi_slave spi_slave; /* Cached TPM device identification. */ -static struct tpm2_info g_tpm_info; +static struct tpm2_info tpm_info; /* * TODO(vbendeb): make CONFIG_DEBUG_TPM an int to allow different level of @@ -60,7 +60,7 @@ typedef struct { void tpm2_get_info(struct tpm2_info *info) { - *info = g_tpm_info; + *info = tpm_info; } __weak int tis_plat_irq_status(void) @@ -133,9 +133,9 @@ static int start_transaction(int read_write, size_t bytes, unsigned int addr) if (wakeup_needed) { /* Just in case Cr50 is asleep. */ - spi_claim_bus(&g_spi_slave); + spi_claim_bus(&spi_slave); udelay(1); - spi_release_bus(&g_spi_slave); + spi_release_bus(&spi_slave); udelay(100); } @@ -158,7 +158,7 @@ static int start_transaction(int read_write, size_t bytes, unsigned int addr) header.body[i + 1] = (addr >> (8 * (2 - i))) & 0xff; /* CS assert wakes up the slave. */ - spi_claim_bus(&g_spi_slave); + spi_claim_bus(&spi_slave); /* * The TCG TPM over SPI specification introduces the notion of SPI @@ -185,7 +185,7 @@ static int start_transaction(int read_write, size_t bytes, unsigned int addr) * to require to stall the master, this would present an issue. * crosbug.com/p/52132 has been opened to track this. */ - spi_xfer(&g_spi_slave, header.body, sizeof(header.body), NULL, 0); + spi_xfer(&spi_slave, header.body, sizeof(header.body), NULL, 0); /* * Now poll the bus until TPM removes the stall bit. Give it up to 100 @@ -196,10 +196,10 @@ static int start_transaction(int read_write, size_t bytes, unsigned int addr) do { if (stopwatch_expired(&sw)) { printk(BIOS_ERR, "TPM flow control failure\n"); - spi_release_bus(&g_spi_slave); + spi_release_bus(&spi_slave); return 0; } - spi_xfer(&g_spi_slave, NULL, 0, &byte, 1); + spi_xfer(&spi_slave, NULL, 0, &byte, 1); } while (!(byte & 1)); return 1; } @@ -267,7 +267,7 @@ static void trace_dump(const char *prefix, uint32_t reg, */ static void write_bytes(const void *buffer, size_t bytes) { - spi_xfer(&g_spi_slave, buffer, bytes, NULL, 0); + spi_xfer(&spi_slave, buffer, bytes, NULL, 0); } /* @@ -276,7 +276,7 @@ static void write_bytes(const void *buffer, size_t bytes) */ static void read_bytes(void *buffer, size_t bytes) { - spi_xfer(&g_spi_slave, NULL, 0, buffer, bytes); + spi_xfer(&spi_slave, NULL, 0, buffer, bytes); } /* @@ -291,7 +291,7 @@ static int tpm2_write_reg(unsigned int reg_number, const void *buffer, size_t by if (!start_transaction(false, bytes, reg_number)) return 0; write_bytes(buffer, bytes); - spi_release_bus(&g_spi_slave); + spi_release_bus(&spi_slave); return 1; } @@ -309,7 +309,7 @@ static int tpm2_read_reg(unsigned int reg_number, void *buffer, size_t bytes) return 0; } read_bytes(buffer, bytes); - spi_release_bus(&g_spi_slave); + spi_release_bus(&spi_slave); trace_dump("R", reg_number, bytes, buffer, 0); return 1; } @@ -417,7 +417,7 @@ int tpm2_init(struct spi_slave *spi_if) uint8_t cmd; int retries; - memcpy(&g_spi_slave, spi_if, sizeof(*spi_if)); + memcpy(&spi_slave, spi_if, sizeof(*spi_if)); /* clear any pending IRQs */ tis_plat_irq_status(); @@ -474,15 +474,15 @@ int tpm2_init(struct spi_slave *spi_if) * structure. */ tpm2_read_reg(TPM_RID_REG, &cmd, sizeof(cmd)); - g_tpm_info.vendor_id = did_vid & 0xffff; - g_tpm_info.device_id = did_vid >> 16; - g_tpm_info.revision = cmd; + tpm_info.vendor_id = did_vid & 0xffff; + tpm_info.device_id = did_vid >> 16; + tpm_info.revision = cmd; printk(BIOS_INFO, "Connected to device vid:did:rid of %4.4x:%4.4x:%2.2x\n", - g_tpm_info.vendor_id, g_tpm_info.device_id, g_tpm_info.revision); + tpm_info.vendor_id, tpm_info.device_id, tpm_info.revision); /* Let's report device FW version if available. */ - if (g_tpm_info.vendor_id == 0x1ae0) { + if (tpm_info.vendor_id == 0x1ae0) { int chunk_count = 0; size_t chunk_size; /* @@ -611,7 +611,7 @@ size_t tpm2_process_command(const void *tpm2_command, size_t command_size, const int HEADER_SIZE = 6; /* Do not try using an uninitialized TPM. */ - if (!g_tpm_info.vendor_id) + if (!tpm_info.vendor_id) return 0; /* Skip the two byte tag, read the size field. */ |