summaryrefslogtreecommitdiff
path: root/src/drivers
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
parentae64f22e8d5707ef715ad4bd01b6181653a3f9ca (diff)
downloadcoreboot-c9b13594eb8d425e54a126b5c10e3f6fbc41528b.tar.xz
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')
-rw-r--r--src/drivers/elog/elog.c81
-rw-r--r--src/drivers/i2c/tpm/cr50.c20
-rw-r--r--src/drivers/i2c/tpm/tis.c36
-rw-r--r--src/drivers/i2c/tpm/tpm.c74
-rw-r--r--src/drivers/pc80/pc/i8254.c14
-rw-r--r--src/drivers/spi/flashconsole.c44
-rw-r--r--src/drivers/spi/tpm/tpm.c40
-rw-r--r--src/drivers/vpd/vpd.c24
8 files changed, 168 insertions, 165 deletions
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 768ea28468..97a9c7fa79 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -65,14 +65,14 @@ struct elog_state {
enum elog_init_state elog_initialized;
};
-static struct elog_state g_elog_state;
+static struct elog_state elog_state;
#define ELOG_SIZE (4 * KiB)
static uint8_t elog_mirror_buf[ELOG_SIZE];
static inline struct region_device *mirror_dev_get(void)
{
- return &g_elog_state.mirror_dev.rdev;
+ return &elog_state.mirror_dev.rdev;
}
static size_t elog_events_start(void)
@@ -83,7 +83,7 @@ static size_t elog_events_start(void)
static size_t elog_events_total_space(void)
{
- return region_device_sz(&g_elog_state.nv_dev) - elog_events_start();
+ return region_device_sz(&elog_state.nv_dev) - elog_events_start();
}
static struct event_header *elog_get_event_buffer(size_t offset, size_t size)
@@ -93,8 +93,9 @@ static struct event_header *elog_get_event_buffer(size_t offset, size_t size)
static struct event_header *elog_get_next_event_buffer(size_t size)
{
- elog_debug("ELOG: new event at offset 0x%zx\n", g_elog_state.mirror_last_write);
- return elog_get_event_buffer(g_elog_state.mirror_last_write, size);
+ elog_debug("ELOG: new event at offset 0x%zx\n",
+ elog_state.mirror_last_write);
+ return elog_get_event_buffer(elog_state.mirror_last_write, size);
}
static void elog_put_event_buffer(struct event_header *event)
@@ -105,53 +106,53 @@ static void elog_put_event_buffer(struct event_header *event)
static size_t elog_mirror_reset_last_write(void)
{
/* Return previous write value. */
- size_t prev = g_elog_state.mirror_last_write;
+ size_t prev = elog_state.mirror_last_write;
- g_elog_state.mirror_last_write = 0;
+ elog_state.mirror_last_write = 0;
return prev;
}
static void elog_mirror_increment_last_write(size_t size)
{
- g_elog_state.mirror_last_write += size;
+ elog_state.mirror_last_write += size;
}
static void elog_nv_reset_last_write(void)
{
- g_elog_state.nv_last_write = 0;
+ elog_state.nv_last_write = 0;
}
static void elog_nv_increment_last_write(size_t size)
{
- g_elog_state.nv_last_write += size;
+ elog_state.nv_last_write += size;
}
static void elog_nv_needs_possible_erase(void)
{
/* If last write is 0 it means it is already erased. */
- if (g_elog_state.nv_last_write != 0)
- g_elog_state.nv_last_write = NV_NEEDS_ERASE;
+ if (elog_state.nv_last_write != 0)
+ elog_state.nv_last_write = NV_NEEDS_ERASE;
}
static bool elog_should_shrink(void)
{
- return g_elog_state.mirror_last_write >= g_elog_state.full_threshold;
+ return elog_state.mirror_last_write >= elog_state.full_threshold;
}
static bool elog_nv_needs_erase(void)
{
- return g_elog_state.nv_last_write == NV_NEEDS_ERASE;
+ return elog_state.nv_last_write == NV_NEEDS_ERASE;
}
static bool elog_nv_needs_update(void)
{
- return g_elog_state.nv_last_write != g_elog_state.mirror_last_write;
+ return elog_state.nv_last_write != elog_state.mirror_last_write;
}
static size_t elog_nv_region_to_update(size_t *offset)
{
- *offset = g_elog_state.nv_last_write;
- return g_elog_state.mirror_last_write - g_elog_state.nv_last_write;
+ *offset = elog_state.nv_last_write;
+ return elog_state.mirror_last_write - elog_state.nv_last_write;
}
/*
@@ -335,7 +336,7 @@ static void elog_nv_write(size_t offset, size_t size)
return;
/* Write the data to flash */
- if (rdev_writeat(&g_elog_state.nv_dev, address, offset, size) != size)
+ if (rdev_writeat(&elog_state.nv_dev, address, offset, size) != size)
printk(BIOS_ERR, "ELOG: NV Write failed at 0x%zx, size 0x%zx\n",
offset, size);
@@ -348,11 +349,11 @@ static void elog_nv_write(size_t offset, size_t size)
*/
static void elog_nv_erase(void)
{
- size_t size = region_device_sz(&g_elog_state.nv_dev);
+ size_t size = region_device_sz(&elog_state.nv_dev);
elog_debug("%s()\n", __func__);
/* Erase the sectors in this region */
- if (rdev_eraseat(&g_elog_state.nv_dev, 0, size) != size)
+ if (rdev_eraseat(&elog_state.nv_dev, 0, size) != size)
printk(BIOS_ERR, "ELOG: erase failure.\n");
}
@@ -411,11 +412,11 @@ static int elog_scan_flash(void)
void *mirror_buffer;
const struct region_device *rdev = mirror_dev_get();
- size_t size = region_device_sz(&g_elog_state.nv_dev);
+ size_t size = region_device_sz(&elog_state.nv_dev);
/* Fill memory buffer by reading from SPI */
mirror_buffer = rdev_mmap_full(rdev);
- if (rdev_readat(&g_elog_state.nv_dev, mirror_buffer, 0, size) != size) {
+ if (rdev_readat(&elog_state.nv_dev, mirror_buffer, 0, size) != size) {
rdev_munmap(rdev, mirror_buffer);
printk(BIOS_ERR, "ELOG: NV read failure.\n");
return -1;
@@ -580,7 +581,7 @@ static int elog_prepare_empty(void)
static int elog_shrink(void)
{
if (elog_should_shrink())
- return elog_shrink_by_size(g_elog_state.shrink_size);
+ return elog_shrink_by_size(elog_state.shrink_size);
return 0;
}
@@ -593,12 +594,13 @@ static inline u8 *elog_flash_offset_to_address(void)
if (!CONFIG(BOOT_DEVICE_MEMORY_MAPPED))
return NULL;
- if (!region_device_sz(&g_elog_state.nv_dev))
+ if (!region_device_sz(&elog_state.nv_dev))
return NULL;
/* Get a view into the read-only boot device. */
- return rdev_mmap(boot_device_ro(), region_device_offset(&g_elog_state.nv_dev),
- region_device_sz(&g_elog_state.nv_dev));
+ return rdev_mmap(boot_device_ro(),
+ region_device_offset(&elog_state.nv_dev),
+ region_device_sz(&elog_state.nv_dev));
}
/*
@@ -611,7 +613,7 @@ int elog_smbios_write_type15(unsigned long *current, int handle)
int len = sizeof(struct smbios_type15);
uintptr_t log_address;
- size_t elog_size = region_device_sz(&g_elog_state.nv_dev);
+ size_t elog_size = region_device_sz(&elog_state.nv_dev);
if (CONFIG(ELOG_CBMEM)) {
/* Save event log buffer into CBMEM for the OS to read */
@@ -665,7 +667,7 @@ static int elog_find_flash(void)
{
size_t total_size;
size_t reserved_space = ELOG_MIN_AVAILABLE_ENTRIES * MAX_EVENT_SIZE;
- struct region_device *rdev = &g_elog_state.nv_dev;
+ struct region_device *rdev = &elog_state.nv_dev;
elog_debug("%s()\n", __func__);
@@ -688,10 +690,10 @@ static int elog_find_flash(void)
total_size = MIN(ELOG_SIZE, region_device_sz(rdev));
rdev_chain(rdev, rdev, 0, total_size);
- g_elog_state.full_threshold = total_size - reserved_space;
- g_elog_state.shrink_size = total_size * ELOG_SHRINK_PERCENTAGE / 100;
+ elog_state.full_threshold = total_size - reserved_space;
+ elog_state.shrink_size = total_size * ELOG_SHRINK_PERCENTAGE / 100;
- if (reserved_space > g_elog_state.shrink_size) {
+ if (reserved_space > elog_state.shrink_size) {
printk(BIOS_ERR, "ELOG: SHRINK_PERCENTAGE too small\n");
return -1;
}
@@ -734,7 +736,7 @@ static int elog_sync_to_nv(void)
if (elog_scan_flash() < 0) {
printk(BIOS_ERR, "ELOG: Sync back from NV storage failed.\n");
elog_debug_dump_buffer("ELOG: Buffer from NV:\n");
- g_elog_state.elog_initialized = ELOG_BROKEN;
+ elog_state.elog_initialized = ELOG_BROKEN;
return -1;
}
@@ -776,7 +778,7 @@ int elog_init(void)
{
void *mirror_buffer;
size_t elog_size;
- switch (g_elog_state.elog_initialized) {
+ switch (elog_state.elog_initialized) {
case ELOG_UNINITIALIZED:
break;
case ELOG_INITIALIZED:
@@ -784,7 +786,7 @@ int elog_init(void)
case ELOG_BROKEN:
return -1;
}
- g_elog_state.elog_initialized = ELOG_BROKEN;
+ elog_state.elog_initialized = ELOG_BROKEN;
elog_debug("elog_init()\n");
@@ -792,19 +794,20 @@ int elog_init(void)
if (elog_find_flash() < 0)
return -1;
- elog_size = region_device_sz(&g_elog_state.nv_dev);
+ elog_size = region_device_sz(&elog_state.nv_dev);
mirror_buffer = elog_mirror_buf;
if (!mirror_buffer) {
printk(BIOS_ERR, "ELOG: Unable to allocate backing store\n");
return -1;
}
- mem_region_device_rw_init(&g_elog_state.mirror_dev, mirror_buffer, elog_size);
+ mem_region_device_rw_init(&elog_state.mirror_dev, mirror_buffer,
+ elog_size);
/*
* Mark as initialized to allow elog_init() to be called and deemed
* successful in the prepare/shrink path which adds events.
*/
- g_elog_state.elog_initialized = ELOG_INITIALIZED;
+ elog_state.elog_initialized = ELOG_INITIALIZED;
/* Load the log from flash and prepare the flash if necessary. */
if (elog_scan_flash() < 0 && elog_prepare_empty() < 0) {
@@ -813,8 +816,8 @@ int elog_init(void)
}
printk(BIOS_INFO, "ELOG: area is %zu bytes, full threshold %d,"
- " shrink size %d\n", region_device_sz(&g_elog_state.nv_dev),
- g_elog_state.full_threshold, g_elog_state.shrink_size);
+ " shrink size %d\n", region_device_sz(&elog_state.nv_dev),
+ elog_state.full_threshold, elog_state.shrink_size);
if (ENV_PAYLOAD_LOADER)
elog_add_boot_count();
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c
index f386dacb0b..8ea544d0db 100644
--- a/src/drivers/i2c/tpm/cr50.c
+++ b/src/drivers/i2c/tpm/cr50.c
@@ -54,7 +54,7 @@ struct tpm_inf_dev {
uint8_t buf[CR50_MAX_BUFSIZE + sizeof(uint8_t)];
};
-static struct tpm_inf_dev g_tpm_dev;
+static struct tpm_inf_dev tpm_dev;
__weak int tis_plat_irq_status(void)
{
@@ -101,14 +101,14 @@ static int cr50_i2c_wait_tpm_ready(struct tpm_chip *chip)
static int cr50_i2c_read(struct tpm_chip *chip, uint8_t addr,
uint8_t *buffer, size_t len)
{
- if (g_tpm_dev.addr == 0)
+ if (tpm_dev.addr == 0)
return -1;
/* Clear interrupt before starting transaction */
tis_plat_irq_status();
/* Send the register address byte to the TPM */
- if (i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, &addr, 1)) {
+ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, &addr, 1)) {
printk(BIOS_ERR, "%s: Address write failed\n", __func__);
return -1;
}
@@ -118,7 +118,7 @@ static int cr50_i2c_read(struct tpm_chip *chip, uint8_t addr,
return -1;
/* Read response data from the TPM */
- if (i2c_read_raw(g_tpm_dev.bus, g_tpm_dev.addr, buffer, len)) {
+ if (i2c_read_raw(tpm_dev.bus, tpm_dev.addr, buffer, len)) {
printk(BIOS_ERR, "%s: Read response failed\n", __func__);
return -1;
}
@@ -143,20 +143,20 @@ static int cr50_i2c_read(struct tpm_chip *chip, uint8_t addr,
static int cr50_i2c_write(struct tpm_chip *chip,
uint8_t addr, uint8_t *buffer, size_t len)
{
- if (g_tpm_dev.addr == 0)
+ if (tpm_dev.addr == 0)
return -1;
if (len > CR50_MAX_BUFSIZE)
return -1;
/* Prepend the 'register address' to the buffer */
- g_tpm_dev.buf[0] = addr;
- memcpy(g_tpm_dev.buf + 1, buffer, len);
+ tpm_dev.buf[0] = addr;
+ memcpy(tpm_dev.buf + 1, buffer, len);
/* Clear interrupt before starting transaction */
tis_plat_irq_status();
/* Send write request buffer with address */
- if (i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, g_tpm_dev.buf, len + 1)) {
+ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, tpm_dev.buf, len + 1)) {
printk(BIOS_ERR, "%s: Error writing to TPM\n", __func__);
return -1;
}
@@ -494,8 +494,8 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr)
return -1;
}
- g_tpm_dev.bus = bus;
- g_tpm_dev.addr = dev_addr;
+ tpm_dev.bus = bus;
+ tpm_dev.addr = dev_addr;
cr50_vendor_init(chip);
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:
diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c
index 71641d0edc..009227eb36 100644
--- a/src/drivers/i2c/tpm/tpm.c
+++ b/src/drivers/i2c/tpm/tpm.c
@@ -80,7 +80,7 @@ struct tpm_inf_dev {
enum i2c_chip_type chip_type;
};
-static struct tpm_inf_dev g_tpm_dev;
+static struct tpm_inf_dev tpm_dev;
/*
* iic_tpm_read() - read from TPM register
@@ -101,20 +101,20 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len)
int rc;
int count;
- if (g_tpm_dev.addr == 0)
+ if (tpm_dev.addr == 0)
return -1;
- switch (g_tpm_dev.chip_type) {
+ switch (tpm_dev.chip_type) {
case SLB9635:
case UNKNOWN:
/* slb9635 protocol should work in both cases */
for (count = 0; count < MAX_COUNT; count++) {
- rc = i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr,
+ rc = i2c_write_raw(tpm_dev.bus, tpm_dev.addr,
&addr, 1);
if (rc == 0)
break; /* success, break to skip sleep */
- udelay(g_tpm_dev.sleep_short);
+ udelay(tpm_dev.sleep_short);
}
if (rc)
@@ -125,8 +125,8 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len)
* retrieving the data
*/
for (count = 0; count < MAX_COUNT; count++) {
- udelay(g_tpm_dev.sleep_short);
- rc = i2c_read_raw(g_tpm_dev.bus, g_tpm_dev.addr,
+ udelay(tpm_dev.sleep_short);
+ rc = i2c_read_raw(tpm_dev.bus, tpm_dev.addr,
buffer, len);
if (rc == 0)
break; /* success, break to skip sleep */
@@ -142,23 +142,23 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len)
* retries should usually not be needed, but are kept just to
* be safe on the safe side.
*/
- struct i2c_msg aseg = { .flags = 0, .slave = g_tpm_dev.addr,
+ struct i2c_msg aseg = { .flags = 0, .slave = tpm_dev.addr,
.buf = &addr, .len = 1 };
struct i2c_msg dseg = { .flags = I2C_M_RD,
- .slave = g_tpm_dev.addr,
+ .slave = tpm_dev.addr,
.buf = buffer, .len = len };
for (count = 0; count < MAX_COUNT; count++) {
- rc = i2c_transfer(g_tpm_dev.bus, &aseg, 1) ||
- i2c_transfer(g_tpm_dev.bus, &dseg, 1);
+ rc = i2c_transfer(tpm_dev.bus, &aseg, 1) ||
+ i2c_transfer(tpm_dev.bus, &dseg, 1);
if (rc == 0)
break; /* break here to skip sleep */
- udelay(g_tpm_dev.sleep_short);
+ udelay(tpm_dev.sleep_short);
}
}
}
/* take care of 'guard time' */
- udelay(g_tpm_dev.sleep_short);
+ udelay(tpm_dev.sleep_short);
if (rc)
return -1;
@@ -179,14 +179,14 @@ static int iic_tpm_write_generic(uint8_t addr, uint8_t *buffer, size_t len,
}
/* prepare send buffer */
- g_tpm_dev.buf[0] = addr;
- memcpy(&(g_tpm_dev.buf[1]), buffer, len);
+ tpm_dev.buf[0] = addr;
+ memcpy(&(tpm_dev.buf[1]), buffer, len);
- if (g_tpm_dev.addr == 0)
+ if (tpm_dev.addr == 0)
return -1;
for (count = 0; count < max_count; count++) {
- rc = i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr,
- g_tpm_dev.buf, len + 1);
+ rc = i2c_write_raw(tpm_dev.bus, tpm_dev.addr,
+ tpm_dev.buf, len + 1);
if (rc == 0)
break; /* success, break to skip sleep */
@@ -194,7 +194,7 @@ static int iic_tpm_write_generic(uint8_t addr, uint8_t *buffer, size_t len,
}
/* take care of 'guard time' */
- udelay(g_tpm_dev.sleep_short);
+ udelay(tpm_dev.sleep_short);
if (rc)
return -1;
@@ -219,8 +219,8 @@ static int iic_tpm_write_generic(uint8_t addr, uint8_t *buffer, size_t len,
*/
static int iic_tpm_write(uint8_t addr, uint8_t *buffer, size_t len)
{
- return iic_tpm_write_generic(addr, buffer, len, g_tpm_dev.sleep_short,
- MAX_COUNT);
+ return iic_tpm_write_generic(addr, buffer, len, tpm_dev.sleep_short,
+ MAX_COUNT);
}
/*
@@ -229,8 +229,8 @@ static int iic_tpm_write(uint8_t addr, uint8_t *buffer, size_t len)
* */
static int iic_tpm_write_long(uint8_t addr, uint8_t *buffer, size_t len)
{
- return iic_tpm_write_generic(addr, buffer, len, g_tpm_dev.sleep_long,
- MAX_COUNT_LONG);
+ return iic_tpm_write_generic(addr, buffer, len, tpm_dev.sleep_long,
+ MAX_COUNT_LONG);
}
static int check_locality(struct tpm_chip *chip, int loc)
@@ -479,11 +479,11 @@ int tpm_vendor_probe(unsigned int bus, uint32_t addr)
int ret;
long sw_run_duration = SLEEP_DURATION_PROBE_MS;
- g_tpm_dev.chip_type = UNKNOWN;
- g_tpm_dev.bus = bus;
- g_tpm_dev.addr = addr;
- g_tpm_dev.sleep_short = SLEEP_DURATION;
- g_tpm_dev.sleep_long = SLEEP_DURATION_LONG;
+ tpm_dev.chip_type = UNKNOWN;
+ tpm_dev.bus = bus;
+ tpm_dev.addr = addr;
+ tpm_dev.sleep_short = SLEEP_DURATION;
+ tpm_dev.sleep_long = SLEEP_DURATION_LONG;
/*
* Probe TPM. Check if the TPM_ACCESS register's ValidSts bit is set(1)
@@ -522,11 +522,11 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr)
return -1;
}
- g_tpm_dev.chip_type = UNKNOWN;
- g_tpm_dev.bus = bus;
- g_tpm_dev.addr = dev_addr;
- g_tpm_dev.sleep_short = SLEEP_DURATION;
- g_tpm_dev.sleep_long = SLEEP_DURATION_LONG;
+ tpm_dev.chip_type = UNKNOWN;
+ tpm_dev.bus = bus;
+ tpm_dev.addr = dev_addr;
+ tpm_dev.sleep_short = SLEEP_DURATION;
+ tpm_dev.sleep_long = SLEEP_DURATION_LONG;
memset(&chip->vendor, 0, sizeof(struct tpm_vendor_specific));
chip->is_open = 1;
@@ -547,9 +547,9 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr)
goto out_err;
if (vendor == TPM_TIS_I2C_DID_VID_9645) {
- g_tpm_dev.chip_type = SLB9645;
+ tpm_dev.chip_type = SLB9645;
} else if (be32_to_cpu(vendor) == TPM_TIS_I2C_DID_VID_9635) {
- g_tpm_dev.chip_type = SLB9635;
+ tpm_dev.chip_type = SLB9635;
} else {
printk(BIOS_DEBUG, "Vendor ID 0x%08x not recognized.\n",
vendor);
@@ -557,8 +557,8 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr)
}
printk(BIOS_DEBUG, "I2C TPM %u:%02x (chip type %s device-id 0x%X)\n",
- g_tpm_dev.bus, g_tpm_dev.addr,
- chip_name[g_tpm_dev.chip_type], vendor >> 16);
+ tpm_dev.bus, tpm_dev.addr,
+ chip_name[tpm_dev.chip_type], vendor >> 16);
/*
* A timeout query to TPM can be placed here.
diff --git a/src/drivers/pc80/pc/i8254.c b/src/drivers/pc80/pc/i8254.c
index 9d23d4697e..0b04b393e4 100644
--- a/src/drivers/pc80/pc/i8254.c
+++ b/src/drivers/pc80/pc/i8254.c
@@ -106,19 +106,19 @@ bad_ctc:
}
#if CONFIG(UNKNOWN_TSC_RATE)
-static u32 g_timer_tsc;
+static u32 timer_tsc;
unsigned long tsc_freq_mhz(void)
{
- if (g_timer_tsc > 0)
- return g_timer_tsc;
+ if (timer_tsc > 0)
+ return timer_tsc;
- g_timer_tsc = calibrate_tsc_with_pit();
+ timer_tsc = calibrate_tsc_with_pit();
/* Set some semi-ridiculous rate if approximation fails. */
- if (g_timer_tsc == 0)
- g_timer_tsc = 5000;
+ if (timer_tsc == 0)
+ timer_tsc = 5000;
- return g_timer_tsc;
+ return timer_tsc;
}
#endif
diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c
index c56bf52d92..98f3cb4796 100644
--- a/src/drivers/spi/flashconsole.c
+++ b/src/drivers/spi/flashconsole.c
@@ -22,11 +22,11 @@
#define LINE_BUFFER_SIZE 128
#define READ_BUFFER_SIZE 0x100
-static const struct region_device *g_rdev_ptr;
-static struct region_device g_rdev;
-static uint8_t g_line_buffer[LINE_BUFFER_SIZE];
-static size_t g_offset;
-static size_t g_line_offset;
+static const struct region_device *rdev_ptr;
+static struct region_device rdev;
+static uint8_t line_buffer[LINE_BUFFER_SIZE];
+static size_t offset;
+static size_t line_offset;
void flashconsole_init(void)
{
@@ -36,11 +36,11 @@ void flashconsole_init(void)
size_t len = READ_BUFFER_SIZE;
size_t i;
- if (fmap_locate_area_as_rdev_rw("CONSOLE", &g_rdev)) {
+ if (fmap_locate_area_as_rdev_rw("CONSOLE", &rdev)) {
printk(BIOS_INFO, "Can't find 'CONSOLE' area in FMAP\n");
return;
}
- size = region_device_sz(&g_rdev);
+ size = region_device_sz(&rdev);
/*
* We need to check the region until we find a 0xff indicating
@@ -56,7 +56,7 @@ void flashconsole_init(void)
// Fill the buffer on first iteration
if (i == 0) {
len = min(READ_BUFFER_SIZE, size - offset);
- if (rdev_readat(&g_rdev, buffer, offset, len) != len)
+ if (rdev_readat(&rdev, buffer, offset, len) != len)
return;
}
if (buffer[i] == 0xff) {
@@ -75,29 +75,29 @@ void flashconsole_init(void)
return;
}
- g_offset = offset;
- g_rdev_ptr = &g_rdev;
+ offset = offset;
+ rdev_ptr = &rdev;
}
void flashconsole_tx_byte(unsigned char c)
{
- if (!g_rdev_ptr)
+ if (!rdev_ptr)
return;
- size_t region_size = region_device_sz(g_rdev_ptr);
+ size_t region_size = region_device_sz(rdev_ptr);
- g_line_buffer[g_line_offset++] = c;
+ line_buffer[line_offset++] = c;
- if (g_line_offset >= LINE_BUFFER_SIZE ||
- g_offset + g_line_offset >= region_size || c == '\n') {
+ if (line_offset >= LINE_BUFFER_SIZE ||
+ offset + line_offset >= region_size || c == '\n') {
flashconsole_tx_flush();
}
}
void flashconsole_tx_flush(void)
{
- size_t offset = g_offset;
- size_t len = g_line_offset;
+ size_t offset = offset;
+ size_t len = line_offset;
size_t region_size;
static int busy;
@@ -107,23 +107,23 @@ void flashconsole_tx_flush(void)
if (busy)
return;
- if (!g_rdev_ptr)
+ if (!rdev_ptr)
return;
busy = 1;
- region_size = region_device_sz(g_rdev_ptr);
+ region_size = region_device_sz(rdev_ptr);
if (offset + len >= region_size)
len = region_size - offset;
- if (rdev_writeat(&g_rdev, g_line_buffer, offset, len) != len)
+ if (rdev_writeat(&rdev, line_buffer, offset, len) != len)
return;
// If the region is full, stop future write attempts
if (offset + len >= region_size)
return;
- g_offset = offset + len;
- g_line_offset = 0;
+ offset = offset + len;
+ line_offset = 0;
busy = 0;
}
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. */
diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c
index b81a719176..ab77a01bff 100644
--- a/src/drivers/vpd/vpd.c
+++ b/src/drivers/vpd/vpd.c
@@ -23,7 +23,7 @@ struct vpd_gets_arg {
int matched;
};
-struct vpd_blob g_vpd_blob;
+struct vpd_blob vpd_blob;
/*
* returns the size of data in a VPD 2.0 formatted fmap region, or 0.
@@ -85,10 +85,10 @@ static void vpd_get_blob(void)
if (ro_vpd_size == 0 && rw_vpd_size == 0)
return;
- g_vpd_blob.ro_base = NULL;
- g_vpd_blob.ro_size = 0;
- g_vpd_blob.rw_base = NULL;
- g_vpd_blob.rw_size = 0;
+ vpd_blob.ro_base = NULL;
+ vpd_blob.ro_size = 0;
+ vpd_blob.rw_base = NULL;
+ vpd_blob.rw_size = 0;
struct region_device vpd;
@@ -101,9 +101,9 @@ static void vpd_get_blob(void)
}
rdev_chain(&vpd, &vpd, GOOGLE_VPD_2_0_OFFSET,
region_device_sz(&vpd) - GOOGLE_VPD_2_0_OFFSET);
- g_vpd_blob.ro_base = (uint8_t *)(rdev_mmap_full(&vpd) +
+ vpd_blob.ro_base = (uint8_t *)(rdev_mmap_full(&vpd) +
sizeof(struct google_vpd_info));
- g_vpd_blob.ro_size = ro_vpd_size;
+ vpd_blob.ro_size = ro_vpd_size;
}
if (rw_vpd_size) {
if (fmap_locate_area_as_rdev("RW_VPD", &vpd)) {
@@ -114,19 +114,19 @@ static void vpd_get_blob(void)
}
rdev_chain(&vpd, &vpd, GOOGLE_VPD_2_0_OFFSET,
region_device_sz(&vpd) - GOOGLE_VPD_2_0_OFFSET);
- g_vpd_blob.rw_base = (uint8_t *)(rdev_mmap_full(&vpd) +
+ vpd_blob.rw_base = (uint8_t *)(rdev_mmap_full(&vpd) +
sizeof(struct google_vpd_info));
- g_vpd_blob.rw_size = rw_vpd_size;
+ vpd_blob.rw_size = rw_vpd_size;
}
- g_vpd_blob.initialized = true;
+ vpd_blob.initialized = true;
}
const struct vpd_blob *vpd_load_blob(void)
{
- if (g_vpd_blob.initialized == false)
+ if (vpd_blob.initialized == false)
vpd_get_blob();
- return &g_vpd_blob;
+ return &vpd_blob;
}
static int vpd_gets_callback(const uint8_t *key, uint32_t key_len,