[Skiboot] [PATCH 2/6] pci: Add pci_next_phb()

Oliver oohall at gmail.com
Mon Jul 30 16:31:43 AEST 2018


On Sat, Jul 28, 2018 at 12:47 AM, Reza Arbab <arbab at linux.ibm.com> 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;
> +}

So __pci_next_phb_idx() is kind of weird so I don't mind replacing it
with this, but you should probably do the replacement too ;)

> +
>  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;
> --
> 1.8.3.1
>
> _______________________________________________
> Skiboot mailing list
> Skiboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot


More information about the Skiboot mailing list