Commit b8846a4d authored by Peter Maydell's avatar Peter Maydell
Browse files

vl.c: new function serial_max_hds()



Create a new function serial_max_hds() which returns the number of
serial ports defined by the user. This is needed only by spapr.

This allows us to remove the MAX_SERIAL_PORTS define.

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Tested-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180420145249.32435-14-peter.maydell@linaro.org
parent 6af2692e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2589,7 +2589,7 @@ static void spapr_machine_init(MachineState *machine)
    /* Set up VIO bus */
    spapr->vio_bus = spapr_vio_bus_init();

    for (i = 0; i < MAX_SERIAL_PORTS; i++) {
    for (i = 0; i < serial_max_hds(); i++) {
        if (serial_hd(i)) {
            spapr_vty_create(spapr->vio_bus, serial_hd(i));
        }
+4 −2
Original line number Diff line number Diff line
@@ -159,10 +159,12 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);

/* serial ports */

#define MAX_SERIAL_PORTS 4

/* Return the Chardev for serial port i, or NULL if none */
Chardev *serial_hd(int i);
/* return the number of serial ports defined by the user. serial_hd(i)
 * will always return NULL for any i which is greater than or equal to this.
 */
int serial_max_hds(void);

/* parallel ports */

+5 −0
Original line number Diff line number Diff line
@@ -2524,6 +2524,11 @@ Chardev *serial_hd(int i)
    return NULL;
}

int serial_max_hds(void)
{
    return num_serial_hds;
}

static int parallel_parse(const char *devname)
{
    static int index = 0;