diff mbox

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

Message ID 1465575021-3774-1-git-send-email-peter.maydell@linaro.org
State New
Headers show

Commit Message

Peter Maydell June 10, 2016, 4:10 p.m. UTC
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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/sh4/sh_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Blake June 11, 2016, 8:41 p.m. UTC | #1
On 06/10/2016 10:10 AM, Peter Maydell wrote:
> 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/sh4/sh_pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
Aurelien Jarno June 13, 2016, 6:55 a.m. UTC | #2
On 2016-06-10 17:10, Peter Maydell wrote:
> 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/sh4/sh_pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c
> index e820a32..1747628 100644
> --- a/hw/sh4/sh_pci.c
> +++ b/hw/sh4/sh_pci.c
> @@ -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:

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

Acked-by: Aurelien Jarno <aurelien@aurel32.net>
Peter Maydell June 28, 2016, 2:38 p.m. UTC | #3
On 13 June 2016 at 07:55, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On 2016-06-10 17:10, Peter Maydell wrote:
>> 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.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  hw/sh4/sh_pci.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c
>> index e820a32..1747628 100644
>> --- a/hw/sh4/sh_pci.c
>> +++ b/hw/sh4/sh_pci.c
>> @@ -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:
>
> Thanks for the patch. I confirm it builds and works fine.
>
> Acked-by: Aurelien Jarno <aurelien@aurel32.net>

Applied to master, thanks.

-- PMM
diff mbox

Patch

diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c
index e820a32..1747628 100644
--- a/hw/sh4/sh_pci.c
+++ b/hw/sh4/sh_pci.c
@@ -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: