Skip to contentSkip to conversation

hw/sh4/sh_pci.c: Use ldl_le_p() and stl_le_p()

PATCH In review Peter Maydell 3 participants 4 messages Jun 10, 2016 – Jun 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/sh4/sh_pci.c: Use ldl_le_p() and stl_le_p()

Use ldl_le_p() and stl_le_p() instead of le32_to_cpup() and cpu_to_le32w(); the former handle misaligned addresses and don't need casts, and the latter are deprecated.

---
 hw/sh4/sh_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/sh4/sh_pci.c +2 -2
index e820a32..1747628 100644
@@ -55,7 +55,7 @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val,
 
     switch(addr) {
     case 0 ... 0xfc:
-        cpu_to_le32w((uint32_t*)(pcic->dev->config + addr), val);
+        stl_le_p(pcic->dev->config + addr, val);
         break;
     case 0x1c0:
         pcic->par = val;
@@ -85,7 +85,7 @@ static uint64_t sh_pci_reg_read (void *p, hwaddr addr,
 
     switch(addr) {
     case 0 ... 0xfc:
-        return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
+        return ldl_le_p(pcic->dev->config + addr);
     case 0x1c0:
         return pcic->par;
     case 0x1c4:
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Peter Maydell

Use ldl_le_p() and stl_le_p() instead of le32_to_cpup() and cpu_to_le32w(); the former handle misaligned addresses and don't need casts, and the latter are deprecated.

---
 hw/sh4/sh_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Acked-by on v1 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 23 lines · Peter Maydell

Use ldl_le_p() and stl_le_p() instead of le32_to_cpup() and cpu_to_le32w(); the former handle misaligned addresses and don't need casts, and the latter are deprecated.

---
 hw/sh4/sh_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/sh4/sh_pci.c +1 -1
index e820a32..1747628 100644
@@ -55,7 +55,7 @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val,
 
     switch(addr) {
     case 0 ... 0xfc:
-        cpu_to_le32w((uint32_t*)(pcic->dev->config + addr), val);
+        stl_le_p(pcic->dev->config + addr, val);
         break;
     case 0x1c0:
         pcic->par = val;

hw/sh4/sh_pci.c static uint64_t sh_pci_reg_read (void *p, hwaddr addr, · line 91

Quoted 8 lines
hw/sh4/sh_pci.c +1 -1
@@ -85,7 +85,7 @@ static uint64_t sh_pci_reg_read (void *p, hwaddr addr,
 
     switch(addr) {
     case 0 ... 0xfc:
-        return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
+        return ldl_le_p(pcic->dev->config + addr);
     case 0x1c0:
         return pcic->par;
     case 0x1c4:

Thanks for the patch. I confirm it builds and works fine.

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
author Applied
#3 lore raw
Quoted 35 lines · Aurelien Jarno
Quoted 23 lines · Peter Maydell

Use ldl_le_p() and stl_le_p() instead of le32_to_cpup() and cpu_to_le32w(); the former handle misaligned addresses and don't need casts, and the latter are deprecated.

---
 hw/sh4/sh_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/sh4/sh_pci.c +1 -1
index e820a32..1747628 100644
@@ -55,7 +55,7 @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val,
 
     switch(addr) {
     case 0 ... 0xfc:
-        cpu_to_le32w((uint32_t*)(pcic->dev->config + addr), val);
+        stl_le_p(pcic->dev->config + addr, val);
         break;
     case 0x1c0:
         pcic->par = val;

hw/sh4/sh_pci.c static uint64_t sh_pci_reg_read (void *p, hwaddr addr, · line 91

Quoted 8 lines
hw/sh4/sh_pci.c +1 -1
@@ -85,7 +85,7 @@ static uint64_t sh_pci_reg_read (void *p, hwaddr addr,
 
     switch(addr) {
     case 0 ... 0xfc:
-        return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
+        return ldl_le_p(pcic->dev->config + addr);
     case 0x1c0:
         return pcic->par;
     case 0x1c4:

Thanks for the patch. I confirm it builds and works fine.

Quoted 1 line

Applied to master, thanks.

-- PMM