qemu-arm
[Top][All Lists]
Advanced

[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>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]