···2454 .resume = serial8250_resume,2455 .driver = {2456 .name = "serial8250",02457 },2458};2459···2595 if (ret)2596 goto out;25972598- serial8250_isa_devs = platform_device_register_simple("serial8250",2599- PLAT8250_DEV_LEGACY, NULL, 0);2600- if (IS_ERR(serial8250_isa_devs)) {2601- ret = PTR_ERR(serial8250_isa_devs);2602- goto unreg;00002603 }000026042605 serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);26062607- ret = platform_driver_register(&serial8250_isa_driver);2608- if (ret == 0)2609- goto out;26102611- platform_device_unregister(serial8250_isa_devs);2612- unreg:0002613 uart_unregister_driver(&serial8250_reg);2614 out:2615 return ret;
···2454 .resume = serial8250_resume,2455 .driver = {2456 .name = "serial8250",2457+ .owner = THIS_MODULE,2458 },2459};2460···2594 if (ret)2595 goto out;25962597+ ret = platform_driver_register(&serial8250_isa_driver);2598+ if (ret)2599+ goto unreg_uart_drv;2600+2601+ serial8250_isa_devs = platform_device_alloc("serial8250",2602+ PLAT8250_DEV_LEGACY);2603+ if (!serial8250_isa_devs) {2604+ ret = -ENOMEM;2605+ goto unreg_plat_drv;2606 }2607+2608+ ret = platform_device_add(serial8250_isa_devs);2609+ if (ret)2610+ goto put_dev;26112612 serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);26132614+ goto out;0026152616+ put_dev:2617+ platform_device_put(serial8250_isa_devs);2618+ unreg_plat_drv:2619+ platform_driver_unregister(&serial8250_isa_driver);2620+ unreg_uart_drv:2621 uart_unregister_driver(&serial8250_reg);2622 out:2623 return ret;
+1-1
drivers/serial/Kconfig
···847848config SERIAL_M32R_PLDSIO849 bool "M32R SIO I/F on a PLD"850- depends on SERIAL_M32R_SIO=y && (PLAT_OPSPUT || PALT_USRV || PLAT_M32700UT)851 default n852 help853 Say Y here if you want to use the M32R serial controller
···847848config SERIAL_M32R_PLDSIO849 bool "M32R SIO I/F on a PLD"850+ depends on SERIAL_M32R_SIO=y && (PLAT_OPSPUT || PLAT_USRV || PLAT_M32700UT)851 default n852 help853 Say Y here if you want to use the M32R serial controller
+4-5
drivers/serial/pmac_zilog.c
···69#include <asm/pmac_feature.h>70#include <asm/dbdma.h>71#include <asm/macio.h>72-#include <asm/semaphore.h>7374#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)75#define SUPPORT_SYSRQ···1592 state = pmz_uart_reg.state + uap->port.line;15931594 mutex_lock(&pmz_irq_mutex);1595- down(&state->sem);15961597 spin_lock_irqsave(&uap->port.lock, flags);1598···1623 /* Shut the chip down */1624 pmz_set_scc_power(uap, 0);16251626- up(&state->sem);1627 mutex_unlock(&pmz_irq_mutex);16281629 pmz_debug("suspend, switching complete\n");···1652 state = pmz_uart_reg.state + uap->port.line;16531654 mutex_lock(&pmz_irq_mutex);1655- down(&state->sem);16561657 spin_lock_irqsave(&uap->port.lock, flags);1658 if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) {···1684 }16851686 bail:1687- up(&state->sem);1688 mutex_unlock(&pmz_irq_mutex);16891690 /* Right now, we deal with delay by blocking here, I'll be
···69#include <asm/pmac_feature.h>70#include <asm/dbdma.h>71#include <asm/macio.h>07273#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)74#define SUPPORT_SYSRQ···1593 state = pmz_uart_reg.state + uap->port.line;15941595 mutex_lock(&pmz_irq_mutex);1596+ mutex_lock(&state->mutex);15971598 spin_lock_irqsave(&uap->port.lock, flags);1599···1624 /* Shut the chip down */1625 pmz_set_scc_power(uap, 0);16261627+ mutex_unlock(&state->mutex);1628 mutex_unlock(&pmz_irq_mutex);16291630 pmz_debug("suspend, switching complete\n");···1653 state = pmz_uart_reg.state + uap->port.line;16541655 mutex_lock(&pmz_irq_mutex);1656+ mutex_lock(&state->mutex);16571658 spin_lock_irqsave(&uap->port.lock, flags);1659 if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) {···1685 }16861687 bail:1688+ mutex_unlock(&state->mutex);1689 mutex_unlock(&pmz_irq_mutex);16901691 /* Right now, we deal with delay by blocking here, I'll be
+30-30
drivers/serial/serial_core.c
···638 * module insertion/removal doesn't change anything639 * under us.640 */641- down(&state->sem);642643 change_irq = new_serial.irq != port->irq;644···797 } else798 retval = uart_startup(state, 1);799 exit:800- up(&state->sem);801 return retval;802}803···834 struct uart_port *port = state->port;835 int result = -EIO;836837- down(&state->sem);838 if ((!file || !tty_hung_up_p(file)) &&839 !(tty->flags & (1 << TTY_IO_ERROR))) {840 result = port->mctrl;···843 result |= port->ops->get_mctrl(port);844 spin_unlock_irq(&port->lock);845 }846- up(&state->sem);847848 return result;849}···856 struct uart_port *port = state->port;857 int ret = -EIO;858859- down(&state->sem);860 if ((!file || !tty_hung_up_p(file)) &&861 !(tty->flags & (1 << TTY_IO_ERROR))) {862 uart_update_mctrl(port, set, clear);863 ret = 0;864 }865- up(&state->sem);866 return ret;867}868···873874 BUG_ON(!kernel_locked());875876- down(&state->sem);877878 if (port->type != PORT_UNKNOWN)879 port->ops->break_ctl(port, break_state);880881- up(&state->sem);882}883884static int uart_do_autoconfig(struct uart_state *state)···894 * changing, and hence any extra opens of the port while895 * we're auto-configuring.896 */897- if (down_interruptible(&state->sem))898 return -ERESTARTSYS;899900 ret = -EBUSY;···920921 ret = uart_startup(state, 1);922 }923- up(&state->sem);924 return ret;925}926···1074 if (ret != -ENOIOCTLCMD)1075 goto out;10761077- down(&state->sem);10781079 if (tty_hung_up_p(filp)) {1080 ret = -EIO;···1098 }1099 }1100 out_up:1101- up(&state->sem);1102 out:1103 return ret;1104}···11861187 DPRINTK("uart_close(%d) called\n", port->line);11881189- down(&state->sem);11901191 if (tty_hung_up_p(filp))1192 goto done;···1260 wake_up_interruptible(&state->info->open_wait);12611262 done:1263- up(&state->sem);1264}12651266static void uart_wait_until_sent(struct tty_struct *tty, int timeout)···1334 BUG_ON(!kernel_locked());1335 DPRINTK("uart_hangup(%d)\n", state->port->line);13361337- down(&state->sem);1338 if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) {1339 uart_flush_buffer(tty);1340 uart_shutdown(state);···1344 wake_up_interruptible(&state->info->open_wait);1345 wake_up_interruptible(&state->info->delta_msr_wait);1346 }1347- up(&state->sem);1348}13491350/*···1447 if (mctrl & TIOCM_CAR)1448 break;14491450- up(&state->sem);1451 schedule();1452- down(&state->sem);14531454 if (signal_pending(current))1455 break;···14751476 mutex_lock(&port_mutex);1477 state = drv->state + line;1478- if (down_interruptible(&state->sem)) {1479 state = ERR_PTR(-ERESTARTSYS);1480 goto out;1481 }···1483 state->count++;1484 if (!state->port) {1485 state->count--;1486- up(&state->sem);1487 state = ERR_PTR(-ENXIO);1488 goto out;1489 }···1504 (unsigned long)state);1505 } else {1506 state->count--;1507- up(&state->sem);1508 state = ERR_PTR(-ENOMEM);1509 }1510 }···1571 if (tty_hung_up_p(filp)) {1572 retval = -EAGAIN;1573 state->count--;1574- up(&state->sem);1575 goto fail;1576 }1577···1591 */1592 if (retval == 0)1593 retval = uart_block_til_ready(filp, state);1594- up(&state->sem);15951596 /*1597 * If this is the first open to succeed, adjust things to suit.···1867{1868 struct uart_state *state = drv->state + port->line;18691870- down(&state->sem);18711872 if (state->info && state->info->flags & UIF_INITIALIZED) {1873 struct uart_ops *ops = port->ops;···18961897 uart_change_pm(state, 3);18981899- up(&state->sem);19001901 return 0;1902}···1905{1906 struct uart_state *state = drv->state + port->line;19071908- down(&state->sem);19091910 uart_change_pm(state, 0);1911···1954 }1955 }19561957- up(&state->sem);19581959 return 0;1960}···2049 if (info && info->tty)2050 tty_vhangup(info->tty);20512052- down(&state->sem);20532054 state->info = NULL;2055···2072 kfree(info);2073 }20742075- up(&state->sem);2076}20772078static struct tty_operations uart_ops = {···2161 state->close_delay = 500; /* .5 seconds */2162 state->closing_wait = 30000; /* 30 seconds */21632164- init_MUTEX(&state->sem);2165 }21662167 retval = tty_register_driver(normal);
···638 * module insertion/removal doesn't change anything639 * under us.640 */641+ mutex_lock(&state->mutex);642643 change_irq = new_serial.irq != port->irq;644···797 } else798 retval = uart_startup(state, 1);799 exit:800+ mutex_unlock(&state->mutex);801 return retval;802}803···834 struct uart_port *port = state->port;835 int result = -EIO;836837+ mutex_lock(&state->mutex);838 if ((!file || !tty_hung_up_p(file)) &&839 !(tty->flags & (1 << TTY_IO_ERROR))) {840 result = port->mctrl;···843 result |= port->ops->get_mctrl(port);844 spin_unlock_irq(&port->lock);845 }846+ mutex_unlock(&state->mutex);847848 return result;849}···856 struct uart_port *port = state->port;857 int ret = -EIO;858859+ mutex_lock(&state->mutex);860 if ((!file || !tty_hung_up_p(file)) &&861 !(tty->flags & (1 << TTY_IO_ERROR))) {862 uart_update_mctrl(port, set, clear);863 ret = 0;864 }865+ mutex_unlock(&state->mutex);866 return ret;867}868···873874 BUG_ON(!kernel_locked());875876+ mutex_lock(&state->mutex);877878 if (port->type != PORT_UNKNOWN)879 port->ops->break_ctl(port, break_state);880881+ mutex_unlock(&state->mutex);882}883884static int uart_do_autoconfig(struct uart_state *state)···894 * changing, and hence any extra opens of the port while895 * we're auto-configuring.896 */897+ if (mutex_lock_interruptible(&state->mutex))898 return -ERESTARTSYS;899900 ret = -EBUSY;···920921 ret = uart_startup(state, 1);922 }923+ mutex_unlock(&state->mutex);924 return ret;925}926···1074 if (ret != -ENOIOCTLCMD)1075 goto out;10761077+ mutex_lock(&state->mutex);10781079 if (tty_hung_up_p(filp)) {1080 ret = -EIO;···1098 }1099 }1100 out_up:1101+ mutex_unlock(&state->mutex);1102 out:1103 return ret;1104}···11861187 DPRINTK("uart_close(%d) called\n", port->line);11881189+ mutex_lock(&state->mutex);11901191 if (tty_hung_up_p(filp))1192 goto done;···1260 wake_up_interruptible(&state->info->open_wait);12611262 done:1263+ mutex_unlock(&state->mutex);1264}12651266static void uart_wait_until_sent(struct tty_struct *tty, int timeout)···1334 BUG_ON(!kernel_locked());1335 DPRINTK("uart_hangup(%d)\n", state->port->line);13361337+ mutex_lock(&state->mutex);1338 if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) {1339 uart_flush_buffer(tty);1340 uart_shutdown(state);···1344 wake_up_interruptible(&state->info->open_wait);1345 wake_up_interruptible(&state->info->delta_msr_wait);1346 }1347+ mutex_unlock(&state->mutex);1348}13491350/*···1447 if (mctrl & TIOCM_CAR)1448 break;14491450+ mutex_unlock(&state->mutex);1451 schedule();1452+ mutex_lock(&state->mutex);14531454 if (signal_pending(current))1455 break;···14751476 mutex_lock(&port_mutex);1477 state = drv->state + line;1478+ if (mutex_lock_interruptible(&state->mutex)) {1479 state = ERR_PTR(-ERESTARTSYS);1480 goto out;1481 }···1483 state->count++;1484 if (!state->port) {1485 state->count--;1486+ mutex_unlock(&state->mutex);1487 state = ERR_PTR(-ENXIO);1488 goto out;1489 }···1504 (unsigned long)state);1505 } else {1506 state->count--;1507+ mutex_unlock(&state->mutex);1508 state = ERR_PTR(-ENOMEM);1509 }1510 }···1571 if (tty_hung_up_p(filp)) {1572 retval = -EAGAIN;1573 state->count--;1574+ mutex_unlock(&state->mutex);1575 goto fail;1576 }1577···1591 */1592 if (retval == 0)1593 retval = uart_block_til_ready(filp, state);1594+ mutex_unlock(&state->mutex);15951596 /*1597 * If this is the first open to succeed, adjust things to suit.···1867{1868 struct uart_state *state = drv->state + port->line;18691870+ mutex_lock(&state->mutex);18711872 if (state->info && state->info->flags & UIF_INITIALIZED) {1873 struct uart_ops *ops = port->ops;···18961897 uart_change_pm(state, 3);18981899+ mutex_unlock(&state->mutex);19001901 return 0;1902}···1905{1906 struct uart_state *state = drv->state + port->line;19071908+ mutex_lock(&state->mutex);19091910 uart_change_pm(state, 0);1911···1954 }1955 }19561957+ mutex_unlock(&state->mutex);19581959 return 0;1960}···2049 if (info && info->tty)2050 tty_vhangup(info->tty);20512052+ mutex_lock(&state->mutex);20532054 state->info = NULL;2055···2072 kfree(info);2073 }20742075+ mutex_unlock(&state->mutex);2076}20772078static struct tty_operations uart_ops = {···2161 state->close_delay = 500; /* .5 seconds */2162 state->closing_wait = 30000; /* 30 seconds */21632164+ mutex_init(&state->mutex);2165 }21662167 retval = tty_register_driver(normal);