static void __init m32r_sio_init_ports(void) { struct uart_sio_port *up; static int first = 1; int i; if (!first) return; first = 0; for (i = 0, up = m32r_sio_ports; i < UART_NR; i++, up++) { up->port.iobase = old_serial_port[i].port; up->port.irq = irq_canonicalize(old_serial_port[i].irq); up->port.uartclk = BAUD_RATE * 16; up->port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST; up->port.membase = 0; up->port.iotype = 0; up->port.regshift = 0; up->port.ops = &m32r_sio_pops; } }
static void __init m32r_sio_init_ports(void) { struct uart_sio_port *up; static int first = 1; int i; if (!first) return; first = 0; for (i = 0, up = m32r_sio_ports; i < ARRAY_SIZE(old_serial_port); i++, up++) { up->port.iobase = old_serial_port[i].port; up->port.irq = irq_canonicalize(old_serial_port[i].irq); up->port.uartclk = old_serial_port[i].baud_base * 16; up->port.flags = old_serial_port[i].flags; up->port.membase = old_serial_port[i].iomem_base; up->port.iotype = old_serial_port[i].io_type; up->port.regshift = old_serial_port[i].iomem_reg_shift; up->port.ops = &m32r_sio_pops; } }
static int __init ac_probe1(int ioaddr, struct net_device *dev) { int i, retval; if (!request_region(ioaddr, AC_IO_EXTENT, DRV_NAME)) return -EBUSY; if (inb_p(ioaddr + AC_ID_PORT) == 0xff) { retval = -ENODEV; goto out; } if (inl(ioaddr + AC_ID_PORT) != AC_EISA_ID) { retval = -ENODEV; goto out; } #ifndef final_version printk(KERN_DEBUG "AC3200 ethercard configuration register is %#02x," " EISA ID %02x %02x %02x %02x.\n", inb(ioaddr + AC_CONFIG), inb(ioaddr + AC_ID_PORT + 0), inb(ioaddr + AC_ID_PORT + 1), inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3)); #endif for (i = 0; i < 6; i++) dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i); printk(KERN_DEBUG "AC3200 in EISA slot %d, node %pM", ioaddr/0x1000, dev->dev_addr); #if 0 /* Check the vendor ID/prefix. Redundant after checking the EISA ID */ if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0 || inb(ioaddr + AC_SA_PROM + 1) != AC_ADDR1 || inb(ioaddr + AC_SA_PROM + 2) != AC_ADDR2 ) { printk(", not found (invalid prefix).\n"); retval = -ENODEV; goto out; } #endif /* Assign and allocate the interrupt now. */ if (dev->irq == 0) { dev->irq = config2irq(inb(ioaddr + AC_CONFIG)); printk(", using"); } else { dev->irq = irq_canonicalize(dev->irq); printk(", assigning"); } retval = request_irq(dev->irq, ei_interrupt, 0, DRV_NAME, dev); if (retval) { printk (" nothing! Unable to get IRQ %d.\n", dev->irq); goto out1; } printk(" IRQ %d, %s port\n", dev->irq, port_name[dev->if_port]); dev->base_addr = ioaddr; #ifdef notyet if (dev->mem_start) { /* Override the value from the board. */ for (i = 0; i < 7; i++) if (addrmap[i] == dev->mem_start) break; if (i >= 7) i = 0; outb((inb(ioaddr + AC_CONFIG) & ~7) | i, ioaddr + AC_CONFIG); } #endif dev->if_port = inb(ioaddr + AC_CONFIG) >> 6; dev->mem_start = config2mem(inb(ioaddr + AC_CONFIG)); printk("%s: AC3200 at %#3x with %dkB memory at physical address %#lx.\n", dev->name, ioaddr, AC_STOP_PG/4, dev->mem_start); /* * BEWARE!! Some dain-bramaged EISA SCUs will allow you to put * the card mem within the region covered by `normal' RAM !!! * * ioremap() will fail in that case. */ ei_status.mem = ioremap(dev->mem_start, AC_STOP_PG*0x100); if (!ei_status.mem) { printk(KERN_ERR "ac3200.c: Unable to remap card memory above 1MB !!\n"); printk(KERN_ERR "ac3200.c: Try using EISA SCU to set memory below 1MB.\n"); printk(KERN_ERR "ac3200.c: Driver NOT installed.\n"); retval = -EINVAL; goto out1; } printk("ac3200.c: remapped %dkB card memory to virtual address %p\n", AC_STOP_PG/4, ei_status.mem); dev->mem_start = (unsigned long)ei_status.mem; dev->mem_end = dev->mem_start + (AC_STOP_PG - AC_START_PG)*256; ei_status.name = "AC3200"; ei_status.tx_start_page = AC_START_PG; ei_status.rx_start_page = AC_START_PG + TX_PAGES; ei_status.stop_page = AC_STOP_PG; ei_status.word16 = 1; if (ei_debug > 0) printk(version); ei_status.reset_8390 = &ac_reset_8390; ei_status.block_input = &ac_block_input; ei_status.block_output = &ac_block_output; ei_status.get_8390_hdr = &ac_get_8390_hdr; dev->netdev_ops = &ac_netdev_ops; NS8390_init(dev, 0); retval = register_netdev(dev); if (retval) goto out2; return 0; out2: if (ei_status.reg0) iounmap(ei_status.mem); out1: free_irq(dev->irq, dev); out: release_region(ioaddr, AC_IO_EXTENT); return retval; }
static int uart_set_info(struct tty_struct *tty, struct uart_state *state, struct serial_struct __user *newinfo) { struct serial_struct new_serial; struct uart_port *uport = state->uart_port; struct tty_port *port = &state->port; unsigned long new_port; unsigned int change_irq, change_port, closing_wait; unsigned int old_custom_divisor, close_delay; upf_t old_flags, new_flags; int retval = 0; if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) return -EFAULT; new_port = new_serial.port; if (HIGH_BITS_OFFSET) new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET; new_serial.irq = irq_canonicalize(new_serial.irq); close_delay = msecs_to_jiffies(new_serial.close_delay * 10); closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ? ASYNC_CLOSING_WAIT_NONE : msecs_to_jiffies(new_serial.closing_wait * 10); mutex_lock(&port->mutex); change_irq = !(uport->flags & UPF_FIXED_PORT) && new_serial.irq != uport->irq; change_port = !(uport->flags & UPF_FIXED_PORT) && (new_port != uport->iobase || (unsigned long)new_serial.iomem_base != uport->mapbase || new_serial.hub6 != uport->hub6 || new_serial.io_type != uport->iotype || new_serial.iomem_reg_shift != uport->regshift || new_serial.type != uport->type); old_flags = uport->flags; new_flags = new_serial.flags; old_custom_divisor = uport->custom_divisor; if (!capable(CAP_SYS_ADMIN)) { retval = -EPERM; if (change_irq || change_port || (new_serial.baud_base != uport->uartclk / 16) || (close_delay != port->close_delay) || (closing_wait != port->closing_wait) || (new_serial.xmit_fifo_size && new_serial.xmit_fifo_size != uport->fifosize) || (((new_flags ^ old_flags) & ~UPF_USR_MASK) != 0)) goto exit; uport->flags = ((uport->flags & ~UPF_USR_MASK) | (new_flags & UPF_USR_MASK)); uport->custom_divisor = new_serial.custom_divisor; goto check_and_exit; } if (uport->ops->verify_port) retval = uport->ops->verify_port(uport, &new_serial); if ((new_serial.irq >= nr_irqs) || (new_serial.irq < 0) || (new_serial.baud_base < 9600)) retval = -EINVAL; if (retval) goto exit; if (change_port || change_irq) { retval = -EBUSY; if (tty_port_users(port) > 1) goto exit; uart_shutdown(tty, state); } if (change_port) { unsigned long old_iobase, old_mapbase; unsigned int old_type, old_iotype, old_hub6, old_shift; old_iobase = uport->iobase; old_mapbase = uport->mapbase; old_type = uport->type; old_hub6 = uport->hub6; old_iotype = uport->iotype; old_shift = uport->regshift; if (old_type != PORT_UNKNOWN) uport->ops->release_port(uport); uport->iobase = new_port; uport->type = new_serial.type; uport->hub6 = new_serial.hub6; uport->iotype = new_serial.io_type; uport->regshift = new_serial.iomem_reg_shift; uport->mapbase = (unsigned long)new_serial.iomem_base; if (uport->type != PORT_UNKNOWN) { retval = uport->ops->request_port(uport); } else { retval = 0; } if (retval && old_type != PORT_UNKNOWN) { uport->iobase = old_iobase; uport->type = old_type; uport->hub6 = old_hub6; uport->iotype = old_iotype; uport->regshift = old_shift; uport->mapbase = old_mapbase; retval = uport->ops->request_port(uport); if (retval) uport->type = PORT_UNKNOWN; retval = -EBUSY; goto exit; } } if (change_irq) uport->irq = new_serial.irq; if (!(uport->flags & UPF_FIXED_PORT)) uport->uartclk = new_serial.baud_base * 16; uport->flags = (uport->flags & ~UPF_CHANGE_MASK) | (new_flags & UPF_CHANGE_MASK); uport->custom_divisor = new_serial.custom_divisor; port->close_delay = close_delay; port->closing_wait = closing_wait; if (new_serial.xmit_fifo_size) uport->fifosize = new_serial.xmit_fifo_size; if (port->tty) port->tty->low_latency = (uport->flags & UPF_LOW_LATENCY) ? 1 : 0; check_and_exit: retval = 0; if (uport->type == PORT_UNKNOWN) goto exit; if (port->flags & ASYNC_INITIALIZED) { if (((old_flags ^ uport->flags) & UPF_SPD_MASK) || old_custom_divisor != uport->custom_divisor) { if (uport->flags & UPF_SPD_MASK) { char buf[64]; printk(KERN_NOTICE "%s sets custom speed on %s. This " "is deprecated.\n", current->comm, tty_name(port->tty, buf)); } uart_change_speed(tty, state, NULL); } } else retval = uart_startup(tty, state, 1); exit: mutex_unlock(&port->mutex); return retval; }