device: add API to check whether a device is ready to use

Currently this is useful only for some internal applications that
iterate over the device table, since applications can't get access to
a device that isn't ready, and devices can't be made unready.  So it's
introduced as internal API that may be exposed as device_ready() when
those conditions change.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-06-22 10:01:39 -05:00 committed by Carles Cufí
commit d8b86cba3c
4 changed files with 16 additions and 7 deletions

View file

@ -470,7 +470,7 @@ struct device *shell_device_lookup(size_t idx,
struct device *dev_end = dev + len;
while (dev < dev_end) {
if ((dev->driver_api != NULL)
if (z_device_ready(dev)
&& (dev->name != NULL)
&& (strlen(dev->name) != 0)
&& ((prefix == NULL)