Skip to content

Commit 17a7035

Browse files
committed
of: fix sparse warnings in fdt, irq, reserved mem, and resolver code
sparse generates the following warnings in drivers/of/: ../drivers/of/fdt.c:63:36: warning: cast to restricted __be32 ../drivers/of/fdt.c:68:33: warning: cast to restricted __be32 ../drivers/of/irq.c:105:88: warning: incorrect type in initializer (different base types) ../drivers/of/irq.c:105:88: expected restricted __be32 ../drivers/of/irq.c:105:88: got int ../drivers/of/irq.c:526:35: warning: incorrect type in assignment (different modifiers) ../drivers/of/irq.c:526:35: expected int ( *const [usertype] irq_init_cb )( ... ) ../drivers/of/irq.c:526:35: got void const *const data ../drivers/of/of_reserved_mem.c:200:50: warning: incorrect type in initializer (different modifiers) ../drivers/of/of_reserved_mem.c:200:50: expected int ( *[usertype] initfn )( ... ) ../drivers/of/of_reserved_mem.c:200:50: got void const *const data ../drivers/of/resolver.c:95:42: warning: incorrect type in assignment (different base types) ../drivers/of/resolver.c:95:42: expected unsigned int [unsigned] [usertype] <noident> ../drivers/of/resolver.c:95:42: got restricted __be32 [usertype] <noident> All these are harmless type mismatches fixed by adjusting the types. Signed-off-by: Rob Herring <robh@kernel.org>
1 parent eb31003 commit 17a7035

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

drivers/of/fdt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ void of_fdt_limit_memory(int limit)
4848
const void *val;
4949
int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
5050
int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
51-
const uint32_t *addr_prop;
52-
const uint32_t *size_prop;
51+
const __be32 *addr_prop;
52+
const __be32 *size_prop;
5353
int root_offset;
5454
int cell_size;
5555

drivers/of/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
102102
struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
103103
__be32 initial_match_array[MAX_PHANDLE_ARGS];
104104
const __be32 *match_array = initial_match_array;
105-
const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 };
105+
const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
106106
u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
107107
int imaplen, match, i, rc = -EINVAL;
108108

drivers/of/of_reserved_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem)
197197
const struct of_device_id *i;
198198

199199
for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) {
200-
reservedmem_of_init_fn initfn = i->data;
200+
int const (*initfn)(struct reserved_mem *rmem) = i->data;
201201
const char *compat = i->compatible;
202202

203203
if (!of_flat_dt_is_compatible(rmem->fdt_node, compat))

drivers/of/resolver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void adjust_overlay_phandles(struct device_node *overlay,
9292
if (phandle == OF_PHANDLE_ILLEGAL)
9393
continue;
9494

95-
*(uint32_t *)prop->value = cpu_to_be32(overlay->phandle);
95+
*(__be32 *)prop->value = cpu_to_be32(overlay->phandle);
9696
}
9797

9898
for_each_child_of_node(overlay, child)

include/linux/of_irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/ioport.h>
99
#include <linux/of.h>
1010

11-
typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
11+
typedef int const (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
1212

1313
/*
1414
* Workarounds only applied to 32bit powermac machines

0 commit comments

Comments
 (0)