Skip to contentSkip to conversation

pc-dimm: use same mechanism for [get|set]_addr

PATCH In review Wei Yang 2 participants 3 messages Feb 11, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH v2 1/1 pc-dimm: use same mechanism for [get|set]_addr

[get|set]_addr are two counterpart to access PCDIMMDevice.addr.

Since we have already set up a property PC_DIMM_ADDR_PROP for this field and use this mechanism in set_addr, it would be more proper to use the same mechanism in get_addr.

This patch uses object_property_get_uint() to replace the direct memory access to make [get|set]_addr with the same mechanism.

---
v2: replace NULL with error_abort to handle error properly

---
 hw/mem/pc-dimm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/mem/pc-dimm.c +1 -3
index 0c9b9e8292..152400b1fc 100644
@@ -204,9 +204,7 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error **errp)
 
 static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)
 {
-    const PCDIMMDevice *dimm = PC_DIMM(md);
-
-    return dimm->addr;
+    return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, &error_abort);
 }
 
 static void pc_dimm_md_set_addr(MemoryDeviceState *md, uint64_t addr,
Signature · 1 line
2.19.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · On Mon, 11 Feb 2019 14:46:29 +0800 Wei Yang <[email protected]>…

[get|set]_addr are two counterpart to access PCDIMMDevice.addr.

Since we have already set up a property PC_DIMM_ADDR_PROP for this field and use this mechanism in set_addr, it would be more proper to use the same mechanism in get_addr.

This patch uses object_property_get_uint() to replace the direct memory access to make [get|set]_addr with the same mechanism.

Quoted 22 lines

---
v2: replace NULL with error_abort to handle error properly

---
 hw/mem/pc-dimm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/mem/pc-dimm.c +1 -3
index 0c9b9e8292..152400b1fc 100644
@@ -204,9 +204,7 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error **errp)
 
 static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)
 {
-    const PCDIMMDevice *dimm = PC_DIMM(md);
-
-    return dimm->addr;
+    return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, &error_abort);
 }
 
 static void pc_dimm_md_set_addr(MemoryDeviceState *md, uint64_t addr,
author
#2 lore raw
Quoted 9 lines · Igor Mammedov
Quoted 6 lines · On Mon, 11 Feb 2019 14:46:29 +0800 Wei Yang <[email protected]>…

[get|set]_addr are two counterpart to access PCDIMMDevice.addr.

Since we have already set up a property PC_DIMM_ADDR_PROP for this field and use this mechanism in set_addr, it would be more proper to use the same mechanism in get_addr.

Quoted 7 lines
Quoted 4 lines

This patch uses object_property_get_uint() to replace the direct memory access to make [get|set]_addr with the same mechanism.

Thanks :-)

Quoted 22 lines
Quoted 22 lines

---
v2: replace NULL with error_abort to handle error properly

---
 hw/mem/pc-dimm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/mem/pc-dimm.c +1 -3
index 0c9b9e8292..152400b1fc 100644
@@ -204,9 +204,7 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error **errp)
 
 static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md)
 {
-    const PCDIMMDevice *dimm = PC_DIMM(md);
-
-    return dimm->addr;
+    return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, &error_abort);
 }
 
 static void pc_dimm_md_set_addr(MemoryDeviceState *md, uint64_t addr,
Signature · 2 lines
Wei Yang
Help you, Help me