qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH v3 05/33] serial-pci-multi: factor out multi_serial_get_nr_po


From: Marc-André Lureau
Subject: Re: [PATCH v3 05/33] serial-pci-multi: factor out multi_serial_get_nr_ports
Date: Thu, 24 Oct 2019 11:59:45 +0200

On Thu, Oct 24, 2019 at 12:41 AM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> On 10/23/19 7:31 PM, Marc-André Lureau wrote:
> > Reused in following patch.
> >
> > Signed-off-by: Marc-André Lureau <address@hidden>
> > ---
> >   hw/char/serial-pci-multi.c | 26 ++++++++++++++------------
> >   1 file changed, 14 insertions(+), 12 deletions(-)
> >
> > diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c
> > index 5f13b5663b..6fa1cc6225 100644
> > --- a/hw/char/serial-pci-multi.c
> > +++ b/hw/char/serial-pci-multi.c
> > @@ -77,24 +77,26 @@ static void multi_serial_irq_mux(void *opaque, int n, 
> > int level)
> >       pci_set_irq(&pci->dev, pending);
> >   }
> >
> > +static int multi_serial_get_nr_ports(PCIDeviceClass *pc)
>
> static size_t multi_serial_get_port_count()?
>
> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

works for me, thanks

>
> > +{
> > +    switch (pc->device_id) {
> > +    case 0x0003:
> > +        return 2;
> > +    case 0x0004:
> > +        return 4;
> > +    }
> > +
> > +    g_assert_not_reached();
> > +}
> > +
> > +
> >   static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
> >   {
> >       PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
> >       PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev);
> >       SerialState *s;
> >       Error *err = NULL;
> > -    int i, nr_ports = 0;
> > -
> > -    switch (pc->device_id) {
> > -    case 0x0003:
> > -        nr_ports = 2;
> > -        break;
> > -    case 0x0004:
> > -        nr_ports = 4;
> > -        break;
> > -    }
> > -    assert(nr_ports > 0);
> > -    assert(nr_ports <= PCI_SERIAL_MAX_PORTS);
> > +    int i, nr_ports = multi_serial_get_nr_ports(pc);
> >
> >       pci->dev.config[PCI_CLASS_PROG] = pci->prog_if;
> >       pci->dev.config[PCI_INTERRUPT_PIN] = 0x01;
> >



reply via email to

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