Skip to content

Commit d67a308

Browse files
committed
Merge branch 'asm-generic-io.h-cleanup' into asm-generic
MIPS is the last architecture that is yet to start using asm-generic/io.h, so Baoquan He converts it, which allows the other changes to remove code duplication, and it will allow further cleanups in the future. * asm-generic-io.h-cleanup: asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr() mips: io: remove duplicated codes arch/*/io.h: remove ioremap_uc in some architectures mips: add <asm-generic/io.h> including
2 parents 280ac17 + 3cd9445 commit d67a308

16 files changed

Lines changed: 81 additions & 128 deletions

File tree

Documentation/driver-api/device-io.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,12 @@ functions for details on the CPU side of things.
408408
ioremap_uc()
409409
------------
410410

411-
ioremap_uc() behaves like ioremap() except that on the x86 architecture without
412-
'PAT' mode, it marks memory as uncached even when the MTRR has designated
413-
it as cacheable, see Documentation/arch/x86/pat.rst.
411+
ioremap_uc() is only meaningful on old x86-32 systems with the PAT extension,
412+
and on ia64 with its slightly unconventional ioremap() behavior, everywhere
413+
elss ioremap_uc() defaults to return NULL.
414414

415-
Portable drivers should avoid the use of ioremap_uc().
415+
416+
Portable drivers should avoid the use of ioremap_uc(), use ioremap() instead.
416417

417418
ioremap_cache()
418419
---------------

arch/alpha/include/asm/io.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ static inline void __iomem *ioremap(unsigned long port, unsigned long size)
308308
}
309309

310310
#define ioremap_wc ioremap
311-
#define ioremap_uc ioremap
312311

313312
static inline void iounmap(volatile void __iomem *addr)
314313
{
@@ -651,12 +650,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
651650
#endif
652651
#define RTC_ALWAYS_BCD 0
653652

654-
/*
655-
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
656-
* access
657-
*/
658-
#define xlate_dev_mem_ptr(p) __va(p)
659-
660653
/*
661654
* These get provided from <asm-generic/iomap.h> since alpha does not
662655
* select GENERIC_IOMAP.

arch/arm/include/asm/io.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,6 @@ struct pci_dev;
407407
#define pci_iounmap pci_iounmap
408408
extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
409409

410-
/*
411-
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
412-
* access
413-
*/
414-
#define xlate_dev_mem_ptr(p) __va(p)
415-
416410
#include <asm-generic/io.h>
417411

418412
#ifdef CONFIG_MMU

arch/hexagon/include/asm/io.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ static inline void *phys_to_virt(unsigned long address)
5858
return __va(address);
5959
}
6060

61-
/*
62-
* convert a physical pointer to a virtual kernel pointer for
63-
* /dev/mem access.
64-
*/
65-
#define xlate_dev_mem_ptr(p) __va(p)
66-
6761
/*
6862
* IO port access primitives. Hexagon doesn't have special IO access
6963
* instructions; all I/O is memory mapped.
@@ -174,9 +168,6 @@ static inline void writel(u32 data, volatile void __iomem *addr)
174168
#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
175169
(__HEXAGON_C_DEV << 6))
176170

177-
#define ioremap_uc(addr, size) ioremap((addr), (size))
178-
179-
180171
#define __raw_writel writel
181172

182173
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,

arch/m68k/include/asm/io_mm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,6 @@ static inline void isa_delay(void)
389389

390390
#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
391391

392-
/*
393-
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
394-
* access
395-
*/
396-
#define xlate_dev_mem_ptr(p) __va(p)
397-
398392
#define readb_relaxed(addr) readb(addr)
399393
#define readw_relaxed(addr) readw(addr)
400394
#define readl_relaxed(addr) readl(addr)

arch/m68k/include/asm/kmap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
2525
return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
2626
}
2727

28-
#define ioremap_uc ioremap
2928
#define ioremap_wt ioremap_wt
3029
static inline void __iomem *ioremap_wt(unsigned long physaddr,
3130
unsigned long size)

arch/mips/include/asm/io.h

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define _ASM_IO_H
1414

