On 3/7/24 16:02, Cédric Le Goater wrote:
On 7/3/24 3:43 PM, Philippe Mathieu-Daudé wrote:
In order to keep eMMC model simpler to maintain,
extract common properties and the common code from
class_init to the (internal) TYPE_SDMMC_COMMON.
Update the corresponding QOM cast macros.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sd/sdmmc-internal.h | 3 +++
hw/sd/core.c | 29 ++++++++++++------------
hw/sd/sd.c | 50 ++++++++++++++++++++++++++++--------------
3 files changed, 52 insertions(+), 30 deletions(-)
@@ -2508,14 +2521,19 @@ static void sd_spi_class_init(ObjectClass *klass, void
*data)
static const TypeInfo sd_types[] = {
{
- .name = TYPE_SD_CARD,
+ .name = TYPE_SDMMC_COMMON,
.parent = TYPE_DEVICE,
.instance_size = sizeof(SDState),
.class_size = sizeof(SDCardClass),
- .class_init = sd_class_init,
+ .class_init = sdmmc_common_class_init,
.instance_init = sd_instance_init,
.instance_finalize = sd_instance_finalize,
},
Shouldn't it be an abstract class ?
Ah yes, safer. Squashing:
-- >8 --
@@ -2513,6 +2513,7 @@ static const TypeInfo sd_types[] = {
{
.name = TYPE_SDMMC_COMMON,
.parent = TYPE_DEVICE,
+ .abstract = true,
.instance_size = sizeof(SDState),
.class_size = sizeof(SDCardClass),
.class_init = sdmmc_common_class_init,