Browse Source

[usb] Provide usb_endpoint_name() for use by host controller drivers

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
9d43c4080d
2 changed files with 30 additions and 33 deletions
  1. 29
    33
      src/drivers/bus/usb.c
  2. 1
    0
      src/include/ipxe/usb.h

+ 29
- 33
src/drivers/bus/usb.c View File

56
  ******************************************************************************
56
  ******************************************************************************
57
  */
57
  */
58
 
58
 
59
-/**
60
- * Get USB endpoint name (for debugging)
61
- *
62
- * @v address		Endpoint address
63
- * @ret name		Endpoint name
64
- */
65
-static inline const char * usb_endpoint_name ( unsigned int address ) {
66
-	static char buf[ 9 /* "EPxx OUT" + NUL */ ];
67
-
68
-	snprintf ( buf, sizeof ( buf ), "EP%d%s",
69
-		   ( address & USB_ENDPOINT_MAX ),
70
-		   ( address ?
71
-		     ( ( address & USB_ENDPOINT_IN ) ? " IN" : " OUT" ) : "" ));
72
-	return buf;
73
-}
74
-
75
 /**
59
 /**
76
  * Get USB speed name (for debugging)
60
  * Get USB speed name (for debugging)
77
  *
61
  *
227
  ******************************************************************************
211
  ******************************************************************************
228
  */
212
  */
229
 
213
 
214
+/**
215
+ * Get USB endpoint name (for debugging)
216
+ *
217
+ * @v ep		USB endpoint
218
+ * @ret name		Endpoint name
219
+ */
220
+const char * usb_endpoint_name ( struct usb_endpoint *ep ) {
221
+	static char buf[ 9 /* "EPxx OUT" + NUL */ ];
222
+	unsigned int address = ep->address;
223
+
224
+	snprintf ( buf, sizeof ( buf ), "EP%d%s",
225
+		   ( address & USB_ENDPOINT_MAX ),
226
+		   ( address ?
227
+		     ( ( address & USB_ENDPOINT_IN ) ? " IN" : " OUT" ) : "" ));
228
+	return buf;
229
+}
230
+
230
 /**
231
 /**
231
  * Describe USB endpoint from device configuration
232
  * Describe USB endpoint from device configuration
232
  *
233
  *
300
 	/* Add to endpoint list */
301
 	/* Add to endpoint list */
301
 	if ( usb->ep[idx] != NULL ) {
302
 	if ( usb->ep[idx] != NULL ) {
302
 		DBGC ( usb, "USB %s %s is already open\n",
303
 		DBGC ( usb, "USB %s %s is already open\n",
303
-		       usb->name, usb_endpoint_name ( ep->address ) );
304
+		       usb->name, usb_endpoint_name ( ep ) );
304
 		rc = -EALREADY;
305
 		rc = -EALREADY;
305
 		goto err_already;
306
 		goto err_already;
306
 	}
307
 	}
310
 	/* Open endpoint */
311
 	/* Open endpoint */
311
 	if ( ( rc = ep->host->open ( ep ) ) != 0 ) {
312
 	if ( ( rc = ep->host->open ( ep ) ) != 0 ) {
312
 		DBGC ( usb, "USB %s %s could not open: %s\n", usb->name,
313
 		DBGC ( usb, "USB %s %s could not open: %s\n", usb->name,
313
-		       usb_endpoint_name ( ep->address ), strerror ( rc ) );
314
+		       usb_endpoint_name ( ep ), strerror ( rc ) );
314
 		goto err_open;
315
 		goto err_open;
315
 	}
316
 	}
316
 	ep->open = 1;
317
 	ep->open = 1;
317
 
318
 
318
 	DBGC2 ( usb, "USB %s %s opened with MTU %zd, burst %d, interval %d\n",
319
 	DBGC2 ( usb, "USB %s %s opened with MTU %zd, burst %d, interval %d\n",
319
-		usb->name, usb_endpoint_name ( ep->address ), ep->mtu,
320
-		ep->burst, ep->interval );
320
+		usb->name, usb_endpoint_name ( ep ), ep->mtu, ep->burst,
321
+		ep->interval );
321
 	return 0;
322
 	return 0;
322
 
323
 
323
 	ep->open = 0;
324
 	ep->open = 0;
353
 	/* Clear transaction translator buffer */
354
 	/* Clear transaction translator buffer */
354
 	if ( ( rc = tt->hub->driver->clear_tt ( tt->hub, tt, ep ) ) != 0 ) {
355
 	if ( ( rc = tt->hub->driver->clear_tt ( tt->hub, tt, ep ) ) != 0 ) {
355
 		DBGC ( usb, "USB %s %s could not clear transaction translator: "
356
 		DBGC ( usb, "USB %s %s could not clear transaction translator: "
356
-		       "%s\n", usb->name, usb_endpoint_name ( ep->address ),
357
+		       "%s\n", usb->name, usb_endpoint_name ( ep ),
357
 		       strerror ( rc ) );
358
 		       strerror ( rc ) );
358
 		return rc;
359
 		return rc;
359
 	}
360
 	}
407
 	/* Reset endpoint */
408
 	/* Reset endpoint */
