sim: Fix iic/spi bus open failed

when CONFIG_SIM_I2CBUS or CONFIG_SIM_SPI enabled,the iic/spi
bus will report open failed

Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
This commit is contained in:
Shoukui Zhang 2023-03-20 14:52:52 +08:00 committed by Petro Karashchenko
parent 14d1f3b995
commit 947100c5b8
2 changed files with 2 additions and 2 deletions

View File

@ -269,7 +269,7 @@ struct i2c_master_s *sim_i2cbus_initialize(int bus)
struct linux_i2cbus_master_s *priv;
char filename[20];
priv = (struct linux_i2cbus_master_s *)malloc(sizeof(priv));
priv = (struct linux_i2cbus_master_s *)malloc(sizeof(*priv));
if (priv == NULL)
{
ERROR("Failed to allocate private i2c master driver");

View File

@ -702,7 +702,7 @@ struct spi_dev_s *sim_spi_initialize(const char *filename)
{
struct linux_spi_dev_s *priv;
priv = (struct linux_spi_dev_s *)malloc(sizeof(priv));
priv = (struct linux_spi_dev_s *)malloc(sizeof(*priv));
if (priv == NULL)
{
ERROR("Failed to allocate private spi master driver");