tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / soc / nvidia / tegra / types.h
blobdab474d35d5fbb35726d40391296534148f787ea
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2014 Google Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef __TEGRA_MISC_TYPES_H__
17 #define __TEGRA_MISC_TYPES_H__
19 #define EFAULT 1
20 #define EINVAL 2
21 #define ETIMEDOUT 3
22 #define ENOSPC 4
23 #define ENOSYS 5
24 #define EPTR 6
26 #define IS_ERR_PTR(ptr) \
27 (ptr == (void *)-EPTR)
29 #ifndef bool
30 #define bool int
31 #endif
33 #ifndef false
34 #define false 0
35 #endif
37 #ifndef true
38 #define true 1
39 #endif
41 #ifndef container_of
42 /**
43 * container_of - cast a member of a structure out to the containing structure
44 * @ptr: the pointer to the member.
45 * @type: the type of the container struct this is embedded in.
46 * @member: the name of the member within the struct.
49 #define container_of(ptr, type, member) ({ \
50 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
51 (type *)( (char *)__mptr - offsetof(type,member) );})
52 #endif
54 #define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y))
57 * Divide positive or negative dividend by positive divisor and round
58 * to closest integer. Result is undefined for negative divisors and
59 * for negative dividends if the divisor variable type is unsigned.
61 #define DIV_ROUND_CLOSEST(x, divisor)( \
62 { \
63 typeof(x) __x = x; \
64 typeof(divisor) __d = divisor; \
65 (((typeof(x))-1) > 0 || \
66 ((typeof(divisor))-1) > 0 || (__x) > 0) ? \
67 (((__x) + ((__d) / 2)) / (__d)) : \
68 (((__x) - ((__d) / 2)) / (__d)); \
69 } \
72 #endif /* __TEGRA_MISC_TYPES_H__ */