[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 06/13] vl.c: Provide accessor function serial_hd
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH 06/13] vl.c: Provide accessor function serial_hd() for serial_hds[] array |
Date: |
Wed, 25 Apr 2018 11:39:51 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 04/20/2018 11:52 AM, Peter Maydell wrote:
> 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: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> include/sysemu/sysemu.h | 3 +++
> vl.c | 9 +++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 2b42151c63..bd5b55c514 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -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
> diff --git a/vl.c b/vl.c
> index fce1fd12d8..6daf026da6 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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;
>
- Re: [Qemu-devel] [PATCH 12/13] vl.c: Remove compile time limit on number of serial ports, (continued)
- [Qemu-devel] [PATCH 11/13] superio: Don't use MAX_SERIAL_PORTS for serial port limit, Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 13/13] vl.c: new function max_serial_hds(), Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 09/13] hw/char/exynos4210_uart.c: Remove unneeded handling of NULL chardev, Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 06/13] vl.c: Provide accessor function serial_hd() for serial_hds[] array, Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 05/13] hw/xtensa/xtfpga.c: Don't create "null" chardevs for serial devices, Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 04/13] hw/mips/mips_malta: Don't create "null" chardevs for serial devices, Peter Maydell, 2018/04/20
- [Qemu-devel] [PATCH 08/13] Remove checks on MAX_SERIAL_PORTS that are just bounds checks, Peter Maydell, 2018/04/20