Skip to content

Commit d7dc899

Browse files
agnerstorvalds
authored andcommitted
treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX
With PHYS_ADDR_MAX there is now a type safe variant for all bits set. Make use of it. Patch created using a semantic patch as follows: // <smpl> @@ typedef phys_addr_t; @@ -(phys_addr_t)ULLONG_MAX +PHYS_ADDR_MAX // </smpl> Link: http://lkml.kernel.org/r/20180419214204.19322-1-stefan@agner.ch Signed-off-by: Stefan Agner <stefan@agner.ch> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0825a6f commit d7dc899

9 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎arch/arm64/mm/init.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static void __init arm64_memory_present(void)
310310
}
311311
#endif
312312

313-
static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX;
313+
static phys_addr_t memory_limit = PHYS_ADDR_MAX;
314314

315315
/*
316316
* Limit the memory size that was specified via FDT.
@@ -401,7 +401,7 @@ void __init arm64_memblock_init(void)
401401
* high up in memory, add back the kernel region that must be accessible
402402
* via the linear mapping.
403403
*/
404-
if (memory_limit != (phys_addr_t)ULLONG_MAX) {
404+
if (memory_limit != PHYS_ADDR_MAX) {
405405
memblock_mem_limit_remove_map(memory_limit);
406406
memblock_add(__pa_symbol(_text), (u64)(_end - _text));
407407
}
@@ -666,7 +666,7 @@ __setup("keepinitrd", keepinitrd_setup);
666666
*/
667667
static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p)
668668
{
669-
if (memory_limit != (phys_addr_t)ULLONG_MAX) {
669+
if (memory_limit != PHYS_ADDR_MAX) {
670670
pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20);
671671
} else {
672672
pr_emerg("Memory Limit: none\n");

‎arch/mips/kernel/setup.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)
9393
* If the region reaches the top of the physical address space, adjust
9494
* the size slightly so that (start + size) doesn't overflow
9595
*/
96-
if (start + size - 1 == (phys_addr_t)ULLONG_MAX)
96+
if (start + size - 1 == PHYS_ADDR_MAX)
9797
--size;
9898

9999
/* Sanity check */
@@ -376,7 +376,7 @@ static void __init bootmem_init(void)
376376
unsigned long reserved_end;
377377
unsigned long mapstart = ~0UL;
378378
unsigned long bootmap_size;
379-
phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX;
379+
phys_addr_t ramstart = PHYS_ADDR_MAX;
380380
bool bootmap_valid = false;
381381
int i;
382382

‎arch/powerpc/mm/mem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void __init mem_topology_setup(void)
215215
/* Place all memblock_regions in the same node and merge contiguous
216216
* memblock_regions
217217
*/
218-
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
218+
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
219219
}
220220

221221
void __init initmem_init(void)

‎arch/sparc/mm/init_64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void)
16201620
(top_of_ram - total_ram) >> 20);
16211621

16221622
init_node_masks_nonnuma();
1623-
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
1623+
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
16241624
allocate_node_data(0);
16251625
node_set_online(0);
16261626
}

‎arch/x86/mm/init_32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ void __init initmem_init(void)
692692
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
693693
#endif
694694

695-
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
695+
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
696696
sparse_memory_present_with_active_regions(0);
697697

698698
#ifdef CONFIG_FLATMEM

‎arch/x86/mm/init_64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start,
742742
#ifndef CONFIG_NUMA
743743
void __init initmem_init(void)
744744
{
745-
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
745+
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
746746
}
747747
#endif
748748

‎drivers/firmware/efi/arm-init.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static __init void reserve_regions(void)
193193
* uses its own memory map instead.
194194
*/
195195
memblock_dump_all();
196-
memblock_remove(0, (phys_addr_t)ULLONG_MAX);
196+
memblock_remove(0, PHYS_ADDR_MAX);
197197

198198
for_each_efi_memory_desc(md) {
199199
paddr = md->phys_addr;

‎drivers/remoteproc/qcom_q6v5_pil.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
686686
struct elf32_hdr *ehdr;
687687
phys_addr_t mpss_reloc;
688688
phys_addr_t boot_addr;
689-
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
689+
phys_addr_t min_addr = PHYS_ADDR_MAX;
690690
phys_addr_t max_addr = 0;
691691
bool relocate = false;
692692
char seg_name[10];

‎drivers/soc/qcom/mdt_loader.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
5050
const struct elf32_phdr *phdrs;
5151
const struct elf32_phdr *phdr;
5252
const struct elf32_hdr *ehdr;
53-
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
53+
phys_addr_t min_addr = PHYS_ADDR_MAX;
5454
phys_addr_t max_addr = 0;
5555
int i;
5656

@@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
9797
const struct elf32_hdr *ehdr;
9898
const struct firmware *seg_fw;
9999
phys_addr_t mem_reloc;
100-
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
100+
phys_addr_t min_addr = PHYS_ADDR_MAX;
101101
phys_addr_t max_addr = 0;
102102
size_t fw_name_len;
103103
ssize_t offset;

0 commit comments

Comments
 (0)