qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 1/6] hw/nvram/eeprom_at24c: Add header w/ init helper
Date: Mon, 16 Jan 2023 13:23:01 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1

On 14/1/23 18:01, Peter Delevoryas wrote:
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
  hw/nvram/eeprom_at24c.c         | 10 ++++++++++
  include/hw/nvram/eeprom_at24c.h | 10 ++++++++++
  2 files changed, 20 insertions(+)
  create mode 100644 include/hw/nvram/eeprom_at24c.h

+void at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size)
+{
+    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", address);

Please use the type definition: TYPE_AT24C_EE.

+    DeviceState *dev = DEVICE(i2c_dev);
+
+    qdev_prop_set_uint32(dev, "rom-size", rom_size);
+    i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);

Although the allocated object is somehow reachable from the i2c bus
object, it would be simpler to deallocate allowing the parent to keep
a reference to it. So consider this prototype instead:

  I2CSlave *at24c_eeprom_create(I2CBus *bus, uint8_t address,
                                uint32_t rom_size);

+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]