emul: Make emulator parameters consistently named
Some paramaters in prior emulators have historically referred to instances of struct emul as "emulator" or "emul". The proper parameter name for this type is "target" as it designates the struct emul instance is the emul bus (e.g. emul_i2c) controller's target peripheral for dispatch. Do a small refactor renaming some of these parameters to "target". TEST=twister on accel, espi, and eeprom drivers tests Signed-off-by: Aaron Massey <aaronmassey@google.com>
This commit is contained in:
parent
76ae0ba270
commit
5e2678135d
|
@ -65,10 +65,10 @@ static void sample_read(union bmi160_sample *buf)
|
|||
memcpy(buf->raw, raw_data, ARRAY_SIZE(raw_data));
|
||||
}
|
||||
|
||||
static void reg_write(const struct emul *emulator, int regn, int val)
|
||||
static void reg_write(const struct emul *target, int regn, int val)
|
||||
{
|
||||
struct bmi160_emul_data *data = emulator->data;
|
||||
const struct bmi160_emul_cfg *cfg = emulator->cfg;
|
||||
struct bmi160_emul_data *data = target->data;
|
||||
const struct bmi160_emul_cfg *cfg = target->cfg;
|
||||
|
||||
LOG_INF("write %x = %x", regn, val);
|
||||
cfg->reg[regn] = val;
|
||||
|
@ -123,10 +123,10 @@ static void reg_write(const struct emul *emulator, int regn, int val)
|
|||
}
|
||||
}
|
||||
|
||||
static int reg_read(const struct emul *emulator, int regn)
|
||||
static int reg_read(const struct emul *target, int regn)
|
||||
{
|
||||
struct bmi160_emul_data *data = emulator->data;
|
||||
const struct bmi160_emul_cfg *cfg = emulator->cfg;
|
||||
struct bmi160_emul_data *data = target->data;
|
||||
const struct bmi160_emul_cfg *cfg = target->cfg;
|
||||
int val;
|
||||
|
||||
LOG_INF("read %x =", regn);
|
||||
|
@ -167,7 +167,7 @@ static int reg_read(const struct emul *emulator, int regn)
|
|||
}
|
||||
|
||||
#if BMI160_BUS_SPI
|
||||
static int bmi160_emul_io_spi(const struct emul *emulator, const struct spi_config *config,
|
||||
static int bmi160_emul_io_spi(const struct emul *target, const struct spi_config *config,
|
||||
const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
|
||||
{
|
||||
struct bmi160_emul_data *data;
|
||||
|
@ -177,7 +177,7 @@ static int bmi160_emul_io_spi(const struct emul *emulator, const struct spi_conf
|
|||
|
||||
ARG_UNUSED(config);
|
||||
|
||||
data = emulator->data;
|
||||
data = target->data;
|
||||
|
||||
__ASSERT_NO_MSG(tx_bufs || rx_bufs);
|
||||
__ASSERT_NO_MSG(!tx_bufs || !rx_bufs || tx_bufs->count == rx_bufs->count);
|
||||
|
@ -199,11 +199,11 @@ static int bmi160_emul_io_spi(const struct emul *emulator, const struct spi_conf
|
|||
case 1:
|
||||
if (regn & BMI160_REG_READ) {
|
||||
regn &= BMI160_REG_MASK;
|
||||
val = reg_read(emulator, regn);
|
||||
val = reg_read(target, regn);
|
||||
*(uint8_t *)rxd->buf = val;
|
||||
} else {
|
||||
val = *(uint8_t *)txd->buf;
|
||||
reg_write(emulator, regn, val);
|
||||
reg_write(target, regn, val);
|
||||
}
|
||||
break;
|
||||
case BMI160_SAMPLE_SIZE:
|
||||
|
@ -233,13 +233,13 @@ static int bmi160_emul_io_spi(const struct emul *emulator, const struct spi_conf
|
|||
#endif
|
||||
|
||||
#if BMI160_BUS_I2C
|
||||
static int bmi160_emul_transfer_i2c(const struct emul *emulator, struct i2c_msg *msgs, int num_msgs,
|
||||
static int bmi160_emul_transfer_i2c(const struct emul *target, struct i2c_msg *msgs, int num_msgs,
|
||||
int addr)
|
||||
{
|
||||
struct bmi160_emul_data *data;
|
||||
unsigned int val;
|
||||
|
||||
data = emulator->data;
|
||||
data = target->data;
|
||||
|
||||
__ASSERT_NO_MSG(msgs && num_msgs);
|
||||
|
||||
|
@ -261,7 +261,7 @@ static int bmi160_emul_transfer_i2c(const struct emul *emulator, struct i2c_msg
|
|||
if (msgs->flags & I2C_MSG_READ) {
|
||||
switch (msgs->len) {
|
||||
case 1:
|
||||
val = reg_read(emulator, data->cur_reg);
|
||||
val = reg_read(target, data->cur_reg);
|
||||
msgs->buf[0] = val;
|
||||
break;
|
||||
case BMI160_SAMPLE_SIZE:
|
||||
|
@ -275,7 +275,7 @@ static int bmi160_emul_transfer_i2c(const struct emul *emulator, struct i2c_msg
|
|||
if (msgs->len != 1) {
|
||||
LOG_ERR("Unexpected msg1 length %d", msgs->len);
|
||||
}
|
||||
reg_write(emulator, data->cur_reg, msgs->buf[0]);
|
||||
reg_write(target, data->cur_reg, msgs->buf[0]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -123,10 +123,10 @@ static int emul_host_find_index(struct espi_host_emul_data *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int emul_host_set_vw(const struct emul *emulator,
|
||||
static int emul_host_set_vw(const struct emul *target,
|
||||
enum espi_vwire_signal vw, uint8_t level)
|
||||
{
|
||||
struct espi_host_emul_data *data = emulator->data;
|
||||
struct espi_host_emul_data *data = target->data;
|
||||
int idx;
|
||||
|
||||
idx = emul_host_find_index(data, vw);
|
||||
|
@ -141,10 +141,10 @@ static int emul_host_set_vw(const struct emul *emulator,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int emul_host_get_vw(const struct emul *emulator,
|
||||
static int emul_host_get_vw(const struct emul *target,
|
||||
enum espi_vwire_signal vw, uint8_t *level)
|
||||
{
|
||||
struct espi_host_emul_data *data = emulator->data;
|
||||
struct espi_host_emul_data *data = target->data;
|
||||
int idx;
|
||||
|
||||
idx = emul_host_find_index(data, vw);
|
||||
|
@ -214,9 +214,9 @@ int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
|
||||
static uintptr_t emul_espi_dev_get_acpi_shm(const struct emul *emulator)
|
||||
static uintptr_t emul_espi_dev_get_acpi_shm(const struct emul *target)
|
||||
{
|
||||
struct espi_host_emul_data *data = emulator->data;
|
||||
struct espi_host_emul_data *data = target->data;
|
||||
|
||||
return (uintptr_t)data->shm_acpi_mmap;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ struct at24_emul_cfg {
|
|||
* @retval 0 If successful
|
||||
* @retval -EIO General input / output error
|
||||
*/
|
||||
static int at24_emul_transfer(const struct emul *emulator, struct i2c_msg *msgs,
|
||||
static int at24_emul_transfer(const struct emul *target, struct i2c_msg *msgs,
|
||||
int num_msgs, int addr)
|
||||
{
|
||||
struct at24_emul_data *data;
|
||||
|
@ -61,8 +61,8 @@ static int at24_emul_transfer(const struct emul *emulator, struct i2c_msg *msgs,
|
|||
bool too_fast;
|
||||
uint32_t i2c_cfg;
|
||||
|
||||
data = emulator->data;
|
||||
cfg = emulator->cfg;
|
||||
data = target->data;
|
||||
cfg = target->cfg;
|
||||
|
||||
if (cfg->addr != addr) {
|
||||
LOG_ERR("Address mismatch, expected %02x, got %02x", cfg->addr,
|
||||
|
@ -131,18 +131,18 @@ static struct i2c_emul_api bus_api = {
|
|||
* This should be called for each AT24 device that needs to be emulated. It
|
||||
* registers it with the I2C emulation controller.
|
||||
*
|
||||
* @param emulator Emulation information
|
||||
* @param target Emulation information
|
||||
* @param parent Device to emulate (must use AT24 driver)
|
||||
* @return 0 indicating success (always)
|
||||
*/
|
||||
static int emul_atmel_at24_init(const struct emul *emulator, const struct device *parent)
|
||||
static int emul_atmel_at24_init(const struct emul *target, const struct device *parent)
|
||||
{
|
||||
const struct at24_emul_cfg *cfg = emulator->cfg;
|
||||
struct at24_emul_data *data = emulator->data;
|
||||
const struct at24_emul_cfg *cfg = target->cfg;
|
||||
struct at24_emul_data *data = target->data;
|
||||
|
||||
data->emul.api = &bus_api;
|
||||
data->emul.addr = cfg->addr;
|
||||
data->emul.target = emulator;
|
||||
data->emul.target = target;
|
||||
data->i2c = parent;
|
||||
data->cur_reg = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue