Browse Source

spi_shell: add shell device filtering

Add shell device filtering using DEVICE_API_IS.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
pull/84841/head
Fabio Baltieri 5 months ago committed by Benjamin Cabé
parent
commit
7ee8b49c4a
  1. 7
      drivers/spi/spi_shell.c

7
drivers/spi/spi_shell.c

@ -28,9 +28,14 @@ static struct device *spi_device; @@ -28,9 +28,14 @@ static struct device *spi_device;
static struct spi_config config = {.frequency = 1000000,
.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8)};
static bool device_is_spi(const struct device *dev)
{
return DEVICE_API_IS(spi, dev);
}
static void device_name_get(size_t idx, struct shell_static_entry *entry)
{
const struct device *dev = shell_device_lookup(idx, "spi");
const struct device *dev = shell_device_filter(idx, device_is_spi);
entry->syntax = (dev != NULL) ? dev->name : NULL;
entry->handler = NULL;

Loading…
Cancel
Save