[Skiboot] [PATCH 2/6] pci: Add pci_next_phb()
Alistair Popple
alistair at popple.id.au
Mon Jul 30 15:51:27 AEST 2018
Looks good to me.
Reviewed-by: Alistair Popple <alistair at popple.id.au>
On Friday, 27 July 2018 9:47:38 AM AEST Reza Arbab wrote:
> Add an iterator to walk over every PHB.
>
> Signed-off-by: Alistair Popple <alistair at popple.id.au>
> Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
> ---
> core/pci.c | 12 ++++++++++++
> include/pci.h | 1 +
> 2 files changed, 13 insertions(+)
>
> diff --git a/core/pci.c b/core/pci.c
> index 6ba6eda..4faf88e 100644
> --- a/core/pci.c
> +++ b/core/pci.c
> @@ -1104,6 +1104,18 @@ struct phb *pci_get_phb(uint64_t phb_id)
> return phbs[phb_id];
> }
>
> +/* Iterator to walk over every PHB */
> +struct phb *pci_next_phb(struct phb *last)
> +{
> + uint64_t phb_id = last ? last->opal_id + 1 : 0;
> +
> + for (; phb_id < ARRAY_SIZE(phbs); phb_id++)
> + if (phbs[phb_id])
> + return phbs[phb_id];
> +
> + return NULL;
> +}
> +
> static const char *pci_class_name(uint32_t class_code)
> {
> uint8_t class = class_code >> 16;
> diff --git a/include/pci.h b/include/pci.h
> index c6aa664..19fe9c0 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -481,6 +481,7 @@ extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
> extern int64_t pci_register_phb(struct phb *phb, int opal_id);
> extern int64_t pci_unregister_phb(struct phb *phb);
> extern struct phb *pci_get_phb(uint64_t phb_id);
> +extern struct phb *pci_next_phb(struct phb *last);
>
> static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) {
> struct phb *phb = NULL;
>
More information about the Skiboot
mailing list