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

Configure Feed

Select the types of activity you want to include in your feed.

asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n

With all subsystems and drivers either declaring their dependence on
HAS_IOPORT or fencing I/O port specific code sections we can finally
make inb()/outb() and friends compile-time dependent on HAS_IOPORT as
suggested by Linus in the linked mail. The main benefit of this is that
on platforms such as s390 which have no meaningful way of implementing
inb()/outb() their use without the proper HAS_IOPORT dependency will
result in easy to catch and fix compile-time errors instead of compiling
code that can never work.

Link: https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net> # for ARCH=um
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Kalle Valo <kvalo@kernel.org>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Niklas Schnelle and committed by
Arnd Bergmann
6f043e75 7c7e6c89

+60
+60
include/asm-generic/io.h
··· 540 540 541 541 #if !defined(inb) && !defined(_inb) 542 542 #define _inb _inb 543 + #ifdef CONFIG_HAS_IOPORT 543 544 static inline u8 _inb(unsigned long addr) 544 545 { 545 546 u8 val; ··· 550 549 __io_par(val); 551 550 return val; 552 551 } 552 + #else 553 + u8 _inb(unsigned long addr) 554 + __compiletime_error("inb()) requires CONFIG_HAS_IOPORT"); 555 + #endif 553 556 #endif 554 557 555 558 #if !defined(inw) && !defined(_inw) 556 559 #define _inw _inw 560 + #ifdef CONFIG_HAS_IOPORT 557 561 static inline u16 _inw(unsigned long addr) 558 562 { 559 563 u16 val; ··· 568 562 __io_par(val); 569 563 return val; 570 564 } 565 + #else 566 + u16 _inw(unsigned long addr) 567 + __compiletime_error("inw() requires CONFIG_HAS_IOPORT"); 568 + #endif 571 569 #endif 572 570 573 571 #if !defined(inl) && !defined(_inl) 574 572 #define _inl _inl 573 + #ifdef CONFIG_HAS_IOPORT 575 574 static inline u32 _inl(unsigned long addr) 576 575 { 577 576 u32 val; ··· 586 575 __io_par(val); 587 576 return val; 588 577 } 578 + #else 579 + u32 _inl(unsigned long addr) 580 + __compiletime_error("inl() requires CONFIG_HAS_IOPORT"); 581 + #endif 589 582 #endif 590 583 591 584 #if !defined(outb) && !defined(_outb) 592 585 #define _outb _outb 586 + #ifdef CONFIG_HAS_IOPORT 593 587 static inline void _outb(u8 value, unsigned long addr) 594 588 { 595 589 __io_pbw(); 596 590 __raw_writeb(value, PCI_IOBASE + addr); 597 591 __io_paw(); 598 592 } 593 + #else 594 + void _outb(u8 value, unsigned long addr) 595 + __compiletime_error("outb() requires CONFIG_HAS_IOPORT"); 596 + #endif 599 597 #endif 600 598 601 599 #if !defined(outw) && !defined(_outw) 602 600 #define _outw _outw 601 + #ifdef CONFIG_HAS_IOPORT 603 602 static inline void _outw(u16 value, unsigned long addr) 604 603 { 605 604 __io_pbw(); 606 605 __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); 607 606 __io_paw(); 608 607 } 608 + #else 609 + void _outw(u16 value, unsigned long addr) 610 + __compiletime_error("outw() requires CONFIG_HAS_IOPORT"); 611 + #endif 609 612 #endif 610 613 611 614 #if !defined(outl) && !defined(_outl) 612 615 #define _outl _outl 616 + #ifdef CONFIG_HAS_IOPORT 613 617 static inline void _outl(u32 value, unsigned long addr) 614 618 { 615 619 __io_pbw(); 616 620 __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); 617 621 __io_paw(); 618 622 } 623 + #else 624 + void _outl(u32 value, unsigned long addr) 625 + __compiletime_error("outl() requires CONFIG_HAS_IOPORT"); 626 + #endif 619 627 #endif 620 628 621 629 #include <linux/logic_pio.h> ··· 718 688 719 689 #ifndef insb 720 690 #define insb insb 691 + #ifdef CONFIG_HAS_IOPORT 721 692 static inline void insb(unsigned long addr, void *buffer, unsigned int count) 722 693 { 723 694 readsb(PCI_IOBASE + addr, buffer, count); 724 695 } 696 + #else 697 + void insb(unsigned long addr, void *buffer, unsigned int count) 698 + __compiletime_error("insb() requires HAS_IOPORT"); 699 + #endif 725 700 #endif 726 701 727 702 #ifndef insw 728 703 #define insw insw 704 + #ifdef CONFIG_HAS_IOPORT 729 705 static inline void insw(unsigned long addr, void *buffer, unsigned int count) 730 706 { 731 707 readsw(PCI_IOBASE + addr, buffer, count); 732 708 } 709 + #else 710 + void insw(unsigned long addr, void *buffer, unsigned int count) 711 + __compiletime_error("insw() requires HAS_IOPORT"); 712 + #endif 733 713 #endif 734 714 735 715 #ifndef insl 736 716 #define insl insl 717 + #ifdef CONFIG_HAS_IOPORT 737 718 static inline void insl(unsigned long addr, void *buffer, unsigned int count) 738 719 { 739 720 readsl(PCI_IOBASE + addr, buffer, count); 740 721 } 722 + #else 723 + void insl(unsigned long addr, void *buffer, unsigned int count) 724 + __compiletime_error("insl() requires HAS_IOPORT"); 725 + #endif 741 726 #endif 742 727 743 728 #ifndef outsb 744 729 #define outsb outsb 730 + #ifdef CONFIG_HAS_IOPORT 745 731 static inline void outsb(unsigned long addr, const void *buffer, 746 732 unsigned int count) 747 733 { 748 734 writesb(PCI_IOBASE + addr, buffer, count); 749 735 } 736 + #else 737 + void outsb(unsigned long addr, const void *buffer, unsigned int count) 738 + __compiletime_error("outsb() requires HAS_IOPORT"); 739 + #endif 750 740 #endif 751 741 752 742 #ifndef outsw 753 743 #define outsw outsw 744 + #ifdef CONFIG_HAS_IOPORT 754 745 static inline void outsw(unsigned long addr, const void *buffer, 755 746 unsigned int count) 756 747 { 757 748 writesw(PCI_IOBASE + addr, buffer, count); 758 749 } 750 + #else 751 + void outsw(unsigned long addr, const void *buffer, unsigned int count) 752 + __compiletime_error("outsw() requires HAS_IOPORT"); 753 + #endif 759 754 #endif 760 755 761 756 #ifndef outsl 762 757 #define outsl outsl 758 + #ifdef CONFIG_HAS_IOPORT 763 759 static inline void outsl(unsigned long addr, const void *buffer, 764 760 unsigned int count) 765 761 { 766 762 writesl(PCI_IOBASE + addr, buffer, count); 767 763 } 764 + #else 765 + void outsl(unsigned long addr, const void *buffer, unsigned int count) 766 + __compiletime_error("outsl() requires HAS_IOPORT"); 767 + #endif 768 768 #endif 769 769 770 770 #ifndef insb_p