1515
#include <linux/compiler.h>
16-
#include <linux/kernel.h>
1716
#include <linux/types.h>
1817
#include <linux/irqflags.h>
1918

@@ -25,7 +24,6 @@
2524
#include <asm/cpu-features.h>
2625
#include <asm/page.h>
2726
#include <asm/pgtable-bits.h>
28-
#include <asm/processor.h>
2927
#include <asm/string.h>
3028
#include <mangle-port.h>
3129

@@ -41,6 +39,11 @@
4139
# define __raw_ioswabq(a, x) (x)
4240
# define ____raw_ioswabq(a, x) (x)
4341

42+
# define _ioswabb ioswabb
43+
# define _ioswabw ioswabw
44+
# define _ioswabl ioswabl
45+
# define _ioswabq ioswabq
46+
4447
# define __relaxed_ioswabb ioswabb
4548
# define __relaxed_ioswabw ioswabw
4649
# define __relaxed_ioswabl ioswabl
@@ -114,23 +117,6 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
114117
return __virt_to_phys(x);
115118
}
116119

117-
/*
118-
* phys_to_virt - map physical address to virtual
119-
* @address: address to remap
120-
*
121-
* The returned virtual address is a current CPU mapping for
122-
* the memory address given. It is only valid to use this function on
123-
* addresses that have a kernel mapping
124-
*
125-
* This function does not handle bus mappings for DMA transfers. In
126-
* almost all conceivable cases a device driver should not be using
127-
* this function
128-
*/
129-
static inline void * phys_to_virt(unsigned long address)
130-
{
131-
return __va(address);
132-
}
133-
134120
/*
135121
* ISA I/O bus memory addresses are 1:1 with the physical address.
136122
*/
@@ -139,11 +125,6 @@ static inline unsigned long isa_virt_to_bus(volatile void *address)
139125
return virt_to_phys(address);
140126
}
141127

142-
static inline void *isa_bus_to_virt(unsigned long address)
143-
{
144-
return phys_to_virt(address);
145-
}
146-
147128
/*
148129
* Change "struct page" to physical address.
149130
*/
@@ -166,7 +147,6 @@ void iounmap(const volatile void __iomem *addr);
166147
*/
167148
#define ioremap(offset, size) \
168149
ioremap_prot((offset), (size), _CACHE_UNCACHED)
169-
#define ioremap_uc ioremap
170150

171151
/*
172152
* ioremap_cache - map bus memory into CPU space
@@ -296,9 +276,9 @@ static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
296276
return pfx##ioswab##bwlq(__mem, __val); \
297277
}
298278

299-
#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax, p) \
279+
#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax) \
300280
\
301-
static inline void pfx##out##bwlq##p(type val, unsigned long port) \
281+
static inline void pfx##out##bwlq(type val, unsigned long port) \
302282
{ \
303283
volatile type *__addr; \
304284
type __val; \
@@ -318,7 +298,7 @@ static inline void pfx##out##bwlq##p(type val, unsigned long port) \
318298
*__addr = __val; \
319299
} \
320300
\
321-
static inline type pfx##in##bwlq##p(unsigned long port) \
301+
static inline type pfx##in##bwlq(unsigned long port) \
322302
{ \
323303
volatile type *__addr; \
324304
type __val; \
@@ -360,11 +340,10 @@ __BUILD_MEMORY_PFX(__mem_, q, u64, 0)
360340
#endif
361341

362342
#define __BUILD_IOPORT_PFX(bus, bwlq, type) \
363-
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,) \
364-
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0, _p)
343+
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0)
365344

366345
#define BUILDIO_IOPORT(bwlq, type) \
367-
__BUILD_IOPORT_PFX(, bwlq, type) \
346+
__BUILD_IOPORT_PFX(_, bwlq, type) \
368347
__BUILD_IOPORT_PFX(__mem_, bwlq, type)
369348

370349
BUILDIO_IOPORT(b, u8)
@@ -412,14 +391,6 @@ __BUILDIO(q, u64)
412391
#define writeq_be(val, addr) \
413392
__raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))
414393

415-
/*
416-
* Some code tests for these symbols
417-
*/
418-
#ifdef CONFIG_64BIT
419-
#define readq readq
420-
#define writeq writeq
421-
#endif
422-
423394
#define __BUILD_MEMORY_STRING(bwlq, type) \
424395
\
425396
static inline void writes##bwlq(volatile void __iomem *mem, \
@@ -480,18 +451,6 @@ BUILDSTRING(l, u32)
480451
BUILDSTRING(q, u64)
481452
#endif
482453

