[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 13/62] x86/fixmap: Modify fix_to_virt() to return a void pointer



From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Almost all users of fix_to_virt() actually want a pointer.  Include the cast
within the definition, so the callers don't need to.

Two users which need the integer value are switched to using __fix_to_virt()
directly.  A few users stay fully unchanged, due to GCC's void pointer
arithmetic extension causing the same behaviour.  Most users however have
their explicit casting dropped.

Since __iomem is not used consistently in Xen, we drop it too.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
v2: update commit message and remove unnecessary parentheses.
---
 xen/arch/x86/acpi/lib.c         | 2 +-
 xen/arch/x86/mm.c               | 4 ++--
 xen/arch/x86/mpparse.c          | 2 +-
 xen/arch/x86/msi.c              | 3 +--
 xen/arch/x86/tboot.c            | 4 ++--
 xen/drivers/acpi/apei/apei-io.c | 2 +-
 xen/drivers/char/ehci-dbgp.c    | 2 +-
 xen/drivers/char/ns16550.c      | 2 +-
 xen/include/asm-x86/apicdef.h   | 2 +-
 xen/include/asm-x86/fixmap.h    | 2 +-
 10 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
index 7d7c71848b..265b9ad819 100644
--- a/xen/arch/x86/acpi/lib.c
+++ b/xen/arch/x86/acpi/lib.c
@@ -49,7 +49,7 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
        offset = phys & (PAGE_SIZE - 1);
        mapped_size = PAGE_SIZE - offset;
        set_fixmap(FIX_ACPI_END, phys);
-       base = fix_to_virt(FIX_ACPI_END);
+       base = __fix_to_virt(FIX_ACPI_END);
 
        /*
         * Most cases can be covered by the below.
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index a56f875d45..f73fee225e 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5227,12 +5227,12 @@ void __set_fixmap(
     enum fixed_addresses idx, unsigned long mfn, unsigned long flags)
 {
     BUG_ON(idx >= __end_of_fixed_addresses);
-    map_pages_to_xen(fix_to_virt(idx), mfn, 1, flags);
+    map_pages_to_xen(__fix_to_virt(idx), mfn, 1, flags);
 }
 
 void *__init arch_vmap_virt_end(void)
 {
-    return (void *)fix_to_virt(__end_of_fixed_addresses);
+    return fix_to_virt(__end_of_fixed_addresses);
 }
 
 void __iomem *ioremap(paddr_t pa, size_t len)
diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c
index a1a0738a19..49140e46f0 100644
--- a/xen/arch/x86/mpparse.c
+++ b/xen/arch/x86/mpparse.c
@@ -703,7 +703,7 @@ static void __init efi_check_config(void)
                return;
 
        __set_fixmap(FIX_EFI_MPF, PFN_DOWN(efi.mps), __PAGE_HYPERVISOR);
-       mpf = (void *)fix_to_virt(FIX_EFI_MPF) + ((long)efi.mps & 
(PAGE_SIZE-1));
+       mpf = fix_to_virt(FIX_EFI_MPF) + ((long)efi.mps & (PAGE_SIZE-1));
 
        if (memcmp(mpf->mpf_signature, "_MP_", 4) == 0 &&
            mpf->mpf_length == 1 &&
diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
index 095bd3cae7..8c89f072a8 100644
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -960,8 +960,7 @@ static int msix_capability_init(struct pci_dev *dev,
             xfree(entry);
             return idx;
         }
-        base = (void *)(fix_to_virt(idx) +
-                        ((unsigned long)entry_paddr & (PAGE_SIZE - 1)));
+        base = fix_to_virt(idx) + (entry_paddr & (PAGE_SIZE - 1));
 
         /* Mask interrupt here */
         writel(1, base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index 59d7c477f4..d36bf33407 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -82,7 +82,7 @@ static void __init tboot_copy_memory(unsigned char *va, 
uint32_t size,
         {
             map_base = PFN_DOWN(pa + i);
             set_fixmap(FIX_TBOOT_MAP_ADDRESS, map_base << PAGE_SHIFT);
-            map_addr = (unsigned char *)fix_to_virt(FIX_TBOOT_MAP_ADDRESS);
+            map_addr = fix_to_virt(FIX_TBOOT_MAP_ADDRESS);
         }
         va[i] = map_addr[pa + i - (map_base << PAGE_SHIFT)];
     }
@@ -98,7 +98,7 @@ void __init tboot_probe(void)
 
     /* Map and check for tboot UUID. */
     set_fixmap(FIX_TBOOT_SHARED_BASE, opt_tboot_pa);
-    tboot_shared = (tboot_shared_t *)fix_to_virt(FIX_TBOOT_SHARED_BASE);
+    tboot_shared = fix_to_virt(FIX_TBOOT_SHARED_BASE);
     if ( tboot_shared == NULL )
         return;
     if ( memcmp(&tboot_shared_uuid, (uuid_t *)tboot_shared, sizeof(uuid_t)) )
diff --git a/xen/drivers/acpi/apei/apei-io.c b/xen/drivers/acpi/apei/apei-io.c
index 8955de935e..89b70f45ef 100644
--- a/xen/drivers/acpi/apei/apei-io.c
+++ b/xen/drivers/acpi/apei/apei-io.c
@@ -92,7 +92,7 @@ static void __iomem *__init apei_range_map(paddr_t paddr, 
unsigned long size)
                apei_range_nr++;
        }
 
