diff mbox

[3/6] ppc/pnv: introduce an 'isa_bus_name' field under the LPC model

Message ID 20180614140043.9231-4-clg@kaod.org (mailing list archive)
State New, archived
Headers show

Commit Message

Cédric Le Goater June 14, 2018, 2 p.m. UTC
This is again a small cleanup to hide to the machine the details of
the ISA bus. The ISA bus device tree nodename will be different on
Power9.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ppc/pnv_lpc.h | 1 +
 hw/ppc/pnv.c             | 9 +--------
 hw/ppc/pnv_lpc.c         | 4 ++++
 3 files changed, 6 insertions(+), 8 deletions(-)

Comments

David Gibson June 15, 2018, 2:47 a.m. UTC | #1
On Thu, Jun 14, 2018 at 04:00:40PM +0200, Cédric Le Goater wrote:
> This is again a small cleanup to hide to the machine the details of
> the ISA bus. The ISA bus device tree nodename will be different on
> Power9.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>



> ---
>  include/hw/ppc/pnv_lpc.h | 1 +
>  hw/ppc/pnv.c             | 9 +--------
>  hw/ppc/pnv_lpc.c         | 4 ++++
>  3 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/include/hw/ppc/pnv_lpc.h b/include/hw/ppc/pnv_lpc.h
> index fb4b7b83d798..e8f7dcb9bfe9 100644
> --- a/include/hw/ppc/pnv_lpc.h
> +++ b/include/hw/ppc/pnv_lpc.h
> @@ -70,6 +70,7 @@ typedef struct PnvLpcController {
>      PnvPsi *psi;
>  
>      bool   primary;
> +    char   *isa_bus_name;

I'd suggest putting 'dt' somewhere in the field to make it more
obvious that this is about the bus's path in the device tree, rather
than say the bus's QOM path name.

>  } PnvLpcController;
>  
>  ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, int chip_type);
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index d2126ee4affc..72cfe4c2627c 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -267,14 +267,7 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
>  
>  static int pnv_chip_lpc_offset(PnvChip *chip, void *fdt)
>  {
> -    char *name;
> -    int offset;
> -
> -    name = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
> -                           (uint64_t) PNV_XSCOM_BASE(chip), PNV_XSCOM_LPC_BASE);
> -    offset = fdt_path_offset(fdt, name);
> -    g_free(name);
> -    return offset;
> +    return fdt_path_offset(fdt, chip->lpc.isa_bus_name);
>  }

Having reduced this wrapper to 1 line, I'm not sure there is any
remaining point to it.

>  
>  static void pnv_dt_chip(PnvChip *chip, void *fdt)
> diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
> index 7c6c012d5176..7f13c4bcf52c 100644
> --- a/hw/ppc/pnv_lpc.c
> +++ b/hw/ppc/pnv_lpc.c
> @@ -481,6 +481,10 @@ static void pnv_lpc_realize(DeviceState *dev, Error **errp)
>      pnv_xscom_region_init(&lpc->xscom_regs, OBJECT(dev),
>                            &pnv_lpc_xscom_ops, lpc, "xscom-lpc",
>                            PNV_XSCOM_LPC_SIZE);
> +
> +    lpc->isa_bus_name = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
> +                                        (uint64_t) PNV_XSCOM_BASE(chip),
> +                                        PNV_XSCOM_LPC_BASE);
>  }
>  
>  static void pnv_lpc_class_init(ObjectClass *klass, void *data)
diff mbox

Patch

diff --git a/include/hw/ppc/pnv_lpc.h b/include/hw/ppc/pnv_lpc.h
index fb4b7b83d798..e8f7dcb9bfe9 100644
--- a/include/hw/ppc/pnv_lpc.h
+++ b/include/hw/ppc/pnv_lpc.h
@@ -70,6 +70,7 @@  typedef struct PnvLpcController {
     PnvPsi *psi;
 
     bool   primary;
+    char   *isa_bus_name;
 } PnvLpcController;
 
 ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, int chip_type);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index d2126ee4affc..72cfe4c2627c 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -267,14 +267,7 @@  static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
 
 static int pnv_chip_lpc_offset(PnvChip *chip, void *fdt)
 {
-    char *name;
-    int offset;
-
-    name = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
-                           (uint64_t) PNV_XSCOM_BASE(chip), PNV_XSCOM_LPC_BASE);
-    offset = fdt_path_offset(fdt, name);
-    g_free(name);
-    return offset;
+    return fdt_path_offset(fdt, chip->lpc.isa_bus_name);
 }
 
 static void pnv_dt_chip(PnvChip *chip, void *fdt)
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 7c6c012d5176..7f13c4bcf52c 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -481,6 +481,10 @@  static void pnv_lpc_realize(DeviceState *dev, Error **errp)
     pnv_xscom_region_init(&lpc->xscom_regs, OBJECT(dev),
                           &pnv_lpc_xscom_ops, lpc, "xscom-lpc",
                           PNV_XSCOM_LPC_SIZE);
+
+    lpc->isa_bus_name = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
+                                        (uint64_t) PNV_XSCOM_BASE(chip),
+                                        PNV_XSCOM_LPC_BASE);
 }
 
 static void pnv_lpc_class_init(ObjectClass *klass, void *data)