linux-yocto/arch/powerpc/include/asm
Michael Ellerman 9ad656ec23 powerpc/io: Avoid clang null pointer arithmetic warnings
[ Upstream commit 03c0f2c2b2 ]

With -Wextra clang warns about pointer arithmetic using a null pointer.
When building with CONFIG_PCI=n, that triggers a warning in the IO
accessors, eg:

  In file included from linux/arch/powerpc/include/asm/io.h:672:
  linux/arch/powerpc/include/asm/io-defs.h:23:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     23 | DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port)
        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ...
  linux/arch/powerpc/include/asm/io.h:591:53: note: expanded from macro '__do_inb'
    591 | #define __do_inb(port)          readb((PCI_IO_ADDR)_IO_BASE + port);
        |                                       ~~~~~~~~~~~~~~~~~~~~~ ^

That is because when CONFIG_PCI=n, _IO_BASE is defined as 0.

Although _IO_BASE is defined as plain 0, the cast (PCI_IO_ADDR) converts
it to void * before the addition with port happens.

Instead the addition can be done first, and then the cast. The resulting
value will be the same, but avoids the warning, and also avoids void
pointer arithmetic which is apparently non-standard.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Closes: https://lore.kernel.org/all/CA+G9fYtEh8zmq8k8wE-8RZwW-Qr927RLTn+KqGnq1F=ptaaNsA@mail.gmail.com
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240503075619.394467-1-mpe@ellerman.id.au
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-05 09:14:27 +02:00
..
book3s powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
nohash powerpc/40x: Remove stale PTE_ATOMIC_UPDATES macro 2023-11-20 11:08:26 +01:00
vdso powerpc: Redefine HMT_xxx macros as empty on PPC32 2021-08-27 00:56:52 +10:00
8xx_immap.h
accounting.h
agp.h
archrandom.h powerpc/powernv/kvm: Use darn for H_RANDOM on Power9 2022-08-17 14:24:25 +02:00
asm-compat.h powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros 2021-08-25 13:35:49 +10:00
asm-const.h powerpc: remove GCC version check for UPD_CONSTR 2021-09-13 10:18:28 -07:00
asm-offsets.h
asm-prototypes.h powerpc/64: use interrupt restart table to speed up return from interrupt 2021-06-25 00:06:56 +10:00
async_tx.h
atomic.h powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros 2021-08-25 13:35:49 +10:00
backlight.h
barrier.h powerpc/barrier: Avoid collision with clang's __lwsync macro 2021-06-10 21:44:57 +10:00
bitops.h powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros 2021-08-25 13:35:49 +10:00
bootx.h
bpf_perf_event.h powerpc/bpf: Fix use of user_pt_regs in uapi 2022-07-07 17:53:24 +02:00
btext.h
bug.h powerpc/bug: Cast to unsigned long before passing to inline asm 2021-09-01 21:25:43 +10:00
cache.h
cacheflush.h powerpc/mem: Inline flush_dcache_page() 2021-04-14 23:04:19 +10:00
cell-pmu.h
cell-regs.h
checksum.h powerpc: Force inlining of csum_add() 2021-06-16 00:16:47 +10:00
clocksource.h
cmpxchg.h locking/atomic: powerpc: move to ARCH_ATOMIC 2021-05-26 13:20:52 +02:00
code-patching-asm.h
code-patching.h powerpc/lib: Add helper to check if offset is within conditional branch range 2021-10-07 18:52:33 +11:00
compat.h arch: remove compat_alloc_user_space 2021-09-08 15:32:35 -07:00
context_tracking.h
copro.h
cpm.h
cpm1.h powerpc/8xx: Fix early debug when SMC1 is relocated 2020-12-09 17:00:54 +11:00
cpm2.h powerpc: Spelling/typo fixes 2021-04-08 21:17:42 +10:00
cpu_has_feature.h powerpc: Force inlining of cpu_has_feature() to avoid build failure 2021-03-14 20:32:24 +11:00
cpu_setup_power.h
cpufeature.h
cpuidle.h
cputable.h arch: powerpc: Stop building and using oprofile 2021-01-29 10:05:51 +05:30
cputhreads.h KVM: PPC: Book3S HV: Fix TLB management on SMT8 POWER9 and POWER10 processors 2021-06-21 09:22:34 +10:00
cputime.h powerpc/64: move account_stolen_time into its own function 2021-02-09 00:10:49 +11:00
crashdump-ppc64.h
current.h
dbdma.h
dbell.h
dcr-generic.h
dcr-mmio.h
dcr-native.h powerpc/4xx: Fix build errors from mfdcr() 2021-03-01 12:33:31 +11:00
dcr-regs.h
dcr.h
debug.h powerpc: convert interrupt handlers to use wrappers 2021-02-09 00:02:12 +11:00
delay.h
device.h
disassemble.h
dma-direct.h
dma.h
drmem.h pseries/drmem: update LMBs after LPM 2021-08-10 23:14:55 +10:00
dt_cpu_ftrs.h
dtl.h
edac.h
eeh_event.h
eeh.h
ehv_pic.h
elf.h
elfnote.h
emergency-restart.h
emulated_ops.h
epapr_hcalls.h
exception-64e.h
exception-64s.h KVM: PPC: Book3S 64: Move hcall early register setup to KVM 2021-06-10 22:12:12 +10:00
exec.h
extable.h powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto 2021-08-15 13:49:24 +10:00
fadump-internal.h cma: factor out minimum alignment requirement 2024-07-05 09:14:13 +02:00
fadump.h
fb.h
feature-fixups.h powerpc/64s: fix scv entry fallback flush vs interrupt 2021-01-20 15:58:19 +11:00
firmware.h powerpc/pseries: Add support for FORM2 associativity 2021-08-13 22:04:27 +10:00
fixmap.h powerpc/fixmap: Fix VM debug warning on unmap 2022-02-16 12:56:12 +01:00
floppy.h
fs_pd.h
fsl_85xx_cache_sram.h
fsl_gtm.h
fsl_hcalls.h
fsl_lbc.h
fsl_pamu_stash.h iommu/fsl_pamu: replace DOMAIN_ATTR_FSL_PAMU_STASH with a direct call 2021-04-07 10:56:52 +02:00
fsl_pm.h
ftrace.h powerpc/ftrace: Remove ftrace init tramp once kernel init is complete 2022-07-02 16:41:14 +02:00
futex.h powerpc/futex: Switch to user_access block 2021-03-26 23:19:43 +11:00
grackle.h
hardirq.h
head-64.h powerpc/64: move interrupt return asm to interrupt_64.S 2021-06-25 00:06:55 +10:00
heathrow.h
highmem.h powerpc/mm/highmem: use __set_pte_at() for kmap_local() 2021-01-24 10:34:53 -08:00
hmi.h
hugetlb.h powerpc/mm: Enable compound page check for both THP and HugeTLB 2021-02-11 23:35:06 +11:00
hvcall.h powerpc/pseries: Enforce hcall result buffer validity and size 2024-07-05 09:14:27 +02:00
hvconsole.h powerpc/pseries: Move hvc_vio_init_early() prototype to shared location 2021-03-24 14:09:30 +11:00
hvcserver.h
hvsi.h
hw_breakpoint.h
hw_irq.h powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC 2022-01-27 11:04:07 +01:00
hydra.h powerpc/chrp: Make hydra_init() static 2021-03-24 14:09:29 +11:00
i8259.h
ibmebus.h
icswx.h
ide.h
idle.h
imc-pmu.h powerpc/imc-pmu: Fix use of mutex in IRQs disabled section 2023-01-18 11:48:52 +01:00
immap_cpm2.h
inst.h powerpc/inst: Refactor PPC32 and PPC64 versions 2021-06-17 00:09:06 +10:00
interrupt.h powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
io_event_irq.h
io-defs.h
io-workarounds.h
io.h powerpc/io: Avoid clang null pointer arithmetic warnings 2024-07-05 09:14:27 +02:00
iommu.h powerpc/kernel/iommu: Add new iommu_table_in_use() helper 2021-08-27 00:56:54 +10:00
ipic.h
irq_work.h arch: consolidate arch_irq_work_raise prototypes 2024-02-23 08:54:39 +01:00
irq.h powerpc/interrupt: Fix OOPS by not calling do_IRQ() from timer_interrupt() 2021-08-12 22:21:57 +10:00
irqflags.h
isa-bridge.h
jump_label.h powerpc: Fix initrd corruption with relative jump labels 2021-06-15 23:35:57 +10:00
kasan.h powerpc/kasan: Fix shadow start address with modules 2021-04-25 21:29:04 +10:00
Kbuild powerpc/syscalls: switch to generic syscalltbl.sh 2021-04-14 23:04:16 +10:00
kdebug.h
kdump.h
kexec_ranges.h
kexec.h powerpc/kexec_file: Restore FDT size estimation for kdump kernel 2021-03-11 09:53:38 -07:00
keylargo.h
kfence.h powerpc: Enable KFENCE for PPC32 2021-03-24 14:09:30 +11:00
kgdb.h
kprobes.h
kup.h powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
kvm_asm.h KVM: PPC: Book3S HV P9: implement hash host / hash guest support 2021-06-10 22:12:15 +10:00
kvm_book3s_32.h
kvm_book3s_64.h KVM: PPC: Book3S HV Nested: Fix nested HFSCR being clobbered with multiple vCPUs 2022-02-01 17:27:03 +01:00
kvm_book3s_asm.h KVM: PPC: Book3S HV: Remove support for running HPT guest on RPT host without mixed mode support 2021-02-10 14:31:08 +11:00
kvm_book3s_uvmem.h
kvm_book3s.h KVM: PPC: Book3S HV: Nested support in H_RPT_INVALIDATE 2021-06-22 23:35:37 +10:00
kvm_booke_hv_asm.h
kvm_booke.h
kvm_fpu.h
kvm_guest.h powerpc: Fix is_kvm_guest() / kvm_para_available() 2021-06-25 14:47:19 +10:00
kvm_host.h KVM: PPC: Book3S HV Nested: Fix nested HFSCR being clobbered with multiple vCPUs 2022-02-01 17:27:03 +01:00
kvm_para.h
kvm_ppc.h KVM: PPC: Book3S HV: XIVE: Change interface of passthrough interrupt routines 2021-08-10 23:14:59 +10:00
libata-portmap.h
linkage.h
livepatch.h powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
local.h
lppaca.h powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT 2023-09-19 12:22:42 +02:00
lv1call.h
machdep.h powerpc/pci: Add ppc_md.discover_phbs() 2021-02-03 09:46:36 +11:00
macio.h
mc146818rtc.h
mce.h powerpc/mce: Remove per cpu variables from MCE handlers 2021-01-31 22:35:49 +11:00
mediabay.h
mem_encrypt.h
membarrier.h powerpc/non-smp: Unconditionaly call smp_mb() on switch_mm 2021-08-10 23:14:55 +10:00
mman.h
mmiowb.h
mmu_context.h Merge branch 'topic/ppc-kvm' into next 2021-06-23 00:19:08 +10:00
mmu.h powerpc/mm: Fix build failures due to arch_reserved_kernel_pages() 2024-02-23 08:54:36 +01:00
mmzone.h powerpc/64s: Fix CONFIG_NUMA=n build due to create_section_mapping() 2024-02-23 08:54:36 +01:00
module.h
module.lds.h
mpc5xxx.h
mpc6xx.h
mpc52xx_psc.h
mpc52xx.h
mpc85xx.h
mpc5121.h
mpc8260.h
mpic_msgr.h
mpic_timer.h
mpic.h
msi_bitmap.h
nmi.h powerpc: convert interrupt handlers to use wrappers 2021-02-09 00:02:12 +11:00
nvram.h
ohare.h
opal-api.h powerpc/xive: Remove P9 DD1 flag XIVE_IRQ_FLAG_EOI_FW 2020-12-11 09:53:10 +11:00
opal.h powerpc/powernv: remove the nvlink support 2021-05-02 23:35:32 +10:00
paca.h powerpc: Don't include lppaca.h in paca.h 2023-09-19 12:22:42 +02:00
page_32.h powerpc/32s: Cleanup around PTE_FLAGS_OFFSET in hash_low.S 2020-12-09 23:48:14 +11:00
page_64.h
page.h powerpc/64: Only WARN if __pa()/__va() called with bad addresses 2022-06-09 10:23:12 +02:00
paravirt.h powerpc: Don't include lppaca.h in paca.h 2023-09-19 12:22:42 +02:00
parport.h
pasemi_dma.h
pci-bridge.h powerpc/pseries/pci: Add MSI domains 2021-08-10 23:14:57 +10:00
pci.h powerpc/powernv: remove the nvlink support 2021-05-02 23:35:32 +10:00
percpu.h
perf_event_fsl_emb.h
perf_event_server.h powerpc/perf: Expose processor pipeline stage cycles using PERF_SAMPLE_WEIGHT_STRUCT 2021-04-20 14:22:23 +10:00
perf_event.h powerpc/perf: Expose Performance Monitor Counter SPR's as part of extended regs 2021-02-09 01:09:44 +11:00
pgalloc.h mm/thp: define default pmd_pgtable() 2021-07-01 11:06:03 -07:00
pgtable-be-types.h
pgtable-types.h
pgtable.h powerpc updates for 5.14 2021-07-02 12:54:34 -07:00
pkeys.h powerpc/pkeys: Remove unused code 2021-02-09 01:09:44 +11:00
plpar_wrappers.h powerpc: Don't include lppaca.h in paca.h 2023-09-19 12:22:42 +02:00
pmac_feature.h
pmac_low_i2c.h
pmac_pfunc.h
pmc.h KVM: PPC: Book3S HV Nested: Reflect guest PMU in-use to L0 when guest SPRs are live 2021-08-25 16:37:18 +10:00
pmi.h
pnv-ocxl.h
pnv-pci.h powerpc/powernv/pci: Rework pnv_opal_pci_msi_eoi() 2021-08-10 23:15:01 +10:00
powernv.h
ppc_asm.h powerpc: flexible GPR range save/restore macros 2022-07-12 16:35:02 +02:00
ppc-opcode.h powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
ppc-pci.h powerpc/pci: Remove unimplemented prototypes 2021-02-11 23:35:36 +11:00
ppc4xx.h
probes.h powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
processor.h powerpc/64: drop redundant defination of spin_until_cond 2021-06-17 00:09:11 +10:00
prom.h powerpc/pseries: Add support for FORM2 associativity 2021-08-13 22:04:27 +10:00
ps3.h powerpc/ps3: Add dma_mask to ps3_dma_region 2021-06-10 21:44:58 +10:00
ps3av.h
ps3gpu.h
ps3stor.h
pte-walk.h powerpc: Fix reverse map real-mode address lookup with huge vmalloc 2021-05-28 22:54:27 +10:00
ptrace.h Merge branch 'fixes' into next 2021-09-03 22:54:12 +10:00
qspinlock_paravirt.h
qspinlock.h locking/atomic: powerpc: move to ARCH_ATOMIC 2021-05-26 13:20:52 +02:00
reg_8xx.h
reg_a2.h
reg_booke.h powerpc/32: Handle bookE debugging in C in syscall entry/exit 2021-02-11 23:35:12 +11:00
reg_fsl_emb.h powerpc/fsl: Fix mfpmr build errors with newer binutils 2024-04-10 16:18:37 +02:00
reg.h KVM: PPC: Book3S HV Nested: Fix TM softpatch HFAC interrupt emulation 2021-08-25 16:37:17 +10:00
rheap.h
rio.h
rtas-types.h powerpc/rtas: remove unused rtas_suspend_me_data 2020-12-08 21:41:02 +11:00
rtas.h Revert "powerpc/rtas: Implement reentrant rtas call" 2022-10-15 07:59:02 +02:00
runlatch.h
seccomp.h
sections.h powerpc/toc: Future proof kernel toc 2024-01-25 14:52:32 -08:00
secure_boot.h
security_features.h powerpc/security: Add a helper to query stf_barrier type 2021-10-07 19:52:58 +11:00
secvar.h
serial.h
set_memory.h powerpc: Add set_memory_{p/np}() and remove set_memory_attr() 2022-04-08 14:24:04 +02:00
setjmp.h
setup.h powerpc: Remove klimit 2021-06-25 00:07:10 +10:00
sfp-machine.h
shmparam.h
signal.h
simple_spinlock_types.h
simple_spinlock.h powerpc: Fix eh field when calling lwarx on PPC32 2022-08-17 14:24:29 +02:00
slice.h
smp.h powerpc/smp: Use existing L2 cache_map cpumask to find L3 cache siblings 2021-08-04 10:53:39 +10:00
smu.h
sparsemem.h
spinlock_types.h
spinlock.h powerpc/spinlock: Define smp_mb__after_spinlock only once 2021-03-26 23:19:43 +11:00
spu_csa.h
spu_info.h
spu_priv1.h
spu.h arch: powerpc: Stop building and using oprofile 2021-01-29 10:05:51 +05:30
sstep.h powerpc/kprobes: Roll IS_RFI() macro into IS_RFID() 2021-06-25 14:47:18 +10:00
stackprotector.h
stacktrace.h
string.h
svm.h
swab.h
swiotlb.h
switch_to.h powerpc: Fix missing declaration of [en/dis]able_kernel_vsx() 2021-03-10 11:15:00 +11:00
synch.h
syscall.h powerpc/audit: Fix syscall_get_arch() 2022-02-01 17:27:01 +01:00
syscalls.h powerpc: Fix fallocate and fadvise64_64 compat parameter combination 2022-10-26 12:35:22 +02:00
task_size_32.h
task_size_64.h
tce.h powerpc/pseries/iommu: Replace hard-coded page shift 2021-08-27 00:56:54 +10:00
termios.h
thread_info.h powerpc/kasan: Force thread size increase with KASAN 2022-06-14 18:36:16 +02:00
time.h KVM: PPC: Book3S HV P9: Reduce irq_work vs guest decrementer races 2021-06-10 22:12:13 +10:00
timex.h powerpc: define get_cycles macro for arch-override 2022-05-30 09:29:13 +02:00
tlb.h mm/mremap: allow arch runtime override 2021-07-08 11:48:23 -07:00
tlbflush.h
tm.h
topology.h powerpc/numa: Update cpu_cpu_map on CPU online/offline 2021-08-27 00:56:54 +10:00
trace_clock.h
trace.h
tsi108_irq.h
tsi108_pci.h
tsi108.h
types.h
uaccess.h powerpc/uaccess: Fix build errors seen with GCC 13/14 2024-07-05 09:14:15 +02:00
udbg.h
uic.h
ultravisor-api.h
ultravisor.h
uninorth.h
unistd.h powerpc/syscalls: Remove __NR__exit 2021-08-23 19:28:20 +10:00
uprobes.h powerpc: Don't use 'struct ppc_inst' to reference instruction location 2021-06-17 00:09:00 +10:00
user.h
vas.h powerpc/powernv/vas: Assign real address to rx_fifo in vas_rx_win_attr 2022-06-09 10:22:43 +02:00
vdso_datapage.h powerpc/vdso: Add support for time namespaces 2021-04-14 23:04:44 +10:00
vdso.h
vermagic.h
vga.h
vio.h powerpc/pseries: Add shutdown() to vio_driver and vio_bus 2021-04-20 14:22:24 +10:00
vmalloc.h powerpc: Force inlining of arch_vmap_p{u/m}d_supported() 2024-03-26 18:21:28 -04:00
word-at-a-time.h word-at-a-time: use the same return type for has_zero regardless of endianness 2023-08-11 15:13:49 +02:00
xics.h powerpc/xics: Rename the map handler in a check handler 2021-08-10 23:14:59 +10:00
xive-regs.h KVM: PPC: Book3S HV: XIVE: Add support for automatic save-restore 2021-08-10 23:15:02 +10:00
xive.h KVM: PPC: Book3S HV: XIVE: Add support for automatic save-restore 2021-08-10 23:15:02 +10:00
xmon.h powerpc: remove unneeded semicolons 2021-02-09 00:10:50 +11:00
xor_altivec.h
xor.h