Skip to content

Commit

Permalink
add more sparse endian annotations
Browse files Browse the repository at this point in the history
This fixes quite a few sparse endian annotations across the tree.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
npiggin authored and oohal committed Dec 16, 2019
1 parent a0cf95f commit 5178691
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 41 deletions.
17 changes: 9 additions & 8 deletions core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ struct dt_property *__dt_add_property_cells(struct dt_node *node,
int count, ...)
{
struct dt_property *p;
u32 *val;
fdt32_t *val;
unsigned int i;
va_list args;

p = new_property(node, name, count * sizeof(u32));
val = (u32 *)p->prop;
val = (fdt32_t *)p->prop;
va_start(args, count);
for (i = 0; i < count; i++)
val[i] = cpu_to_fdt32(va_arg(args, u32));
Expand All @@ -532,12 +532,12 @@ struct dt_property *__dt_add_property_u64s(struct dt_node *node,
int count, ...)
{
struct dt_property *p;
u64 *val;
fdt64_t *val;
unsigned int i;
va_list args;

p = new_property(node, name, count * sizeof(u64));
val = (u64 *)p->prop;
val = (fdt64_t *)p->prop;
va_start(args, count);
for (i = 0; i < count; i++)
val[i] = cpu_to_fdt64(va_arg(args, u64));
Expand Down Expand Up @@ -590,7 +590,7 @@ u32 dt_property_get_cell(const struct dt_property *prop, u32 index)
{
assert(prop->len >= (index+1)*sizeof(u32));
/* Always aligned, so this works. */
return fdt32_to_cpu(((const u32 *)prop->prop)[index]);
return fdt32_to_cpu(((const fdt32_t *)prop->prop)[index]);
}

u64 dt_property_get_u64(const struct dt_property *prop, u32 index)
Expand Down Expand Up @@ -918,7 +918,7 @@ void dt_expand(const void *fdt)

u64 dt_get_number(const void *pdata, unsigned int cells)
{
const u32 *p = pdata;
const __be32 *p = pdata;
u64 ret = 0;

while(cells--)
Expand Down Expand Up @@ -1095,6 +1095,7 @@ void dt_adjust_subtree_phandle(struct dt_node *dev,
struct dt_node *node;
struct dt_property *prop;
u32 phandle, max_phandle = 0, import_phandle = new_phandle();
__be32 p;
const char **name;

dt_for_each_node(dev, node) {
Expand All @@ -1117,8 +1118,8 @@ void dt_adjust_subtree_phandle(struct dt_node *dev,
continue;
phandle = dt_prop_get_u32(node, *name);
phandle += import_phandle;
phandle = cpu_to_be32(phandle);
memcpy((char *)&prop->prop, &phandle, prop->len);
p = cpu_to_be32(phandle);
memcpy((char *)&prop->prop, &p, prop->len);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void flatten_dt_node(void *fdt, const struct dt_node *root,
static void create_dtb_reservemap(void *fdt, const struct dt_node *root)
{
uint64_t base, size;
const uint64_t *ranges;
const __be64 *ranges;
const struct dt_property *prop;
int i;

Expand Down
3 changes: 2 additions & 1 deletion core/interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ void add_opal_interrupts(void)
{
struct irq_source *is;
unsigned int i, ns, tns = 0, count = 0;
uint32_t *irqs = NULL, isn;
uint32_t isn;
__be32 *irqs = NULL;
char *names = NULL;

lock(&irq_lock);
Expand Down
2 changes: 1 addition & 1 deletion core/mem_region.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ void mem_region_add_dt_reserved(void)
struct mem_region *region;
void *names, *ranges;
struct dt_node *node;
uint64_t *range;
fdt64_t *range;
char *name;

names_len = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ void pci_std_swizzle_irq_map(struct dt_node *np,
struct pci_lsi_state *lstate,
uint8_t swizzle)
{
uint32_t *map, *p;
__be32 *p, *map;
int dev, irq, esize, edevcount;
size_t map_size;

Expand Down
3 changes: 2 additions & 1 deletion core/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ static void trace_add_dt_props(void)
uint64_t boot_buf_phys = (uint64_t) &boot_tracebuf.trace_info;
struct dt_node *exports, *traces;
unsigned int i;
u64 *prop, tmask;
fdt64_t *prop;
u64 tmask;
char tname[256];

exports = dt_find_by_path(opal_node, "firmware/exports");
Expand Down
2 changes: 1 addition & 1 deletion hdata/fsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static uint32_t fsp_create_link(const struct spss_iopath *iopath, int index,
static void fsp_create_links(const void *spss, int index,
struct dt_node *fsp_node)
{
uint32_t *links = NULL;
__be32 *links = NULL;
unsigned int i, lp, lcount = 0;
int count;

Expand Down
8 changes: 4 additions & 4 deletions hdata/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ static void vpd_add_ram_area(const struct HDIF_common_hdr *msarea)

static void vpd_parse_spd(struct dt_node *dimm, const char *spd, u32 size)
{
u16 *vendor;
u32 *sn;
__be16 *vendor;
__be32 *sn;

/* SPD is too small */
if (size < 512) {
Expand All @@ -355,14 +355,14 @@ static void vpd_parse_spd(struct dt_node *dimm, const char *spd, u32 size)
dt_add_property_cells(dimm, "product-version", spd[0x15d]);

/* Serial number */
sn = (u32 *)&spd[0x145];
sn = (__be32 *)&spd[0x145];
dt_add_property_cells(dimm, "serial-number", be32_to_cpu(*sn));

/* Part number */
dt_add_property_nstr(dimm, "part-number", &spd[0x149], 20);

/* Module manufacturer ID */
vendor = (u16 *)&spd[0x140];
vendor = (__be16 *)&spd[0x140];
dt_add_property_cells(dimm, "manufacturer-id", be16_to_cpu(*vendor));
}

Expand Down
2 changes: 1 addition & 1 deletion hdata/spira.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ static void opal_dump_add_mpipl_boot(const struct iplparams_iplparams *p)

static void add_opal_dump_node(void)
{
u64 fw_load_area[4];
__be64 fw_load_area[4];
struct dt_node *node;

opal_node = dt_new_check(dt_root, "ibm,opal");
Expand Down
5 changes: 3 additions & 2 deletions hw/ast-bmc/ast-sf-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ static void ast_sf_end_cmd(struct ast_sf_ctrl *ct)
static int ast_sf_send_addr(struct ast_sf_ctrl *ct, uint32_t addr)
{
const void *ap;
beint32_t tmp;

/* Layout address MSB first in memory */
addr = cpu_to_be32(addr);
tmp = cpu_to_be32(addr);

/* Send the right amount of bytes */
ap = (char *)&addr;
ap = (char *)&tmp;

if (ct->mode_4b)
return ast_copy_to_ahb(ct->flash, ap, 4);
Expand Down
4 changes: 2 additions & 2 deletions hw/imc.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ void imc_catalog_preload(void)
static void imc_dt_update_nest_node(struct dt_node *dev)
{
struct proc_chip *chip;
uint64_t *base_addr = NULL;
uint32_t *chipids = NULL;
__be64 *base_addr = NULL;
__be32 *chipids = NULL;
int i=0, nr_chip = nr_chips();
struct dt_node *node;
const struct dt_property *type;
Expand Down
2 changes: 1 addition & 1 deletion hw/psi.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static void psi_activate_phb(struct psi *psi)

static void psi_create_p9_int_map(struct psi *psi, struct dt_node *np)
{
uint32_t map[P9_PSI_NUM_IRQS][4];
__be32 map[P9_PSI_NUM_IRQS][4];
int i;

for (i = 0; i < P9_PSI_NUM_IRQS; i++) {
Expand Down
10 changes: 5 additions & 5 deletions hw/slw.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,8 @@ void add_cpu_idle_state_properties(void)
bool has_stop_inst = false;
u8 i;

u64 *pm_ctrl_reg_val_buf;
u64 *pm_ctrl_reg_mask_buf;
fdt64_t *pm_ctrl_reg_val_buf;
fdt64_t *pm_ctrl_reg_mask_buf;
u32 supported_states_mask;
u32 opal_disabled_states_mask = ~0xEC000000; /* all but stop11 */
const char* nvram_disable_str;
Expand All @@ -739,9 +739,9 @@ void add_cpu_idle_state_properties(void)

/* Buffers to hold idle state properties */
char *name_buf, *alloced_name_buf;
u32 *latency_ns_buf;
u32 *residency_ns_buf;
u32 *flags_buf;
fdt32_t *latency_ns_buf;
fdt32_t *residency_ns_buf;
fdt32_t *flags_buf;

prlog(PR_DEBUG, "CPU idle state device tree init\n");

Expand Down
2 changes: 1 addition & 1 deletion include/ipmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct ipmi_msg {
};

struct ipmi_backend {
__be64 opal_event_ipmi_recv;
uint64_t opal_event_ipmi_recv;
struct ipmi_msg *(*alloc_msg)(size_t, size_t);
void (*free_msg)(struct ipmi_msg *);
int (*queue_msg)(struct ipmi_msg *);
Expand Down
4 changes: 2 additions & 2 deletions include/opal-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ extern struct dt_node *opal_node;

extern void opal_table_init(void);
extern void opal_update_pending_evt(uint64_t evt_mask, uint64_t evt_values);
__be64 opal_dynamic_event_alloc(void);
void opal_dynamic_event_free(__be64 event);
uint64_t opal_dynamic_event_alloc(void);
void opal_dynamic_event_free(uint64_t event);
extern void add_opal_node(void);

#define opal_register(token, func, nargs) \
Expand Down
8 changes: 4 additions & 4 deletions libflash/mbox-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,23 @@ static void msg_put_u8(struct bmc_mbox_msg *msg, int i, uint8_t val)

static uint16_t msg_get_u16(struct bmc_mbox_msg *msg, int i)
{
return le16_to_cpu(*(uint16_t *)(&msg->args[i]));
return le16_to_cpu(*(__le16 *)(&msg->args[i]));
}

static void msg_put_u16(struct bmc_mbox_msg *msg, int i, uint16_t val)
{
uint16_t tmp = cpu_to_le16(val);
__le16 tmp = cpu_to_le16(val);
memcpy(&msg->args[i], &tmp, sizeof(val));
}

static uint32_t msg_get_u32(struct bmc_mbox_msg *msg, int i)
{
return le32_to_cpu(*(uint32_t *)(&msg->args[i]));
return le32_to_cpu(*(__le32 *)(&msg->args[i]));
}

static void msg_put_u32(struct bmc_mbox_msg *msg, int i, uint32_t val)
{
uint32_t tmp = cpu_to_le32(val);
__le32 tmp = cpu_to_le32(val);
memcpy(&msg->args[i], &tmp, sizeof(val));
}

Expand Down
2 changes: 1 addition & 1 deletion libstb/secureboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void secureboot_init(void)
int secureboot_verify(enum resource_id id, void *buf, size_t len)
{
const char *name;
uint64_t log;
__be64 log;
int rc = -1;

name = flash_map_resource_name(id);
Expand Down
8 changes: 4 additions & 4 deletions platforms/astbmc/vesnin.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
* All fields have Big Endian byte order.
*/
struct pciinv_device {
uint16_t domain_num;
beint16_t domain_num;
uint8_t bus_num;
uint8_t device_num;
uint8_t func_num;
uint16_t vendor_id;
uint16_t device_id;
uint32_t class_code;
beint16_t vendor_id;
beint16_t device_id;
beint32_t class_code;
uint8_t revision;
} __packed;

Expand Down

0 comments on commit 5178691

Please sign in to comment.