Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: improve ZPCI_* macros

Most of the constants defined in pci_io.h depend on each other
and thus can be calculated.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
bf19c94d 9e00caae

+10 -7
+9 -6
arch/s390/include/asm/pci_io.h
··· 8 8 #include <asm/pci_insn.h> 9 9 10 10 /* I/O Map */ 11 - #define ZPCI_IOMAP_MAX_ENTRIES 0x8000 12 - #define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000ULL 13 - #define ZPCI_IOMAP_ADDR_IDX_MASK 0x7fff000000000000ULL 14 - #define ZPCI_IOMAP_ADDR_OFF_MASK 0x0000ffffffffffffULL 11 + #define ZPCI_IOMAP_SHIFT 48 12 + #define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000UL 13 + #define ZPCI_IOMAP_ADDR_OFF_MASK ((1UL << ZPCI_IOMAP_SHIFT) - 1) 14 + #define ZPCI_IOMAP_MAX_ENTRIES \ 15 + ((ULONG_MAX - ZPCI_IOMAP_ADDR_BASE + 1) / (1UL << ZPCI_IOMAP_SHIFT)) 16 + #define ZPCI_IOMAP_ADDR_IDX_MASK \ 17 + (~ZPCI_IOMAP_ADDR_OFF_MASK - ZPCI_IOMAP_ADDR_BASE) 15 18 16 19 struct zpci_iomap_entry { 17 20 u32 fh; ··· 24 21 25 22 extern struct zpci_iomap_entry *zpci_iomap_start; 26 23 27 - #define ZPCI_ADDR(idx) (ZPCI_IOMAP_ADDR_BASE | ((u64) idx << 48)) 24 + #define ZPCI_ADDR(idx) (ZPCI_IOMAP_ADDR_BASE | ((u64) idx << ZPCI_IOMAP_SHIFT)) 28 25 #define ZPCI_IDX(addr) \ 29 - (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> 48) 26 + (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> ZPCI_IOMAP_SHIFT) 30 27 #define ZPCI_OFFSET(addr) \ 31 28 ((__force u64) addr & ZPCI_IOMAP_ADDR_OFF_MASK) 32 29
+1 -1
arch/s390/pci/pci.c
··· 541 541 542 542 static int zpci_alloc_iomap(struct zpci_dev *zdev) 543 543 { 544 - int entry; 544 + unsigned long entry; 545 545 546 546 spin_lock(&zpci_iomap_lock); 547 547 entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);