aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2016-03-03 05:07:35 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2016-03-03 05:07:35 +0000
commit534ccd7bbfadde557eeffe986e5462455c8111ea (patch)
tree6694899d37c3d4102983706c5d1f442c638cbcb1 /sys
parent342af4d5efec74bb4bc11261fdd9991c53616f54 (diff)
downloadsrc-534ccd7bbfadde557eeffe986e5462455c8111ea.tar.gz
src-534ccd7bbfadde557eeffe986e5462455c8111ea.zip
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
Notes
Notes: svn path=/head/; revision=296336
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/bhnd/bhnd.h4
-rw-r--r--sys/dev/pccard/pccard.c4
-rw-r--r--sys/dev/pci/pci.c10
-rw-r--r--sys/dev/pci/pci_iov.c6
-rw-r--r--sys/dev/pci/pci_pci.c2
-rw-r--r--sys/dev/pci/vga_pci.c4
-rw-r--r--sys/isa/isa_common.c2
-rw-r--r--sys/kern/bus_if.m4
-rw-r--r--sys/kern/subr_bus.c8
-rw-r--r--sys/kern/subr_rman.c2
-rw-r--r--sys/sys/bus.h4
-rw-r--r--sys/x86/xen/xenpv.c2
12 files changed, 26 insertions, 26 deletions
diff --git a/sys/dev/bhnd/bhnd.h b/sys/dev/bhnd/bhnd.h
index 15e56f6cd2e9..4d9fce80fa2f 100644
--- a/sys/dev/bhnd/bhnd.h
+++ b/sys/dev/bhnd/bhnd.h
@@ -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);
}
/**
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c
index 1b91d64cb7c4..06812427a2b0 100644
--- a/sys/dev/pccard/pccard.c
+++ b/sys/dev/pccard/pccard.c
@@ -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));
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 2f4408e60c66..492efe02294b 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -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, &reg, 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, &reg, 0, ~0ul,
+ resource_list_add(rl, type, reg, 0, ~0, count);
+ res = resource_list_reserve(rl, bus, dev, type, &reg, 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
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index f3172d6b9fa5..6d66498e8a25 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -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));
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 4c9b0ca937f6..24f9b3aa8d46 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -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;
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 048bc91cecc4..3cc6ac343e9c 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -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);
}
diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c
index bb03ea0dd651..d2c811351a1d 100644
--- a/sys/isa/isa_common.c
+++ b/sys/isa/isa_common.c
@@ -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);
}
}
}
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
index 8acadd7c10b7..3a6a9d625935 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -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
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index a144031867aa..8daa9f2bc6d8 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -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
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index 3050e443d62a..41f1f3458d65 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -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)
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 0e408446f3c6..5f0df65146b6 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -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));
}
/*
diff --git a/sys/x86/xen/xenpv.c b/sys/x86/xen/xenpv.c
index 50fd9df14912..30e8dbce8943 100644
--- a/sys/x86/xen/xenpv.c
+++ b/sys/x86/xen/xenpv.c
@@ -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);