Commit c5f33785 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'tty-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
 "Here are some tty and serial driver fixes for 5.7-rc3.

  The "largest" in here are a number of reverts for previous changes to
  the uartps serial driver that turned out to not be a good idea at all.

  The others are just small fixes found by people and tools. Included in
  here is a much-reported symbol export needed by previous changes that
  happened in 5.7-rc1. All of these have been in linux-next for a while
  with no reported issues"

* tag 'tty-5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  tty: hvc: fix buffer overflow during hvc_alloc().
  tty: rocket, avoid OOB access
  tty: serial: bcm63xx: fix missing clk_put() in bcm63xx_uart
  vt: don't hardcode the mem allocation upper bound
  tty: serial: owl: add "much needed" clk_prepare_enable()
  vt: don't use kmalloc() for the unicode screen buffer
  tty/sysrq: Export sysrq_mask(), sysrq_toggle_support()
  serial: sh-sci: Make sure status register SCxSR is read in correct sequence
  serial: sunhv: Initialize lock for non-registered console
  Revert "serial: uartps: Register own uart console and driver structures"
  Revert "serial: uartps: Move Port ID to device data structure"
  Revert "serial: uartps: Change uart ID port allocation"
  Revert "serial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES"
  Revert "serial: uartps: Fix error path when alloc failed"
  Revert "serial: uartps: Use the same dynamic major number for all ports"
  Revert "serial: uartps: Fix uartps_major handling"
