From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKj-0004RQ-NU for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFLKd-0007e8-LJ for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50639 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKd-0007dr-Fy for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:07 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5LCxNaB004154 for ; Tue, 21 Jun 2016 09:03:07 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 23n2ekuau7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Jun 2016 09:03:07 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Jun 2016 14:03:05 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 27C891B08067 for ; Tue, 21 Jun 2016 14:04:14 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5LD32o29699770 for ; Tue, 21 Jun 2016 13:03:02 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5LC34TA017771 for ; Tue, 21 Jun 2016 06:03:04 -0600 From: David Hildenbrand Date: Tue, 21 Jun 2016 15:02:17 +0200 In-Reply-To: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> References: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> Message-Id: <1466514153-85777-13-git-send-email-dahi@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC 12/28] s390x/sclp: factor out preparation of cpu entries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ehabkost@redhat.com, jdenemar@redhat.com, imammedo@redhat.com, cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com Let's factor out the common code of "read cpu info" and "read scp info". This will make the introduction of new cpu entry fields easier. Acked-by: Cornelia Huck Signed-off-by: David Hildenbrand --- hw/s390x/sclp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index fca37f5..15d7114 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -29,6 +29,16 @@ static inline SCLPDevice *get_sclp_device(void) return SCLP(object_resolve_path_type("", TYPE_SCLP, NULL)); } +static void prepare_cpu_entries(SCLPDevice *sclp, CPUEntry *entry, int count) +{ + int i; + + for (i = 0; i < count; i++) { + entry[i].address = i; + entry[i].type = 0; + } +} + /* Provide information about the configuration, CPUs and storage */ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) { @@ -37,7 +47,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev(); CPUState *cpu; int cpu_count = 0; - int i = 0; int rnsize, rnmax; int slots = MIN(machine->ram_slots, s390_get_memslot_count(kvm_state)); @@ -50,10 +59,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries)); read_info->highest_cpu = cpu_to_be16(max_cpus); - for (i = 0; i < cpu_count; i++) { - read_info->entries[i].address = i; - read_info->entries[i].type = 0; - } + prepare_cpu_entries(sclp, read_info->entries, cpu_count); read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO | SCLP_HAS_PCI_RECONFIG); @@ -304,7 +310,6 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb; CPUState *cpu; int cpu_count = 0; - int i = 0; CPU_FOREACH(cpu) { cpu_count++; @@ -318,10 +323,7 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured + cpu_info->nr_configured*sizeof(CPUEntry)); - for (i = 0; i < cpu_count; i++) { - cpu_info->entries[i].address = i; - cpu_info->entries[i].type = 0; - } + prepare_cpu_entries(sclp, cpu_info->entries, cpu_count); sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION); } -- 2.6.6