Replace all resource occurrences of '0UL/~0UL' with '0/~0'.
Summary: The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a 32-bit platform, will leave the upper 32 bits as 0. The maximum range of a resource is 0xFFF.... (all bits of the full type set). By dropping the 'ul' suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit platforms gets it to a type-independent 'unsigned max'. Reviewed By: cem Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5255
This commit is contained in:
parent
342af4d5ef
commit
534ccd7bbf
@ -334,7 +334,7 @@ bhnd_is_hw_disabled(device_t dev) {
|
||||
* values supported by the standard bus APIs.
|
||||
*
|
||||
* To request the resource's default addresses, pass @p start and
|
||||
* @p end values of @c 0UL and @c ~0UL, respectively, and
|
||||
* @p end values of @c 0 and @c ~0, respectively, and
|
||||
* a @p count of @c 1.
|
||||
*
|
||||
* @retval NULL The resource could not be allocated.
|
||||
@ -366,7 +366,7 @@ bhnd_alloc_resource(device_t dev, int type, int *rid, rman_res_t start,
|
||||
static inline struct bhnd_resource *
|
||||
bhnd_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
|
||||
{
|
||||
return bhnd_alloc_resource(dev, type, rid, 0UL, ~0UL, 1, flags);
|
||||
return bhnd_alloc_resource(dev, type, rid, 0, ~0, 1, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -506,7 +506,7 @@ pccard_function_init(struct pccard_function *pf, int entry)
|
||||
if (start)
|
||||
end = start + ios->length - 1;
|
||||
else
|
||||
end = ~0UL;
|
||||
end = ~0;
|
||||
DEVPRINTF((bus, "I/O rid %d start %#lx end %#lx\n",
|
||||
i, start, end));
|
||||
rid = i;
|
||||
@ -530,7 +530,7 @@ pccard_function_init(struct pccard_function *pf, int entry)
|
||||
if (start)
|
||||
end = start + mems->length - 1;
|
||||
else
|
||||
end = ~0UL;
|
||||
end = ~0;
|
||||
DEVPRINTF((bus, "Memory rid %d start %#lx end %#lx\ncardaddr %#lx hostaddr %#lx length %#lx\n",
|
||||
i, start, end, mems->cardaddr, mems->hostaddr,
|
||||
mems->length));
|
||||
|
@ -3092,7 +3092,7 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl,
|
||||
flags |= RF_PREFETCHABLE;
|
||||
if (basezero || base == pci_mapbase(testval) || pci_clear_bars) {
|
||||
start = 0; /* Let the parent decide. */
|
||||
end = ~0ul;
|
||||
end = ~0;
|
||||
} else {
|
||||
start = base;
|
||||
end = base + count - 1;
|
||||
@ -3107,7 +3107,7 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl,
|
||||
*/
|
||||
res = resource_list_reserve(rl, bus, dev, type, ®, start, end, count,
|
||||
flags);
|
||||
if (pci_do_realloc_bars && res == NULL && (start != 0 || end != ~0ul)) {
|
||||
if (pci_do_realloc_bars && res == NULL && (start != 0 || end != ~0)) {
|
||||
/*
|
||||
* If the allocation fails, try to allocate a resource for
|
||||
* this BAR using any available range. The firmware felt
|
||||
@ -3115,8 +3115,8 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl,
|
||||
* disable decoding if we can help it.
|
||||
*/
|
||||
resource_list_delete(rl, type, reg);
|
||||
resource_list_add(rl, type, reg, 0, ~0ul, count);
|
||||
res = resource_list_reserve(rl, bus, dev, type, ®, 0, ~0ul,
|
||||
resource_list_add(rl, type, reg, 0, ~0, count);
|
||||
res = resource_list_reserve(rl, bus, dev, type, ®, 0, ~0,
|
||||
count, flags);
|
||||
}
|
||||
if (res == NULL) {
|
||||
@ -3507,7 +3507,7 @@ pci_reserve_secbus(device_t bus, device_t dev, pcicfgregs *cfg,
|
||||
end = sub_bus;
|
||||
count = end - start + 1;
|
||||
|
||||
resource_list_add(rl, PCI_RES_BUS, 0, 0ul, ~0ul, count);
|
||||
resource_list_add(rl, PCI_RES_BUS, 0, 0, ~0, count);
|
||||
|
||||
/*
|
||||
* If requested, clear secondary bus registers in
|
||||
|
@ -330,8 +330,8 @@ pci_iov_alloc_bar(struct pci_devinfo *dinfo, int bar, pci_addr_t bar_shift)
|
||||
rid = iov->iov_pos + PCIR_SRIOV_BAR(bar);
|
||||
bar_size = 1 << bar_shift;
|
||||
|
||||
res = pci_alloc_multi_resource(bus, dev, SYS_RES_MEMORY, &rid, 0ul,
|
||||
~0ul, 1, iov->iov_num_vfs, RF_ACTIVE);
|
||||
res = pci_alloc_multi_resource(bus, dev, SYS_RES_MEMORY, &rid, 0,
|
||||
~0, 1, iov->iov_num_vfs, RF_ACTIVE);
|
||||
|
||||
if (res == NULL)
|
||||
return (ENXIO);
|
||||
@ -498,7 +498,7 @@ pci_iov_init_rman(device_t pf, struct pcicfg_iov *iov)
|
||||
int error;
|
||||
|
||||
iov->rman.rm_start = 0;
|
||||
iov->rman.rm_end = ~0ul;
|
||||
iov->rman.rm_end = ~0;
|
||||
iov->rman.rm_type = RMAN_ARRAY;
|
||||
snprintf(iov->rman_name, sizeof(iov->rman_name), "%s VF I/O memory",
|
||||
device_get_nameunit(pf));
|
||||
|
@ -389,7 +389,7 @@ pcib_alloc_window(struct pcib_softc *sc, struct pcib_window *w, int type,
|
||||
int error, rid;
|
||||
|
||||
if (max_address != (rman_res_t)max_address)
|
||||
max_address = ~0ul;
|
||||
max_address = ~0;
|
||||
w->rman.rm_start = 0;
|
||||
w->rman.rm_end = max_address;
|
||||
w->rman.rm_type = RMAN_ARRAY;
|
||||
|
@ -164,8 +164,8 @@ vga_pci_map_bios(device_t dev, size_t *size)
|
||||
#endif
|
||||
|
||||
rid = PCIR_BIOS;
|
||||
res = vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0ul,
|
||||
~0ul, 1, RF_ACTIVE);
|
||||
res = vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0,
|
||||
~0, 1, RF_ACTIVE);
|
||||
if (res == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ isa_claim_resources(device_t dev, device_t child)
|
||||
if (!rle->res) {
|
||||
rid = rle->rid;
|
||||
resource_list_alloc(rl, dev, child, rle->type, &rid,
|
||||
0ul, ~0ul, 1, 0);
|
||||
0, ~0, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,9 +247,9 @@ METHOD device_t add_child {
|
||||
* @param _type the type of resource to allocate
|
||||
* @param _rid a pointer to the resource identifier
|
||||
* @param _start hint at the start of the resource range - pass
|
||||
* @c 0UL for any start address
|
||||
* @c 0 for any start address
|
||||
* @param _end hint at the end of the resource range - pass
|
||||
* @c ~0UL for any end address
|
||||
* @c ~0 for any end address
|
||||
* @param _count hint at the size of range required - pass @c 1
|
||||
* for any size
|
||||
* @param _flags any extra flags to control the resource
|
||||
|
@ -3236,9 +3236,9 @@ resource_list_delete(struct resource_list *rl, int type, int rid)
|
||||
* @param type the type of resource to allocate
|
||||
* @param rid a pointer to the resource identifier
|
||||
* @param start hint at the start of the resource range - pass
|
||||
* @c 0UL for any start address
|
||||
* @c 0 for any start address
|
||||
* @param end hint at the end of the resource range - pass
|
||||
* @c ~0UL for any end address
|
||||
* @c ~0 for any end address
|
||||
* @param count hint at the size of range required - pass @c 1
|
||||
* for any size
|
||||
* @param flags any extra flags to control the resource
|
||||
@ -3293,9 +3293,9 @@ resource_list_reserve(struct resource_list *rl, device_t bus, device_t child,
|
||||
* @param type the type of resource to allocate
|
||||
* @param rid a pointer to the resource identifier
|
||||
* @param start hint at the start of the resource range - pass
|
||||
* @c 0UL for any start address
|
||||
* @c 0 for any start address
|
||||
* @param end hint at the end of the resource range - pass
|
||||
* @c ~0UL for any end address
|
||||
* @c ~0 for any end address
|
||||
* @param count hint at the size of range required - pass @c 1
|
||||
* for any size
|
||||
* @param flags any extra flags to control the resource
|
||||
|
@ -135,7 +135,7 @@ rman_init(struct rman *rm)
|
||||
}
|
||||
|
||||
if (rm->rm_start == 0 && rm->rm_end == 0)
|
||||
rm->rm_end = ~0ul;
|
||||
rm->rm_end = ~0;
|
||||
if (rm->rm_type == RMAN_UNINIT)
|
||||
panic("rman_init");
|
||||
if (rm->rm_type == RMAN_GAUGE)
|
||||
|
@ -478,14 +478,14 @@ void bus_enumerate_hinted_children(device_t bus);
|
||||
static __inline struct resource *
|
||||
bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
|
||||
{
|
||||
return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags));
|
||||
return (bus_alloc_resource(dev, type, rid, 0, ~0, 1, flags));
|
||||
}
|
||||
|
||||
static __inline struct resource *
|
||||
bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
|
||||
rman_res_t count, u_int flags)
|
||||
{
|
||||
return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, count, flags));
|
||||
return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -120,7 +120,7 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size)
|
||||
int error;
|
||||
|
||||
res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT,
|
||||
~0ul, size, RF_ACTIVE);
|
||||
~0, size, RF_ACTIVE);
|
||||
if (res == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user