parents f6da8bd1 9a9fc42b
...@@ -302,10 +302,6 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops) ...@@ -302,10 +302,6 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
vtermnos[index] = vtermno; vtermnos[index] = vtermno;
cons_ops[index] = ops; cons_ops[index] = ops;
/* reserve all indices up to and including this index */
if (last_hvc < index)
last_hvc = index;
/* check if we need to re-register the kernel console */ /* check if we need to re-register the kernel console */
hvc_check_console(index); hvc_check_console(index);
...@@ -960,13 +956,22 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, ...@@ -960,13 +956,22 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
cons_ops[i] == hp->ops) cons_ops[i] == hp->ops)
break; break;
if (i >= MAX_NR_HVC_CONSOLES) {
/* find 'empty' slot for console */
for (i = 0; i < MAX_NR_HVC_CONSOLES && vtermnos[i] != -1; i++) {
}
/* no matching slot, just use a counter */ /* no matching slot, just use a counter */
if (i >= MAX_NR_HVC_CONSOLES) if (i == MAX_NR_HVC_CONSOLES)
i = ++last_hvc; i = ++last_hvc + MAX_NR_HVC_CONSOLES;
}
hp->index = i; hp->index = i;
if (i < MAX_NR_HVC_CONSOLES) {
cons_ops[i] = ops; cons_ops[i] = ops;
vtermnos[i] = vtermno; vtermnos[i] = vtermno;
}
list_add_tail(&(hp->next), &hvc_structs); list_add_tail(&(hp->next), &hvc_structs);
mutex_unlock(&hvc_structs_mutex); mutex_unlock(&hvc_structs_mutex);
......
...@@ -632,6 +632,7 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) ...@@ -632,6 +632,7 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
tty_port_init(&info->port); tty_port_init(&info->port);
info->port.ops = &rocket_port_ops; info->port.ops = &rocket_port_ops;
info->flags &= ~ROCKET_MODE_MASK; info->flags &= ~ROCKET_MODE_MASK;
if (board < ARRAY_SIZE(pc104) && line < ARRAY_SIZE(pc104_1))
switch (pc104[board][line]) { switch (pc104[board][line]) {
case 422: case 422:
info->flags |= ROCKET_MODE_RS422; info->flags |= ROCKET_MODE_RS422;
...@@ -644,6 +645,8 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) ...@@ -644,6 +645,8 @@ init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
info->flags |= ROCKET_MODE_RS232; info->flags |= ROCKET_MODE_RS232;
break; break;
} }
else
info->flags |= ROCKET_MODE_RS232;
info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR; info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR;
if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) {
......
...@@ -843,8 +843,10 @@ static int bcm_uart_probe(struct platform_device *pdev) ...@@ -843,8 +843,10 @@ static int bcm_uart_probe(struct platform_device *pdev)
if (IS_ERR(clk) && pdev->dev.of_node) if (IS_ERR(clk) && pdev->dev.of_node)
clk = of_clk_get(pdev->dev.of_node, 0); clk = of_clk_get(pdev->dev.of_node, 0);
if (IS_ERR(clk)) if (IS_ERR(clk)) {
clk_put(clk);
return -ENODEV; return -ENODEV;
}
port->iotype = UPIO_MEM; port->iotype = UPIO_MEM;
port->irq = res_irq->start; port->irq = res_irq->start;
......
...@@ -680,6 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev) ...@@ -680,6 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev)
return PTR_ERR(owl_port->clk); return PTR_ERR(owl_port->clk);
} }
ret = clk_prepare_enable(owl_port->clk);
if (ret) {
dev_err(&pdev->dev, "could not enable clk\n");
return ret;
}
owl_port->port.dev = &pdev->dev; owl_port->port.dev = &pdev->dev;
owl_port->port.line = pdev->id; owl_port->port.line = pdev->id;
owl_port->port.type = PORT_OWL; owl_port->port.type = PORT_OWL;
...@@ -712,6 +718,7 @@ static int owl_uart_remove(struct platform_device *pdev) ...@@ -712,6 +718,7 @@ static int owl_uart_remove(struct platform_device *pdev)
uart_remove_one_port(&owl_uart_driver, &owl_port->port); uart_remove_one_port(&owl_uart_driver, &owl_port->port);
owl_uart_ports[pdev->id] = NULL; owl_uart_ports[pdev->id] = NULL;
clk_disable_unprepare(owl_port->clk);
return 0; return 0;
} }
......
...@@ -870,9 +870,16 @@ static void sci_receive_chars(struct uart_port *port) ...@@ -870,9 +870,16 @@ static void sci_receive_chars(struct uart_port *port)
tty_insert_flip_char(tport, c, TTY_NORMAL); tty_insert_flip_char(tport, c, TTY_NORMAL);
} else { } else {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
char c = serial_port_in(port, SCxRDR); char c;
if (port->type == PORT_SCIF ||
port->type == PORT_HSCIF) {
status = serial_port_in(port, SCxSR);
c = serial_port_in(port, SCxRDR);
} else {
c = serial_port_in(port, SCxRDR);
status = serial_port_in(port, SCxSR); status = serial_port_in(port, SCxSR);
}
if (uart_handle_sysrq_char(port, c)) { if (uart_handle_sysrq_char(port, c)) {
count--; i--; count--; i--;
continue; continue;
......
...@@ -567,6 +567,9 @@ static int hv_probe(struct platform_device *op) ...@@ -567,6 +567,9 @@ static int hv_probe(struct platform_device *op)
sunserial_console_match(&sunhv_console, op->dev.of_node, sunserial_console_match(&sunhv_console, op->dev.of_node,
&sunhv_reg, port->line, false); &sunhv_reg, port->line, false);
/* We need to initialize lock even for non-registered console */
spin_lock_init(&port->lock);
err = uart_add_one_port(&sunhv_reg, port); err = uart_add_one_port(&sunhv_reg, port);
if (err) if (err)
goto out_unregister_driver; goto out_unregister_driver;
......
...@@ -26,13 +26,15 @@ ...@@ -26,13 +26,15 @@
#define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_TTY_NAME "ttyPS"
#define CDNS_UART_NAME "xuartps" #define CDNS_UART_NAME "xuartps"
#define CDNS_UART_MAJOR 0 /* use dynamic node allocation */
#define CDNS_UART_MINOR 0 /* works best with devtmpfs */
#define CDNS_UART_NR_PORTS 16
#define CDNS_UART_FIFO_SIZE 64 /* FIFO size */ #define CDNS_UART_FIFO_SIZE 64 /* FIFO size */
#define CDNS_UART_REGISTER_SPACE 0x1000 #define CDNS_UART_REGISTER_SPACE 0x1000
#define TX_TIMEOUT 500000 #define TX_TIMEOUT 500000
/* Rx Trigger level */ /* Rx Trigger level */
static int rx_trigger_level = 56; static int rx_trigger_level = 56;
static int uartps_major;
module_param(rx_trigger_level, uint, 0444); module_param(rx_trigger_level, uint, 0444);
MODULE_PARM_DESC(rx_trigger_level, "Rx trigger level, 1-63 bytes"); MODULE_PARM_DESC(rx_trigger_level, "Rx trigger level, 1-63 bytes");
...@@ -188,7 +190,6 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); ...@@ -188,7 +190,6 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255");
* @pclk: APB clock * @pclk: APB clock
* @cdns_uart_driver: Pointer to UART driver * @cdns_uart_driver: Pointer to UART driver
* @baud: Current baud rate * @baud: Current baud rate
* @id: Port ID
* @clk_rate_change_nb: Notifier block for clock changes * @clk_rate_change_nb: Notifier block for clock changes
* @quirks: Flags for RXBS support. * @quirks: Flags for RXBS support.
*/ */
...@@ -198,7 +199,6 @@ struct cdns_uart { ...@@ -198,7 +199,6 @@ struct cdns_uart {
struct clk *pclk; struct clk *pclk;
struct uart_driver *cdns_uart_driver; struct uart_driver *cdns_uart_driver;
unsigned int baud; unsigned int baud;
int id;
struct notifier_block clk_rate_change_nb; struct notifier_block clk_rate_change_nb;
u32 quirks; u32 quirks;
bool cts_override; bool cts_override;
...@@ -1133,6 +1133,8 @@ static const struct uart_ops cdns_uart_ops = { ...@@ -1133,6 +1133,8 @@ static const struct uart_ops cdns_uart_ops = {
#endif #endif
}; };
static struct uart_driver cdns_uart_uart_driver;
#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
/** /**
* cdns_uart_console_putchar - write the character to the FIFO buffer * cdns_uart_console_putchar - write the character to the FIFO buffer
...@@ -1272,6 +1274,16 @@ static int cdns_uart_console_setup(struct console *co, char *options) ...@@ -1272,6 +1274,16 @@ static int cdns_uart_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow); return uart_set_options(port, co, baud, parity, bits, flow);
} }
static struct console cdns_uart_console = {
.name = CDNS_UART_TTY_NAME,
.write = cdns_uart_console_write,
.device = uart_console_device,
.setup = cdns_uart_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */
.data = &cdns_uart_uart_driver,
};
#endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
...@@ -1403,89 +1415,8 @@ static const struct of_device_id cdns_uart_of_match[] = { ...@@ -1403,89 +1415,8 @@ static const struct of_device_id cdns_uart_of_match[] = {
}; };
MODULE_DEVICE_TABLE(of, cdns_uart_of_match); MODULE_DEVICE_TABLE(of, cdns_uart_of_match);
/* /* Temporary variable for storing number of instances */
* Maximum number of instances without alias IDs but if there is alias static int instances;
* which target "< MAX_UART_INSTANCES" range this ID can't be used.
*/
#define MAX_UART_INSTANCES 32
/* Stores static aliases list */
static DECLARE_BITMAP(alias_bitmap, MAX_UART_INSTANCES);
static int alias_bitmap_initialized;
/* Stores actual bitmap of allocated IDs with alias IDs together */
static DECLARE_BITMAP(bitmap, MAX_UART_INSTANCES);
/* Protect bitmap operations to have unique IDs */
static DEFINE_MUTEX(bitmap_lock);
static int cdns_get_id(struct platform_device *pdev)
{
int id, ret;
mutex_lock(&bitmap_lock);
/* Alias list is stable that's why get alias bitmap only once */
if (!alias_bitmap_initialized) {
ret = of_alias_get_alias_list(cdns_uart_of_match, "serial",
alias_bitmap, MAX_UART_INSTANCES);
if (ret && ret != -EOVERFLOW) {
mutex_unlock(&bitmap_lock);
return ret;
}
alias_bitmap_initialized++;
}
/* Make sure that alias ID is not taken by instance without alias */
bitmap_or(bitmap, bitmap, alias_bitmap, MAX_UART_INSTANCES);
dev_dbg(&pdev->dev, "Alias bitmap: %*pb\n",
MAX_UART_INSTANCES, bitmap);
/* Look for a serialN alias */
id = of_alias_get_id(pdev->dev.of_node, "serial");
if (id < 0) {
dev_warn(&pdev->dev,
"No serial alias passed. Using the first free id\n");
/*
* Start with id 0 and check if there is no serial0 alias
* which points to device which is compatible with this driver.
* If alias exists then try next free position.
*/
id = 0;
for (;;) {
dev_info(&pdev->dev, "Checking id %d\n", id);
id = find_next_zero_bit(bitmap, MAX_UART_INSTANCES, id);
/* No free empty instance */
if (id == MAX_UART_INSTANCES) {
dev_err(&pdev->dev, "No free ID\n");
mutex_unlock(&bitmap_lock);
return -EINVAL;
}
dev_dbg(&pdev->dev, "The empty id is %d\n", id);
/* Check if ID is empty */
if (!test_and_set_bit(id, bitmap)) {
/* Break the loop if bit is taken */
dev_dbg(&pdev->dev,
"Selected ID %d allocation passed\n",
id);
break;
}
dev_dbg(&pdev->dev,
"Selected ID %d allocation failed\n", id);
/* if taking bit fails then try next one */
id++;
}
}
mutex_unlock(&bitmap_lock);
return id;
}
/** /**
* cdns_uart_probe - Platform driver probe * cdns_uart_probe - Platform driver probe
...@@ -1495,16 +1426,11 @@ static int cdns_get_id(struct platform_device *pdev) ...@@ -1495,16 +1426,11 @@ static int cdns_get_id(struct platform_device *pdev)
*/ */
static int cdns_uart_probe(struct platform_device *pdev) static int cdns_uart_probe(struct platform_device *pdev)
{ {
int rc, irq; int rc, id, irq;
struct uart_port *port; struct uart_port *port;
struct resource *res; struct resource *res;
struct cdns_uart *cdns_uart_data; struct cdns_uart *cdns_uart_data;
const struct of_device_id *match; const struct of_device_id *match;
struct uart_driver *cdns_uart_uart_driver;
char *driver_name;
#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
struct console *cdns_uart_console;
#endif
cdns_uart_data = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data), cdns_uart_data = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data),
GFP_KERNEL); GFP_KERNEL);
...@@ -1514,64 +1440,35 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1514,64 +1440,35 @@ static int cdns_uart_probe(struct platform_device *pdev)
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;
cdns_uart_uart_driver = devm_kzalloc(&pdev->dev, /* Look for a serialN alias */
sizeof(*cdns_uart_uart_driver), id = of_alias_get_id(pdev->dev.of_node, "serial");
GFP_KERNEL); if (id < 0)
if (!cdns_uart_uart_driver) id = 0;
return -ENOMEM;
cdns_uart_data->id = cdns_get_id(pdev);
if (cdns_uart_data->id < 0)
return cdns_uart_data->id;
/* There is a need to use unique driver name */ if (id >= CDNS_UART_NR_PORTS) {
driver_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%d", dev_err(&pdev->dev, "Cannot get uart_port structure\n");
CDNS_UART_NAME, cdns_uart_data->id); return -ENODEV;
if (!driver_name) {
rc = -ENOMEM;
goto err_out_id;
} }
cdns_uart_uart_driver->owner = THIS_MODULE; if (!cdns_uart_uart_driver.state) {
cdns_uart_uart_driver->driver_name = driver_name; cdns_uart_uart_driver.owner = THIS_MODULE;
cdns_uart_uart_driver->dev_name = CDNS_UART_TTY_NAME; cdns_uart_uart_driver.driver_name = CDNS_UART_NAME;
cdns_uart_uart_driver->major = uartps_major; cdns_uart_uart_driver.dev_name = CDNS_UART_TTY_NAME;
cdns_uart_uart_driver->minor = cdns_uart_data->id; cdns_uart_uart_driver.major = CDNS_UART_MAJOR;
cdns_uart_uart_driver->nr = 1; cdns_uart_uart_driver.minor = CDNS_UART_MINOR;
cdns_uart_uart_driver.nr = CDNS_UART_NR_PORTS;
#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
cdns_uart_console = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_console), cdns_uart_uart_driver.cons = &cdns_uart_console;
GFP_KERNEL);
if (!cdns_uart_console) {
rc = -ENOMEM;
goto err_out_id;
}
strncpy(cdns_uart_console->name, CDNS_UART_TTY_NAME,
sizeof(cdns_uart_console->name));
cdns_uart_console->index = cdns_uart_data->id;
cdns_uart_console->write = cdns_uart_console_write;
cdns_uart_console->device = uart_console_device;
cdns_uart_console->setup = cdns_uart_console_setup;
cdns_uart_console->flags = CON_PRINTBUFFER;
cdns_uart_console->data = cdns_uart_uart_driver;
cdns_uart_uart_driver->cons = cdns_uart_console;
#endif #endif
rc = uart_register_driver(cdns_uart_uart_driver); rc = uart_register_driver(&cdns_uart_uart_driver);
if (rc < 0) { if (rc < 0) {
dev_err(&pdev->dev, "Failed to register driver\n"); dev_err(&pdev->dev, "Failed to register driver\n");
goto err_out_id; return rc;
}
} }
cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver; cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver;
/*
* Setting up proper name_base needs to be done after uart
* registration because tty_driver structure is not filled.
* name_base is 0 by default.
*/
cdns_uart_uart_driver->tty_driver->name_base = cdns_uart_data->id;
match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); match = of_match_node(cdns_uart_of_match, pdev->dev.of_node);
if (match && match->data) { if (match && match->data) {
...@@ -1649,6 +1546,7 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1649,6 +1546,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
port->ops = &cdns_uart_ops; port->ops = &cdns_uart_ops;
port->fifosize = CDNS_UART_FIFO_SIZE; port->fifosize = CDNS_UART_FIFO_SIZE;
port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE); port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE);
port->line = id;
/* /*
* Register the port. * Register the port.
...@@ -1680,7 +1578,7 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1680,7 +1578,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
console_port = port; console_port = port;
#endif #endif
rc = uart_add_one_port(cdns_uart_uart_driver, port); rc = uart_add_one_port(&cdns_uart_uart_driver, port);
if (rc) { if (rc) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"uart_add_one_port() failed; err=%i\n", rc); "uart_add_one_port() failed; err=%i\n", rc);
...@@ -1690,13 +1588,15 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1690,13 +1588,15 @@ static int cdns_uart_probe(struct platform_device *pdev)
#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
/* This is not port which is used for console that's why clean it up */ /* This is not port which is used for console that's why clean it up */
if (console_port == port && if (console_port == port &&
!(cdns_uart_uart_driver->cons->flags & CON_ENABLED)) !(cdns_uart_uart_driver.cons->flags & CON_ENABLED))
console_port = NULL; console_port = NULL;
#endif #endif
uartps_major = cdns_uart_uart_driver->tty_driver->major;
cdns_uart_data->cts_override = of_property_read_bool(pdev->dev.of_node, cdns_uart_data->cts_override = of_property_read_bool(pdev->dev.of_node,
"cts-override"); "cts-override");
instances++;
return 0; return 0;
err_out_pm_disable: err_out_pm_disable:
...@@ -1712,12 +1612,8 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1712,12 +1612,8 @@ static int cdns_uart_probe(struct platform_device *pdev)
err_out_clk_dis_pclk: err_out_clk_dis_pclk:
clk_disable_unprepare(cdns_uart_data->pclk); clk_disable_unprepare(cdns_uart_data->pclk);
err_out_unregister_driver: err_out_unregister_driver:
if (!instances)
uart_unregister_driver(cdns_uart_data->cdns_uart_driver); uart_unregister_driver(cdns_uart_data->cdns_uart_driver);
err_out_id:
mutex_lock(&bitmap_lock);
if (cdns_uart_data->id < MAX_UART_INSTANCES)
clear_bit(cdns_uart_data->id, bitmap);
mutex_unlock(&bitmap_lock);
return rc; return rc;
} }
...@@ -1740,10 +1636,6 @@ static int cdns_uart_remove(struct platform_device *pdev) ...@@ -1740,10 +1636,6 @@ static int cdns_uart_remove(struct platform_device *pdev)
#endif #endif
rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port); rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port);
port->mapbase = 0; port->mapbase = 0;
mutex_lock(&bitmap_lock);
if (cdns_uart_data->id < MAX_UART_INSTANCES)
clear_bit(cdns_uart_data->id, bitmap);
mutex_unlock(&bitmap_lock);
clk_disable_unprepare(cdns_uart_data->uartclk); clk_disable_unprepare(cdns_uart_data->uartclk);
clk_disable_unprepare(cdns_uart_data->pclk); clk_disable_unprepare(cdns_uart_data->pclk);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
...@@ -1756,12 +1648,7 @@ static int cdns_uart_remove(struct platform_device *pdev) ...@@ -1756,12 +1648,7 @@ static int cdns_uart_remove(struct platform_device *pdev)
console_port = NULL; console_port = NULL;
#endif #endif
/* If this is last instance major number should be initialized */ if (!--instances)
mutex_lock(&bitmap_lock);
if (bitmap_empty(bitmap, MAX_UART_INSTANCES))
uartps_major = 0;
mutex_unlock(&bitmap_lock);
uart_unregister_driver(cdns_uart_data->cdns_uart_driver); uart_unregister_driver(cdns_uart_data->cdns_uart_driver);
return rc; return rc;
} }
......
...@@ -74,6 +74,7 @@ int sysrq_mask(void) ...@@ -74,6 +74,7 @@ int sysrq_mask(void)
return 1; return 1;
return sysrq_enabled; return sysrq_enabled;
} }
EXPORT_SYMBOL_GPL(sysrq_mask);
/* /*
* A value of 1 means 'all', other nonzero values are an op mask: * A value of 1 means 'all', other nonzero values are an op mask:
...@@ -1058,6 +1059,7 @@ int sysrq_toggle_support(int enable_mask) ...@@ -1058,6 +1059,7 @@ int sysrq_toggle_support(int enable_mask)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(sysrq_toggle_support);
static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
struct sysrq_key_op *remove_op_p) struct sysrq_key_op *remove_op_p)
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/kd.h> #include <linux/kd.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/major.h> #include <linux/major.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/console.h> #include <linux/console.h>
...@@ -350,7 +351,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows) ...@@ -350,7 +351,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
/* allocate everything in one go */ /* allocate everything in one go */
memsize = cols * rows * sizeof(char32_t); memsize = cols * rows * sizeof(char32_t);
memsize += rows * sizeof(char32_t *); memsize += rows * sizeof(char32_t *);
p = kmalloc(memsize, GFP_KERNEL); p = vmalloc(memsize);
if (!p) if (!p)
return NULL; return NULL;
...@@ -366,7 +367,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows) ...@@ -366,7 +367,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr) static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr)
{ {
kfree(vc->vc_uni_screen); vfree(vc->vc_uni_screen);
vc->vc_uni_screen = new_uniscr; vc->vc_uni_screen = new_uniscr;
} }
...@@ -1206,7 +1207,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, ...@@ -1206,7 +1207,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
return 0; return 0;
if (new_screen_size > (4 << 20)) if (new_screen_size > KMALLOC_MAX_SIZE)
return -EINVAL; return -EINVAL;
newscreen = kzalloc(new_screen_size, GFP_USER); newscreen = kzalloc(new_screen_size, GFP_USER);
if (!newscreen) if (!newscreen)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment