[adm5120] license cleanup
[openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / prom / prom_read.h
1 /*
2  *  $Id$
3  *
4  *  Generic prom definitions
5  *
6  *  Copyright (C) 2007 OpenWrt.org
7  *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8  *
9  *  This program is free software; you can redistribute it and/or modify it
10  *  under the terms of the GNU General Public License version 2 as published
11  *  by the Free Software Foundation.
12  *
13  */
14
15 #ifndef _ADM5120_PROM_H_
16 #define _ADM5120_PROM_H_
17
18 /*
19  * Helper routines
20  */
21 static inline u16 prom_read_le16(void *buf)
22 {
23         u8 *p = buf;
24
25         return ((u16)p[0] + ((u16)p[1] << 8));
26 }
27
28 static inline u32 prom_read_le32(void *buf)
29 {
30         u8 *p = buf;
31
32         return ((u32)p[0] + ((u32)p[1] << 8) + ((u32)p[2] << 16) +
33                 ((u32)p[3] << 24));
34 }
35
36 static inline u16 prom_read_be16(void *buf)
37 {
38         u8 *p = buf;
39
40         return (((u16)p[0] << 8) + (u16)p[1]);
41 }
42
43 static inline u32 prom_read_be32(void *buf)
44 {
45         u8 *p = buf;
46
47         return (((u32)p[0] << 24) + ((u32)p[1] << 16) + ((u32)p[2] << 8) +
48                 ((u32)p[3]));
49 }
50
51 #endif /* _ADM5120_PROM_H_ */
52
53