uart drivers: use xzalloc instead of xmalloc
The flags in struct console_device have to be initialized to zero. Otherwise the following can happen: - console_register sets the initial baudrate of a new console before we set the global console init state to CONSOLE_INIT_FULL. - In console_baudrate_set we test whether the current console is active which may be true because of unitialized flags. - we then call getc() to wait for the user to accept the new settings and we are stuck because of the CONSOLE_UNINITIALIZED state we will never get anything from getc(). Looking back this explains some cases for me when barebox refused to start and I really wonder why this did not become a more visible problem before. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
f02a48ea00
commit
4b8750c956
|
@ -159,7 +159,7 @@ static int pl011_probe(struct device_d *dev)
|
|||
struct amba_uart_port *uart;
|
||||
struct console_device *cdev;
|
||||
|
||||
uart = xmalloc(sizeof(struct amba_uart_port));
|
||||
uart = xzalloc(sizeof(struct amba_uart_port));
|
||||
uart->clk = clk_get(dev, NULL);
|
||||
|
||||
if (IS_ERR(uart->clk))
|
||||
|
|
|
@ -399,7 +399,7 @@ static int atmel_serial_probe(struct device_d *dev)
|
|||
struct atmel_uart_port *uart;
|
||||
struct console_device *cdev;
|
||||
|
||||
uart = xmalloc(sizeof(struct atmel_uart_port));
|
||||
uart = xzalloc(sizeof(struct atmel_uart_port));
|
||||
cdev = &uart->uart;
|
||||
dev->type_data = cdev;
|
||||
cdev->dev = dev;
|
||||
|
|
|
@ -85,7 +85,7 @@ static int altera_serial_probe(struct device_d *dev)
|
|||
struct console_device *cdev;
|
||||
struct altera_serial_priv *priv;
|
||||
|
||||
priv = xmalloc(sizeof(*priv));
|
||||
priv = xzalloc(sizeof(*priv));
|
||||
cdev = &priv->cdev;
|
||||
|
||||
priv->regs = dev_request_mem_region(dev, 0);
|
||||
|
|
|
@ -90,7 +90,7 @@ static int altera_serial_jtag_probe(struct device_d *dev) {
|
|||
struct console_device *cdev;
|
||||
struct altera_serial_jtag_priv *priv;
|
||||
|
||||
priv = xmalloc(sizeof(*priv));
|
||||
priv = xzalloc(sizeof(*priv));
|
||||
cdev = &priv->cdev;
|
||||
|
||||
priv->regs = dev_request_mem_region(dev, 0);
|
||||
|
|
|
@ -115,7 +115,7 @@ static int blackfin_serial_probe(struct device_d *dev)
|
|||
{
|
||||
struct console_device *cdev;
|
||||
|
||||
cdev = xmalloc(sizeof(struct console_device));
|
||||
cdev = xzalloc(sizeof(struct console_device));
|
||||
dev->type_data = cdev;
|
||||
cdev->dev = dev;
|
||||
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
|
||||
|
|
|
@ -320,7 +320,7 @@ static int imx_serial_probe(struct device_d *dev)
|
|||
struct imx_serial_priv *priv;
|
||||
uint32_t val;
|
||||
|
||||
priv = xmalloc(sizeof(*priv));
|
||||
priv = xzalloc(sizeof(*priv));
|
||||
cdev = &priv->cdev;
|
||||
|
||||
priv->regs = dev_request_mem_region(dev, 0);
|
||||
|
|
|
@ -140,7 +140,7 @@ static int netx_serial_probe(struct device_d *dev)
|
|||
{
|
||||
struct console_device *cdev;
|
||||
|
||||
cdev = xmalloc(sizeof(struct console_device));
|
||||
cdev = xzalloc(sizeof(struct console_device));
|
||||
dev->type_data = cdev;
|
||||
dev->priv = dev_request_mem_region(dev, 0);
|
||||
cdev->dev = dev;
|
||||
|
|
|
@ -141,7 +141,7 @@ static int pl010_probe(struct device_d *dev)
|
|||
{
|
||||
struct console_device *cdev;
|
||||
|
||||
cdev = xmalloc(sizeof(struct console_device));
|
||||
cdev = xzalloc(sizeof(struct console_device));
|
||||
dev->type_data = cdev;
|
||||
dev->priv = dev_request_mem_region(dev, 0);
|
||||
cdev->dev = dev;
|
||||
|
|
|
@ -129,7 +129,7 @@ static int s3c24x0_serial_probe(struct device_d *dev)
|
|||
{
|
||||
struct console_device *cdev;
|
||||
|
||||
cdev = xmalloc(sizeof(struct console_device));
|
||||
cdev = xzalloc(sizeof(struct console_device));
|
||||
dev->type_data = cdev;
|
||||
dev->priv = dev_request_mem_region(dev, 0);
|
||||
cdev->dev = dev;
|
||||
|
|
Loading…
Reference in New Issue