Date: Thu, 3 Mar 2016 05:07:36 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296336 - in head/sys: dev/bhnd dev/pccard dev/pci isa kern sys x86/xen Message-ID: <201603030507.u2357ae2098576@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Thu Mar 3 05:07:35 2016 New Revision: 296336 URL: https://svnweb.freebsd.org/changeset/base/296336 Log: 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 Modified: head/sys/dev/bhnd/bhnd.h head/sys/dev/pccard/pccard.c head/sys/dev/pci/pci.c head/sys/dev/pci/pci_iov.c head/sys/dev/pci/pci_pci.c head/sys/dev/pci/vga_pci.c head/sys/isa/isa_common.c head/sys/kern/bus_if.m head/sys/kern/subr_bus.c head/sys/kern/subr_rman.c head/sys/sys/bus.h head/sys/x86/xen/xenpv.c Modified: head/sys/dev/bhnd/bhnd.h ============================================================================== --- head/sys/dev/bhnd/bhnd.h Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/bhnd/bhnd.h Thu Mar 3 05:07:35 2016 (r296336) @@ -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 ty 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); } /** Modified: head/sys/dev/pccard/pccard.c ============================================================================== --- head/sys/dev/pccard/pccard.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/pccard/pccard.c Thu Mar 3 05:07:35 2016 (r296336) @@ -506,7 +506,7 @@ pccard_function_init(struct pccard_funct 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_funct 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)); Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/pci/pci.c Thu Mar 3 05:07:35 2016 (r296336) @@ -3092,7 +3092,7 @@ pci_add_map(device_t bus, device_t dev, 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, */ 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, * 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_ 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 Modified: head/sys/dev/pci/pci_iov.c ============================================================================== --- head/sys/dev/pci/pci_iov.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/pci/pci_iov.c Thu Mar 3 05:07:35 2016 (r296336) @@ -330,8 +330,8 @@ pci_iov_alloc_bar(struct pci_devinfo *di 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 pc 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)); Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/pci/pci_pci.c Thu Mar 3 05:07:35 2016 (r296336) @@ -389,7 +389,7 @@ pcib_alloc_window(struct pcib_softc *sc, 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; Modified: head/sys/dev/pci/vga_pci.c ============================================================================== --- head/sys/dev/pci/vga_pci.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/dev/pci/vga_pci.c Thu Mar 3 05:07:35 2016 (r296336) @@ -164,8 +164,8 @@ vga_pci_map_bios(device_t dev, size_t *s #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); } Modified: head/sys/isa/isa_common.c ============================================================================== --- head/sys/isa/isa_common.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/isa/isa_common.c Thu Mar 3 05:07:35 2016 (r296336) @@ -483,7 +483,7 @@ isa_claim_resources(device_t dev, device if (!rle->res) { rid = rle->rid; resource_list_alloc(rl, dev, child, rle->type, &rid, - 0ul, ~0ul, 1, 0); + 0, ~0, 1, 0); } } } Modified: head/sys/kern/bus_if.m ============================================================================== --- head/sys/kern/bus_if.m Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/kern/bus_if.m Thu Mar 3 05:07:35 2016 (r296336) @@ -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 Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/kern/subr_bus.c Thu Mar 3 05:07:35 2016 (r296336) @@ -3236,9 +3236,9 @@ resource_list_delete(struct resource_lis * @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_li * @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 Modified: head/sys/kern/subr_rman.c ============================================================================== --- head/sys/kern/subr_rman.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/kern/subr_rman.c Thu Mar 3 05:07:35 2016 (r296336) @@ -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) Modified: head/sys/sys/bus.h ============================================================================== --- head/sys/sys/bus.h Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/sys/bus.h Thu Mar 3 05:07:35 2016 (r296336) @@ -478,14 +478,14 @@ void bus_enumerate_hinted_children(devic 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)); } /* Modified: head/sys/x86/xen/xenpv.c ============================================================================== --- head/sys/x86/xen/xenpv.c Thu Mar 3 02:46:12 2016 (r296335) +++ head/sys/x86/xen/xenpv.c Thu Mar 3 05:07:35 2016 (r296336) @@ -120,7 +120,7 @@ xenpv_alloc_physmem(device_t dev, device 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603030507.u2357ae2098576>