summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/io-typeconfused.h
blob: d25ed7db24732c006b326ac0802540ee47f2a109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Generic I/O port emulation, based on MN10300 code
 *
 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public Licence
 * as published by the Free Software Foundation; either version
 * 2 of the Licence, or (at your option) any later version.
 */
#ifndef __ASM_GENERIC_IO_TYPECONFUSED_H
#define __ASM_GENERIC_IO_TYPECONFUSED_H

#include <linux/string.h> /* for memset() and memcpy() */
#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/byteorder.h>

/*****************************************************************************/
/*
 * Unlike the definitions in <asm-generic/io.h>, these macros don't complain
 * about integer arguments and just silently cast them to pointers. This is
 * a common cause of bugs, but lots of existing code depends on this, so
 * this header is provided as a transitory measure.
 */

#ifndef __raw_readb
#define __raw_readb(a)		(__chk_io_ptr(a), *(volatile unsigned char __force  *)(a))
#endif

#ifndef __raw_readw
#define __raw_readw(a)		(__chk_io_ptr(a), *(volatile unsigned short __force *)(a))
#endif

#ifndef __raw_readl
#define __raw_readl(a)		(__chk_io_ptr(a), *(volatile unsigned int __force   *)(a))
#endif

#ifndef readb
#define readb __raw_readb
#endif

#ifndef readw
#define readw(addr) __le16_to_cpu(__raw_readw(addr))
#endif

#ifndef readl
#define readl(addr) __le32_to_cpu(__raw_readl(addr))
#endif

#ifndef __raw_writeb
#define __raw_writeb(v,a)	(__chk_io_ptr(a), *(volatile unsigned char __force  *)(a) = (v))
#endif

#ifndef __raw_writew
#define __raw_writew(v,a)	(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v))
#endif

#ifndef __raw_writel
#define __raw_writel(v,a)	(__chk_io_ptr(a), *(volatile unsigned int __force   *)(a) = (v))
#endif

#ifndef writeb
#define writeb __raw_writeb
#endif

#ifndef writew
#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)
#endif

#ifndef writel
#define writel(b,addr) __raw_writel(__cpu_to_le32(b),addr)
#endif

#endif /* __ASM_GENERIC_IO_TYPECONFUSED_H */