diff mbox

[v2] audio: intel-hda: do not use old_mmio accesses

Message ID 20170823193703.10808-1-mtparkr@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matt Parker Aug. 23, 2017, 7:37 p.m. UTC
intel-hda is currently using the old_mmio accessors for io.
This updates the device to use .read and .write accessors instead.

Signed-off-by: Matt Parker <mtparkr@gmail.com>
---
 hw/audio/intel-hda.c | 57 +++++++++-------------------------------------------
 1 file changed, 10 insertions(+), 47 deletions(-)

Comments

Matt Parker Aug. 23, 2017, 8:13 p.m. UTC | #1
I've just noticed the suggested changes from the v1 patch regarding
using MAKE_64BIT_MASK.
This patch is can be ignored for now.

On 23 August 2017 at 20:37, Matt Parker <mtparkr@gmail.com> wrote:
> intel-hda is currently using the old_mmio accessors for io.
> This updates the device to use .read and .write accessors instead.
>
> Signed-off-by: Matt Parker <mtparkr@gmail.com>
> ---
>  hw/audio/intel-hda.c | 57 +++++++++-------------------------------------------
>  1 file changed, 10 insertions(+), 47 deletions(-)
>
> diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
> index 06acc98f7b..95e3e460fb 100644
> --- a/hw/audio/intel-hda.c
> +++ b/hw/audio/intel-hda.c
> @@ -1043,66 +1043,29 @@ static void intel_hda_regs_reset(IntelHDAState *d)
>
>  /* --------------------------------------------------------------------- */
>
> -static void intel_hda_mmio_writeb(void *opaque, hwaddr addr, uint32_t val)
> +static void intel_hda_mmio_write(void *opaque, hwaddr addr, uint64_t val,
> +                                 unsigned size)
>  {
>      IntelHDAState *d = opaque;
>      const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
>
> -    intel_hda_reg_write(d, reg, val, 0xff);
> +    intel_hda_reg_write(d, reg, val, (1UL << (size * 8)) - 1);
>  }
>
> -static void intel_hda_mmio_writew(void *opaque, hwaddr addr, uint32_t val)
> +static uint64_t intel_hda_mmio_read(void *opaque, hwaddr addr, unsigned size)
>  {
>      IntelHDAState *d = opaque;
>      const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
>
> -    intel_hda_reg_write(d, reg, val, 0xffff);
> -}
> -
> -static void intel_hda_mmio_writel(void *opaque, hwaddr addr, uint32_t val)
> -{
> -    IntelHDAState *d = opaque;
> -    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
> -
> -    intel_hda_reg_write(d, reg, val, 0xffffffff);
> -}
> -
> -static uint32_t intel_hda_mmio_readb(void *opaque, hwaddr addr)
> -{
> -    IntelHDAState *d = opaque;
> -    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
> -
> -    return intel_hda_reg_read(d, reg, 0xff);
> -}
> -
> -static uint32_t intel_hda_mmio_readw(void *opaque, hwaddr addr)
> -{
> -    IntelHDAState *d = opaque;
> -    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
> -
> -    return intel_hda_reg_read(d, reg, 0xffff);
> -}
> -
> -static uint32_t intel_hda_mmio_readl(void *opaque, hwaddr addr)
> -{
> -    IntelHDAState *d = opaque;
> -    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
> -
> -    return intel_hda_reg_read(d, reg, 0xffffffff);
> +    return intel_hda_reg_read(d, reg, (1UL << (size * 8)) - 1);
>  }
>
>  static const MemoryRegionOps intel_hda_mmio_ops = {
> -    .old_mmio = {
> -        .read = {
> -            intel_hda_mmio_readb,
> -            intel_hda_mmio_readw,
> -            intel_hda_mmio_readl,
> -        },
> -        .write = {
> -            intel_hda_mmio_writeb,
> -            intel_hda_mmio_writew,
> -            intel_hda_mmio_writel,
> -        },
> +    .read = intel_hda_mmio_read,
> +    .write = intel_hda_mmio_write,
> +    .impl = {
> +        .min_access_size = 1,
> +        .max_access_size = 4,
>      },
>      .endianness = DEVICE_NATIVE_ENDIAN,
>  };
> --
> 2.13.2
>
Gerd Hoffmann Aug. 24, 2017, 8:15 a.m. UTC | #2
On Wed, 2017-08-23 at 20:37 +0100, Matt Parker wrote:
> +    intel_hda_reg_write(d, reg, val, (1UL << (size * 8)) - 1);

Hmm?  Same as v1, forgot to commit the changes?

cheers,
  Gerd
diff mbox

Patch

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 06acc98f7b..95e3e460fb 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -1043,66 +1043,29 @@  static void intel_hda_regs_reset(IntelHDAState *d)
 
 /* --------------------------------------------------------------------- */
 
-static void intel_hda_mmio_writeb(void *opaque, hwaddr addr, uint32_t val)
+static void intel_hda_mmio_write(void *opaque, hwaddr addr, uint64_t val,
+                                 unsigned size)
 {
     IntelHDAState *d = opaque;
     const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
 
-    intel_hda_reg_write(d, reg, val, 0xff);
+    intel_hda_reg_write(d, reg, val, (1UL << (size * 8)) - 1);
 }
 
-static void intel_hda_mmio_writew(void *opaque, hwaddr addr, uint32_t val)
+static uint64_t intel_hda_mmio_read(void *opaque, hwaddr addr, unsigned size)
 {
     IntelHDAState *d = opaque;
     const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
 
-    intel_hda_reg_write(d, reg, val, 0xffff);
-}
-
-static void intel_hda_mmio_writel(void *opaque, hwaddr addr, uint32_t val)
-{
-    IntelHDAState *d = opaque;
-    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
-
-    intel_hda_reg_write(d, reg, val, 0xffffffff);
-}
-
-static uint32_t intel_hda_mmio_readb(void *opaque, hwaddr addr)
-{
-    IntelHDAState *d = opaque;
-    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
-
-    return intel_hda_reg_read(d, reg, 0xff);
-}
-
-static uint32_t intel_hda_mmio_readw(void *opaque, hwaddr addr)
-{
-    IntelHDAState *d = opaque;
-    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
-
-    return intel_hda_reg_read(d, reg, 0xffff);
-}
-
-static uint32_t intel_hda_mmio_readl(void *opaque, hwaddr addr)
-{
-    IntelHDAState *d = opaque;
-    const IntelHDAReg *reg = intel_hda_reg_find(d, addr);
-
-    return intel_hda_reg_read(d, reg, 0xffffffff);
+    return intel_hda_reg_read(d, reg, (1UL << (size * 8)) - 1);
 }
 
 static const MemoryRegionOps intel_hda_mmio_ops = {
-    .old_mmio = {
-        .read = {
-            intel_hda_mmio_readb,
-            intel_hda_mmio_readw,
-            intel_hda_mmio_readl,
-        },
-        .write = {
-            intel_hda_mmio_writeb,
-            intel_hda_mmio_writew,
-            intel_hda_mmio_writel,
-        },
+    .read = intel_hda_mmio_read,
+    .write = intel_hda_mmio_write,
+    .impl = {
+        .min_access_size = 1,
+        .max_access_size = 4,
     },
     .endianness = DEVICE_NATIVE_ENDIAN,
 };