2 * Line6 Linux USB driver - 0.9.1beta
4 * Copyright (C) 2004-2010 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.
12 #include <linux/slab.h>
15 #include "dumprequest.h"
18 Set "dump in progress" flag.
20 void line6_dump_started(struct line6_dump_request
*l6dr
, int dest
)
22 l6dr
->in_progress
= dest
;
26 Invalidate current channel, i.e., set "dump in progress" flag.
27 Reading from the "dump" special file blocks until dump is completed.
29 void line6_invalidate_current(struct line6_dump_request
*l6dr
)
31 line6_dump_started(l6dr
, LINE6_DUMP_CURRENT
);
35 Clear "dump in progress" flag and notify waiting processes.
37 void line6_dump_finished(struct line6_dump_request
*l6dr
)
39 l6dr
->in_progress
= LINE6_DUMP_NONE
;
44 Send an asynchronous channel dump request.
46 int line6_dump_request_async(struct line6_dump_request
*l6dr
,
47 struct usb_line6
*line6
, int num
, int dest
)
50 line6_dump_started(l6dr
, dest
);
51 ret
= line6_send_raw_message_async(line6
, l6dr
->reqbufs
[num
].buffer
,
52 l6dr
->reqbufs
[num
].length
);
55 line6_dump_finished(l6dr
);
61 Wait for completion (interruptible).
63 int line6_dump_wait_interruptible(struct line6_dump_request
*l6dr
)
65 return wait_event_interruptible(l6dr
->wait
,
66 l6dr
->in_progress
== LINE6_DUMP_NONE
);
72 void line6_dump_wait(struct line6_dump_request
*l6dr
)
74 wait_event(l6dr
->wait
, l6dr
->in_progress
== LINE6_DUMP_NONE
);
78 Wait for completion (with timeout).
80 int line6_dump_wait_timeout(struct line6_dump_request
*l6dr
, long timeout
)
82 return wait_event_timeout(l6dr
->wait
,
83 l6dr
->in_progress
== LINE6_DUMP_NONE
,
88 Initialize dump request buffer.
90 int line6_dumpreq_initbuf(struct line6_dump_request
*l6dr
, const void *buf
,
93 l6dr
->reqbufs
[num
].buffer
= kmemdup(buf
, len
, GFP_KERNEL
);
94 if (l6dr
->reqbufs
[num
].buffer
== NULL
)
96 l6dr
->reqbufs
[num
].length
= len
;
101 Initialize dump request data structure (including one buffer).
103 int line6_dumpreq_init(struct line6_dump_request
*l6dr
, const void *buf
,
107 ret
= line6_dumpreq_initbuf(l6dr
, buf
, len
, 0);
110 init_waitqueue_head(&l6dr
->wait
);
115 Destruct dump request data structure.
117 void line6_dumpreq_destructbuf(struct line6_dump_request
*l6dr
, int num
)
121 if (l6dr
->reqbufs
[num
].buffer
== NULL
)
123 kfree(l6dr
->reqbufs
[num
].buffer
);
124 l6dr
->reqbufs
[num
].buffer
= NULL
;
128 Destruct dump request data structure.
130 void line6_dumpreq_destruct(struct line6_dump_request
*l6dr
)
132 if (l6dr
->reqbufs
[0].buffer
== NULL
)
134 line6_dumpreq_destructbuf(l6dr
, 0);