qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 4/8] pci: Define pci_bus_fn/pci_bus_ret_fn type


From: Peter Xu
Subject: Re: [PATCH 4/8] pci: Define pci_bus_fn/pci_bus_ret_fn type
Date: Fri, 22 Oct 2021 10:24:34 +0800

On Thu, Oct 21, 2021 at 02:54:44PM +0200, Philippe Mathieu-Daudé wrote:
> On 10/21/21 13:44, Philippe Mathieu-Daudé wrote:
> > On 10/21/21 12:42, Peter Xu wrote:
> >> The pci_bus_fn is similar to pci_bus_dev_fn that only takes a PCIBus* and 
> >> an
> >> opaque.  The pci_bus_ret_fn is similar to pci_bus_fn but it allows to 
> >> return a
> >> void* pointer.
> >>
> >> Use them where proper in pci.[ch], and to be used elsewhere.
> >>
> >> Signed-off-by: Peter Xu <peterx@redhat.com>
> >> ---
> >>  hw/pci/pci.c         |  6 ++----
> >>  include/hw/pci/pci.h | 12 +++++-------
> >>  2 files changed, 7 insertions(+), 11 deletions(-)
> > 
> >> --- a/include/hw/pci/pci.h
> >> +++ b/include/hw/pci/pci.h
> >> @@ -402,6 +402,8 @@ OBJECT_DECLARE_TYPE(PCIBus, PCIBusClass, PCI_BUS)
> >>  #define TYPE_PCIE_BUS "PCIE"
> >>  
> >>  typedef void (*pci_bus_dev_fn)(PCIBus *b, PCIDevice *d, void *opaque);
> >> +typedef void (*pci_bus_fn)(PCIBus *b, void *opaque);
> >> +typedef void* (*pci_bus_ret_fn)(PCIBus *b, void *opaque);
> 
> Now looking at patch #8, I wonder if it wouldn't be cleaner to have
> a single:
> 
> /*
>  * pci_bus_fn:
>  * @bus: PCI bus
>  * @opaque: Pointer to opaque pointer,
>             can be used as input *and* output
>  * Return #true on success, #false on failure
>  */
> typedef bool (*pci_bus_fn)(PCIBus *bus, void **opaque);

Having the errp could be better imho for patch 8 so we can allow the per-device
hook to set the exact error message.  That could be useful when we extend the
list of devices to scan (besides vfio-pci) so we can set different error
messages rather than return "false" for all.

I'll stole the rb and I'll adjust the "void* ()".  Thanks for looking, Phil.

-- 
Peter Xu




reply via email to

[Prev in Thread] Current Thread [Next in Thread]