On Tue, Dec 10, 2019 at 09:52:05AM +0100, Cédric Le Goater wrote: > On 10/12/2019 04:34, David Gibson wrote: > >> +static inline bool pnv_chip_is_power10(const PnvChip *chip) > >> +{ > >> + return PNV_CHIP_GET_CLASS(chip)->chip_type == PNV_CHIP_POWER10; > >> +} > >> + > >> +static inline bool pnv_is_power10(PnvMachineState *pnv) > >> +{ > >> + return pnv_chip_is_power10(pnv->chips[0]); > >> +} > > > > I agree this is starting to be ugly. > > > It's not in scope for this series, but now that we have P8/9/10 > > specific chip object types and powernv8/powernv9, we should be able to > > remove the ugly chip_type field, and just do object class checks on > > the chip and or machine objects themselves. > > > So we would use object_class_dynamic_cast() instead of field > chip_type ?
Just object_dynamic_cast() should suffice, since you have access to the chip and machine instances. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature