qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qemu-s390x] [PATCH v4 05/15] spapr_irq: Expose the phandle of the i


From: David Gibson
Subject: Re: [qemu-s390x] [PATCH v4 05/15] spapr_irq: Expose the phandle of the interrupt controller
Date: Wed, 13 Feb 2019 14:52:04 +1100
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Feb 12, 2019 at 07:24:26PM +0100, Greg Kurz wrote:
> This will be used by PHB hotplug in order to create the "interrupt-map"
> property of the PHB node.
> 
> Reviewed-by: Cédric Le Goater <address@hidden>
> Signed-off-by: Greg Kurz <address@hidden>
> ---
> v4: - return phandle via a pointer

You don't really need to do this.  You already have an Error ** to
return errors via, so you don't need an error return code.  Plus
phandles are not permitted to be 0 or -1, so you have some safe values
even for that case.

> ---
>  hw/ppc/spapr_irq.c         |   26 ++++++++++++++++++++++++++
>  include/hw/ppc/spapr_irq.h |    2 ++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
> index b8d725e251ba..31495033c37c 100644
> --- a/hw/ppc/spapr_irq.c
> +++ b/hw/ppc/spapr_irq.c
> @@ -692,6 +692,32 @@ void spapr_irq_reset(sPAPRMachineState *spapr, Error 
> **errp)
>      }
>  }
>  
> +int spapr_irq_get_phandle(sPAPRMachineState *spapr, void *fdt,
> +                          uint32_t *phandle, Error **errp)
> +{
> +    const char *nodename = spapr->irq->get_nodename(spapr);
> +    int offset, ph;
> +
> +    offset = fdt_subnode_offset(fdt, 0, nodename);
> +    if (offset < 0) {
> +        error_setg(errp, "Can't find node \"%s\": %s", nodename,
> +                   fdt_strerror(offset));
> +        return -1;
> +    }
> +
> +    ph = fdt_get_phandle(fdt, offset);
> +    if (!ph) {
> +        error_setg(errp, "Can't get phandle of node \"%s\"", nodename);
> +        return -1;
> +    }
> +
> +    if (phandle) {
> +        *phandle = ph;
> +    }
> +
> +    return 0;
> +}
> +
>  /*
>   * XICS legacy routines - to deprecate one day
>   */
> diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
> index ad7127355441..4b3303ef4f6a 100644
> --- a/include/hw/ppc/spapr_irq.h
> +++ b/include/hw/ppc/spapr_irq.h
> @@ -62,6 +62,8 @@ void spapr_irq_free(sPAPRMachineState *spapr, int irq, int 
> num);
>  qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq);
>  int spapr_irq_post_load(sPAPRMachineState *spapr, int version_id);
>  void spapr_irq_reset(sPAPRMachineState *spapr, Error **errp);
> +int spapr_irq_get_phandle(sPAPRMachineState *spapr, void *fdt,
> +                          uint32_t *phandle, Error **errp);
>  
>  /*
>   * XICS legacy routines
> 

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

Attachment: signature.asc
Description: PGP signature


reply via email to

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