dev/fdt: Add const to pointers to const data

fdt_data_get and fdt_data_to_res don't change the value of the data
passed to them via a pointer. Add const to these pointers.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49703
This commit is contained in:
Andrew Turner 2025-04-08 11:30:56 +01:00
parent 211ca9061b
commit a2aff11aeb
2 changed files with 9 additions and 9 deletions

View file

@ -303,13 +303,13 @@ fdt_parent_addr_cells(phandle_t node)
}
u_long
fdt_data_get(void *data, int cells)
fdt_data_get(const void *data, int cells)
{
if (cells == 1)
return (fdt32_to_cpu(*((uint32_t *)data)));
return (fdt32_to_cpu(*((const uint32_t *)data)));
return (fdt64_to_cpu(*((uint64_t *)data)));
return (fdt64_to_cpu(*((const uint64_t *)data)));
}
int
@ -336,22 +336,22 @@ fdt_addrsize_cells(phandle_t node, int *addr_cells, int *size_cells)
}
int
fdt_data_to_res(pcell_t *data, int addr_cells, int size_cells, u_long *start,
u_long *count)
fdt_data_to_res(const pcell_t *data, int addr_cells, int size_cells,
u_long *start, u_long *count)
{
/* Address portion. */
if (addr_cells > 2)
return (ERANGE);
*start = fdt_data_get((void *)data, addr_cells);
*start = fdt_data_get((const void *)data, addr_cells);
data += addr_cells;
/* Size portion. */
if (size_cells > 2)
return (ERANGE);
*count = fdt_data_get((void *)data, size_cells);
*count = fdt_data_get((const void *)data, size_cells);
return (0);
}

View file

@ -79,8 +79,8 @@ SYSCTL_DECL(_hw_fdt);
typedef void (*fdt_mem_region_cb)(const struct mem_region *, void *);
int fdt_addrsize_cells(phandle_t, int *, int *);
u_long fdt_data_get(void *, int);
int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
u_long fdt_data_get(const void *, int);
int fdt_data_to_res(const pcell_t *, int, int, u_long *, u_long *);
phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
int fdt_foreach_mem_region(fdt_mem_region_cb, void *);