提交 a8d78cd0 编写于 作者: P Peter Maydell

vl.c: Provide accessor function serial_hd() for serial_hds[] array

Provide an accessor function serial_hd() to return the Chardev
(if any) associated with the numbered serial port. This will
be used to replace direct accesses to the serial_hds[] array,
so that calling code doesn't need to care about the size of
that array.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: NThomas Huth <thuth@redhat.com>
Tested-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180420145249.32435-7-peter.maydell@linaro.org
上级 b82fcd30
无相关合并请求
......@@ -163,6 +163,9 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
extern Chardev *serial_hds[MAX_SERIAL_PORTS];
/* Return the Chardev for serial port i, or NULL if none */
Chardev *serial_hd(int i);
/* parallel ports */
#define MAX_PARALLEL_PORTS 3
......
......@@ -2516,6 +2516,15 @@ static int serial_parse(const char *devname)
return 0;
}
Chardev *serial_hd(int i)
{
assert(i >= 0);
if (i < ARRAY_SIZE(serial_hds)) {
return serial_hds[i];
}
return NULL;
}
static int parallel_parse(const char *devname)
{
static int index = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部