Lines Matching +full:reg +full:- +full:rc

4  * SPDX-License-Identifier: Apache-2.0
37 static int emul_max17048_reg_write(const struct emul *target, int reg, int val) in emul_max17048_reg_write() argument
40 return -EIO; in emul_max17048_reg_write()
43 static int emul_max17048_reg_read(const struct emul *target, int reg, int *val) in emul_max17048_reg_read() argument
46 switch (reg) { in emul_max17048_reg_read()
60 LOG_ERR("Unknown register 0x%x read", reg); in emul_max17048_reg_read()
61 return -EIO; in emul_max17048_reg_read()
63 LOG_INF("read 0x%x = 0x%x", reg, *val); in emul_max17048_reg_read()
73 int reg; in max17048_emul_transfer_i2c() local
74 int rc; in max17048_emul_transfer_i2c() local
78 i2c_dump_msgs_rw(target->dev, msgs, num_msgs, addr, false); in max17048_emul_transfer_i2c()
81 if (msgs->flags & I2C_MSG_READ) { in max17048_emul_transfer_i2c()
83 return -EIO; in max17048_emul_transfer_i2c()
85 if (msgs->len != 1) { in max17048_emul_transfer_i2c()
86 LOG_ERR("Unexpected msg0 length %d", msgs->len); in max17048_emul_transfer_i2c()
87 return -EIO; in max17048_emul_transfer_i2c()
89 reg = msgs->buf[0]; in max17048_emul_transfer_i2c()
93 if (msgs->flags & I2C_MSG_READ) { in max17048_emul_transfer_i2c()
94 switch (msgs->len - 1) { in max17048_emul_transfer_i2c()
96 rc = emul_max17048_reg_read(target, reg, &val); in max17048_emul_transfer_i2c()
97 if (rc) { in max17048_emul_transfer_i2c()
99 return rc; in max17048_emul_transfer_i2c()
102 /* SBS uses SMBus, which sends data in little-endian format. */ in max17048_emul_transfer_i2c()
103 sys_put_le16(val, msgs->buf); in max17048_emul_transfer_i2c()
106 LOG_ERR("Unexpected msg1 length %d", msgs->len); in max17048_emul_transfer_i2c()
107 return -EIO; in max17048_emul_transfer_i2c()
111 if (msgs->len != 2) { in max17048_emul_transfer_i2c()
112 LOG_ERR("Unexpected msg1 length %d", msgs->len); in max17048_emul_transfer_i2c()
114 uint16_t value = sys_get_le16(msgs->buf); in max17048_emul_transfer_i2c()
116 rc = emul_max17048_reg_write(target, reg, value); in max17048_emul_transfer_i2c()
121 return -EIO; in max17048_emul_transfer_i2c()
124 return rc; in max17048_emul_transfer_i2c()