Skip to content

Commit e2ae4ec

Browse files
mbolivar-nordiccfriedt
authored andcommitted
Revert "device: supported devices visitor API"
This reverts commit b01e41c. It's not clear that the supported devices are being properly computed, so let's revert this for v2.7.0 until we've had more time to think it through. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 1f09c92 commit e2ae4ec

File tree

2 files changed

+7
-103
lines changed

2 files changed

+7
-103
lines changed

include/device.h

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -488,47 +488,6 @@ device_required_handles_get(const struct device *dev,
488488
return rv;
489489
}
490490

491-
/**
492-
* @brief Get the set of handles that this device supports.
493-
*
494-
* The set of supported devices is inferred from devicetree, and does not
495-
* include any software constructs that may depend on the device.
496-
*
497-
* @param dev the device for which supports are desired.
498-
*
499-
* @param count pointer to a place to store the number of devices provided at
500-
* the returned pointer. The value is not set if the call returns a null
501-
* pointer. The value may be set to zero.
502-
*
503-
* @return a pointer to a sequence of @p *count device handles, or a null
504-
* pointer if @p dh does not provide dependency information.
505-
*/
506-
static inline const device_handle_t *
507-
device_supported_handles_get(const struct device *dev,
508-
size_t *count)
509-
{
510-
const device_handle_t *rv = dev->handles;
511-
size_t region = 0;
512-
size_t i = 0;
513-
514-
if (rv != NULL) {
515-
/* Fast forward to supporting devices */
516-
while (region != 2) {
517-
if (*rv == DEVICE_HANDLE_SEP) {
518-
region++;
519-
}
520-
rv++;
521-
}
522-
/* Count supporting devices */
523-
while (rv[i] != DEVICE_HANDLE_ENDS) {
524-
++i;
525-
}
526-
*count = i;
527-
}
528-
529-
return rv;
530-
}
531-
532491
/**
533492
* @brief Visit every device that @p dev directly requires.
534493
*
@@ -566,42 +525,6 @@ int device_required_foreach(const struct device *dev,
566525
device_visitor_callback_t visitor_cb,
567526
void *context);
568527

569-
/**
570-
* @brief Visit every device that @p dev directly supports.
571-
*
572-
* Zephyr maintains information about which devices are directly supported by
573-
* another device; for example an I2C controller will support an I2C-based
574-
* sensor driver. Supported devices can derive from statically-defined
575-
* devicetree relationships.
576-
*
577-
* This API supports operating on the set of supported devices. Example uses
578-
* include iterating over the devices connected to a regulator when it is
579-
* powered on.
580-
*
581-
* There is no guarantee on the order in which required devices are visited.
582-
*
583-
* If the @p visitor function returns a negative value iteration is halted,
584-
* and the returned value from the visitor is returned from this function.
585-
*
586-
* @note This API is not available to unprivileged threads.
587-
*
588-
* @param dev a device of interest. The devices that this device supports
589-
* will be used as the set of devices to visit. This parameter must not be
590-
* null.
591-
*
592-
* @param visitor_cb the function that should be invoked on each device in the
593-
* support set. This parameter must not be null.
594-
*
595-
* @param context state that is passed through to the visitor function. This
596-
* parameter may be null if @p visitor tolerates a null @p context.
597-
*
598-
* @return The number of devices that were visited if all visits succeed, or
599-
* the negative value returned from the first visit that did not succeed.
600-
*/
601-
int device_supported_foreach(const struct device *dev,
602-
device_visitor_callback_t visitor_cb,
603-
void *context);
604-
605528
/**
606529
* @brief Retrieve the device structure for a driver by name
607530
*

kernel/device.c

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,14 @@ bool z_device_ready(const struct device *dev)
162162
return dev->state->initialized && (dev->state->init_res == 0U);
163163
}
164164

165-
static int device_visitor(const device_handle_t *handles,
166-
size_t handle_count,
167-
device_visitor_callback_t visitor_cb,
168-
void *context)
165+
int device_required_foreach(const struct device *dev,
166+
device_visitor_callback_t visitor_cb,
167+
void *context)
169168
{
169+
size_t handle_count = 0;
170+
const device_handle_t *handles =
171+
device_required_handles_get(dev, &handle_count);
172+
170173
/* Iterate over fixed devices */
171174
for (size_t i = 0; i < handle_count; ++i) {
172175
device_handle_t dh = handles[i];
@@ -180,25 +183,3 @@ static int device_visitor(const device_handle_t *handles,
180183

181184
return handle_count;
182185
}
183-
184-
int device_required_foreach(const struct device *dev,
185-
device_visitor_callback_t visitor_cb,
186-
void *context)
187-
{
188-
size_t handle_count = 0;
189-
const device_handle_t *handles =
190-
device_required_handles_get(dev, &handle_count);
191-
192-
return device_visitor(handles, handle_count, visitor_cb, context);
193-
}
194-
195-
int device_supported_foreach(const struct device *dev,
196-
device_visitor_callback_t visitor_cb,
197-
void *context)
198-
{
199-
size_t handle_count = 0;
200-
const device_handle_t *handles =
201-
device_supported_handles_get(dev, &handle_count);
202-
203-
return device_visitor(handles, handle_count, visitor_cb, context);
204-
}

0 commit comments

Comments
 (0)