mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: <kvm@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <matt@ozlabs.org>,
	<penberg@kernel.org>, <kvm-ppc@vger.kernel.org>,
	<prerna@linux.vnet.ibm.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 04/10] kvm tools, powerpc: Use designated initializers for struct cpu_info
Date: Tue, 17 Jul 2012 15:00:14 +1000	[thread overview]
Message-ID: <1342501220-10209-5-git-send-email-michael@ellerman.id.au> (raw)
In-Reply-To: <1342501220-10209-1-git-send-email-michael@ellerman.id.au>

Using designated initializers for structs is preferable because it
is self documenting, and more robust against changes to the structure
layout.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 tools/kvm/powerpc/cpu_info.c |   38 +++++++++++++++++++++-----------------
 tools/kvm/powerpc/cpu_info.h |    6 +++---
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/tools/kvm/powerpc/cpu_info.c b/tools/kvm/powerpc/cpu_info.c
index c364b74..ad27451 100644
--- a/tools/kvm/powerpc/cpu_info.c
+++ b/tools/kvm/powerpc/cpu_info.c
@@ -30,14 +30,16 @@ static u32 power7_page_sizes_prop[] = {0xc, 0x0, 0x1, 0xc, 0x0, 0x18, 0x100, 0x1
 static u32 power7_segment_sizes_prop[] = {0x1c, 0x28, 0xffffffff, 0xffffffff};
 
 static struct cpu_info cpu_power7_info = {
-	"POWER7",
-	power7_page_sizes_prop, sizeof(power7_page_sizes_prop),
-	power7_segment_sizes_prop, sizeof(power7_segment_sizes_prop),
-	32, 		/* SLB size */
-	512000000, 	/* TB frequency */
-	128,		/* d-cache block size */
-	128,		/* i-cache block size */
-	CPUINFO_FLAG_DFP | CPUINFO_FLAG_VSX | CPUINFO_FLAG_VMX
+	.name = "POWER7",
+	.page_sizes_prop = power7_page_sizes_prop,
+	.page_sizes_prop_len = sizeof(power7_segment_sizes_prop),
+	.segment_sizes_prop = power7_segment_sizes_prop,
+	.segment_sizes_prop_len = sizeof(power7_segment_sizes_prop),
+	.slb_size = 32,
+	.tb_freq = 512000000,
+	.d_bsize = 128,
+	.i_bsize = 128,
+	.flags = CPUINFO_FLAG_DFP | CPUINFO_FLAG_VSX | CPUINFO_FLAG_VMX,
 };
 
 /* PPC970/G5 */
@@ -45,18 +47,20 @@ static struct cpu_info cpu_power7_info = {
 static u32 g5_page_sizes_prop[] = {0xc, 0x0, 0x1, 0xc, 0x0, 0x18, 0x100, 0x1, 0x18, 0x0};
 
 static struct cpu_info cpu_970_info = {
-	"G5",
-	g5_page_sizes_prop, sizeof(g5_page_sizes_prop),
-	0 /* Null = no segment sizes prop, use defaults */, 0,
-	0, 		/* SLB size default */
-	33333333, 	/* TB frequency */
-	128,		/* d-cache block size */
-	128,		/* i-cache block size */
-	CPUINFO_FLAG_VMX
+	.name = "G5",
+	.page_sizes_prop = g5_page_sizes_prop,
+	.page_sizes_prop_len = sizeof(g5_page_sizes_prop),
+	.segment_sizes_prop = NULL /* no segment sizes prop, use defaults */,
+	.segment_sizes_prop_len = 0,
+	.slb_size = 0,
+	.tb_freq = 33333333,
+	.d_bsize = 128,
+	.i_bsize = 128,
+	.flags = CPUINFO_FLAG_VMX,
 };
 
 /* This is a default catchall for 'no match' on PVR: */
-static struct cpu_info cpu_dummy_info = { "unknown", 0, 0, 0, 0, 0, 0, 0, 0 };
+static struct cpu_info cpu_dummy_info = { .name = "unknown" };
 
 static struct pvr_info host_pvr_info[] = {
 	{ 0xffffffff, 0x0f000003, &cpu_power7_info },
diff --git a/tools/kvm/powerpc/cpu_info.h b/tools/kvm/powerpc/cpu_info.h
index 4a43ed5..2115c7f 100644
--- a/tools/kvm/powerpc/cpu_info.h
+++ b/tools/kvm/powerpc/cpu_info.h
@@ -21,9 +21,9 @@ struct cpu_info {
 	u32 		*segment_sizes_prop;
 	u32		segment_sizes_prop_len;
 	u32		slb_size;
-	u32		tb_freq;
-	u32		d_bsize;
-	u32		i_bsize;
+	u32		tb_freq; /* timebase frequency */
+	u32		d_bsize; /* d-cache block size */
+	u32		i_bsize; /* i-cache block size */
 	u32		flags;
 };
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-07-17  5:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-17  5:00 [RFC/PATCH] Use kernel supplied MMU info for kvm tool Michael Ellerman
2012-07-17  5:00 ` [PATCH 01/10] kvm tools: Move mmap_anon_or_hugetblfs() into util Michael Ellerman
2012-07-17  5:00 ` [PATCH 02/10] kvm tools, powerpc: Use mmap_anon_or_hugetblfs() in kvm__arch_init() Michael Ellerman
2012-07-17  5:00 ` [PATCH 03/10] kvm tools: Remember page size as kvm->ram_pagesize Michael Ellerman
2012-07-17  5:00 ` Michael Ellerman [this message]
2012-07-17  5:00 ` [PATCH 05/10] kvm tools, powerpc: Use ARRAY_SIZE() in find_cpu_info() Michael Ellerman
2012-07-17  5:00 ` [PATCH 06/10] kvm tools, powerpc: Reformatting " Michael Ellerman
2012-07-17  5:00 ` [PATCH 07/10] kvm tools, powerpc: Restructure find_cpu_info() Michael Ellerman
2012-07-17  5:00 ` [PATCH 08/10] kvm tools, powerpc: Use MMU info from the kernel for ibm,segment-page-sizes Michael Ellerman
2012-07-17  5:00 ` [PATCH 09/10] kvm tools, powerpc: Use MMU info for ibm,processor-segment-sizes Michael Ellerman
2012-07-17  5:00 ` [PATCH 10/10] kvm tools, powerpc: Use MMU info for ibm,slb-size Michael Ellerman
2012-07-17  9:33 ` [RFC/PATCH] Use kernel supplied MMU info for kvm tool Matt Evans
2012-07-17 14:09   ` Pekka Enberg
2012-07-18  2:08     ` Michael Ellerman
2012-07-31  6:22       ` Pekka Enberg
2012-07-18  2:03   ` Michael Ellerman

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=1342501220-10209-5-git-send-email-michael@ellerman.id.au \
    --to=michael@ellerman.id.au \
    --cc=david@gibson.dropbear.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@ozlabs.org \
    --cc=penberg@kernel.org \
    --cc=prerna@linux.vnet.ibm.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

all inboxes | Powered by JetHome®