diff options
author | Steven J. Hill <Steven.Hill@imgtec.com> | 2014-01-01 10:35:32 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-01-22 14:19:02 -0500 |
commit | 5792bf6438658cb129c3022aa2cf7e9b19b5de3a (patch) | |
tree | 41d36b19a9d79bad816e3557a45aa920491db4c9 /arch/mips/kernel/rtlx.c | |
parent | 1336113a6c93fa345f7465e066313e5629f581d9 (diff) |
MIPS: APRP: Code formatting clean-ups.
Clean-up code according to the 'checkpatch.pl' script.
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
Patchwork: http://patchwork.linux-mips.org/patch/6097/
Reviewed-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/kernel/rtlx.c')
-rw-r--r-- | arch/mips/kernel/rtlx.c | 131 |
1 files changed, 52 insertions, 79 deletions
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c index 59db407d0499..31b1b763cb29 100644 --- a/arch/mips/kernel/rtlx.c +++ b/arch/mips/kernel/rtlx.c | |||
@@ -1,46 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
2 | * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved. | 6 | * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved. |
3 | * Copyright (C) 2005, 06 Ralf Baechle (ralf@linux-mips.org) | 7 | * Copyright (C) 2005, 06 Ralf Baechle (ralf@linux-mips.org) |
4 | * | 8 | * Copyright (C) 2013 Imagination Technologies Ltd. |
5 | * This program is free software; you can distribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License (Version 2) as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | * for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
17 | * | ||
18 | */ | 9 | */ |
19 | |||
20 | #include <linux/device.h> | ||
21 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
22 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
23 | #include <linux/init.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <linux/vmalloc.h> | ||
27 | #include <linux/elf.h> | ||
28 | #include <linux/seq_file.h> | ||
29 | #include <linux/syscalls.h> | 12 | #include <linux/syscalls.h> |
30 | #include <linux/moduleloader.h> | 13 | #include <linux/moduleloader.h> |
31 | #include <linux/interrupt.h> | 14 | #include <linux/atomic.h> |
32 | #include <linux/poll.h> | ||
33 | #include <linux/sched.h> | ||
34 | #include <linux/wait.h> | ||
35 | #include <asm/mipsmtregs.h> | 15 | #include <asm/mipsmtregs.h> |
36 | #include <asm/mips_mt.h> | 16 | #include <asm/mips_mt.h> |
37 | #include <asm/cacheflush.h> | ||
38 | #include <linux/atomic.h> | ||
39 | #include <asm/cpu.h> | ||
40 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
41 | #include <asm/vpe.h> | ||
42 | #include <asm/rtlx.h> | 18 | #include <asm/rtlx.h> |
43 | #include <asm/setup.h> | 19 | #include <asm/setup.h> |
20 | #include <asm/vpe.h> | ||
44 | 21 | ||
45 | static int sp_stopping; | 22 | static int sp_stopping; |
46 | struct rtlx_info *rtlx; | 23 | struct rtlx_info *rtlx; |
@@ -53,22 +30,22 @@ static void __used dump_rtlx(void) | |||
53 | { | 30 | { |
54 | int i; | 31 | int i; |
55 | 32 | ||
56 | printk("id 0x%lx state %d\n", rtlx->id, rtlx->state); | 33 | pr_info("id 0x%lx state %d\n", rtlx->id, rtlx->state); |
57 | 34 | ||
58 | for (i = 0; i < RTLX_CHANNELS; i++) { | 35 | for (i = 0; i < RTLX_CHANNELS; i++) { |
59 | struct rtlx_channel *chan = &rtlx->channel[i]; | 36 | struct rtlx_channel *chan = &rtlx->channel[i]; |
60 | 37 | ||
61 | printk(" rt_state %d lx_state %d buffer_size %d\n", | 38 | pr_info(" rt_state %d lx_state %d buffer_size %d\n", |
62 | chan->rt_state, chan->lx_state, chan->buffer_size); | 39 | chan->rt_state, chan->lx_state, chan->buffer_size); |
63 | 40 | ||
64 | printk(" rt_read %d rt_write %d\n", | 41 | pr_info(" rt_read %d rt_write %d\n", |
65 | chan->rt_read, chan->rt_write); | 42 | chan->rt_read, chan->rt_write); |
66 | 43 | ||
67 | printk(" lx_read %d lx_write %d\n", | 44 | pr_info(" lx_read %d lx_write %d\n", |
68 | chan->lx_read, chan->lx_write); | 45 | chan->lx_read, chan->lx_write); |
69 | 46 | ||
70 | printk(" rt_buffer <%s>\n", chan->rt_buffer); | 47 | pr_info(" rt_buffer <%s>\n", chan->rt_buffer); |
71 | printk(" lx_buffer <%s>\n", chan->lx_buffer); | 48 | pr_info(" lx_buffer <%s>\n", chan->lx_buffer); |
72 | } | 49 | } |
73 | } | 50 | } |
74 | 51 | ||
@@ -76,8 +53,7 @@ static void __used dump_rtlx(void) | |||
76 | static int rtlx_init(struct rtlx_info *rtlxi) | 53 | static int rtlx_init(struct rtlx_info *rtlxi) |
77 | { | 54 | { |
78 | if (rtlxi->id != RTLX_ID) { | 55 | if (rtlxi->id != RTLX_ID) { |
79 | printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n", | 56 | pr_err("no valid RTLX id at 0x%p 0x%lx\n", rtlxi, rtlxi->id); |
80 | rtlxi, rtlxi->id); | ||
81 | return -ENOEXEC; | 57 | return -ENOEXEC; |
82 | } | 58 | } |
83 | 59 | ||
@@ -93,7 +69,7 @@ void rtlx_starting(int vpe) | |||
93 | sp_stopping = 0; | 69 | sp_stopping = 0; |
94 | 70 | ||
95 | /* force a reload of rtlx */ | 71 | /* force a reload of rtlx */ |
96 | rtlx=NULL; | 72 | rtlx = NULL; |
97 | 73 | ||
98 | /* wake up any sleeping rtlx_open's */ | 74 | /* wake up any sleeping rtlx_open's */ |
99 | for (i = 0; i < RTLX_CHANNELS; i++) | 75 | for (i = 0; i < RTLX_CHANNELS; i++) |
@@ -118,31 +94,30 @@ int rtlx_open(int index, int can_sleep) | |||
118 | int ret = 0; | 94 | int ret = 0; |
119 | 95 | ||
120 | if (index >= RTLX_CHANNELS) { | 96 | if (index >= RTLX_CHANNELS) { |
121 | printk(KERN_DEBUG "rtlx_open index out of range\n"); | 97 | pr_debug(KERN_DEBUG "rtlx_open index out of range\n"); |
122 | return -ENOSYS; | 98 | return -ENOSYS; |
123 | } | 99 | } |
124 | 100 | ||
125 | if (atomic_inc_return(&channel_wqs[index].in_open) > 1) { | 101 | if (atomic_inc_return(&channel_wqs[index].in_open) > 1) { |
126 | printk(KERN_DEBUG "rtlx_open channel %d already opened\n", | 102 | pr_debug(KERN_DEBUG "rtlx_open channel %d already opened\n", index); |
127 | index); | ||
128 | ret = -EBUSY; | 103 | ret = -EBUSY; |
129 | goto out_fail; | 104 | goto out_fail; |
130 | } | 105 | } |
131 | 106 | ||
132 | if (rtlx == NULL) { | 107 | if (rtlx == NULL) { |
133 | if( (p = vpe_get_shared(tclimit)) == NULL) { | 108 | p = vpe_get_shared(aprp_cpu_index()); |
134 | if (can_sleep) { | 109 | if (p == NULL) { |
135 | ret = __wait_event_interruptible( | 110 | if (can_sleep) { |
111 | ret = __wait_event_interruptible( | ||
136 | channel_wqs[index].lx_queue, | 112 | channel_wqs[index].lx_queue, |
137 | (p = vpe_get_shared(tclimit))); | 113 | (p = vpe_get_shared(aprp_cpu_index()))); |
138 | if (ret) | 114 | if (ret) |
115 | goto out_fail; | ||
116 | } else { | ||
117 | pr_debug("No SP program loaded, and device opened with O_NONBLOCK\n"); | ||
118 | ret = -ENOSYS; | ||
139 | goto out_fail; | 119 | goto out_fail; |
140 | } else { | 120 | } |
141 | printk(KERN_DEBUG "No SP program loaded, and device " | ||
142 | "opened with O_NONBLOCK\n"); | ||
143 | ret = -ENOSYS; | ||
144 | goto out_fail; | ||
145 | } | ||
146 | } | 121 | } |
147 | 122 | ||
148 | smp_rmb(); | 123 | smp_rmb(); |
@@ -164,24 +139,24 @@ int rtlx_open(int index, int can_sleep) | |||
164 | ret = -ERESTARTSYS; | 139 | ret = -ERESTARTSYS; |
165 | goto out_fail; | 140 | goto out_fail; |
166 | } | 141 | } |
167 | finish_wait(&channel_wqs[index].lx_queue, &wait); | 142 | finish_wait(&channel_wqs[index].lx_queue, |
143 | &wait); | ||
168 | } else { | 144 | } else { |
169 | pr_err(" *vpe_get_shared is NULL. " | 145 | pr_err(" *vpe_get_shared is NULL. Has an SP program been loaded?\n"); |
170 | "Has an SP program been loaded?\n"); | ||
171 | ret = -ENOSYS; | 146 | ret = -ENOSYS; |
172 | goto out_fail; | 147 | goto out_fail; |
173 | } | 148 | } |
174 | } | 149 | } |
175 | 150 | ||
176 | if ((unsigned int)*p < KSEG0) { | 151 | if ((unsigned int)*p < KSEG0) { |
177 | printk(KERN_WARNING "vpe_get_shared returned an " | 152 | pr_warn("vpe_get_shared returned an invalid pointer maybe an error code %d\n", |
178 | "invalid pointer maybe an error code %d\n", | 153 | (int)*p); |
179 | (int)*p); | ||
180 | ret = -ENOSYS; | 154 | ret = -ENOSYS; |
181 | goto out_fail; | 155 | goto out_fail; |
182 | } | 156 | } |
183 | 157 | ||
184 | if ((ret = rtlx_init(*p)) < 0) | 158 | ret = rtlx_init(*p); |
159 | if (ret < 0) | ||
185 | goto out_ret; | 160 | goto out_ret; |
186 | } | 161 | } |
187 | 162 | ||
@@ -312,7 +287,7 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count) | |||
312 | size_t fl; | 287 | size_t fl; |
313 | 288 | ||
314 | if (rtlx == NULL) | 289 | if (rtlx == NULL) |
315 | return(-ENOSYS); | 290 | return -ENOSYS; |
316 | 291 | ||
317 | rt = &rtlx->channel[index]; | 292 | rt = &rtlx->channel[index]; |
318 | 293 | ||
@@ -321,8 +296,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count) | |||
321 | rt_read = rt->rt_read; | 296 | rt_read = rt->rt_read; |
322 | 297 | ||
323 | /* total number of bytes to copy */ | 298 | /* total number of bytes to copy */ |
324 | count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write, | 299 | count = min_t(size_t, count, write_spacefree(rt_read, rt->rt_write, |
325 | rt->buffer_size)); | 300 | rt->buffer_size)); |
326 | 301 | ||
327 | /* first bit from write pointer to the end of the buffer, or count */ | 302 | /* first bit from write pointer to the end of the buffer, or count */ |
328 | fl = min(count, (size_t) rt->buffer_size - rt->rt_write); | 303 | fl = min(count, (size_t) rt->buffer_size - rt->rt_write); |
@@ -332,9 +307,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count) | |||
332 | goto out; | 307 | goto out; |
333 | 308 | ||
334 | /* if there's any left copy to the beginning of the buffer */ | 309 | /* if there's any left copy to the beginning of the buffer */ |
335 | if (count - fl) { | 310 | if (count - fl) |
336 | failed = copy_from_user(rt->rt_buffer, buffer + fl, count - fl); | 311 | failed = copy_from_user(rt->rt_buffer, buffer + fl, count - fl); |
337 | } | ||
338 | 312 | ||
339 | out: | 313 | out: |
340 | count -= failed; | 314 | count -= failed; |
@@ -360,7 +334,7 @@ static int file_release(struct inode *inode, struct file *filp) | |||
360 | return rtlx_release(iminor(inode)); | 334 | return rtlx_release(iminor(inode)); |
361 | } | 335 | } |
362 | 336 | ||
363 | static unsigned int file_poll(struct file *file, poll_table * wait) | 337 | static unsigned int file_poll(struct file *file, poll_table *wait) |
364 | { | 338 | { |
365 | int minor = iminor(file_inode(file)); | 339 | int minor = iminor(file_inode(file)); |
366 | unsigned int mask = 0; | 340 | unsigned int mask = 0; |
@@ -382,21 +356,20 @@ static unsigned int file_poll(struct file *file, poll_table * wait) | |||
382 | return mask; | 356 | return mask; |
383 | } | 357 | } |
384 | 358 | ||
385 | static ssize_t file_read(struct file *file, char __user * buffer, size_t count, | 359 | static ssize_t file_read(struct file *file, char __user *buffer, size_t count, |
386 | loff_t * ppos) | 360 | loff_t *ppos) |
387 | { | 361 | { |
388 | int minor = iminor(file_inode(file)); | 362 | int minor = iminor(file_inode(file)); |
389 | 363 | ||
390 | /* data available? */ | 364 | /* data available? */ |
391 | if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) { | 365 | if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) |
392 | return 0; // -EAGAIN makes cat whinge | 366 | return 0; /* -EAGAIN makes 'cat' whine */ |
393 | } | ||
394 | 367 | ||
395 | return rtlx_read(minor, buffer, count); | 368 | return rtlx_read(minor, buffer, count); |
396 | } | 369 | } |
397 | 370 | ||
398 | static ssize_t file_write(struct file *file, const char __user * buffer, | 371 | static ssize_t file_write(struct file *file, const char __user *buffer, |
399 | size_t count, loff_t * ppos) | 372 | size_t count, loff_t *ppos) |
400 | { | 373 | { |
401 | int minor = iminor(file_inode(file)); | 374 | int minor = iminor(file_inode(file)); |
402 | 375 | ||
@@ -418,11 +391,11 @@ static ssize_t file_write(struct file *file, const char __user * buffer, | |||
418 | 391 | ||
419 | const struct file_operations rtlx_fops = { | 392 | const struct file_operations rtlx_fops = { |
420 | .owner = THIS_MODULE, | 393 | .owner = THIS_MODULE, |
421 | .open = file_open, | 394 | .open = file_open, |
422 | .release = file_release, | 395 | .release = file_release, |
423 | .write = file_write, | 396 | .write = file_write, |
424 | .read = file_read, | 397 | .read = file_read, |
425 | .poll = file_poll, | 398 | .poll = file_poll, |
426 | .llseek = noop_llseek, | 399 | .llseek = noop_llseek, |
427 | }; | 400 | }; |
428 | 401 | ||