Skip to content

Commit f8ccd46

Browse files
committed
drivers: gpio: introduce gpio_get_dt
Align with new device patterns. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
1 parent 07258bd commit f8ccd46

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

include/zephyr/drivers/gpio.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ struct gpio_dt_spec {
319319
* // .dt_flags = GPIO_ACTIVE_LOW
320320
* // }
321321
*
322-
* The 'gpio' field must still be checked for readiness, e.g. using
323-
* device_is_ready(). It is an error to use this macro unless the node
324-
* exists, has the given property, and that property specifies a GPIO
325-
* controller, pin number, and flags as shown above.
322+
* Usage of the 'gpio' field must still be notified using device_get().
323+
* It is an error to use this macro unless the node exists, has the given
324+
* property, and that property specifies a GPIO controller, pin number, and
325+
* flags as shown above.
326326
*
327327
* @param node_id devicetree node identifier
328328
* @param prop lowercase-and-underscores property name
@@ -825,18 +825,25 @@ __subsystem struct gpio_driver_api {
825825
* @endcond
826826
*/
827827

828+
static inline int gpio_get_dt(const struct gpio_dt_spec *spec)
829+
{
830+
return device_get(spec->port);
831+
}
832+
828833
/**
829834
* @brief Validate that GPIO port is ready.
830835
*
831836
* @param spec GPIO specification from devicetree
832837
*
838+
* @note Usage of gpio_get_dt() is preferred, this function will be deprecated.
839+
*
833840
* @retval true if the GPIO spec is ready for use.
834841
* @retval false if the GPIO spec is not ready for use.
835842
*/
836843
static inline bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
837844
{
838845
/* Validate port is ready */
839-
return device_is_ready(spec->port);
846+
return gpio_get_dt(spec);
840847
}
841848

842849
/**

0 commit comments

Comments
 (0)