@@ -415,15 +415,8 @@ int of_machine_is_compatible(const char *compat)
415
415
}
416
416
EXPORT_SYMBOL (of_machine_is_compatible );
417
417
418
- /**
419
- * __of_device_is_available - check if a device is available for use
420
- *
421
- * @device: Node to check for availability, with locks already held
422
- *
423
- * Return: True if the status property is absent or set to "okay" or "ok",
424
- * false otherwise
425
- */
426
- static bool __of_device_is_available (const struct device_node * device )
418
+ static bool __of_device_is_status (const struct device_node * device ,
419
+ const char * const * strings )
427
420
{
428
421
const char * status ;
429
422
int statlen ;
@@ -433,16 +426,45 @@ static bool __of_device_is_available(const struct device_node *device)
433
426
434
427
status = __of_get_property (device , "status" , & statlen );
435
428
if (status == NULL )
436
- return true ;
429
+ return false ;
437
430
438
431
if (statlen > 0 ) {
439
- if (!strcmp (status , "okay" ) || !strcmp (status , "ok" ))
440
- return true;
432
+ while (* strings ) {
433
+ unsigned int len = strlen (* strings );
434
+
435
+ if ((* strings )[len - 1 ] == '-' ) {
436
+ if (!strncmp (status , * strings , len ))
437
+ return true;
438
+ } else {
439
+ if (!strcmp (status , * strings ))
440
+ return true;
441
+ }
442
+ strings ++ ;
443
+ }
441
444
}
442
445
443
446
return false;
444
447
}
445
448
449
+ /**
450
+ * __of_device_is_available - check if a device is available for use
451
+ *
452
+ * @device: Node to check for availability, with locks already held
453
+ *
454
+ * Return: True if the status property is absent or set to "okay" or "ok",
455
+ * false otherwise
456
+ */
457
+ static bool __of_device_is_available (const struct device_node * device )
458
+ {
459
+ static const char * const ok [] = {"okay" , "ok" , NULL };
460
+
461
+ if (!device )
462
+ return false;
463
+
464
+ return !__of_get_property (device , "status" , NULL ) ||
465
+ __of_device_is_status (device , ok );
466
+ }
467
+
446
468
/**
447
469
* of_device_is_available - check if a device is available for use
448
470
*
@@ -474,16 +496,9 @@ EXPORT_SYMBOL(of_device_is_available);
474
496
*/
475
497
static bool __of_device_is_fail (const struct device_node * device )
476
498
{
477
- const char * status ;
478
-
479
- if (!device )
480
- return false;
481
-
482
- status = __of_get_property (device , "status" , NULL );
483
- if (status == NULL )
484
- return false;
499
+ static const char * const fail [] = {"fail" , "fail-" , NULL };
485
500
486
- return ! strcmp ( status , " fail" ) || ! strncmp ( status , "fail-" , 5 );
501
+ return __of_device_is_status ( device , fail );
487
502
}
488
503
489
504
/**
0 commit comments