qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/arm/spitz: Provide usual QOM macros for corgi-ssp and spitz-lcdtg

The QOM types "spitz-lcdtg" and "corgi-ssp" are missing the
usual QOM TYPE and casting macros; provide and use them.

In particular, we can safely use the QOM cast macros instead of
FROM_SSI_SLAVE() because in both cases the 'ssidev' field of
the instance state struct is the first field in it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20200628142429.17111-17-peter.maydell@linaro.org

+15 -8
+15 -8
hw/arm/spitz.c
··· 579 579 #define LCDTG_PICTRL 0x06 580 580 #define LCDTG_POLCTRL 0x07 581 581 582 + #define TYPE_SPITZ_LCDTG "spitz-lcdtg" 583 + #define SPITZ_LCDTG(obj) OBJECT_CHECK(SpitzLCDTG, (obj), TYPE_SPITZ_LCDTG) 584 + 582 585 typedef struct { 583 586 SSISlave ssidev; 584 587 uint32_t bl_intensity; ··· 616 619 617 620 static uint32_t spitz_lcdtg_transfer(SSISlave *dev, uint32_t value) 618 621 { 619 - SpitzLCDTG *s = FROM_SSI_SLAVE(SpitzLCDTG, dev); 622 + SpitzLCDTG *s = SPITZ_LCDTG(dev); 620 623 int addr; 621 624 addr = value >> 5; 622 625 value &= 0x1f; ··· 645 648 646 649 static void spitz_lcdtg_realize(SSISlave *ssi, Error **errp) 647 650 { 648 - SpitzLCDTG *s = FROM_SSI_SLAVE(SpitzLCDTG, ssi); 651 + SpitzLCDTG *s = SPITZ_LCDTG(ssi); 649 652 DeviceState *dev = DEVICE(s); 650 653 651 654 s->bl_power = 0; ··· 663 666 #define SPITZ_GPIO_ADS7846_CS 14 664 667 #define SPITZ_GPIO_MAX1111_CS 20 665 668 #define SPITZ_GPIO_TP_INT 11 669 + 670 + #define TYPE_CORGI_SSP "corgi-ssp" 671 + #define CORGI_SSP(obj) OBJECT_CHECK(CorgiSSPState, (obj), TYPE_CORGI_SSP) 666 672 667 673 /* "Demux" the signal based on current chipselect */ 668 674 typedef struct { ··· 673 679 674 680 static uint32_t corgi_ssp_transfer(SSISlave *dev, uint32_t value) 675 681 { 676 - CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev); 682 + CorgiSSPState *s = CORGI_SSP(dev); 677 683 int i; 678 684 679 685 for (i = 0; i < 3; i++) { ··· 702 708 static void corgi_ssp_realize(SSISlave *d, Error **errp) 703 709 { 704 710 DeviceState *dev = DEVICE(d); 705 - CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, d); 711 + CorgiSSPState *s = CORGI_SSP(d); 706 712 707 713 qdev_init_gpio_in(dev, corgi_ssp_gpio_cs, 3); 708 714 s->bus[0] = ssi_create_bus(dev, "ssi0"); ··· 714 720 { 715 721 void *bus; 716 722 717 - sms->mux = ssi_create_slave(sms->mpu->ssp[CORGI_SSP_PORT - 1], "corgi-ssp"); 723 + sms->mux = ssi_create_slave(sms->mpu->ssp[CORGI_SSP_PORT - 1], 724 + TYPE_CORGI_SSP); 718 725 719 726 bus = qdev_get_child_bus(sms->mux, "ssi0"); 720 - sms->lcdtg = ssi_create_slave(bus, "spitz-lcdtg"); 727 + sms->lcdtg = ssi_create_slave(bus, TYPE_SPITZ_LCDTG); 721 728 722 729 bus = qdev_get_child_bus(sms->mux, "ssi1"); 723 730 sms->ads7846 = ssi_create_slave(bus, "ads7846"); ··· 1220 1227 } 1221 1228 1222 1229 static const TypeInfo corgi_ssp_info = { 1223 - .name = "corgi-ssp", 1230 + .name = TYPE_CORGI_SSP, 1224 1231 .parent = TYPE_SSI_SLAVE, 1225 1232 .instance_size = sizeof(CorgiSSPState), 1226 1233 .class_init = corgi_ssp_class_init, ··· 1249 1256 } 1250 1257 1251 1258 static const TypeInfo spitz_lcdtg_info = { 1252 - .name = "spitz-lcdtg", 1259 + .name = TYPE_SPITZ_LCDTG, 1253 1260 .parent = TYPE_SSI_SLAVE, 1254 1261 .instance_size = sizeof(SpitzLCDTG), 1255 1262 .class_init = spitz_lcdtg_class_init,