i.MX: Fix UART driver to work with unitialized "chardev" device
The "chardev" property initialization might have failed (for example because there are not enough chardevs provided by QEMU). The serial device emulator needs to be able to work with an uninitialized (NULL) chardev device pointer. This patch adds some missing tests on the chr pointer value before using it. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Message-id: 1438342461-18967-1-git-send-email-jcd@tribudubois.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
5dfaa75b4d
commit
f7a6785e12
@ -125,8 +125,10 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
|
||||
s->usr2 &= ~USR2_RDR;
|
||||
s->uts1 |= UTS1_RXEMPTY;
|
||||
imx_update(s);
|
||||
if (s->chr) {
|
||||
qemu_chr_accept_input(s->chr);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
|
||||
case 0x20: /* UCR1 */
|
||||
@ -212,9 +214,11 @@ static void imx_serial_write(void *opaque, hwaddr offset,
|
||||
}
|
||||
if (value & UCR2_RXEN) {
|
||||
if (!(s->ucr2 & UCR2_RXEN)) {
|
||||
if (s->chr) {
|
||||
qemu_chr_accept_input(s->chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
s->ucr2 = value & 0xffff;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user