qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH 3/3] hw/i2c/pmbus_device: Fix modifying QOM class internals f


From: Richard Henderson
Subject: Re: [PATCH 3/3] hw/i2c/pmbus_device: Fix modifying QOM class internals from instance
Date: Tue, 23 May 2023 11:30:34 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

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<shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
---
  hw/i2c/pmbus_device.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)

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

r~



reply via email to

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