Skip to content

Commit e1d908a

Browse files
committed
Merge tag 'hisi-drivers-for-5.8' of git://github.com/hisilicon/linux-hisi into arm/drivers
ARM64: hisi: SoC driver updates for 5.8 - Generate consistent behaviour for logic_pio by defining and using generic _inX() and _outX() in asm-generic/io.h which have per-arch overrideable barriers. * tag 'hisi-drivers-for-5.8' of git://github.com/hisilicon/linux-hisi: logic_pio: Use _inX() and _outX() logic_pio: Improve macro argument name io: Provide _inX() and _outX()
2 parents 7b972f3 + 4acaa93 commit e1d908a

File tree

2 files changed

+55
-31
lines changed

2 files changed

+55
-31
lines changed

include/asm-generic/io.h

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,15 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
448448
#define IO_SPACE_LIMIT 0xffff
449449
#endif
450450

451-
#include <linux/logic_pio.h>
452-
453451
/*
454452
* {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
455453
* implemented on hardware that needs an additional delay for I/O accesses to
456454
* take effect.
457455
*/
458456

459-
#ifndef inb
460-
#define inb inb
461-
static inline u8 inb(unsigned long addr)
457+
#if !defined(inb) && !defined(_inb)
458+
#define _inb _inb
459+
static inline u16 _inb(unsigned long addr)
462460
{
463461
u8 val;
464462

@@ -469,9 +467,9 @@ static inline u8 inb(unsigned long addr)
469467
}
470468
#endif
471469

472-
#ifndef inw
473-
#define inw inw
474-
static inline u16 inw(unsigned long addr)
470+
#if !defined(inw) && !defined(_inw)
471+
#define _inw _inw
472+
static inline u16 _inw(unsigned long addr)
475473
{
476474
u16 val;
477475

@@ -482,9 +480,9 @@ static inline u16 inw(unsigned long addr)
482480
}
483481
#endif
484482

485-
#ifndef inl
486-
#define inl inl
487-
static inline u32 inl(unsigned long addr)
483+
#if !defined(inl) && !defined(_inl)
484+
#define _inl _inl
485+
static inline u16 _inl(unsigned long addr)
488486
{
489487
u32 val;
490488

@@ -495,36 +493,62 @@ static inline u32 inl(unsigned long addr)
495493
}
496494
#endif
497495

498-
#ifndef outb
499-
#define outb outb
500-
static inline void outb(u8 value, unsigned long addr)
496+
#if !defined(outb) && !defined(_outb)
497+
#define _outb _outb
498+
static inline void _outb(u8 value, unsigned long addr)
501499
{
502500
__io_pbw();
503501
__raw_writeb(value, PCI_IOBASE + addr);
504502
__io_paw();
505503
}
506504
#endif
507505

508-
#ifndef outw
509-
#define outw outw
510-
static inline void outw(u16 value, unsigned long addr)
506+
#if !defined(outw) && !defined(_outw)
507+
#define _outw _outw
508+
static inline void _outw(u16 value, unsigned long addr)
511509
{
512510
__io_pbw();
513511
__raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
514512
__io_paw();
515513
}
516514
#endif
517515

518-
#ifndef outl
519-
#define outl outl
520-
static inline void outl(u32 value, unsigned long addr)
516+
#if !defined(outl) && !defined(_outl)
517+
#define _outl _outl
518+
static inline void _outl(u32 value, unsigned long addr)
521519
{
522520
__io_pbw();
523521
__raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
524522
__io_paw();
525523
}
526524
#endif
527525

526+
#include <linux/logic_pio.h>
527+
528+
#ifndef inb
529+
#define inb _inb
530+
#endif
531+
532+
#ifndef inw
533+
#define inw _inw
534+
#endif
535+
536+
#ifndef inl
537+
#define inl _inl
538+
#endif
539+
540+
#ifndef outb
541+
#define outb _outb
542+
#endif
543+
544+
#ifndef outw
545+
#define outw _outw
546+
#endif
547+
548+
#ifndef outl
549+
#define outl _outl
550+
#endif
551+
528552
#ifndef inb_p
529553
#define inb_p inb_p
530554
static inline u8 inb_p(unsigned long addr)

lib/logic_pio.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ unsigned long logic_pio_trans_cpuaddr(resource_size_t addr)
229229
}
230230

231231
#if defined(CONFIG_INDIRECT_PIO) && defined(PCI_IOBASE)
232-
#define BUILD_LOGIC_IO(bw, type) \
233-
type logic_in##bw(unsigned long addr) \
232+
#define BUILD_LOGIC_IO(bwl, type) \
233+
type logic_in##bwl(unsigned long addr) \
234234
{ \
235235
type ret = (type)~0; \
236236
\
237237
if (addr < MMIO_UPPER_LIMIT) { \
238-
ret = read##bw(PCI_IOBASE + addr); \
238+
ret = _in##bwl(addr); \
239239
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
240240
struct logic_pio_hwaddr *entry = find_io_range(addr); \
241241
\
@@ -248,10 +248,10 @@ type logic_in##bw(unsigned long addr) \
248248
return ret; \
249249
} \
250250
\
251-
void logic_out##bw(type value, unsigned long addr) \
251+
void logic_out##bwl(type value, unsigned long addr) \
252252
{ \
253253
if (addr < MMIO_UPPER_LIMIT) { \
254-
write##bw(value, PCI_IOBASE + addr); \
254+
_out##bwl(value, addr); \
255255
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
256256
struct logic_pio_hwaddr *entry = find_io_range(addr); \
257257
\
@@ -263,11 +263,11 @@ void logic_out##bw(type value, unsigned long addr) \
263263
} \
264264
} \
265265
\
266-
void logic_ins##bw(unsigned long addr, void *buffer, \
267-
unsigned int count) \
266+
void logic_ins##bwl(unsigned long addr, void *buffer, \
267+
unsigned int count) \
268268
{ \
269269
if (addr < MMIO_UPPER_LIMIT) { \
270-
reads##bw(PCI_IOBASE + addr, buffer, count); \
270+
reads##bwl(PCI_IOBASE + addr, buffer, count); \
271271
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
272272
struct logic_pio_hwaddr *entry = find_io_range(addr); \
273273
\
@@ -280,11 +280,11 @@ void logic_ins##bw(unsigned long addr, void *buffer, \
280280
\
281281
} \
282282
\
283-
void logic_outs##bw(unsigned long addr, const void *buffer, \
284-
unsigned int count) \
283+
void logic_outs##bwl(unsigned long addr, const void *buffer, \
284+
unsigned int count) \
285285
{ \
286286
if (addr < MMIO_UPPER_LIMIT) { \
287-
writes##bw(PCI_IOBASE + addr, buffer, count); \
287+
writes##bwl(PCI_IOBASE + addr, buffer, count); \
288288
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
289289
struct logic_pio_hwaddr *entry = find_io_range(addr); \
290290
\

0 commit comments

Comments
 (0)