Mark pointers as const
Resulting binaries are identical. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
d60a8e4c8e
commit
9fb08ffa46
@@ -37,7 +37,7 @@ struct VirtualWire __code VW_SUS_PWRDN_ACK = VIRTUAL_WIRE(41, 1);
|
||||
// Index 47 - AP to EC (platform specific)
|
||||
struct VirtualWire __code VW_HOST_C10 = VIRTUAL_WIRE(47, 0);
|
||||
|
||||
enum VirtualWireState vw_get(struct VirtualWire *vw) __critical {
|
||||
enum VirtualWireState vw_get(struct VirtualWire *const vw) __critical {
|
||||
uint8_t index = *vw->index;
|
||||
if (index & vw->valid_mask) {
|
||||
if (index & vw->data_mask) {
|
||||
@@ -50,7 +50,7 @@ enum VirtualWireState vw_get(struct VirtualWire *vw) __critical {
|
||||
}
|
||||
}
|
||||
|
||||
void vw_set(struct VirtualWire *vw, enum VirtualWireState state) __critical {
|
||||
void vw_set(struct VirtualWire *const vw, enum VirtualWireState state) __critical {
|
||||
uint8_t index = *vw->index;
|
||||
switch (state) {
|
||||
case VWS_LOW:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <ec/gpio.h>
|
||||
#include <common/debug.h>
|
||||
|
||||
bool gpio_get(struct Gpio *gpio) {
|
||||
bool gpio_get(struct Gpio *const gpio) {
|
||||
if (*(gpio->data) & gpio->value) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -11,7 +11,7 @@ bool gpio_get(struct Gpio *gpio) {
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_set(struct Gpio *gpio, bool value) {
|
||||
void gpio_set(struct Gpio *const gpio, bool value) {
|
||||
if (value) {
|
||||
*(gpio->data) |= gpio->value;
|
||||
} else {
|
||||
@@ -21,11 +21,11 @@ void gpio_set(struct Gpio *gpio, bool value) {
|
||||
|
||||
#ifdef GPIO_DEBUG
|
||||
static void gpio_debug_bank(
|
||||
char *bank,
|
||||
char *const bank,
|
||||
uint8_t data,
|
||||
uint8_t mirror,
|
||||
uint8_t pot,
|
||||
volatile uint8_t *control
|
||||
volatile uint8_t *const control
|
||||
) {
|
||||
for (char i = 0; i < 8; i++) {
|
||||
DEBUG(
|
||||
|
@@ -42,7 +42,7 @@ struct I2C __code I2C_4 = {
|
||||
};
|
||||
#endif
|
||||
|
||||
void i2c_reset(struct I2C *i2c, bool kill) {
|
||||
void i2c_reset(struct I2C *const i2c, bool kill) {
|
||||
if (*(i2c->hosta) & HOSTA_BUSY) {
|
||||
// Set kill bit
|
||||
if (kill)
|
||||
@@ -58,7 +58,7 @@ void i2c_reset(struct I2C *i2c, bool kill) {
|
||||
*(i2c->hoctl2) = 0;
|
||||
}
|
||||
|
||||
int16_t i2c_start(struct I2C *i2c, uint8_t addr, bool read) __reentrant {
|
||||
int16_t i2c_start(struct I2C *const i2c, uint8_t addr, bool read) __reentrant {
|
||||
// If we are already in a transaction
|
||||
if (*(i2c->hosta) & HOSTA_BYTE_DONE) {
|
||||
// If we are switching direction
|
||||
@@ -86,7 +86,7 @@ int16_t i2c_start(struct I2C *i2c, uint8_t addr, bool read) __reentrant {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i2c_stop(struct I2C *i2c) {
|
||||
void i2c_stop(struct I2C *const i2c) {
|
||||
// Disable i2c compatibility
|
||||
*(i2c->hoctl2) &= ~BIT(1);
|
||||
// Clear status
|
||||
@@ -95,7 +95,12 @@ void i2c_stop(struct I2C *i2c) {
|
||||
i2c_reset(i2c, false);
|
||||
}
|
||||
|
||||
static int16_t i2c_transaction(struct I2C *i2c, uint8_t *data, uint16_t length, bool read) {
|
||||
static int16_t i2c_transaction(
|
||||
struct I2C *const i2c,
|
||||
uint8_t *const data,
|
||||
uint16_t length,
|
||||
bool read
|
||||
) {
|
||||
uint16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
if (read) {
|
||||
@@ -154,10 +159,10 @@ static int16_t i2c_transaction(struct I2C *i2c, uint8_t *data, uint16_t length,
|
||||
return i;
|
||||
}
|
||||
|
||||
int16_t i2c_read(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant {
|
||||
int16_t i2c_read(struct I2C *const i2c, uint8_t *const data, uint16_t length) __reentrant {
|
||||
return i2c_transaction(i2c, data, length, true);
|
||||
}
|
||||
|
||||
int16_t i2c_write(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant {
|
||||
int16_t i2c_write(struct I2C *const i2c, uint8_t *const data, uint16_t length) __reentrant {
|
||||
return i2c_transaction(i2c, data, length, false);
|
||||
}
|
||||
|
@@ -27,9 +27,9 @@ enum VirtualWireState {
|
||||
VWS_HIGH = 0x11,
|
||||
};
|
||||
|
||||
enum VirtualWireState vw_get(struct VirtualWire *vw) __critical;
|
||||
enum VirtualWireState vw_get(struct VirtualWire *const vw) __critical;
|
||||
|
||||
void vw_set(struct VirtualWire *vw, enum VirtualWireState state) __critical;
|
||||
void vw_set(struct VirtualWire *const vw, enum VirtualWireState state) __critical;
|
||||
|
||||
// Not all wires are defined or implemented
|
||||
// Index 2 - AP to EC
|
||||
|
@@ -32,8 +32,8 @@ struct Gpio {
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
bool gpio_get(struct Gpio *gpio);
|
||||
void gpio_set(struct Gpio *gpio, bool value);
|
||||
bool gpio_get(struct Gpio *const gpio);
|
||||
void gpio_set(struct Gpio *const gpio, bool value);
|
||||
|
||||
#ifdef GPIO_DEBUG
|
||||
void gpio_debug(void);
|
||||
|
@@ -11,6 +11,6 @@ extern struct I2C __code I2C_1;
|
||||
extern struct I2C __code I2C_4;
|
||||
#endif
|
||||
|
||||
void i2c_reset(struct I2C *i2c, bool kill);
|
||||
void i2c_reset(struct I2C *const i2c, bool kill);
|
||||
|
||||
#endif // _EC_I2C_H
|
||||
|
@@ -29,10 +29,10 @@ extern struct Kbc __code KBC;
|
||||
#define KBC_STS_IBF BIT(1)
|
||||
#define KBC_STS_CMD BIT(3)
|
||||
|
||||
uint8_t kbc_status(struct Kbc *kbc);
|
||||
uint8_t kbc_read(struct Kbc *kbc);
|
||||
bool kbc_keyboard(struct Kbc *kbc, uint8_t data, uint16_t timeout);
|
||||
bool kbc_mouse(struct Kbc *kbc, uint8_t data, uint16_t timeout);
|
||||
uint8_t kbc_status(struct Kbc *const kbc);
|
||||
uint8_t kbc_read(struct Kbc *const kbc);
|
||||
bool kbc_keyboard(struct Kbc *const kbc, uint8_t data, uint16_t timeout);
|
||||
bool kbc_mouse(struct Kbc *const kbc, uint8_t data, uint16_t timeout);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1300) KBHICR;
|
||||
volatile uint8_t __xdata __at(0x1302) KBIRQR;
|
||||
|
@@ -33,10 +33,10 @@ extern struct Pmc __code PMC_5;
|
||||
#define PMC_STS_IBF BIT(1)
|
||||
#define PMC_STS_CMD BIT(3)
|
||||
|
||||
uint8_t pmc_status(struct Pmc *pmc);
|
||||
void pmc_set_status(struct Pmc *pmc, uint8_t status);
|
||||
uint8_t pmc_read(struct Pmc *pmc);
|
||||
void pmc_write(struct Pmc *pmc, uint8_t data);
|
||||
uint8_t pmc_status(struct Pmc *const pmc);
|
||||
void pmc_set_status(struct Pmc *const pmc, uint8_t status);
|
||||
uint8_t pmc_read(struct Pmc *const pmc);
|
||||
void pmc_write(struct Pmc *const pmc, uint8_t data);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1500) PM1STS;
|
||||
volatile uint8_t __xdata __at(0x1501) PM1DO;
|
||||
|
@@ -22,7 +22,7 @@ extern struct Ps2 __code PS2_1;
|
||||
extern struct Ps2 __code PS2_2;
|
||||
extern struct Ps2 __code PS2_3;
|
||||
|
||||
void ps2_reset(struct Ps2 *ps2);
|
||||
void ps2_reset(struct Ps2 *const ps2);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1700) PSCTL1;
|
||||
volatile uint8_t __xdata __at(0x1701) PSCTL2;
|
||||
|
@@ -12,15 +12,15 @@ struct Kbc __code KBC = {
|
||||
.data_in = &KBHIDIR,
|
||||
};
|
||||
|
||||
uint8_t kbc_status(struct Kbc *kbc) {
|
||||
uint8_t kbc_status(struct Kbc *const kbc) {
|
||||
return *(kbc->status);
|
||||
}
|
||||
|
||||
uint8_t kbc_read(struct Kbc *kbc) {
|
||||
uint8_t kbc_read(struct Kbc *const kbc) {
|
||||
return *(kbc->data_in);
|
||||
}
|
||||
|
||||
static bool kbc_wait(struct Kbc *kbc, uint16_t timeout) {
|
||||
static bool kbc_wait(struct Kbc *const kbc, uint16_t timeout) {
|
||||
while (*(kbc->status) & KBC_STS_OBF) {
|
||||
if (timeout == 0)
|
||||
return false;
|
||||
@@ -30,7 +30,7 @@ static bool kbc_wait(struct Kbc *kbc, uint16_t timeout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool kbc_keyboard(struct Kbc *kbc, uint8_t data, uint16_t timeout) {
|
||||
bool kbc_keyboard(struct Kbc *const kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout))
|
||||
return false;
|
||||
*(kbc->status) &= ~0x20;
|
||||
@@ -38,7 +38,7 @@ bool kbc_keyboard(struct Kbc *kbc, uint8_t data, uint16_t timeout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool kbc_mouse(struct Kbc *kbc, uint8_t data, uint16_t timeout) {
|
||||
bool kbc_mouse(struct Kbc *const kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout))
|
||||
return false;
|
||||
*(kbc->status) |= 0x20;
|
||||
|
@@ -19,18 +19,18 @@ struct Pmc __code PMC_3 = PMC(3);
|
||||
struct Pmc __code PMC_4 = PMC(4);
|
||||
struct Pmc __code PMC_5 = PMC(5);
|
||||
|
||||
uint8_t pmc_status(struct Pmc *pmc) {
|
||||
uint8_t pmc_status(struct Pmc *const pmc) {
|
||||
return *(pmc->status);
|
||||
}
|
||||
|
||||
void pmc_set_status(struct Pmc *pmc, uint8_t status) {
|
||||
void pmc_set_status(struct Pmc *const pmc, uint8_t status) {
|
||||
*(pmc->status) = status;
|
||||
}
|
||||
|
||||
uint8_t pmc_read(struct Pmc *pmc) {
|
||||
uint8_t pmc_read(struct Pmc *const pmc) {
|
||||
return *(pmc->data_in);
|
||||
}
|
||||
|
||||
void pmc_write(struct Pmc *pmc, uint8_t data) {
|
||||
void pmc_write(struct Pmc *const pmc, uint8_t data) {
|
||||
*(pmc->data_out) = data;
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ struct Ps2 __code PS2_1 = PS2(1);
|
||||
struct Ps2 __code PS2_2 = PS2(2);
|
||||
struct Ps2 __code PS2_3 = PS2(3);
|
||||
|
||||
void ps2_reset(struct Ps2 *ps2) {
|
||||
void ps2_reset(struct Ps2 *const ps2) {
|
||||
// Reset interface to defaults
|
||||
*(ps2->control) = 1;
|
||||
// Clear status
|
||||
|
Reference in New Issue
Block a user