Thanks for your suggestion. How about these changes? 1. aspeed_smc.h struct AspeedSMCClass { const MemoryRegionOps *reg_ops; }2. aspeed_smc.c a. create new memory region opts for ast2700 static const MemoryRegionOps aspeed_2700_smc_flash_ops = { .read = aspeed_smc_flash_read, .write = aspeed_smc_flash_write, .endianness = DEVICE_LITTLE_ENDIAN, .valid = { .min_access_size = 1, .max_access_size = 8, }, }; b. set memory region opts in all model class init static void aspeed_2400_smc_class_init(ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2400_fmc_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2400_spi1_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2500_fmc_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2500_spi1_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2500_spi2_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2600_fmc_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2600_spi1_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2600_spi2_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_1030_fmc_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_1030_spi1_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_1030_spi2_class_init (ObjectClass *klass, void *data){ asc->reg_ops = &aspeed_smc_flash_ops; } static void aspeed_2700_fmc_class_init(ObjectClass *klass, void *data) { asc->reg_ops = &aspeed_2700_smc_flash_ops; } static void aspeed_2700_spi0_class_init (ObjectClass *klass, void *data) { asc->reg_ops = &aspeed_2700_smc_flash_ops; } static void aspeed_2700_spi1_class_init (ObjectClass *klass, void *data) { asc->reg_ops = &aspeed_2700_smc_flash_ops; } static void aspeed_2700_spi2_class_init (ObjectClass *klass, void *data) { asc->reg_ops = &aspeed_2700_smc_flash_ops; } c. update realize to use memory region opts from class reg_opts static void aspeed_smc_flash_realize(DeviceState *dev, Error **errp) { memory_region_init_io(&s->mmio, OBJECT(s), s->asc->reg_ops, s, name, s->asc->segments[s->cs].size); }
LGTM, Thanks, C.
