@@ -359,14 +359,17 @@ int bootdev_unbind_dev(struct udevice *parent)
359359 *
360360 * @label: Label to look up (e.g. "mmc1" or "mmc0")
361361 * @seqp: Returns the sequence number, or -1 if none
362+ * @method_flagsp: If non-NULL, returns any flags implied by the label
363+ * (enum bootflow_meth_flags_t), 0 if none
362364 * Returns: sequence number on success, else -ve error code
363365 */
364- static int label_to_uclass (const char * label , int * seqp )
366+ static int label_to_uclass (const char * label , int * seqp , int * method_flagsp )
365367{
368+ int seq , len , method_flags ;
366369 enum uclass_id id ;
367370 const char * end ;
368- int seq , len ;
369371
372+ method_flags = 0 ;
370373 seq = trailing_strtoln_end (label , NULL , & end );
371374 len = end - label ;
372375 if (!len )
@@ -379,6 +382,14 @@ static int label_to_uclass(const char *label, int *seqp)
379382 if (IS_ENABLED (CONFIG_BOOTDEV_SPI_FLASH ) &&
380383 !strncmp ("spi" , label , len )) {
381384 id = UCLASS_SPI_FLASH ;
385+ } else if (IS_ENABLED (CONFIG_BOOTDEV_ETH ) &&
386+ !strncmp ("pxe" , label , len )) {
387+ id = UCLASS_ETH ;
388+ method_flags |= BOOTFLOW_METHF_PXE_ONLY ;
389+ } else if (IS_ENABLED (CONFIG_BOOTDEV_ETH ) &&
390+ !strncmp ("dhcp" , label , len )) {
391+ id = UCLASS_ETH ;
392+ method_flags |= BOOTFLOW_METHF_DHCP_ONLY ;
382393 } else {
383394 log_warning ("Unknown uclass '%s' in label\n" , label );
384395 return - EINVAL ;
@@ -387,31 +398,21 @@ static int label_to_uclass(const char *label, int *seqp)
387398 if (id == UCLASS_USB )
388399 id = UCLASS_MASS_STORAGE ;
389400 * seqp = seq ;
401+ if (method_flagsp )
402+ * method_flagsp = method_flags ;
390403
391404 return id ;
392405}
393406
394- /**
395- * bootdev_find_by_label() - Convert a label string to a bootdev device
396- *
397- * Looks up a label name to find the associated bootdev. For example, if the
398- * label name is "mmc2", this will find a bootdev for an mmc device whose
399- * sequence number is 2.
400- *
401- * @label: Label string to convert, e.g. "mmc2"
402- * @devp: Returns bootdev device corresponding to that boot label
403- * Return: 0 if OK, -EINVAL if the label name (e.g. "mmc") does not refer to a
404- * uclass, -ENOENT if no bootdev for that media has the sequence number
405- * (e.g. 2)
406- */
407- int bootdev_find_by_label (const char * label , struct udevice * * devp )
407+ int bootdev_find_by_label (const char * label , struct udevice * * devp ,
408+ int * method_flagsp )
408409{
410+ int seq , ret , method_flags = 0 ;
409411 struct udevice * media ;
410412 struct uclass * uc ;
411413 enum uclass_id id ;
412- int seq , ret ;
413414
414- ret = label_to_uclass (label , & seq );
415+ ret = label_to_uclass (label , & seq , & method_flags );
415416 if (ret < 0 )
416417 return log_msg_ret ("uc" , ret );
417418 id = ret ;
@@ -441,6 +442,8 @@ int bootdev_find_by_label(const char *label, struct udevice **devp)
441442 if (!ret ) {
442443 log_debug ("- found %s\n" , bdev -> name );
443444 * devp = bdev ;
445+ if (method_flagsp )
446+ * method_flagsp = method_flags ;
444447 return 0 ;
445448 }
446449 log_debug ("- no device in %s\n" , media -> name );
@@ -450,9 +453,11 @@ int bootdev_find_by_label(const char *label, struct udevice **devp)
450453 return - ENOENT ;
451454}
452455
453- int bootdev_find_by_any (const char * name , struct udevice * * devp )
456+ int bootdev_find_by_any (const char * name , struct udevice * * devp ,
457+ int * method_flagsp )
454458{
455459 struct udevice * dev ;
460+ int method_flags = 0 ;
456461 int ret , seq ;
457462 char * endp ;
458463
@@ -462,18 +467,18 @@ int bootdev_find_by_any(const char *name, struct udevice **devp)
462467 if (* endp ) {
463468 ret = uclass_get_device_by_name (UCLASS_BOOTDEV , name , & dev );
464469 if (ret == - ENODEV ) {
465- ret = bootdev_find_by_label (name , & dev );
470+ ret = bootdev_find_by_label (name , & dev , & method_flags );
466471 if (ret ) {
467472 printf ("Cannot find bootdev '%s' (err=%d)\n" ,
468473 name , ret );
469- return ret ;
474+ return log_msg_ret ( "lab" , ret ) ;
470475 }
471476 ret = device_probe (dev );
472477 }
473478 if (ret ) {
474479 printf ("Cannot probe bootdev '%s' (err=%d)\n" , name ,
475480 ret );
476- return ret ;
481+ return log_msg_ret ( "pro" , ret ) ;
477482 }
478483 } else {
479484 ret = uclass_get_device_by_seq (UCLASS_BOOTDEV , seq , & dev );
@@ -484,6 +489,8 @@ int bootdev_find_by_any(const char *name, struct udevice **devp)
484489 }
485490
486491 * devp = dev ;
492+ if (method_flagsp )
493+ * method_flagsp = method_flags ;
487494
488495 return 0 ;
489496}
@@ -593,7 +600,7 @@ static int build_order(struct udevice *bootstd, struct udevice **order,
593600
594601 upto = 0 ;
595602 for (i = 0 ; labels [i ]; i ++ ) {
596- ret = bootdev_find_by_label (labels [i ], & dev );
603+ ret = bootdev_find_by_label (labels [i ], & dev , NULL );
597604 if (!ret ) {
598605 if (upto == max_count ) {
599606 overflow_target = labels [i ];
0 commit comments