-       return (void __iomem *)fix_to_virt(FIX_APEI_RANGE_BASE + start_nr);
+       return fix_to_virt(FIX_APEI_RANGE_BASE + start_nr);
 }
 
 /*
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index d48e777c34..d0071d3114 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1327,7 +1327,7 @@ static void __init ehci_dbgp_init_preirq(struct 
serial_port *port)
      * than enough.  1k is the biggest that was seen.
      */
     set_fixmap_nocache(FIX_EHCI_DBGP, dbgp->bar_val);
-    ehci_bar = (void __iomem *)fix_to_virt(FIX_EHCI_DBGP);
+    ehci_bar = fix_to_virt(FIX_EHCI_DBGP);
     ehci_bar += dbgp->bar_val & ~PAGE_MASK;
     dbgp_printk("ehci_bar: %p\n", ehci_bar);
 
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index e0f8199f98..f32dbd3247 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -697,7 +697,7 @@ static void __init ns16550_init_preirq(struct serial_port 
*port)
         enum fixed_addresses idx = FIX_COM_BEGIN + (uart - ns16550_com);
 
         set_fixmap_nocache(idx, uart->io_base);
-        uart->remapped_io_base = (void __iomem *)fix_to_virt(idx);
+        uart->remapped_io_base = fix_to_virt(idx);
         uart->remapped_io_base += uart->io_base & ~PAGE_MASK;
 #else
         uart->remapped_io_base = (char *)ioremap(uart->io_base, uart->io_size);
diff --git a/xen/include/asm-x86/apicdef.h b/xen/include/asm-x86/apicdef.h
index eed504a31a..2fa0b77a8a 100644
--- a/xen/include/asm-x86/apicdef.h
+++ b/xen/include/asm-x86/apicdef.h
@@ -119,7 +119,7 @@
 /* Only available in x2APIC mode */
 #define                APIC_SELF_IPI   0x3F0
 
-#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
+#define APIC_BASE __fix_to_virt(FIX_APIC_BASE)
 
 /* It's only used in x2APIC mode of an x2APIC unit. */
 #define APIC_MSR_BASE 0x800
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 89bf6cb611..51b0e7e945 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -79,7 +79,7 @@ extern void __set_fixmap(
 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
 #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
 
-#define fix_to_virt(x)   (__fix_to_virt(x))
+#define fix_to_virt(x)   ((void *)__fix_to_virt(x))
 
 static inline unsigned long virt_to_fix(const unsigned long vaddr)
 {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.