483-
static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
484-
{
485-
memset((void __force *) addr, val, count);
486-
}
487-
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
488-
{
489-
memcpy(dst, (void __force *) src, count);
490-
}
491-
static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
492-
{
493-
memcpy((void __force *) dst, src, count);
494-
}
495454

496455
/*
497456
* The caches on some architectures aren't dma-coherent and have need to
@@ -548,13 +507,66 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
548507
#define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
549508
#define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
550509

551-
/*
552-
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
553-
* access
554-
*/
555-
#define xlate_dev_mem_ptr(p) __va(p)
556-
#define unxlate_dev_mem_ptr(p, v) do { } while (0)
510+
#define __raw_readb __raw_readb
511+
#define __raw_readw __raw_readw
512+
#define __raw_readl __raw_readl
513+
#ifdef CONFIG_64BIT
514+
#define __raw_readq __raw_readq
515+
#endif
516+
#define __raw_writeb __raw_writeb
517+
#define __raw_writew __raw_writew
518+
#define __raw_writel __raw_writel
519+
#ifdef CONFIG_64BIT
520+
#define __raw_writeq __raw_writeq
521+
#endif
522+
523+
#define readb readb
524+
#define readw readw
525+
#define readl readl
526+
#ifdef CONFIG_64BIT
527+
#define readq readq
528+
#endif
529+
#define writeb writeb
530+
#define writew writew
531+
#define writel writel
532+
#ifdef CONFIG_64BIT
533+
#define writeq writeq
534+
#endif
535+
536+
#define readsb readsb
537+
#define readsw readsw
538+
#define readsl readsl
539+
#ifdef CONFIG_64BIT
540+
#define readsq readsq
541+
#endif
542+
#define writesb writesb
543+
#define writesw writesw
544+
#define writesl writesl
545+
#ifdef CONFIG_64BIT
546+
#define writesq writesq
547+
#endif
548+
549+
#define _inb _inb
550+
#define _inw _inw
551+
#define _inl _inl
552+
#define insb insb
553+
#define insw insw
554+
#define insl insl
555+
556+
#define _outb _outb
557+
#define _outw _outw
558+
#define _outl _outl
559+
#define outsb outsb
560+
#define outsw outsw
561+
#define outsl outsl
557562

558563
void __ioread64_copy(void *to, const void __iomem *from, size_t count);
559564

565+
#include <asm-generic/io.h>
566+
567+
static inline void *isa_bus_to_virt(unsigned long address)
568+
{
569+
return phys_to_virt(address);
570+
}
571+
560572
#endif /* _ASM_IO_H */

arch/mips/include/asm/mmiowb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#ifndef _ASM_MMIOWB_H
33
#define _ASM_MMIOWB_H
44

5-
#include <asm/io.h>
5+
#include <asm/barrier.h>
66

7-
#define mmiowb() iobarrier_w()
7+
#define mmiowb() wmb()
88

99
#include <asm-generic/mmiowb.h>
1010

arch/mips/include/asm/smp-ops.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include <linux/errno.h>
1515

16-
#include <asm/mips-cps.h>
17-
1816
#ifdef CONFIG_SMP
1917

2018
#include <linux/cpumask.h>

arch/mips/include/asm/smp.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
#ifndef __ASM_SMP_H
1212
#define __ASM_SMP_H
1313

14-
#include <linux/bitops.h>
14+
#include <linux/compiler.h>
1515
#include <linux/linkage.h>
16-
#include <linux/smp.h>
1716
#include <linux/threads.h>
1817
#include <linux/cpumask.h>
1918

20-
#include <linux/atomic.h>
2119
#include <asm/smp-ops.h>
2220

2321
extern int smp_num_siblings;

0 commit comments

Comments
 (0)