From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
bharata@linux.vnet.ibm.com, sursingh@redhat.com, groug@kaod.org
Subject: Re: [Qemu-devel] [PATCH 4/5] spapr: Eliminate spapr_drc_get_type_str()
Date: Sat, 03 Jun 2017 17:27:47 -0500 [thread overview]
Message-ID: <149652886727.2695.14249081582792918118@loki> (raw)
In-Reply-To: <20170602072952.25454-5-david@gibson.dropbear.id.au>
Quoting David Gibson (2017-06-02 02:29:51)
> This function was used in generating the device tree. However, now that
> we have different QOM types for different DRC types we can easily store
> the information we need in the class structure and avoid this specialized
> lookup function.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr_drc.c | 31 ++++---------------------------
> include/hw/ppc/spapr_drc.h | 1 +
> 2 files changed, 5 insertions(+), 27 deletions(-)
>
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index 27d4bd3..d43c9cd 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -716,6 +716,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, void *data)
> sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
>
> drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU;
> + drck->typename = "CPU";
> }
>
> static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
> @@ -723,6 +724,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
> sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
>
> drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI;
> + drck->typename = "28";
> }
>
> static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
> @@ -730,6 +732,7 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
> sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
>
> drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB;
> + drck->typename = "MEM";
> }
>
> static const TypeInfo spapr_dr_connector_info = {
> @@ -796,31 +799,6 @@ sPAPRDRConnector *spapr_drc_by_id(const char *type, uint32_t id)
> | (id & DRC_INDEX_ID_MASK));
> }
>
> -/* generate a string the describes the DRC to encode into the
> - * device tree.
> - *
> - * as documented by PAPR+ v2.7, 13.5.2.6 and C.6.1
> - */
> -static const char *spapr_drc_get_type_str(sPAPRDRConnectorType type)
> -{
> - switch (type) {
> - case SPAPR_DR_CONNECTOR_TYPE_CPU:
> - return "CPU";
> - case SPAPR_DR_CONNECTOR_TYPE_PHB:
> - return "PHB";
> - case SPAPR_DR_CONNECTOR_TYPE_VIO:
> - return "SLOT";
> - case SPAPR_DR_CONNECTOR_TYPE_PCI:
> - return "28";
> - case SPAPR_DR_CONNECTOR_TYPE_LMB:
> - return "MEM";
> - default:
> - g_assert(false);
> - }
> -
> - return NULL;
> -}
> -
> /**
> * spapr_drc_populate_dt
> *
> @@ -902,8 +880,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
> drc_names = g_string_insert_len(drc_names, -1, "\0", 1);
>
> /* ibm,drc-types */
> - drc_types = g_string_append(drc_types,
> - spapr_drc_get_type_str(spapr_drc_type(drc)));
> + drc_types = g_string_append(drc_types, drck->typename);
> drc_types = g_string_insert_len(drc_types, -1, "\0", 1);
> }
>
> diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
> index 53b0f8b..8a4889a 100644
> --- a/include/hw/ppc/spapr_drc.h
> +++ b/include/hw/ppc/spapr_drc.h
> @@ -212,6 +212,7 @@ typedef struct sPAPRDRConnectorClass {
>
> /*< public >*/
> sPAPRDRConnectorTypeShift typeshift;
> + const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */
>
> /* accessors for guest-visible (generally via RTAS) DR state */
> uint32_t (*set_isolation_state)(sPAPRDRConnector *drc,
> --
> 2.9.4
>
next prev parent reply other threads:[~2017-06-03 22:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 7:29 [Qemu-devel] [PATCH 0/5] spapr: DRC cleanups (part II) David Gibson
2017-06-02 7:29 ` [Qemu-devel] [PATCH 1/5] spapr: Introduce DRC subclasses David Gibson
2017-06-03 22:05 ` Michael Roth
2017-06-04 10:25 ` David Gibson
2017-06-05 3:31 ` [Qemu-devel] [PATCHv2 " David Gibson
2017-06-05 16:32 ` Michael Roth
2017-06-05 23:37 ` David Gibson
2017-06-02 7:29 ` [Qemu-devel] [PATCH 2/5] spapr: Clean up spapr_dr_connector_by_*() David Gibson
2017-06-03 22:16 ` Michael Roth
2017-06-02 7:29 ` [Qemu-devel] [PATCH 3/5] spapr: Move configure-connector state into DRC David Gibson
2017-06-03 22:24 ` Michael Roth
2017-06-04 10:26 ` David Gibson
2017-06-02 7:29 ` [Qemu-devel] [PATCH 4/5] spapr: Eliminate spapr_drc_get_type_str() David Gibson
2017-06-03 22:27 ` Michael Roth [this message]
2017-06-02 7:29 ` [Qemu-devel] [PATCH 5/5] spapr: Remove some non-useful properties on DRC objects David Gibson
2017-06-03 22:34 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=149652886727.2695.14249081582792918118@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=bharata@linux.vnet.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sursingh@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).