[Pdbg] [PATCH 04/10] path: Add device tree path based targeting

Alistair Popple alistair at popple.id.au
Thu Nov 1 12:56:10 AEDT 2018


> +/**
> + * @brief Iterator for list of path targets
> + *
> + * @param[in]  prev The last pdbg target
> + * @param[in]  only_enabled Whether to list enabled targets or all

Just a minor documentation nit-pick ... reading that makes me think it would 
just check the status. However it also has the side-effect of trying to probe 
the device first.

In general I think it would be nicer to have seperate macros/calls for probed 
and enabled only vs. iterating over all rather than a bool flag whos meaning is 
a little less obvious when reading the calls in code.

- Alistair

> + * @return the next pdbg target in the list, NULL otherwise
> + *
> + * If prev is NULL, then return the first pdbg target in the list.
> + * If there are no more pdbg targets in the list, NULL is returned.
> + */
> +struct pdbg_target *path_target_next(struct pdbg_target *prev,
> +				     bool only_enabled);
> +
> +/**
> + * @brief Iterator for a list of path targets of specified class
> + *
> + * @param[in]  klass The class of the targets required
> + * @param[in]  prev The last pdbg target
> + * @param[in]  only_enabled Whether to list enabled targets or all
> + * @return the next matching pdbg target in the list, NULL otherwise
> + *
> + * If prev is NULL, then return the first matching pdbg target in the list.
> + * If there are no more matching pdbg targets, NULL is returned.
> + */
> +struct pdbg_target *path_target_next_class(const char *klass,
> +					   struct pdbg_target *prev,
> +					   bool only_enabled);
> +
> +/**
> + * @brief Macro for iterating through all path targets
> + *
> + * target is of type struct pdbg_target
> + * only_eanbled is boolean
> + *
> + * If only_enabled is true, iterate through targets that are enabled;
> + * otherwise iterate through all targets
> + */
> +#define for_each_path_target(target, only_enabled)          \
> +	for (target = path_target_next(NULL, only_enabled); \
> +	     target;                                        \
> +	     target = path_target_next(target, only_enabled))
> +
> +/**
> + * @brief Macro for iterating through all path targets of specific class
> + *
> + * class is of type char *
> + * target is of type struct pdbg_target
> + * only_eanbled is boolean
> + *
> + * If only_enabled is true, iterate through targets that are enabled;
> + * otherwise iterate through all targets
> + */
> +#define for_each_path_target_class(class, target, only_enabled)          \
> +	for (target = path_target_next_class(class, NULL, only_enabled); \
> +	     target;                                                     \
> +	     target = path_target_next_class(class, target, only_enabled))
> +
> +#endif




More information about the Pdbg mailing list