[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/53] pci/shpc: refactor shpc_device_plug_common()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 25/53] pci/shpc: refactor shpc_device_plug_common() |
Date: |
Thu, 2 Mar 2023 03:25:47 -0500 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Rename it to shpc_device_get_slot(), to mention what it does rather
than how it is used. It also helps to reuse it in further commit.
Also, add a return value and get rid of local_err.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Anton Kuchin <antonkuchin@yandex-team.ru>
Message-Id: <20230216180356.156832-7-vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci/shpc.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index 9f964b1d70..e7bc7192f1 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -496,8 +496,9 @@ static const MemoryRegionOps shpc_mmio_ops = {
.max_access_size = 4,
},
};
-static void shpc_device_plug_common(PCIDevice *affected_dev, int *slot,
- SHPCDevice *shpc, Error **errp)
+
+static bool shpc_device_get_slot(PCIDevice *affected_dev, int *slot,
+ SHPCDevice *shpc, Error **errp)
{
int pci_slot = PCI_SLOT(affected_dev->devfn);
*slot = SHPC_PCI_TO_IDX(pci_slot);
@@ -507,21 +508,20 @@ static void shpc_device_plug_common(PCIDevice
*affected_dev, int *slot,
"controller. Valid slots are between %d and %d.",
pci_slot, SHPC_IDX_TO_PCI(0),
SHPC_IDX_TO_PCI(shpc->nslots) - 1);
- return;
+ return false;
}
+
+ return true;
}
void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
- Error *local_err = NULL;
PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
SHPCDevice *shpc = pci_hotplug_dev->shpc;
int slot;
- shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!shpc_device_get_slot(PCI_DEVICE(dev), &slot, shpc, errp)) {
return;
}
@@ -563,16 +563,13 @@ void shpc_device_unplug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev,
void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
- Error *local_err = NULL;
PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
SHPCDevice *shpc = pci_hotplug_dev->shpc;
uint8_t state;
uint8_t led;
int slot;
- shpc_device_plug_common(PCI_DEVICE(dev), &slot, shpc, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!shpc_device_get_slot(PCI_DEVICE(dev), &slot, shpc, errp)) {
return;
}
--
MST
- [PULL 15/53] hw/timer/hpet: Fix expiration time overflow, (continued)
- [PULL 15/53] hw/timer/hpet: Fix expiration time overflow, Michael S. Tsirkin, 2023/03/02
- [PULL 06/53] Revert "x86: use typedef for SetupData struct", Michael S. Tsirkin, 2023/03/02
- [PULL 18/53] vhost-user: Adopt new backend naming, Michael S. Tsirkin, 2023/03/02
- [PULL 19/53] vdpa: stop all svq on device deletion, Michael S. Tsirkin, 2023/03/02
- [PULL 20/53] pci/shpc: set attention led to OFF on reset, Michael S. Tsirkin, 2023/03/02
- [PULL 21/53] pci/shpc: change shpc_get_status() return type to uint8_t, Michael S. Tsirkin, 2023/03/02
- [PULL 22/53] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition, Michael S. Tsirkin, 2023/03/02
- [PULL 23/53] pci/shpc: more generic handle hot-unplug in shpc_slot_command(), Michael S. Tsirkin, 2023/03/02
- [PULL 27/53] pcie_regs: drop duplicated indicator value macros, Michael S. Tsirkin, 2023/03/02
- [PULL 24/53] pci/shpc: pass PCIDevice pointer to shpc_slot_command(), Michael S. Tsirkin, 2023/03/02
- [PULL 25/53] pci/shpc: refactor shpc_device_plug_common(),
Michael S. Tsirkin <=
- [PULL 26/53] pcie: pcie_cap_slot_write_config(): use correct macro, Michael S. Tsirkin, 2023/03/02
- [PULL 29/53] pcie: pcie_cap_slot_enable_power() use correct helper, Michael S. Tsirkin, 2023/03/02
- [PULL 28/53] pcie: drop unused PCIExpressIndicator, Michael S. Tsirkin, 2023/03/02
- [PULL 31/53] pcie: set power indicator to off on reset by default, Michael S. Tsirkin, 2023/03/02
- [PULL 32/53] vhost: avoid a potential use of an uninitialized variable in vhost_svq_poll(), Michael S. Tsirkin, 2023/03/02
- [PULL 34/53] hw/pci: Trace IRQ routing on PCI topology, Michael S. Tsirkin, 2023/03/02
- [PULL 33/53] libvhost-user: check for NULL when allocating a virtqueue element, Michael S. Tsirkin, 2023/03/02