aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/gmidi.c80
1 files changed, 32 insertions, 48 deletions
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 1c5aa49d7432..d2475755a206 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -18,17 +18,11 @@
18 * http://www.usb.org/developers/devclass_docs/midi10.pdf 18 * http://www.usb.org/developers/devclass_docs/midi10.pdf
19 */ 19 */
20 20
21#define DEBUG 1 21/* #define VERBOSE_DEBUG */
22// #define VERBOSE
23 22
24#include <linux/module.h>
25#include <linux/kernel.h> 23#include <linux/kernel.h>
26#include <linux/delay.h>
27#include <linux/errno.h>
28#include <linux/init.h>
29#include <linux/utsname.h> 24#include <linux/utsname.h>
30#include <linux/device.h> 25#include <linux/device.h>
31#include <linux/moduleparam.h>
32 26
33#include <sound/driver.h> 27#include <sound/driver.h>
34#include <sound/core.h> 28#include <sound/core.h>
@@ -139,30 +133,16 @@ struct gmidi_device {
139static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req); 133static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req);
140 134
141 135
142#define xprintk(d,level,fmt,args...) \ 136#define DBG(d, fmt, args...) \
143 dev_printk(level , &(d)->gadget->dev , fmt , ## args) 137 dev_dbg(&(d)->gadget->dev , fmt , ## args)
144 138#define VDBG(d, fmt, args...) \
145#ifdef DEBUG 139 dev_vdbg(&(d)->gadget->dev , fmt , ## args)
146#define DBG(dev,fmt,args...) \ 140#define ERROR(d, fmt, args...) \
147 xprintk(dev , KERN_DEBUG , fmt , ## args) 141 dev_err(&(d)->gadget->dev , fmt , ## args)
148#else 142#define WARN(d, fmt, args...) \
149#define DBG(dev,fmt,args...) \ 143 dev_warn(&(d)->gadget->dev , fmt , ## args)
150 do { } while (0) 144#define INFO(d, fmt, args...) \
151#endif /* DEBUG */ 145 dev_info(&(d)->gadget->dev , fmt , ## args)
152
153#ifdef VERBOSE
154#define VDBG DBG
155#else
156#define VDBG(dev,fmt,args...) \
157 do { } while (0)
158#endif /* VERBOSE */
159
160#define ERROR(dev,fmt,args...) \
161 xprintk(dev , KERN_ERR , fmt , ## args)
162#define WARN(dev,fmt,args...) \
163 xprintk(dev , KERN_WARNING , fmt , ## args)
164#define INFO(dev,fmt,args...) \
165 xprintk(dev , KERN_INFO , fmt , ## args)
166 146
167 147
168static unsigned buflen = 256; 148static unsigned buflen = 256;
@@ -425,7 +405,7 @@ static int config_buf(struct usb_gadget *gadget,
425 return len; 405 return len;
426} 406}
427 407
428static struct usb_request* alloc_ep_req(struct usb_ep *ep, unsigned length) 408static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length)
429{ 409{
430 struct usb_request *req; 410 struct usb_request *req;
431 411
@@ -455,7 +435,7 @@ static const uint8_t gmidi_cin_length[] = {
455 * Receives a chunk of MIDI data. 435 * Receives a chunk of MIDI data.
456 */ 436 */
457static void gmidi_read_data(struct usb_ep *ep, int cable, 437static void gmidi_read_data(struct usb_ep *ep, int cable,
458 uint8_t* data, int length) 438 uint8_t *data, int length)
459{ 439{
460 struct gmidi_device *dev = ep->driver_data; 440 struct gmidi_device *dev = ep->driver_data;
461 /* cable is ignored, because for now we only have one. */ 441 /* cable is ignored, because for now we only have one. */
@@ -541,7 +521,7 @@ static int set_gmidi_config(struct gmidi_device *dev, gfp_t gfp_flags)
541{ 521{
542 int err = 0; 522 int err = 0;
543 struct usb_request *req; 523 struct usb_request *req;
544 struct usb_ep* ep; 524 struct usb_ep *ep;
545 unsigned i; 525 unsigned i;
546 526
547 err = usb_ep_enable(dev->in_ep, &bulk_in_desc); 527 err = usb_ep_enable(dev->in_ep, &bulk_in_desc);
@@ -628,7 +608,7 @@ gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags)
628 608
629 if (gadget_is_sa1100(gadget) && dev->config) { 609 if (gadget_is_sa1100(gadget) && dev->config) {
630 /* tx fifo is full, but we can't clear it...*/ 610 /* tx fifo is full, but we can't clear it...*/
631 INFO(dev, "can't change configurations\n"); 611 ERROR(dev, "can't change configurations\n");
632 return -ESPIPE; 612 return -ESPIPE;
633 } 613 }
634 gmidi_reset_config(dev); 614 gmidi_reset_config(dev);
@@ -843,7 +823,7 @@ static void gmidi_disconnect(struct usb_gadget *gadget)
843static void /* __init_or_exit */ gmidi_unbind(struct usb_gadget *gadget) 823static void /* __init_or_exit */ gmidi_unbind(struct usb_gadget *gadget)
844{ 824{
845 struct gmidi_device *dev = get_gadget_data(gadget); 825 struct gmidi_device *dev = get_gadget_data(gadget);
846 struct snd_card* card; 826 struct snd_card *card;
847 827
848 DBG(dev, "unbind\n"); 828 DBG(dev, "unbind\n");
849 829
@@ -867,12 +847,12 @@ static int gmidi_snd_free(struct snd_device *device)
867 return 0; 847 return 0;
868} 848}
869 849
870static void gmidi_transmit_packet(struct usb_request* req, uint8_t p0, 850static void gmidi_transmit_packet(struct usb_request *req, uint8_t p0,
871 uint8_t p1, uint8_t p2, uint8_t p3) 851 uint8_t p1, uint8_t p2, uint8_t p3)
872{ 852{
873 unsigned length = req->length; 853 unsigned length = req->length;
854 u8 *buf = (u8 *)req->buf + length;
874 855
875 uint8_t* buf = (uint8_t*)req->buf + length;
876 buf[0] = p0; 856 buf[0] = p0;
877 buf[1] = p1; 857 buf[1] = p1;
878 buf[2] = p2; 858 buf[2] = p2;
@@ -883,8 +863,8 @@ static void gmidi_transmit_packet(struct usb_request* req, uint8_t p0,
883/* 863/*
884 * Converts MIDI commands to USB MIDI packets. 864 * Converts MIDI commands to USB MIDI packets.
885 */ 865 */
886static void gmidi_transmit_byte(struct usb_request* req, 866static void gmidi_transmit_byte(struct usb_request *req,
887 struct gmidi_in_port* port, uint8_t b) 867 struct gmidi_in_port *port, uint8_t b)
888{ 868{
889 uint8_t p0 = port->cable; 869 uint8_t p0 = port->cable;
890 870
@@ -981,10 +961,10 @@ static void gmidi_transmit_byte(struct usb_request* req,
981 } 961 }
982} 962}
983 963
984static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req) 964static void gmidi_transmit(struct gmidi_device *dev, struct usb_request *req)
985{ 965{
986 struct usb_ep* ep = dev->in_ep; 966 struct usb_ep *ep = dev->in_ep;
987 struct gmidi_in_port* port = &dev->in_port; 967 struct gmidi_in_port *port = &dev->in_port;
988 968
989 if (!ep) { 969 if (!ep) {
990 return; 970 return;
@@ -1020,14 +1000,14 @@ static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req)
1020 1000
1021static void gmidi_in_tasklet(unsigned long data) 1001static void gmidi_in_tasklet(unsigned long data)
1022{ 1002{
1023 struct gmidi_device* dev = (struct gmidi_device*)data; 1003 struct gmidi_device *dev = (struct gmidi_device *)data;
1024 1004
1025 gmidi_transmit(dev, NULL); 1005 gmidi_transmit(dev, NULL);
1026} 1006}
1027 1007
1028static int gmidi_in_open(struct snd_rawmidi_substream *substream) 1008static int gmidi_in_open(struct snd_rawmidi_substream *substream)
1029{ 1009{
1030 struct gmidi_device* dev = substream->rmidi->private_data; 1010 struct gmidi_device *dev = substream->rmidi->private_data;
1031 1011
1032 VDBG(dev, "gmidi_in_open\n"); 1012 VDBG(dev, "gmidi_in_open\n");
1033 dev->in_substream = substream; 1013 dev->in_substream = substream;
@@ -1037,13 +1017,15 @@ static int gmidi_in_open(struct snd_rawmidi_substream *substream)
1037 1017
1038static int gmidi_in_close(struct snd_rawmidi_substream *substream) 1018static int gmidi_in_close(struct snd_rawmidi_substream *substream)
1039{ 1019{
1020 struct gmidi_device *dev = substream->rmidi->private_data;
1021
1040 VDBG(dev, "gmidi_in_close\n"); 1022 VDBG(dev, "gmidi_in_close\n");
1041 return 0; 1023 return 0;
1042} 1024}
1043 1025
1044static void gmidi_in_trigger(struct snd_rawmidi_substream *substream, int up) 1026static void gmidi_in_trigger(struct snd_rawmidi_substream *substream, int up)
1045{ 1027{
1046 struct gmidi_device* dev = substream->rmidi->private_data; 1028 struct gmidi_device *dev = substream->rmidi->private_data;
1047 1029
1048 VDBG(dev, "gmidi_in_trigger %d\n", up); 1030 VDBG(dev, "gmidi_in_trigger %d\n", up);
1049 dev->in_port.active = up; 1031 dev->in_port.active = up;
@@ -1054,7 +1036,7 @@ static void gmidi_in_trigger(struct snd_rawmidi_substream *substream, int up)
1054 1036
1055static int gmidi_out_open(struct snd_rawmidi_substream *substream) 1037static int gmidi_out_open(struct snd_rawmidi_substream *substream)
1056{ 1038{
1057 struct gmidi_device* dev = substream->rmidi->private_data; 1039 struct gmidi_device *dev = substream->rmidi->private_data;
1058 1040
1059 VDBG(dev, "gmidi_out_open\n"); 1041 VDBG(dev, "gmidi_out_open\n");
1060 dev->out_substream = substream; 1042 dev->out_substream = substream;
@@ -1063,13 +1045,15 @@ static int gmidi_out_open(struct snd_rawmidi_substream *substream)
1063 1045
1064static int gmidi_out_close(struct snd_rawmidi_substream *substream) 1046static int gmidi_out_close(struct snd_rawmidi_substream *substream)
1065{ 1047{
1048 struct gmidi_device *dev = substream->rmidi->private_data;
1049
1066 VDBG(dev, "gmidi_out_close\n"); 1050 VDBG(dev, "gmidi_out_close\n");
1067 return 0; 1051 return 0;
1068} 1052}
1069 1053
1070static void gmidi_out_trigger(struct snd_rawmidi_substream *substream, int up) 1054static void gmidi_out_trigger(struct snd_rawmidi_substream *substream, int up)
1071{ 1055{
1072 struct gmidi_device* dev = substream->rmidi->private_data; 1056 struct gmidi_device *dev = substream->rmidi->private_data;
1073 1057
1074 VDBG(dev, "gmidi_out_trigger %d\n", up); 1058 VDBG(dev, "gmidi_out_trigger %d\n", up);
1075 if (up) { 1059 if (up) {