@@ -209,7 +209,7 @@ typedef int16_t device_handle_t;
209
209
* device object can be obtained with `DEVICE_DT_GET(node_id)` from any source
210
210
* file that includes `<zephyr/device.h>` (even from extensions, when
211
211
* @kconfig{CONFIG_LLEXT_EXPORT_DEVICES} is enabled). Before using the
212
- * pointer, the referenced object should be checked using device_is_ready ().
212
+ * pointer, its usage should be registered using device_get ().
213
213
*
214
214
* @param node_id The devicetree node identifier.
215
215
* @param init_fn Pointer to the device's initialization function, which will be
@@ -302,8 +302,8 @@ typedef int16_t device_handle_t;
302
302
*
303
303
* If there are multiple, this returns an arbitrary one.
304
304
*
305
- * If this returns non-NULL, the device must be checked for readiness
306
- * before use, e.g. with device_is_ready ().
305
+ * If this returns non-NULL, device usage must be notified using
306
+ * device_get ().
307
307
*
308
308
* @param compat lowercase-and-underscores devicetree compatible
309
309
* @return a pointer to a device, or NULL
@@ -323,8 +323,8 @@ typedef int16_t device_handle_t;
323
323
*
324
324
* If there are multiple, this returns an arbitrary one.
325
325
*
326
- * If this returns non-NULL, the device must be checked for readiness before
327
- * use, e.g. with device_is_ready ().
326
+ * If this returns non-NULL, device usage must be notified using
327
+ * device_get ().
328
328
*
329
329
* @param compat lowercase-and-underscores devicetree compatible
330
330
* @return a pointer to a device
@@ -817,6 +817,21 @@ __syscall const struct device *device_get_binding(const char *name);
817
817
*/
818
818
size_t z_device_get_all_static (const struct device * * devices );
819
819
820
+ /**
821
+ * Get a device.
822
+ *
823
+ * When getting a device, its usage count will be increased and, if not yet
824
+ * initialized, its initialization routine will be called. This function will
825
+ * not return until device initialization has finished.
826
+ *
827
+ * @param dev Device instance
828
+ *
829
+ * @retval -errno Device failed to initialize.
830
+ * @retval >=0 Device was successfully initialized and can be used. Values > 0
831
+ * indicate the current reference count.
832
+ */
833
+ __syscall int device_get (const struct device * dev );
834
+
820
835
/**
821
836
* @brief Verify that a device is ready for use.
822
837
*
@@ -829,26 +844,17 @@ size_t z_device_get_all_static(const struct device **devices);
829
844
*
830
845
* @param dev pointer to the device in question.
831
846
*
847
+ * @note Usage of device_get() if preferred, this function will be deprecated
848
+ * in the future.
849
+ *
832
850
* @retval true If the device is ready for use.
833
851
* @retval false If the device is not ready for use or if a NULL device pointer
834
852
* is passed as argument.
835
853
*/
836
- __syscall bool device_is_ready (const struct device * dev );
837
-
838
- /**
839
- * Get a device.
840
- *
841
- * When getting a device, its usage count will be increased and, if not yet
842
- * initialized, its initialization routine will be called. This function will
843
- * not return until device initialization has finished.
844
- *
845
- * @param dev Device instance
846
- *
847
- * @retval -errno Device failed to initialize.
848
- * @retval >=0 Device was successfully initialized and can be used. Values > 0
849
- * indicate the current reference count.
850
- */
851
- __syscall int device_get (const struct device * dev );
854
+ static inline bool device_is_ready (const struct device * dev )
855
+ {
856
+ return device_get (dev ) >= 0 ;
857
+ }
852
858
853
859
/**
854
860
* @brief Initialize a device.
0 commit comments