[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 3/7] xen/arm: setup MMIO range trap handlers for hardware domain




On 05.11.21 08:33, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>
> [snip]
> +int pci_host_iterate_bridges(struct domain *d,
> +                             int (*cb)(struct domain *d,
> +                                       struct pci_host_bridge *bridge))
> +{
> +    struct pci_host_bridge *bridge;
> +    int err;
> +
> +    list_for_each_entry( bridge, &pci_host_bridges, node )
> +    {
> +        err = cb(d, bridge);
> +        if ( err )
> +            return err;
> +    }
> +    return 0;
> +}
> +
> +unsigned int pci_host_get_num_bridges(void)
> +{
> +    struct pci_host_bridge *bridge;
> +    unsigned int count = 0;
> +
> +    list_for_each_entry( bridge, &pci_host_bridges, node )
> +        count++;
> +
> +    return count;
> +}
> +
>
This can be even simpler if pci_host_iterate_bridges returns the count:

-int pci_host_iterate_bridges(struct domain *d,
-                             int (*cb)(struct domain *d,
-                                       struct pci_host_bridge *bridge))
+int pci_host_iterate_bridges_and_count(struct domain *d,
+                                       int (*cb)(struct domain *d,
+                                                 struct pci_host_bridge 
*bridge))
  {
      struct pci_host_bridge *bridge;
-    int err;
+    int err, count = 0;

      list_for_each_entry( bridge, &pci_host_bridges, node )
      {
          err = cb(d, bridge);
          if ( err )
              return err;
+        count += err;
      }
-    return 0;
-}

Then pci_host_get_num_bridges goes away and we can count
different entities with the same iterator and a simple callback.
This becomes possible as there is a single user for pci_host_iterate_bridges
now which sets up MMIOs, so the change above seems to be reasonable
I will include this change in v7

Thank you,
Oleksandr

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.