[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/20] s390x/pci: separate s390_sclp_configure functi
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PULL 13/20] s390x/pci: separate s390_sclp_configure function |
Date: |
Tue, 17 May 2016 16:46:10 +0200 |
From: Yi Min Zhao <address@hidden>
Split s390_sclp_configure() into separate functions for sclp
configuring and deconfiguring in order to make the code more readable.
Signed-off-by: Yi Min Zhao <address@hidden>
Reviewed-by: Pierre Morel <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/s390-pci-bus.c | 30 +++++++++++++++++++++++++-----
hw/s390x/s390-pci-bus.h | 3 ++-
hw/s390x/sclp.c | 4 ++--
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 918b585..c749d00 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -106,22 +106,42 @@ S390PCIBusDevice *s390_pci_find_dev_by_fid(uint32_t fid)
return NULL;
}
-void s390_pci_sclp_configure(int configure, SCCB *sccb)
+void s390_pci_sclp_configure(SCCB *sccb)
{
PciCfgSccb *psccb = (PciCfgSccb *)sccb;
S390PCIBusDevice *pbdev =
s390_pci_find_dev_by_fid(be32_to_cpu(psccb->aid));
uint16_t rc;
if (pbdev) {
- if ((configure == 1 && pbdev->configured == true) ||
- (configure == 0 && pbdev->configured == false)) {
+ if (pbdev->configured) {
rc = SCLP_RC_NO_ACTION_REQUIRED;
} else {
- pbdev->configured = !pbdev->configured;
+ pbdev->configured = true;
rc = SCLP_RC_NORMAL_COMPLETION;
}
} else {
- DPRINTF("sclp config %d no dev found\n", configure);
+ DPRINTF("sclp config no dev found\n");
+ rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
+ }
+
+ psccb->header.response_code = cpu_to_be16(rc);
+}
+
+void s390_pci_sclp_deconfigure(SCCB *sccb)
+{
+ PciCfgSccb *psccb = (PciCfgSccb *)sccb;
+ S390PCIBusDevice *pbdev =
s390_pci_find_dev_by_fid(be32_to_cpu(psccb->aid));
+ uint16_t rc;
+
+ if (pbdev) {
+ if (!pbdev->configured) {
+ rc = SCLP_RC_NO_ACTION_REQUIRED;
+ } else {
+ pbdev->configured = false;
+ rc = SCLP_RC_NORMAL_COMPLETION;
+ }
+ } else {
+ DPRINTF("sclp deconfig no dev found\n");
rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
}
diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h
index 59fd5c9..d6e17d2 100644
--- a/hw/s390x/s390-pci-bus.h
+++ b/hw/s390x/s390-pci-bus.h
@@ -247,7 +247,8 @@ typedef struct S390pciState {
int chsc_sei_nt2_get_event(void *res);
int chsc_sei_nt2_have_event(void);
-void s390_pci_sclp_configure(int configure, SCCB *sccb);
+void s390_pci_sclp_configure(SCCB *sccb);
+void s390_pci_sclp_deconfigure(SCCB *sccb);
void s390_pcihost_iommu_configure(S390PCIBusDevice *pbdev, bool enable);
S390PCIBusDevice *s390_pci_find_dev_by_idx(uint32_t idx);
S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh);
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 85dbe1b..fca37f5 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -357,10 +357,10 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb,
uint32_t code)
sclp_c->unassign_storage(sclp, sccb);
break;
case SCLP_CMDW_CONFIGURE_PCI:
- s390_pci_sclp_configure(1, sccb);
+ s390_pci_sclp_configure(sccb);
break;
case SCLP_CMDW_DECONFIGURE_PCI:
- s390_pci_sclp_configure(0, sccb);
+ s390_pci_sclp_deconfigure(sccb);
break;
default:
efc->command_handler(ef, sccb, code);
--
2.8.2
- [Qemu-devel] [PULL 00/20] First round of s390x patches for 2.7, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 12/20] s390x/pci: fix reg_irqs(), Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 04/20] s390x/ipl: Add type and length checks for IplParameterBlock values, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 01/20] s390x: add compat machine for 2.7, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 13/20] s390x/pci: separate s390_sclp_configure function,
Cornelia Huck <=
- [Qemu-devel] [PULL 14/20] s390x/pci: separate s390_pcihost_iommu_configure function, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 07/20] pc-bios/s390-ccw: Get device address via diag 308/6, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 18/20] s390x/pci: enhance mpcifc_service_call, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 19/20] s390x/pci: add length checking for pci sclp handlers, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 05/20] s390x/ipl: Provide ipl parameter block, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 20/20] s390x/pci: remove whitespace, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 06/20] s390x/ipl: Add ssid field to IplParameterBlock, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 10/20] hw/char: QOM'ify sclpconsole-lm.c, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 15/20] s390x/pci: export pci_dereg_ioat and pci_dereg_irqs, Cornelia Huck, 2016/05/17
- [Qemu-devel] [PULL 09/20] s390x/ipl: Remove redundant usage of gr7, Cornelia Huck, 2016/05/17