Skip to contentSkip to conversation

hw/arm: Adjust some coding styles about memory hotplug

PATCH In review Keqian Zhu 3 participants 4 messages Jan 17, 2020 – Jan 19, 2020

lore
Share & tools
lore

Keqian Zhu

author
#0 lore raw

PATCH v2 1/1 hw/arm: Adjust some coding styles about memory hotplug

From: zhukeqian <[email protected]>

There is extra indent in ACPI GED plug cb. And we can use existing helper function to trigger hotplug handler plug.

---

v1->v2:
- Add Igor's R-b

Cc Shameer Kolothum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Maydell <[email protected]>
---
 hw/acpi/generic_event_device.c | 2 +-
 hw/arm/virt.c                  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/generic_event_device.c +1 -1
index 9cee90cc70..55eb29d80a 100644
@@ -175,7 +175,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
     AcpiGedState *s = ACPI_GED(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
+        acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
     } else {
         error_setg(errp, "virt: device plug request for unsupported device"
                    " type: %s", object_get_typename(OBJECT(dev)));
hw/arm/virt.c +3 -3
index 39ab5f47e0..656b0081c2 100644
@@ -1934,7 +1934,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void virt_memory_plug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
-    HotplugHandlerClass *hhc;
     VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
@@ -1943,8 +1942,9 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
         goto out;
     }
 
-    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
-    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort);
+    hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev),
+                         dev, &error_abort);
+
 out:
     error_propagate(errp, local_err);
 }
Signature · 1 line
2.19.1
#1 lore raw
Quoted 11 lines · On Fri, 17 Jan 2020 14:38:22 +0800 Keqian Zhu <[email protected]> wrote:

From: zhukeqian <[email protected]>

There is extra indent in ACPI GED plug cb. And we can use existing helper function to trigger hotplug handler plug.

---

v1->v2:
- Add Igor's R-b

FYI one does not need to repost v2 for the purpose of picking up tags, usually maintainer takes care of that when patch is queued

Quoted 47 lines
Cc Shameer Kolothum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Maydell <[email protected]>
---
 hw/acpi/generic_event_device.c | 2 +-
 hw/arm/virt.c                  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/generic_event_device.c +1 -1
index 9cee90cc70..55eb29d80a 100644
@@ -175,7 +175,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
     AcpiGedState *s = ACPI_GED(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
+        acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
     } else {
         error_setg(errp, "virt: device plug request for unsupported device"
                    " type: %s", object_get_typename(OBJECT(dev)));
hw/arm/virt.c +3 -3
index 39ab5f47e0..656b0081c2 100644
@@ -1934,7 +1934,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void virt_memory_plug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
-    HotplugHandlerClass *hhc;
     VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
@@ -1943,8 +1942,9 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
         goto out;
     }
 
-    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
-    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort);
+    hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev),
+                         dev, &error_abort);
+
 out:
     error_propagate(errp, local_err);
 }
#2 lore raw
In reply to Keqian Zhu
Quoted 49 lines · Keqian Zhu

From: zhukeqian <[email protected]>

There is extra indent in ACPI GED plug cb. And we can use existing helper function to trigger hotplug handler plug.

---

v1->v2:
- Add Igor's R-b

Cc Shameer Kolothum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Maydell <[email protected]>
---
 hw/acpi/generic_event_device.c | 2 +-
 hw/arm/virt.c                  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/generic_event_device.c +1 -1
index 9cee90cc70..55eb29d80a 100644
@@ -175,7 +175,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
     AcpiGedState *s = ACPI_GED(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
+        acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
     } else {
         error_setg(errp, "virt: device plug request for unsupported device"
                    " type: %s", object_get_typename(OBJECT(dev)));
hw/arm/virt.c +0 -1
index 39ab5f47e0..656b0081c2 100644
@@ -1934,7 +1934,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void virt_memory_plug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
-    HotplugHandlerClass *hhc;
     VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
@@ -1943,8 +1942,9 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
         goto out;

hw/arm/virt.c static void virt_memory_plug(HotplugHandler *hotplug_dev, · line 1950

Quoted 10 lines
hw/arm/virt.c +3 -2
     }
 
-    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
-    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort);
+    hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev),
+                         dev, &error_abort);
+
 out:
     error_propagate(errp, local_err);
 }

These two changes are unrelated (one is just a whitespace fixup, and it's in an entirely different file to the other one, which is making an actual code change). I think they should not be in the same patch.

thanks
-- PMM

author
#3 lore raw
Quoted 66 lines · Peter Maydell
Quoted 49 lines · Keqian Zhu

From: zhukeqian <[email protected]>

There is extra indent in ACPI GED plug cb. And we can use existing helper function to trigger hotplug handler plug.

---

v1->v2:
- Add Igor's R-b

Cc Shameer Kolothum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Maydell <[email protected]>
---
 hw/acpi/generic_event_device.c | 2 +-
 hw/arm/virt.c                  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/generic_event_device.c +1 -1
index 9cee90cc70..55eb29d80a 100644
@@ -175,7 +175,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
     AcpiGedState *s = ACPI_GED(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
+        acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
     } else {
         error_setg(errp, "virt: device plug request for unsupported device"
                    " type: %s", object_get_typename(OBJECT(dev)));
hw/arm/virt.c +0 -1
index 39ab5f47e0..656b0081c2 100644
@@ -1934,7 +1934,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void virt_memory_plug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
-    HotplugHandlerClass *hhc;
     VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
@@ -1943,8 +1942,9 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
         goto out;

hw/arm/virt.c static void virt_memory_plug(HotplugHandler *hotplug_dev, · line 1950

Quoted 10 lines
hw/arm/virt.c +3 -2
     }
 
-    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
-    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort);
+    hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_dev),
+                         dev, &error_abort);
+
 out:
     error_propagate(errp, local_err);
 }

These two changes are unrelated (one is just a whitespace fixup, and it's in an entirely different file to the other one, which is making an actual code change). I think they should not be in the same patch.

Quoted 3 lines

thanks
-- PMM

Ok, I will reform this patch.

Thanks,
Keqian

Quoted 2 lines

.