summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross2013-11-08 21:04:18 -0600
committerColin Cross2013-12-18 20:27:54 -0600
commit92d7ca6af3ee38027d7341f24c6b550eaa41417a (patch)
tree6ab8da5165f8668a27033d07fa8db523cf76f3ff /libion/ion.c
parent03c932dffa2f72ee63de24c221d07d249a6eafd3 (diff)
downloadplatform-system-core-92d7ca6af3ee38027d7341f24c6b550eaa41417a.tar.gz
platform-system-core-92d7ca6af3ee38027d7341f24c6b550eaa41417a.tar.xz
platform-system-core-92d7ca6af3ee38027d7341f24c6b550eaa41417a.zip
libion: clean up whitespace
Convert everything to 4 space indents, no tabs. Change-Id: I376fad866864f0579b91ffad406e872fcce566ad
Diffstat (limited to 'libion/ion.c')
-rw-r--r--libion/ion.c154
1 files changed, 77 insertions, 77 deletions
diff --git a/libion/ion.c b/libion/ion.c
index 5fd35fefe..ea40245f7 100644
--- a/libion/ion.c
+++ b/libion/ion.c
@@ -32,119 +32,119 @@
32 32
33int ion_open() 33int ion_open()
34{ 34{
35 int fd = open("/dev/ion", O_RDWR); 35 int fd = open("/dev/ion", O_RDWR);
36 if (fd < 0) 36 if (fd < 0)
37 ALOGE("open /dev/ion failed!\n"); 37 ALOGE("open /dev/ion failed!\n");
38 return fd; 38 return fd;
39} 39}
40 40
41int ion_close(int fd) 41int ion_close(int fd)
42{ 42{
43 return close(fd); 43 return close(fd);
44} 44}
45 45
46static int ion_ioctl(int fd, int req, void *arg) 46static int ion_ioctl(int fd, int req, void *arg)
47{ 47{
48 int ret = ioctl(fd, req, arg); 48 int ret = ioctl(fd, req, arg);
49 if (ret < 0) { 49 if (ret < 0) {
50 ALOGE("ioctl %x failed with code %d: %s\n", req, 50 ALOGE("ioctl %x failed with code %d: %s\n", req,
51 ret, strerror(errno)); 51 ret, strerror(errno));
52 return -errno; 52 return -errno;
53 } 53 }
54 return ret; 54 return ret;
55} 55}
56 56
57int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 57int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
58 unsigned int flags, ion_user_handle_t *handle) 58 unsigned int flags, ion_user_handle_t *handle)
59{ 59{
60 int ret; 60 int ret;
61 struct ion_allocation_data data = { 61 struct ion_allocation_data data = {
62 .len = len, 62 .len = len,
63 .align = align, 63 .align = align,
64 .heap_id_mask = heap_mask, 64 .heap_id_mask = heap_mask,
65 .flags = flags, 65 .flags = flags,
66 }; 66 };
67 67
68 ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); 68 ret = ion_ioctl(fd, ION_IOC_ALLOC, &data);
69 if (ret < 0) 69 if (ret < 0)
70 return ret;
71 *handle = data.handle;
72 return ret; 70 return ret;
71 *handle = data.handle;
72 return ret;
73} 73}
74 74
75int ion_free(int fd, ion_user_handle_t handle) 75int ion_free(int fd, ion_user_handle_t handle)
76{ 76{
77 struct ion_handle_data data = { 77 struct ion_handle_data data = {
78 .handle = handle, 78 .handle = handle,
79 }; 79 };
80 return ion_ioctl(fd, ION_IOC_FREE, &data); 80 return ion_ioctl(fd, ION_IOC_FREE, &data);
81} 81}
82 82
83int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 83int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
84 int flags, off_t offset, unsigned char **ptr, int *map_fd) 84 int flags, off_t offset, unsigned char **ptr, int *map_fd)
85{ 85{
86 struct ion_fd_data data = { 86 struct ion_fd_data data = {
87 .handle = handle, 87 .handle = handle,
88 }; 88 };
89 89
90 int ret = ion_ioctl(fd, ION_IOC_MAP, &data); 90 int ret = ion_ioctl(fd, ION_IOC_MAP, &data);
91 if (ret < 0) 91 if (ret < 0)
92 return ret;
93 *map_fd = data.fd;
94 if (*map_fd < 0) {
95 ALOGE("map ioctl returned negative fd\n");
96 return -EINVAL;
97 }
98 *ptr = mmap(NULL, length, prot, flags, *map_fd, offset);
99 if (*ptr == MAP_FAILED) {
100 ALOGE("mmap failed: %s\n", strerror(errno));
101 return -errno;
102 }
103 return ret; 92 return ret;
93 *map_fd = data.fd;
94 if (*map_fd < 0) {
95 ALOGE("map ioctl returned negative fd\n");
96 return -EINVAL;
97 }
98 *ptr = mmap(NULL, length, prot, flags, *map_fd, offset);
99 if (*ptr == MAP_FAILED) {
100 ALOGE("mmap failed: %s\n", strerror(errno));
101 return -errno;
102 }
103 return ret;
104} 104}
105 105
106int ion_share(int fd, ion_user_handle_t handle, int *share_fd) 106int ion_share(int fd, ion_user_handle_t handle, int *share_fd)
107{ 107{
108 int map_fd; 108 int map_fd;
109 struct ion_fd_data data = { 109 struct ion_fd_data data = {
110 .handle = handle, 110 .handle = handle,
111 }; 111 };
112 112
113 int ret = ion_ioctl(fd, ION_IOC_SHARE, &data); 113 int ret = ion_ioctl(fd, ION_IOC_SHARE, &data);
114 if (ret < 0) 114 if (ret < 0)
115 return ret;
116 *share_fd = data.fd;
117 if (*share_fd < 0) {
118 ALOGE("share ioctl returned negative fd\n");
119 return -EINVAL;
120 }
121 return ret; 115 return ret;
116 *share_fd = data.fd;
117 if (*share_fd < 0) {
118 ALOGE("share ioctl returned negative fd\n");
119 return -EINVAL;
120 }
121 return ret;
122} 122}
123 123
124int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 124int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
125 unsigned int flags, int *handle_fd) { 125 unsigned int flags, int *handle_fd) {
126 ion_user_handle_t handle; 126 ion_user_handle_t handle;
127 int ret; 127 int ret;
128 128
129 ret = ion_alloc(fd, len, align, heap_mask, flags, &handle); 129 ret = ion_alloc(fd, len, align, heap_mask, flags, &handle);
130 if (ret < 0) 130 if (ret < 0)
131 return ret; 131 return ret;
132 ret = ion_share(fd, handle, handle_fd); 132 ret = ion_share(fd, handle, handle_fd);
133 ion_free(fd, handle); 133 ion_free(fd, handle);
134 return ret; 134 return ret;
135} 135}
136 136
137int ion_import(int fd, int share_fd, ion_user_handle_t *handle) 137int ion_import(int fd, int share_fd, ion_user_handle_t *handle)
138{ 138{
139 struct ion_fd_data data = { 139 struct ion_fd_data data = {
140 .fd = share_fd, 140 .fd = share_fd,
141 }; 141 };
142 142
143 int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); 143 int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data);
144 if (ret < 0) 144 if (ret < 0)
145 return ret;
146 *handle = data.handle;
147 return ret; 145 return ret;
146 *handle = data.handle;
147 return ret;
148} 148}
149 149
150int ion_sync_fd(int fd, int handle_fd) 150int ion_sync_fd(int fd, int handle_fd)