[PATCH 2/2] hw: aspeed: Init all UART's with serial devices

Peter Maydell peter.maydell at linaro.org
Tue May 17 00:56:58 AEST 2022


On Fri, 13 May 2022 at 22:09, Peter Delevoryas <pdel at fb.com> wrote

> I was actually intentionally skipping that. If serial_hd(i)
> doesn’t exist, the function will return NULL.
>
> Chardev *serial_hd(int i)
> {
>     assert(i >= 0);
>     if (i < num_serial_hds) {
>         return serial_hds[i];
>     }
>     return NULL;
> }
>
> So then, the serial device’s CharBackend’s “Chardev *chr”
> will be initialized as NULL. Looking at all of the
> usage of this attribute in “hw/char/serial.c”, I think
> that’s ok, the read/write functions will just be no-ops.
> They all have guards for “chr == NULL”.

Yes, this is deliberate. We added these in commit 12051d82f0040
because otherwise lots of board/SoC code would have to create
NullChardev dummy backends (or forget to and then crash depending
on the user's commandline).

thanks
-- PMM


More information about the openbmc mailing list