On 5/22/23 23:44, Philippe Mathieu-Daudé wrote:
QOM object instance should not modify its class state (because
all other objects instanciated from this class get affected).

Instead of modifying the PMBusDeviceClass 'device_num_pages' field
the first time a instance is initialized (in pmbus_pages_alloc),
introduce a new pmbus_pages_num() helper which returns the page
number from the class without modifying the class state.

The code logic become slighly simplified.

Inspired-by: Bernhard Beschow<shen...@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé<phi...@linaro.org>
---
  hw/i2c/pmbus_device.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)

Reviewed-by: Richard Henderson <richard.hender...@linaro.org>

r~

Reply via email to