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: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180420145249.32435-14-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2018-04-20 15:52:49 +01:00
parent 6af2692e86
commit b8846a4d63
3 changed files with 10 additions and 3 deletions

View File

@ -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));
}

View File

@ -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
vl.c
View File

@ -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;