powerpc: Annotate endianness of various variables and functions
authorBenjamin Gray <bgray@linux.ibm.com>
Wed, 11 Oct 2023 05:37:05 +0000 (16:37 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 19 Oct 2023 06:12:47 +0000 (17:12 +1100)
Sparse reports several endianness warnings on variables and functions
that are consistently treated as big endian. There are no
multi-endianness shenanigans going on here so fix these low hanging
fruit up in one patch.

All changes are just type annotations; no endianness switching
operations are introduced by this patch.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231011053711.93427-7-bgray@linux.ibm.com
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/imc-pmu.h
arch/powerpc/kernel/prom_init.c
arch/powerpc/kexec/core_64.c
arch/powerpc/kexec/file_load_64.c
arch/powerpc/mm/drmem.c
arch/powerpc/perf/hv-24x7.c
arch/powerpc/perf/imc-pmu.c
arch/powerpc/platforms/powermac/feature.c
arch/powerpc/platforms/pseries/hotplug-memory.c

index 751b01227e364ea4a27ea5265ab013a57ebfce14..cb77eddca54b9961c2f72c966f6ee27699e19d73 100644 (file)
@@ -626,7 +626,7 @@ static inline pte_t pte_mkdevmap(pte_t pte)
  */
 static inline int pte_devmap(pte_t pte)
 {
-       u64 mask = cpu_to_be64(_PAGE_DEVMAP | _PAGE_PTE);
+       __be64 mask = cpu_to_be64(_PAGE_DEVMAP | _PAGE_PTE);
 
        return (pte_raw(pte) & mask) == mask;
 }
index 699a88584ae16f194c7c7ccf4f8212af9977a876..a656635df3861583b20eeacb1e98ab2c5f09a0b1 100644 (file)
@@ -74,14 +74,14 @@ struct imc_events {
  * The following is the data structure to hold trace imc data.
  */
 struct trace_imc_data {
-       u64 tb1;
-       u64 ip;
-       u64 val;
-       u64 cpmc1;
-       u64 cpmc2;
-       u64 cpmc3;
-       u64 cpmc4;
-       u64 tb2;
+       __be64 tb1;
+       __be64 ip;
+       __be64 val;
+       __be64 cpmc1;
+       __be64 cpmc2;
+       __be64 cpmc3;
+       __be64 cpmc4;
+       __be64 tb2;
 };
 
 /* Event attribute array index */
index d464ba412084d10e5d4d7cd9dd27485a1c556aca..e67effdba85cc03096132223ad9c4d7dbc698f58 100644 (file)
@@ -947,7 +947,7 @@ struct option_vector7 {
 } __packed;
 
 struct ibm_arch_vec {
-       struct { u32 mask, val; } pvrs[14];
+       struct { __be32 mask, val; } pvrs[14];
 
        u8 num_vectors;
 
index a79e28c91e2be312efb2f1bf177b14e4c07adb66..0bee7ca9a77c62212f375dc8c0a759b97fe85bf5 100644 (file)
@@ -379,8 +379,8 @@ void default_machine_kexec(struct kimage *image)
 
 #ifdef CONFIG_PPC_64S_HASH_MMU
 /* Values we need to export to the second kernel via the device tree. */
-static unsigned long htab_base;
-static unsigned long htab_size;
+static __be64 htab_base;
+static __be64 htab_size;
 
 static struct property htab_base_prop = {
        .name = "linux,htab-base",
index 09187aca3d1f8b17e1666d8f478f94461bcd574d..961a6dd6736566958145b972bfaee85872319cfe 100644 (file)
@@ -32,7 +32,7 @@
 #include <asm/plpks.h>
 
 struct umem_info {
-       u64 *buf;               /* data buffer for usable-memory property */
+       __be64 *buf;            /* data buffer for usable-memory property */
        u32 size;               /* size allocated for the data buffer */
        u32 max_entries;        /* maximum no. of entries */
        u32 idx;                /* index of current entry */
@@ -443,10 +443,10 @@ static int locate_mem_hole_bottom_up_ppc64(struct kexec_buf *kbuf,
  *
  * Returns buffer on success, NULL on error.
  */
-static u64 *check_realloc_usable_mem(struct umem_info *um_info, int cnt)
+static __be64 *check_realloc_usable_mem(struct umem_info *um_info, int cnt)
 {
        u32 new_size;
-       u64 *tbuf;
+       __be64 *tbuf;
 
        if ((um_info->idx + cnt) <= um_info->max_entries)
                return um_info->buf;
index 2369d1bf2411e741713aba07ea419af2a9bb617c..fde7790277f75045576e706909a21e89e4111658 100644 (file)
@@ -67,7 +67,7 @@ static int drmem_update_dt_v1(struct device_node *memory,
        struct property *new_prop;
        struct of_drconf_cell_v1 *dr_cell;
        struct drmem_lmb *lmb;
-       u32 *p;
+       __be32 *p;
 
        new_prop = clone_property(prop, prop->length);
        if (!new_prop)
index 3449be7c0d51f7e9e62112523a0f182891f4bf8d..057ec2e3451d19cb81d41668ca86e9649dc9c5e3 100644 (file)
@@ -1338,7 +1338,7 @@ static int get_count_from_result(struct perf_event *event,
        for (i = count = 0, element_data = res->elements + data_offset;
             i < num_elements;
             i++, element_data += data_size + data_offset)
-               count += be64_to_cpu(*((u64 *) element_data));
+               count += be64_to_cpu(*((__be64 *)element_data));
 
        *countp = count;
 
index eba2baabccb03a822a19491a07f89fd121c8ff7a..2016aee2703798c4eb37cb5c2de9a080eb81dc5f 100644 (file)
@@ -1025,16 +1025,16 @@ static bool is_thread_imc_pmu(struct perf_event *event)
        return false;
 }
 
-static u64 * get_event_base_addr(struct perf_event *event)
+static __be64 *get_event_base_addr(struct perf_event *event)
 {
        u64 addr;
 
        if (is_thread_imc_pmu(event)) {
                addr = (u64)per_cpu(thread_imc_mem, smp_processor_id());
-               return (u64 *)(addr + (event->attr.config & IMC_EVENT_OFFSET_MASK));
+               return (__be64 *)(addr + (event->attr.config & IMC_EVENT_OFFSET_MASK));
        }
 
-       return (u64 *)event->hw.event_base;
+       return (__be64 *)event->hw.event_base;
 }
 
 static void thread_imc_pmu_start_txn(struct pmu *pmu,
@@ -1058,7 +1058,8 @@ static int thread_imc_pmu_commit_txn(struct pmu *pmu)
 
 static u64 imc_read_counter(struct perf_event *event)
 {
-       u64 *addr, data;
+       __be64 *addr;
+       u64 data;
 
        /*
         * In-Memory Collection (IMC) counters are free flowing counters.
index ae62d432db8bbf0382963f1c9eda1951495eefa1..81c9fbae88b140253c9551e451b8a71645e00953 100644 (file)
@@ -2614,7 +2614,8 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
        struct device_node*     node;
        int                     i;
        volatile u32 __iomem    *base;
-       const u32               *addrp, *revp;
+       const __be32            *addrp;
+       const u32               *revp;
        phys_addr_t             addr;
        u64                     size;
 
index aa4042dcd6d40e7f851ac72ee6153baae488bd67..a43bfb01720aef28ff2daf5689463e713c7732f0 100644 (file)
@@ -55,7 +55,8 @@ static bool find_aa_index(struct device_node *dr_node,
                         struct property *ala_prop,
                         const u32 *lmb_assoc, u32 *aa_index)
 {
-       u32 *assoc_arrays, new_prop_size;
+       __be32 *assoc_arrays;
+       u32 new_prop_size;
        struct property *new_prop;
        int aa_arrays, aa_array_entries, aa_array_sz;
        int i, index;