aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/midi.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-02-26 07:02:17 -0500
committerTakashi Iwai <tiwai@suse.de>2014-02-26 10:45:34 -0500
commit0ba41d917eeb87f608cf147f870ff2f4c1056bab (patch)
treee848ad3bb355ec92150b7f22eab66e88d7eee34b /sound/usb/midi.c
parent6436bcf6a4a35ae83af9ff3c250435e5fd001205 (diff)
ALSA: usb-audio: Use standard printk helpers
Convert with dev_err() and co from snd_printk(), etc. As there are too deep indirections (e.g. ep->chip->dev->dev), a few new local macros, usb_audio_err() & co, are introduced. Also, the device numbers in some messages are dropped, as they are shown in the prefix automatically. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/midi.c')
-rw-r--r--sound/usb/midi.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index b901f468b67a..9da74d2e8eee 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -191,16 +191,16 @@ static int snd_usbmidi_submit_urb(struct urb* urb, gfp_t flags)
191{ 191{
192 int err = usb_submit_urb(urb, flags); 192 int err = usb_submit_urb(urb, flags);
193 if (err < 0 && err != -ENODEV) 193 if (err < 0 && err != -ENODEV)
194 snd_printk(KERN_ERR "usb_submit_urb: %d\n", err); 194 dev_err(&urb->dev->dev, "usb_submit_urb: %d\n", err);
195 return err; 195 return err;
196} 196}
197 197
198/* 198/*
199 * Error handling for URB completion functions. 199 * Error handling for URB completion functions.
200 */ 200 */
201static int snd_usbmidi_urb_error(int status) 201static int snd_usbmidi_urb_error(const struct urb *urb)
202{ 202{
203 switch (status) { 203 switch (urb->status) {
204 /* manually unlinked, or device gone */ 204 /* manually unlinked, or device gone */
205 case -ENOENT: 205 case -ENOENT:
206 case -ECONNRESET: 206 case -ECONNRESET:
@@ -213,7 +213,7 @@ static int snd_usbmidi_urb_error(int status)
213 case -EILSEQ: 213 case -EILSEQ:
214 return -EIO; 214 return -EIO;
215 default: 215 default:
216 snd_printk(KERN_ERR "urb status %d\n", status); 216 dev_err(&urb->dev->dev, "urb status %d\n", urb->status);
217 return 0; /* continue */ 217 return 0; /* continue */
218 } 218 }
219} 219}
@@ -227,7 +227,7 @@ static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint* ep, int port
227 struct usbmidi_in_port* port = &ep->ports[portidx]; 227 struct usbmidi_in_port* port = &ep->ports[portidx];
228 228
229 if (!port->substream) { 229 if (!port->substream) {
230 snd_printd("unexpected port %d!\n", portidx); 230 dev_dbg(&ep->umidi->dev->dev, "unexpected port %d!\n", portidx);
231 return; 231 return;
232 } 232 }
233 if (!test_bit(port->substream->number, &ep->umidi->input_triggered)) 233 if (!test_bit(port->substream->number, &ep->umidi->input_triggered))
@@ -259,7 +259,7 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb)
259 ep->umidi->usb_protocol_ops->input(ep, urb->transfer_buffer, 259 ep->umidi->usb_protocol_ops->input(ep, urb->transfer_buffer,
260 urb->actual_length); 260 urb->actual_length);
261 } else { 261 } else {
262 int err = snd_usbmidi_urb_error(urb->status); 262 int err = snd_usbmidi_urb_error(urb);
263 if (err < 0) { 263 if (err < 0) {
264 if (err != -ENODEV) { 264 if (err != -ENODEV) {
265 ep->error_resubmit = 1; 265 ep->error_resubmit = 1;
@@ -289,7 +289,7 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb)
289 } 289 }
290 spin_unlock(&ep->buffer_lock); 290 spin_unlock(&ep->buffer_lock);
291 if (urb->status < 0) { 291 if (urb->status < 0) {
292 int err = snd_usbmidi_urb_error(urb->status); 292 int err = snd_usbmidi_urb_error(urb);
293 if (err < 0) { 293 if (err < 0) {
294 if (err != -ENODEV) 294 if (err != -ENODEV)
295 mod_timer(&ep->umidi->error_timer, 295 mod_timer(&ep->umidi->error_timer,
@@ -1668,7 +1668,7 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi,
1668 1668
1669 struct snd_rawmidi_substream *substream = snd_usbmidi_find_substream(umidi, stream, number); 1669 struct snd_rawmidi_substream *substream = snd_usbmidi_find_substream(umidi, stream, number);
1670 if (!substream) { 1670 if (!substream) {
1671 snd_printd(KERN_ERR "substream %d:%d not found\n", stream, number); 1671 dev_err(&umidi->dev->dev, "substream %d:%d not found\n", stream, number);
1672 return; 1672 return;
1673 } 1673 }
1674 1674
@@ -1717,7 +1717,7 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi,
1717 } 1717 }
1718 } 1718 }
1719 } 1719 }
1720 snd_printdd(KERN_INFO "created %d output and %d input ports\n", 1720 dev_dbg(&umidi->dev->dev, "created %d output and %d input ports\n",
1721 out_ports, in_ports); 1721 out_ports, in_ports);
1722 return 0; 1722 return 0;
1723} 1723}
@@ -1747,10 +1747,11 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1747 ms_header->bLength >= 7 && 1747 ms_header->bLength >= 7 &&
1748 ms_header->bDescriptorType == USB_DT_CS_INTERFACE && 1748 ms_header->bDescriptorType == USB_DT_CS_INTERFACE &&
1749 ms_header->bDescriptorSubtype == UAC_HEADER) 1749 ms_header->bDescriptorSubtype == UAC_HEADER)
1750 snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n", 1750 dev_dbg(&umidi->dev->dev, "MIDIStreaming version %02x.%02x\n",
1751 ms_header->bcdMSC[1], ms_header->bcdMSC[0]); 1751 ms_header->bcdMSC[1], ms_header->bcdMSC[0]);
1752 else 1752 else
1753 snd_printk(KERN_WARNING "MIDIStreaming interface descriptor not found\n"); 1753 dev_warn(&umidi->dev->dev,
1754 "MIDIStreaming interface descriptor not found\n");
1754 1755
1755 epidx = 0; 1756 epidx = 0;
1756 for (i = 0; i < intfd->bNumEndpoints; ++i) { 1757 for (i = 0; i < intfd->bNumEndpoints; ++i) {
@@ -1767,7 +1768,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1767 if (usb_endpoint_dir_out(ep)) { 1768 if (usb_endpoint_dir_out(ep)) {
1768 if (endpoints[epidx].out_ep) { 1769 if (endpoints[epidx].out_ep) {
1769 if (++epidx >= MIDI_MAX_ENDPOINTS) { 1770 if (++epidx >= MIDI_MAX_ENDPOINTS) {
1770 snd_printk(KERN_WARNING "too many endpoints\n"); 1771 dev_warn(&umidi->dev->dev,
1772 "too many endpoints\n");
1771 break; 1773 break;
1772 } 1774 }
1773 } 1775 }
@@ -1782,12 +1784,13 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1782 */ 1784 */
1783 endpoints[epidx].out_interval = 1; 1785 endpoints[epidx].out_interval = 1;
1784 endpoints[epidx].out_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; 1786 endpoints[epidx].out_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1;
1785 snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n", 1787 dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
1786 ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack); 1788 ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
1787 } else { 1789 } else {
1788 if (endpoints[epidx].in_ep) { 1790 if (endpoints[epidx].in_ep) {
1789 if (++epidx >= MIDI_MAX_ENDPOINTS) { 1791 if (++epidx >= MIDI_MAX_ENDPOINTS) {
1790 snd_printk(KERN_WARNING "too many endpoints\n"); 1792 dev_warn(&umidi->dev->dev,
1793 "too many endpoints\n");
1791 break; 1794 break;
1792 } 1795 }
1793 } 1796 }
@@ -1797,7 +1800,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1797 else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW) 1800 else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
1798 endpoints[epidx].in_interval = 1; 1801 endpoints[epidx].in_interval = 1;
1799 endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; 1802 endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1;
1800 snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n", 1803 dev_dbg(&umidi->dev->dev, "EP %02X: %d jack(s)\n",
1801 ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack); 1804 ep->bEndpointAddress, ms_ep->bNumEmbMIDIJack);
1802 } 1805 }
1803 } 1806 }
@@ -1865,7 +1868,7 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
1865 (get_endpoint(hostif, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) 1868 (get_endpoint(hostif, 1)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
1866 return; 1869 return;
1867 1870
1868 snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n", 1871 dev_dbg(&umidi->dev->dev, "switching to altsetting %d with int ep\n",
1869 intfd->bAlternateSetting); 1872 intfd->bAlternateSetting);
1870 usb_set_interface(umidi->dev, intfd->bInterfaceNumber, 1873 usb_set_interface(umidi->dev, intfd->bInterfaceNumber,
1871 intfd->bAlternateSetting); 1874 intfd->bAlternateSetting);
@@ -2047,25 +2050,25 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
2047 * input bulk endpoints (at indices 1 and 3) which aren't used. 2050 * input bulk endpoints (at indices 1 and 3) which aren't used.
2048 */ 2051 */
2049 if (intfd->bNumEndpoints < (endpoint->out_cables > 0x0001 ? 5 : 3)) { 2052 if (intfd->bNumEndpoints < (endpoint->out_cables > 0x0001 ? 5 : 3)) {
2050 snd_printdd(KERN_ERR "not enough endpoints\n"); 2053 dev_dbg(&umidi->dev->dev, "not enough endpoints\n");
2051 return -ENOENT; 2054 return -ENOENT;
2052 } 2055 }
2053 2056
2054 epd = get_endpoint(hostif, 0); 2057 epd = get_endpoint(hostif, 0);
2055 if (!usb_endpoint_dir_in(epd) || !usb_endpoint_xfer_int(epd)) { 2058 if (!usb_endpoint_dir_in(epd) || !usb_endpoint_xfer_int(epd)) {
2056 snd_printdd(KERN_ERR "endpoint[0] isn't interrupt\n"); 2059 dev_dbg(&umidi->dev->dev, "endpoint[0] isn't interrupt\n");
2057 return -ENXIO; 2060 return -ENXIO;
2058 } 2061 }
2059 epd = get_endpoint(hostif, 2); 2062 epd = get_endpoint(hostif, 2);
2060 if (!usb_endpoint_dir_out(epd) || !usb_endpoint_xfer_bulk(epd)) { 2063 if (!usb_endpoint_dir_out(epd) || !usb_endpoint_xfer_bulk(epd)) {
2061 snd_printdd(KERN_ERR "endpoint[2] isn't bulk output\n"); 2064 dev_dbg(&umidi->dev->dev, "endpoint[2] isn't bulk output\n");
2062 return -ENXIO; 2065 return -ENXIO;
2063 } 2066 }
2064 if (endpoint->out_cables > 0x0001) { 2067 if (endpoint->out_cables > 0x0001) {
2065 epd = get_endpoint(hostif, 4); 2068 epd = get_endpoint(hostif, 4);
2066 if (!usb_endpoint_dir_out(epd) || 2069 if (!usb_endpoint_dir_out(epd) ||
2067 !usb_endpoint_xfer_bulk(epd)) { 2070 !usb_endpoint_xfer_bulk(epd)) {
2068 snd_printdd(KERN_ERR "endpoint[4] isn't bulk output\n"); 2071 dev_dbg(&umidi->dev->dev, "endpoint[4] isn't bulk output\n");
2069 return -ENXIO; 2072 return -ENXIO;
2070 } 2073 }
2071 } 2074 }
@@ -2289,7 +2292,7 @@ int snd_usbmidi_create(struct snd_card *card,
2289 err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); 2292 err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
2290 break; 2293 break;
2291 default: 2294 default:
2292 snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); 2295 dev_err(&umidi->dev->dev, "invalid quirk type %d\n", quirk->type);
2293 err = -ENXIO; 2296 err = -ENXIO;
2294 break; 2297 break;
2295 } 2298 }