blob: 59db407d04998e24a2e7299df5aec4f819d8078d [file] [log] [blame]
Ralf Baechlee01402b2005-07-14 15:57:16 +00001/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
Ralf Baechlea84c96e2006-01-15 18:11:28 +00003 * Copyright (C) 2005, 06 Ralf Baechle (ralf@linux-mips.org)
Ralf Baechlee01402b2005-07-14 15:57:16 +00004 *
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 */
19
Ralf Baechlebb3d7c72007-02-07 15:36:56 +000020#include <linux/device.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000021#include <linux/kernel.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000022#include <linux/fs.h>
23#include <linux/init.h>
Ralf Baechle26009902006-04-05 09:45:45 +010024#include <asm/uaccess.h>
Ralf Baechle26009902006-04-05 09:45:45 +010025#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>
30#include <linux/moduleloader.h>
Ralf Baechlea84c96e2006-01-15 18:11:28 +000031#include <linux/interrupt.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000032#include <linux/poll.h>
33#include <linux/sched.h>
34#include <linux/wait.h>
35#include <asm/mipsmtregs.h>
Ralf Baechlebb3d7c72007-02-07 15:36:56 +000036#include <asm/mips_mt.h>
Ralf Baechle26009902006-04-05 09:45:45 +010037#include <asm/cacheflush.h>
Arun Sharma600634972011-07-26 16:09:06 -070038#include <linux/atomic.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000039#include <asm/cpu.h>
40#include <asm/processor.h>
Ralf Baechle26009902006-04-05 09:45:45 +010041#include <asm/vpe.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000042#include <asm/rtlx.h>
Yoichi Yuasa406b5ee2013-05-28 01:23:22 +000043#include <asm/setup.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000044
Ralf Baechle982f6ff2009-09-17 02:25:07 +020045static int sp_stopping;
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010046struct rtlx_info *rtlx;
47struct chan_waitqueues channel_wqs[RTLX_CHANNELS];
48struct vpe_notifications rtlx_notify;
49void (*aprp_hook)(void) = NULL;
50EXPORT_SYMBOL(aprp_hook);
Ralf Baechlee01402b2005-07-14 15:57:16 +000051
David Rientjesf5dbeaf2007-07-22 01:01:39 -070052static void __used dump_rtlx(void)
Ralf Baechlee01402b2005-07-14 15:57:16 +000053{
54 int i;
55
Ralf Baechle26009902006-04-05 09:45:45 +010056 printk("id 0x%lx state %d\n", rtlx->id, rtlx->state);
57
58 for (i = 0; i < RTLX_CHANNELS; i++) {
59 struct rtlx_channel *chan = &rtlx->channel[i];
60
61 printk(" rt_state %d lx_state %d buffer_size %d\n",
62 chan->rt_state, chan->lx_state, chan->buffer_size);
63
64 printk(" rt_read %d rt_write %d\n",
65 chan->rt_read, chan->rt_write);
66
67 printk(" lx_read %d lx_write %d\n",
68 chan->lx_read, chan->lx_write);
69
70 printk(" rt_buffer <%s>\n", chan->rt_buffer);
71 printk(" lx_buffer <%s>\n", chan->lx_buffer);
72 }
73}
74
75/* call when we have the address of the shared structure from the SP side. */
76static int rtlx_init(struct rtlx_info *rtlxi)
77{
Ralf Baechlee01402b2005-07-14 15:57:16 +000078 if (rtlxi->id != RTLX_ID) {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +020079 printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n",
80 rtlxi, rtlxi->id);
Ralf Baechleafc48412005-10-31 00:30:39 +000081 return -ENOEXEC;
Ralf Baechlee01402b2005-07-14 15:57:16 +000082 }
83
Ralf Baechlee01402b2005-07-14 15:57:16 +000084 rtlx = rtlxi;
Ralf Baechleafc48412005-10-31 00:30:39 +000085
86 return 0;
Ralf Baechlee01402b2005-07-14 15:57:16 +000087}
88
Ralf Baechle26009902006-04-05 09:45:45 +010089/* notifications */
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010090void rtlx_starting(int vpe)
Ralf Baechlee01402b2005-07-14 15:57:16 +000091{
Ralf Baechle26009902006-04-05 09:45:45 +010092 int i;
93 sp_stopping = 0;
Ralf Baechlee01402b2005-07-14 15:57:16 +000094
Ralf Baechle26009902006-04-05 09:45:45 +010095 /* force a reload of rtlx */
96 rtlx=NULL;
97
98 /* wake up any sleeping rtlx_open's */
99 for (i = 0; i < RTLX_CHANNELS; i++)
100 wake_up_interruptible(&channel_wqs[i].lx_queue);
101}
102
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +0100103void rtlx_stopping(int vpe)
Ralf Baechle26009902006-04-05 09:45:45 +0100104{
105 int i;
106
107 sp_stopping = 1;
108 for (i = 0; i < RTLX_CHANNELS; i++)
109 wake_up_interruptible(&channel_wqs[i].lx_queue);
110}
111
112
113int rtlx_open(int index, int can_sleep)
114{
Ralf Baechle9e346822007-03-15 17:08:28 +0000115 struct rtlx_info **p;
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000116 struct rtlx_channel *chan;
Ralf Baechlec4c40182007-02-23 13:40:45 +0000117 enum rtlx_state state;
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000118 int ret = 0;
Ralf Baechle26009902006-04-05 09:45:45 +0100119
120 if (index >= RTLX_CHANNELS) {
121 printk(KERN_DEBUG "rtlx_open index out of range\n");
122 return -ENOSYS;
123 }
124
Ralf Baechlec4c40182007-02-23 13:40:45 +0000125 if (atomic_inc_return(&channel_wqs[index].in_open) > 1) {
126 printk(KERN_DEBUG "rtlx_open channel %d already opened\n",
127 index);
128 ret = -EBUSY;
129 goto out_fail;
Ralf Baechle26009902006-04-05 09:45:45 +0100130 }
131
Ralf Baechlee01402b2005-07-14 15:57:16 +0000132 if (rtlx == NULL) {
Ralf Baechle07cc0c92007-07-27 19:31:10 +0100133 if( (p = vpe_get_shared(tclimit)) == NULL) {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200134 if (can_sleep) {
Peter Zijlstra35a2af92013-10-02 11:22:33 +0200135 ret = __wait_event_interruptible(
136 channel_wqs[index].lx_queue,
137 (p = vpe_get_shared(tclimit)));
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200138 if (ret)
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000139 goto out_fail;
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200140 } else {
141 printk(KERN_DEBUG "No SP program loaded, and device "
142 "opened with O_NONBLOCK\n");
143 ret = -ENOSYS;
144 goto out_fail;
145 }
Ralf Baechlee01402b2005-07-14 15:57:16 +0000146 }
147
Ralf Baechle9e346822007-03-15 17:08:28 +0000148 smp_rmb();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000149 if (*p == NULL) {
Ralf Baechle26009902006-04-05 09:45:45 +0100150 if (can_sleep) {
Ralf Baechle9e346822007-03-15 17:08:28 +0000151 DEFINE_WAIT(wait);
152
153 for (;;) {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200154 prepare_to_wait(
155 &channel_wqs[index].lx_queue,
156 &wait, TASK_INTERRUPTIBLE);
Ralf Baechle9e346822007-03-15 17:08:28 +0000157 smp_rmb();
158 if (*p != NULL)
159 break;
160 if (!signal_pending(current)) {
161 schedule();
162 continue;
163 }
164 ret = -ERESTARTSYS;
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000165 goto out_fail;
Ralf Baechle9e346822007-03-15 17:08:28 +0000166 }
167 finish_wait(&channel_wqs[index].lx_queue, &wait);
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000168 } else {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200169 pr_err(" *vpe_get_shared is NULL. "
Ralf Baechle26009902006-04-05 09:45:45 +0100170 "Has an SP program been loaded?\n");
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000171 ret = -ENOSYS;
172 goto out_fail;
Ralf Baechle26009902006-04-05 09:45:45 +0100173 }
Ralf Baechlee01402b2005-07-14 15:57:16 +0000174 }
175
Ralf Baechle26009902006-04-05 09:45:45 +0100176 if ((unsigned int)*p < KSEG0) {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200177 printk(KERN_WARNING "vpe_get_shared returned an "
178 "invalid pointer maybe an error code %d\n",
179 (int)*p);
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000180 ret = -ENOSYS;
181 goto out_fail;
Ralf Baechle26009902006-04-05 09:45:45 +0100182 }
183
Ralf Baechlec4c40182007-02-23 13:40:45 +0000184 if ((ret = rtlx_init(*p)) < 0)
185 goto out_ret;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000186 }
187
Ralf Baechle26009902006-04-05 09:45:45 +0100188 chan = &rtlx->channel[index];
Ralf Baechlee01402b2005-07-14 15:57:16 +0000189
Ralf Baechlec4c40182007-02-23 13:40:45 +0000190 state = xchg(&chan->lx_state, RTLX_STATE_OPENED);
191 if (state == RTLX_STATE_OPENED) {
192 ret = -EBUSY;
193 goto out_fail;
194 }
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000195
196out_fail:
Ralf Baechlec4c40182007-02-23 13:40:45 +0000197 smp_mb();
198 atomic_dec(&channel_wqs[index].in_open);
199 smp_mb();
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000200
Ralf Baechlec4c40182007-02-23 13:40:45 +0000201out_ret:
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000202 return ret;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000203}
204
Ralf Baechle26009902006-04-05 09:45:45 +0100205int rtlx_release(int index)
Ralf Baechlee01402b2005-07-14 15:57:16 +0000206{
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200207 if (rtlx == NULL) {
208 pr_err("rtlx_release() with null rtlx\n");
209 return 0;
210 }
Ralf Baechle26009902006-04-05 09:45:45 +0100211 rtlx->channel[index].lx_state = RTLX_STATE_UNUSED;
Ralf Baechleafc48412005-10-31 00:30:39 +0000212 return 0;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000213}
214
Ralf Baechle26009902006-04-05 09:45:45 +0100215unsigned int rtlx_read_poll(int index, int can_sleep)
Ralf Baechlee01402b2005-07-14 15:57:16 +0000216{
Ralf Baechle70342282013-01-22 12:59:30 +0100217 struct rtlx_channel *chan;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000218
Ralf Baechle70342282013-01-22 12:59:30 +0100219 if (rtlx == NULL)
220 return 0;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000221
Ralf Baechle70342282013-01-22 12:59:30 +0100222 chan = &rtlx->channel[index];
Ralf Baechlee01402b2005-07-14 15:57:16 +0000223
224 /* data available to read? */
Ralf Baechle26009902006-04-05 09:45:45 +0100225 if (chan->lx_read == chan->lx_write) {
226 if (can_sleep) {
Peter Zijlstra35a2af92013-10-02 11:22:33 +0200227 int ret = __wait_event_interruptible(
228 channel_wqs[index].lx_queue,
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200229 (chan->lx_read != chan->lx_write) ||
Peter Zijlstra35a2af92013-10-02 11:22:33 +0200230 sp_stopping);
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000231 if (ret)
232 return ret;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000233
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000234 if (sp_stopping)
235 return 0;
236 } else
Ralf Baechle26009902006-04-05 09:45:45 +0100237 return 0;
238 }
239
240 return (chan->lx_write + chan->buffer_size - chan->lx_read)
241 % chan->buffer_size;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000242}
243
Ralf Baechle26009902006-04-05 09:45:45 +0100244static inline int write_spacefree(int read, int write, int size)
Ralf Baechlee01402b2005-07-14 15:57:16 +0000245{
Ralf Baechle26009902006-04-05 09:45:45 +0100246 if (read == write) {
247 /*
248 * Never fill the buffer completely, so indexes are always
249 * equal if empty and only empty, or !equal if data available
250 */
251 return size - 1;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000252 }
253
Ralf Baechle26009902006-04-05 09:45:45 +0100254 return ((read + size - write) % size) - 1;
255}
256
257unsigned int rtlx_write_poll(int index)
258{
259 struct rtlx_channel *chan = &rtlx->channel[index];
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200260
261 return write_spacefree(chan->rt_read, chan->rt_write,
262 chan->buffer_size);
Ralf Baechle26009902006-04-05 09:45:45 +0100263}
264
Ralf Baechle7f5a7712007-04-25 15:08:57 +0100265ssize_t rtlx_read(int index, void __user *buff, size_t count)
Ralf Baechle26009902006-04-05 09:45:45 +0100266{
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000267 size_t lx_write, fl = 0L;
Ralf Baechle26009902006-04-05 09:45:45 +0100268 struct rtlx_channel *lx;
Ralf Baechle46230aa2007-03-16 12:16:27 +0000269 unsigned long failed;
Ralf Baechle26009902006-04-05 09:45:45 +0100270
271 if (rtlx == NULL)
272 return -ENOSYS;
273
274 lx = &rtlx->channel[index];
275
Ralf Baechlebc4809e2007-03-15 17:13:47 +0000276 mutex_lock(&channel_wqs[index].mutex);
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000277 smp_rmb();
278 lx_write = lx->lx_write;
279
Ralf Baechlee01402b2005-07-14 15:57:16 +0000280 /* find out how much in total */
Ralf Baechleafc48412005-10-31 00:30:39 +0000281 count = min(count,
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000282 (size_t)(lx_write + lx->buffer_size - lx->lx_read)
Ralf Baechle26009902006-04-05 09:45:45 +0100283 % lx->buffer_size);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000284
285 /* then how much from the read pointer onwards */
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000286 fl = min(count, (size_t)lx->buffer_size - lx->lx_read);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000287
Ralf Baechle46230aa2007-03-16 12:16:27 +0000288 failed = copy_to_user(buff, lx->lx_buffer + lx->lx_read, fl);
289 if (failed)
290 goto out;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000291
292 /* and if there is anything left at the beginning of the buffer */
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000293 if (count - fl)
Ralf Baechle46230aa2007-03-16 12:16:27 +0000294 failed = copy_to_user(buff + fl, lx->lx_buffer, count - fl);
295
296out:
297 count -= failed;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000298
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000299 smp_wmb();
300 lx->lx_read = (lx->lx_read + count) % lx->buffer_size;
301 smp_wmb();
Ralf Baechlebc4809e2007-03-15 17:13:47 +0000302 mutex_unlock(&channel_wqs[index].mutex);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000303
Ralf Baechleafc48412005-10-31 00:30:39 +0000304 return count;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000305}
306
Ralf Baechle7f5a7712007-04-25 15:08:57 +0100307ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
Ralf Baechlee01402b2005-07-14 15:57:16 +0000308{
Ralf Baechlee01402b2005-07-14 15:57:16 +0000309 struct rtlx_channel *rt;
Ralf Baechle7f5a7712007-04-25 15:08:57 +0100310 unsigned long failed;
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000311 size_t rt_read;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000312 size_t fl;
Ralf Baechle26009902006-04-05 09:45:45 +0100313
314 if (rtlx == NULL)
315 return(-ENOSYS);
316
317 rt = &rtlx->channel[index];
318
Ralf Baechlebc4809e2007-03-15 17:13:47 +0000319 mutex_lock(&channel_wqs[index].mutex);
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000320 smp_rmb();
321 rt_read = rt->rt_read;
322
Ralf Baechle26009902006-04-05 09:45:45 +0100323 /* total number of bytes to copy */
Kevin D. Kissell1928cc82008-04-16 15:32:22 +0200324 count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
325 rt->buffer_size));
Ralf Baechle26009902006-04-05 09:45:45 +0100326
327 /* 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);
329
Ralf Baechle46230aa2007-03-16 12:16:27 +0000330 failed = copy_from_user(rt->rt_buffer + rt->rt_write, buffer, fl);
331 if (failed)
332 goto out;
Ralf Baechle26009902006-04-05 09:45:45 +0100333
334 /* if there's any left copy to the beginning of the buffer */
Ralf Baechle46230aa2007-03-16 12:16:27 +0000335 if (count - fl) {
336 failed = copy_from_user(rt->rt_buffer, buffer + fl, count - fl);
337 }
338
339out:
Ralf Baechle7f5a7712007-04-25 15:08:57 +0100340 count -= failed;
Ralf Baechle26009902006-04-05 09:45:45 +0100341
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000342 smp_wmb();
343 rt->rt_write = (rt->rt_write + count) % rt->buffer_size;
344 smp_wmb();
Ralf Baechlebc4809e2007-03-15 17:13:47 +0000345 mutex_unlock(&channel_wqs[index].mutex);
Ralf Baechle26009902006-04-05 09:45:45 +0100346
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +0100347 _interrupt_sp();
348
Ralf Baechle61dcc6f2007-03-15 17:10:16 +0000349 return count;
Ralf Baechle26009902006-04-05 09:45:45 +0100350}
351
352
353static int file_open(struct inode *inode, struct file *filp)
354{
Ralf Baechle1bbfc202009-09-29 00:52:27 +0100355 return rtlx_open(iminor(inode), (filp->f_flags & O_NONBLOCK) ? 0 : 1);
Ralf Baechle26009902006-04-05 09:45:45 +0100356}
357
358static int file_release(struct inode *inode, struct file *filp)
359{
Ralf Baechle1bbfc202009-09-29 00:52:27 +0100360 return rtlx_release(iminor(inode));
Ralf Baechle26009902006-04-05 09:45:45 +0100361}
362
363static unsigned int file_poll(struct file *file, poll_table * wait)
364{
Al Viro496ad9a2013-01-23 17:07:38 -0500365 int minor = iminor(file_inode(file));
Ralf Baechle26009902006-04-05 09:45:45 +0100366 unsigned int mask = 0;
367
Ralf Baechle26009902006-04-05 09:45:45 +0100368 poll_wait(file, &channel_wqs[minor].rt_queue, wait);
369 poll_wait(file, &channel_wqs[minor].lx_queue, wait);
370
371 if (rtlx == NULL)
372 return 0;
373
374 /* data available to read? */
375 if (rtlx_read_poll(minor, 0))
376 mask |= POLLIN | POLLRDNORM;
377
378 /* space to write */
379 if (rtlx_write_poll(minor))
380 mask |= POLLOUT | POLLWRNORM;
381
382 return mask;
383}
384
385static ssize_t file_read(struct file *file, char __user * buffer, size_t count,
386 loff_t * ppos)
387{
Al Viro496ad9a2013-01-23 17:07:38 -0500388 int minor = iminor(file_inode(file));
Ralf Baechle26009902006-04-05 09:45:45 +0100389
390 /* data available? */
391 if (!rtlx_read_poll(minor, (file->f_flags & O_NONBLOCK) ? 0 : 1)) {
392 return 0; // -EAGAIN makes cat whinge
393 }
394
Ralf Baechle46230aa2007-03-16 12:16:27 +0000395 return rtlx_read(minor, buffer, count);
Ralf Baechle26009902006-04-05 09:45:45 +0100396}
397
398static ssize_t file_write(struct file *file, const char __user * buffer,
399 size_t count, loff_t * ppos)
400{
Al Viro496ad9a2013-01-23 17:07:38 -0500401 int minor = iminor(file_inode(file));
Ralf Baechlee01402b2005-07-14 15:57:16 +0000402
403 /* any space left... */
Ralf Baechle26009902006-04-05 09:45:45 +0100404 if (!rtlx_write_poll(minor)) {
Peter Zijlstra35a2af92013-10-02 11:22:33 +0200405 int ret;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000406
407 if (file->f_flags & O_NONBLOCK)
Ralf Baechleafc48412005-10-31 00:30:39 +0000408 return -EAGAIN;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000409
Peter Zijlstra35a2af92013-10-02 11:22:33 +0200410 ret = __wait_event_interruptible(channel_wqs[minor].rt_queue,
411 rtlx_write_poll(minor));
Ralf Baechle67e2ccc2007-02-22 14:19:48 +0000412 if (ret)
413 return ret;
Ralf Baechlee01402b2005-07-14 15:57:16 +0000414 }
415
Ralf Baechle46230aa2007-03-16 12:16:27 +0000416 return rtlx_write(minor, buffer, count);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000417}
418
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +0100419const struct file_operations rtlx_fops = {
Ralf Baechle26009902006-04-05 09:45:45 +0100420 .owner = THIS_MODULE,
Ralf Baechle70342282013-01-22 12:59:30 +0100421 .open = file_open,
Ralf Baechle26009902006-04-05 09:45:45 +0100422 .release = file_release,
423 .write = file_write,
Ralf Baechle70342282013-01-22 12:59:30 +0100424 .read = file_read,
425 .poll = file_poll,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200426 .llseek = noop_llseek,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000427};
428
Ralf Baechlee01402b2005-07-14 15:57:16 +0000429module_init(rtlx_module_init);
430module_exit(rtlx_module_exit);
Ralf Baechleafc48412005-10-31 00:30:39 +0000431
Ralf Baechlee01402b2005-07-14 15:57:16 +0000432MODULE_DESCRIPTION("MIPS RTLX");
Ralf Baechle26009902006-04-05 09:45:45 +0100433MODULE_AUTHOR("Elizabeth Oldham, MIPS Technologies, Inc.");
Ralf Baechlee01402b2005-07-14 15:57:16 +0000434MODULE_LICENSE("GPL");