408
 	if ( ( rc = ep->host->reset ( ep ) ) != 0 ) {
409
 	if ( ( rc = ep->host->reset ( ep ) ) != 0 ) {
409
 		DBGC ( usb, "USB %s %s could not reset: %s\n",
410
 		DBGC ( usb, "USB %s %s could not reset: %s\n",
410
-		       usb->name, usb_endpoint_name ( ep->address ),
411
-		       strerror ( rc ) );
411
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
412
 		return rc;
412
 		return rc;
413
 	}
413
 	}
414
 
414
 
423
 					  USB_ENDPOINT_HALT,
423
 					  USB_ENDPOINT_HALT,
424
 					  ep->address ) ) != 0 ) ) {
424
 					  ep->address ) ) != 0 ) ) {
425
 		DBGC ( usb, "USB %s %s could not clear endpoint halt: %s\n",
425
 		DBGC ( usb, "USB %s %s could not clear endpoint halt: %s\n",
426
-		       usb->name, usb_endpoint_name ( ep->address ),
427
-		       strerror ( rc ) );
426
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
428
 		return rc;
427
 		return rc;
429
 	}
428
 	}
430
 
429
 
433
 	INIT_LIST_HEAD ( &ep->halted );
432
 	INIT_LIST_HEAD ( &ep->halted );
434
 
433
 
435
 	DBGC ( usb, "USB %s %s reset\n",
434
 	DBGC ( usb, "USB %s %s reset\n",
436
-	       usb->name, usb_endpoint_name ( ep->address ) );
435
+	       usb->name, usb_endpoint_name ( ep ) );
437
 	return 0;
436
 	return 0;
438
 }
437
 }
439
 
438
 
452
 	ep->mtu = mtu;
451
 	ep->mtu = mtu;
453
 	if ( ( rc = ep->host->mtu ( ep ) ) != 0 ) {
452
 	if ( ( rc = ep->host->mtu ( ep ) ) != 0 ) {
454
 		DBGC ( usb, "USB %s %s could not update MTU: %s\n",
453
 		DBGC ( usb, "USB %s %s could not update MTU: %s\n",
455
-		       usb->name, usb_endpoint_name ( ep->address ),
456
-		       strerror ( rc ) );
454
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
457
 		return rc;
455
 		return rc;
458
 	}
456
 	}
459
 
457
 
508
 	/* Enqueue message transfer */
506
 	/* Enqueue message transfer */
509
 	if ( ( rc = ep->host->message ( ep, iobuf ) ) != 0 ) {
507
 	if ( ( rc = ep->host->message ( ep, iobuf ) ) != 0 ) {
510
 		DBGC ( usb, "USB %s %s could not enqueue message transfer: "
508
 		DBGC ( usb, "USB %s %s could not enqueue message transfer: "
511
-		       "%s\n", usb->name, usb_endpoint_name ( ep->address ),
509
+		       "%s\n", usb->name, usb_endpoint_name ( ep ),
512
 		       strerror ( rc ) );
510
 		       strerror ( rc ) );
513
 		return rc;
511
 		return rc;
514
 	}
512
 	}
545
 	/* Enqueue stream transfer */
543
 	/* Enqueue stream transfer */
546
 	if ( ( rc = ep->host->stream ( ep, iobuf, terminate ) ) != 0 ) {
544
 	if ( ( rc = ep->host->stream ( ep, iobuf, terminate ) ) != 0 ) {
547
 		DBGC ( usb, "USB %s %s could not enqueue stream transfer: %s\n",
545
 		DBGC ( usb, "USB %s %s could not enqueue stream transfer: %s\n",
548
-		       usb->name, usb_endpoint_name ( ep->address ),
549
-		       strerror ( rc ) );
546
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
550
 		return rc;
547
 		return rc;
551
 	}
548
 	}
552
 
549
 
574
 	/* Schedule reset, if applicable */
571
 	/* Schedule reset, if applicable */
575
 	if ( ( rc != 0 ) && ep->open ) {
572
 	if ( ( rc != 0 ) && ep->open ) {
576
 		DBGC ( usb, "USB %s %s completion failed: %s\n",
573
 		DBGC ( usb, "USB %s %s completion failed: %s\n",
577
-		       usb->name, usb_endpoint_name ( ep->address ),
578
-		       strerror ( rc ) );
574
+		       usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
579
 		list_del ( &ep->halted );
575
 		list_del ( &ep->halted );
580
 		list_add_tail ( &ep->halted, &usb_halted );
576
 		list_add_tail ( &ep->halted, &usb_halted );
581
 	}
577
 	}

+ 1
- 0
src/include/ipxe/usb.h View File

562
 	return ep->priv;
562
 	return ep->priv;
563
 }
563
 }
564
 
564
 
565
+extern const char * usb_endpoint_name ( struct usb_endpoint *ep );
565
 extern int
566
 extern int
566
 usb_endpoint_described ( struct usb_endpoint *ep,
567
 usb_endpoint_described ( struct usb_endpoint *ep,
567
 			 struct usb_configuration_descriptor *config,
568
 			 struct usb_configuration_descriptor *config,

Loading…
Cancel
Save