[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 17/17] Replace uses of FROM_SSI_SLAVE() macro with QOM casts
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 17/17] Replace uses of FROM_SSI_SLAVE() macro with QOM casts |
Date: |
Mon, 29 Jun 2020 11:18:51 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 6/28/20 4:24 PM, Peter Maydell wrote:
> The FROM_SSI_SLAVE() macro predates QOM and is used as a typesafe way
> to cast from an SSISlave* to the instance struct of a subtype of
> TYPE_SSI_SLAVE. Switch to using the QOM cast macros instead, which
> have the same effect (by writing the QOM macros if the types were
> previously missing them.)
>
> (The FROM_SSI_SLAVE() macro allows the SSISlave member of the
> subtype's struct to be anywhere as long as it is named "ssidev",
> whereas a QOM cast macro insists that it is the first thing in the
> subtype's struct. This is true for all the types we convert here.)
>
> This removes all the uses of FROM_SSI_SLAVE() so we can delete the
> definition.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/hw/ssi/ssi.h | 2 --
> hw/arm/z2.c | 11 +++++++----
> hw/display/ads7846.c | 9 ++++++---
> hw/display/ssd0323.c | 10 +++++++---
> hw/sd/ssi-sd.c | 4 ++--
> 5 files changed, 22 insertions(+), 14 deletions(-)
>
[...]
> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
> index 25cec2ddeaa..25cdf4c966d 100644
> --- a/hw/sd/ssi-sd.c
> +++ b/hw/sd/ssi-sd.c
> @@ -74,7 +74,7 @@ typedef struct {
>
> static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val)
> {
> - ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, dev);
> + ssi_sd_state *s = SSI_SD(dev);
>
> /* Special case: allow CMD12 (STOP TRANSMISSION) while reading data. */
> if (s->mode == SSI_SD_DATA_READ && val == 0x4d) {
> @@ -241,7 +241,7 @@ static const VMStateDescription vmstate_ssi_sd = {
>
> static void ssi_sd_realize(SSISlave *d, Error **errp)
> {
> - ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
> + ssi_sd_state *s = SSI_SD(d);
> DeviceState *carddev;
> DriveInfo *dinfo;
> Error *err = NULL;
>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
- Re: [PATCH 12/17] hw/arm/spitz: Encapsulate misc GPIO handling in a device, (continued)
- [PATCH 13/17] hw/gpio/zaurus.c: Use LOG_GUEST_ERROR for bad guest register accesses, Peter Maydell, 2020/06/28
- [PATCH 14/17] hw/arm/spitz: Use LOG_GUEST_ERROR for bad guest register accesses, Peter Maydell, 2020/06/28
- [PATCH 15/17] hw/arm/pxa2xx_pic: Use LOG_GUEST_ERROR for bad guest register accesses, Peter Maydell, 2020/06/28
- [PATCH 16/17] hw/arm/spitz: Provide usual QOM macros for corgi-ssp and spitz-lcdtg, Peter Maydell, 2020/06/28
- [PATCH 17/17] Replace uses of FROM_SSI_SLAVE() macro with QOM casts, Peter Maydell, 2020/06/28
- Re: [PATCH 17/17] Replace uses of FROM_SSI_SLAVE() macro with QOM casts,
Philippe Mathieu-Daudé <=
- Re: [PATCH 00/17] spitz: fix hacks, fix CID 1421913, various cleanups, no-reply, 2020/06/28