2 * Line6 Linux USB driver - 0.8.0
4 * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
13 #include "dumprequest.h"
17 Set "dump in progress" flag.
19 void line6_dump_started(struct line6_dump_request
*l6dr
, int dest
)
21 l6dr
->in_progress
= dest
;
25 Invalidate current channel, i.e., set "dump in progress" flag.
26 Reading from the "dump" special file blocks until dump is completed.
28 void line6_invalidate_current(struct line6_dump_request
*l6dr
)
30 line6_dump_started(l6dr
, LINE6_DUMP_CURRENT
);
34 Clear "dump in progress" flag and notify waiting processes.
36 void line6_dump_finished(struct line6_dump_request
*l6dr
)
38 l6dr
->in_progress
= LINE6_DUMP_NONE
;
39 wake_up_interruptible(&l6dr
->wait
);
43 Send an asynchronous channel dump request.
45 int line6_dump_request_async(struct line6_dump_request
*l6dr
,
46 struct usb_line6
*line6
, int num
)
49 line6_invalidate_current(l6dr
);
50 ret
= line6_send_raw_message_async(line6
, l6dr
->reqbufs
[num
].buffer
,
51 l6dr
->reqbufs
[num
].length
);
54 line6_dump_finished(l6dr
);
60 Send an asynchronous dump request after a given interval.
62 void line6_startup_delayed(struct line6_dump_request
*l6dr
, int seconds
,
63 void (*function
)(unsigned long), void *data
)
65 l6dr
->timer
.expires
= jiffies
+ seconds
* HZ
;
66 l6dr
->timer
.function
= function
;
67 l6dr
->timer
.data
= (unsigned long)data
;
68 add_timer(&l6dr
->timer
);
74 int line6_wait_dump(struct line6_dump_request
*l6dr
, int nonblock
)
77 DECLARE_WAITQUEUE(wait
, current
);
78 add_wait_queue(&l6dr
->wait
, &wait
);
79 current
->state
= TASK_INTERRUPTIBLE
;
81 while (l6dr
->in_progress
) {
87 if (signal_pending(current
)) {
88 retval
= -ERESTARTSYS
;
94 current
->state
= TASK_RUNNING
;
95 remove_wait_queue(&l6dr
->wait
, &wait
);
100 Initialize dump request buffer.
102 int line6_dumpreq_initbuf(struct line6_dump_request
*l6dr
, const void *buf
,
105 l6dr
->reqbufs
[num
].buffer
= kmalloc(len
, GFP_KERNEL
);
106 if (l6dr
->reqbufs
[num
].buffer
== NULL
)
108 memcpy(l6dr
->reqbufs
[num
].buffer
, buf
, len
);
109 l6dr
->reqbufs
[num
].length
= len
;
114 Initialize dump request data structure (including one buffer).
116 int line6_dumpreq_init(struct line6_dump_request
*l6dr
, const void *buf
,
120 ret
= line6_dumpreq_initbuf(l6dr
, buf
, len
, 0);
123 init_waitqueue_head(&l6dr
->wait
);
124 init_timer(&l6dr
->timer
);
129 Destruct dump request data structure.
131 void line6_dumpreq_destructbuf(struct line6_dump_request
*l6dr
, int num
)
135 if (l6dr
->reqbufs
[num
].buffer
== NULL
)
137 kfree(l6dr
->reqbufs
[num
].buffer
);
138 l6dr
->reqbufs
[num
].buffer
= NULL
;
142 Destruct dump request data structure.
144 void line6_dumpreq_destruct(struct line6_dump_request
*l6dr
)
146 if (l6dr
->reqbufs
[0].buffer
== NULL
)
148 line6_dumpreq_destructbuf(l6dr
, 0);
150 del_timer_sync(&l6dr
->timer
);