spi: add spi_is_ready_dt function

Add `spi_is_ready_dt` function that validates SPI DT spec
is ready and it allows the user to pass `spi_dt_spec` directly.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
diff --git a/include/zephyr/drivers/spi.h b/include/zephyr/drivers/spi.h
index fcd9cbc..d108ae5 100644
--- a/include/zephyr/drivers/spi.h
+++ b/include/zephyr/drivers/spi.h
@@ -523,6 +523,27 @@
 }
 
 /**
+ * @brief Validate that SPI bus (and CS gpio if defined) is ready.
+ *
+ * @param spec SPI specification from devicetree
+ *
+ * @retval true if the SPI bus is ready for use.
+ * @retval false if the SPI bus (or the CS gpio defined) is not ready for use.
+ */
+static inline bool spi_is_ready_dt(const struct spi_dt_spec *spec)
+{
+	/* Validate bus is ready */
+	if (!device_is_ready(spec->bus)) {
+		return false;
+	}
+	/* Validate CS gpio port is ready, if it is used */
+	if (spec->config.cs &&
+	    !device_is_ready(spec->config.cs->gpio.port)) {
+		return false;
+	}
+	return true;
+}
+/**
  * @brief Read/write the specified amount of data from the SPI driver.
  *
  * @note This function is synchronous.