Commit 6c849620 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://gkernel.bkbits.net/minitramfs-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 98c587d4 0630b89d
......@@ -226,6 +226,7 @@ static int sg_io(request_queue_t *q, struct block_device *bdev,
/*
* fill in request structure
*/
rq->cmd_len = hdr.cmd_len;
copy_from_user(rq->cmd, hdr.cmdp, hdr.cmd_len);
if (sizeof(rq->cmd) != hdr.cmd_len)
memset(rq->cmd + hdr.cmd_len, 0, sizeof(rq->cmd) - hdr.cmd_len);
......@@ -348,6 +349,7 @@ static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
* get command and data to send to device, if any
*/
err = -EFAULT;
rq->cmd_len = cmdlen;
if (copy_from_user(rq->cmd, sic->data, cmdlen))
goto error;
......
......@@ -882,6 +882,15 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
struct request *rq,
ide_handler_t *handler)
{
/*
* FIXME! This should be 'rq->cmd_len' when that is reliable.
*
* This breaks for real 16-byte commands. however, lots of drives
* currently break if we just send 16-bytes for 10/12 byte commands.
*/
#define MAX_CDB_BYTES 12
int cmd_len = MAX_CDB_BYTES;
struct cdrom_info *info = drive->driver_data;
ide_startstop_t startstop;
......@@ -906,7 +915,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry);
/* Send the command to the device. */
HWIF(drive)->atapi_output_bytes(drive, rq->cmd, sizeof(rq->cmd));
HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len);
/* Start the DMA if need be */
if (info->dma)
......@@ -3004,6 +3013,7 @@ static int ide_cdrom_prep_fs(request_queue_t *q, struct request *rq)
*/
rq->cmd[7] = (blocks >> 8) & 0xff;
rq->cmd[8] = blocks & 0xff;
rq->cmd_len = 10;
return BLKPREP_OK;
}
......@@ -3026,6 +3036,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
c[2] = 0;
c[1] &= 0xe0;
c[0] += (READ_10 - READ_6);
rq->cmd_len = 10;
return BLKPREP_OK;
}
......
......@@ -104,9 +104,6 @@ struct ide_cd_state_flags {
#define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags))
struct packet_command {
};
/* Structure of a MSF cdrom address. */
struct atapi_msf {
byte reserved;
......@@ -472,7 +469,6 @@ struct cdrom_info {
struct request_sense sense_data;
struct request request_sense_request;
struct packet_command request_sense_pc;
int dma;
int cmd;
unsigned long last_block;
......
......@@ -171,7 +171,7 @@ static void serial21285_tx_chars(int irq, void *dev_id, struct pt_regs *regs)
} while (--count > 0 && !(*CSR_UARTFLG & 0x20));
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
if (uart_circ_empty(xmit))
serial21285_stop_tx(port, 0);
......@@ -485,11 +485,7 @@ void __init rs285_console_init(void)
static struct uart_driver serial21285_reg = {
.owner = THIS_MODULE,
.driver_name = "ttyFB",
#ifdef CONFIG_DEVFS_FS
.dev_name = "ttyFB%d",
#else
.dev_name = "ttyFB",
#endif
.major = SERIAL_21285_MAJOR,
.minor = SERIAL_21285_MINOR,
.nr = 1,
......
......@@ -124,6 +124,8 @@ struct uart_8250_port {
unsigned char ier;
unsigned char rev;
unsigned char lcr;
unsigned char mcr_mask; /* mask of user bits */
unsigned char mcr_force; /* mask of forced bits */
unsigned int lsr_break_flag;
/*
......@@ -342,10 +344,9 @@ static int size_fifo(struct uart_8250_port *up)
*
* What evil have men's minds wrought...
*/
static void
autoconfig_startech_uarts(struct uart_8250_port *up)
static void autoconfig_has_efr(struct uart_8250_port *up)
{
unsigned char scratch, scratch2, scratch3, scratch4;
unsigned char id1, id2, id3, rev, saved_dll, saved_dlm;
/*
* First we check to see if it's an Oxford Semiconductor UART.
......@@ -354,31 +355,32 @@ autoconfig_startech_uarts(struct uart_8250_port *up)
* Semiconductor clone chips lock up if you try writing to the
* LSR register (which serial_icr_read does)
*/
if (up->port.type == PORT_16550A) {
/*
* EFR [4] must be set else this test fails
*
* This shouldn't be necessary, but Mike Hudson
* (Exoray@isys.ca) claims that it's needed for 952
* dual UART's (which are not recommended for new designs).
*/
up->acr = 0;
serial_out(up, UART_LCR, 0xBF);
serial_out(up, UART_EFR, 0x10);
serial_out(up, UART_LCR, 0x00);
/* Check for Oxford Semiconductor 16C950 */
scratch = serial_icr_read(up, UART_ID1);
scratch2 = serial_icr_read(up, UART_ID2);
scratch3 = serial_icr_read(up, UART_ID3);
if (scratch == 0x16 && scratch2 == 0xC9 &&
(scratch3 == 0x50 || scratch3 == 0x52 ||
scratch3 == 0x54)) {
up->port.type = PORT_16C950;
up->rev = serial_icr_read(up, UART_REV) |
(scratch3 << 8);
return;
}
/*
* Check for Oxford Semiconductor 16C950.
*
* EFR [4] must be set else this test fails.
*
* This shouldn't be necessary, but Mike Hudson (Exoray@isys.ca)
* claims that it's needed for 952 dual UART's (which are not
* recommended for new designs).
*/
up->acr = 0;
serial_out(up, UART_LCR, 0xBF);
serial_out(up, UART_EFR, UART_EFR_ECB);
serial_out(up, UART_LCR, 0x00);
id1 = serial_icr_read(up, UART_ID1);
id2 = serial_icr_read(up, UART_ID2);
id3 = serial_icr_read(up, UART_ID3);
rev = serial_icr_read(up, UART_REV);
DEBUG_AUTOCONF("950id=%02x:%02x:%02x:%02x ", id1, id2, id3, rev);
if (id1 == 0x16 && id2 == 0xC9 &&
(id3 == 0x50 || id3 == 0x52 || id3 == 0x54)) {
up->port.type = PORT_16C950;
up->rev = rev | (id3 << 8);
return;
}
/*
......@@ -389,34 +391,28 @@ autoconfig_startech_uarts(struct uart_8250_port *up)
* 0x12 - XR16C2850.
* 0x14 - XR16C854.
*/
/* Save the DLL and DLM */
serial_outp(up, UART_LCR, UART_LCR_DLAB);
scratch3 = serial_inp(up, UART_DLL);
scratch4 = serial_inp(up, UART_DLM);
saved_dll = serial_inp(up, UART_DLL);
saved_dlm = serial_inp(up, UART_DLM);
serial_outp(up, UART_DLL, 0);
serial_outp(up, UART_DLM, 0);
scratch2 = serial_inp(up, UART_DLL);
scratch = serial_inp(up, UART_DLM);
serial_outp(up, UART_LCR, 0);
id2 = serial_inp(up, UART_DLL);
id1 = serial_inp(up, UART_DLM);
serial_outp(up, UART_DLL, saved_dll);
serial_outp(up, UART_DLM, saved_dlm);
DEBUG_AUTOCONF("850id=%02x:%02x ", id1, id2);
if (scratch == 0x10 || scratch == 0x12 || scratch == 0x14) {
if (scratch == 0x10)
up->rev = scratch2;
if (id1 == 0x10 || id1 == 0x12 || id1 == 0x14) {
if (id1 == 0x10)
up->rev = id2;
up->port.type = PORT_16850;
return;
}
/* Restore the DLL and DLM */
serial_outp(up, UART_LCR, UART_LCR_DLAB);
serial_outp(up, UART_DLL, scratch3);
serial_outp(up, UART_DLM, scratch4);
serial_outp(up, UART_LCR, 0);
/*
* It wasn't an XR16C850.
*
* We distinguish between the '654 and the '650 by counting
* how many bytes are in the FIFO. I'm using this for now,
* since that's the technique that was sent to me in the
......@@ -429,6 +425,85 @@ autoconfig_startech_uarts(struct uart_8250_port *up)
up->port.type = PORT_16650V2;
}
/*
* We detected a chip without a FIFO. Only two fall into
* this category - the original 8250 and the 16450. The
* 16450 has a scratch register (accessible with LCR=0)
*/
static void autoconfig_8250(struct uart_8250_port *up)
{
unsigned char scratch, status1, status2;
up->port.type = PORT_8250;
scratch = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, 0xa5);
status1 = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, 0x5a);
status2 = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, scratch);
if (status1 == 0xa5 && status2 == 0x5a)
up->port.type = PORT_16450;
}
/*
* We know that the chip has FIFOs. Does it have an EFR? The
* EFR is located in the same register position as the IIR and
* we know the top two bits of the IIR are currently set. The
* EFR should contain zero. Try to read the EFR.
*/
static void autoconfig_16550a(struct uart_8250_port *up)
{
unsigned char status1, status2;
up->port.type = PORT_16550A;
/*
* Check for presence of the EFR when DLAB is set.
* Only ST16C650V1 UARTs pass this test.
*/
serial_outp(up, UART_LCR, UART_LCR_DLAB);
if (serial_in(up, UART_EFR) == 0) {
DEBUG_AUTOCONF("EFRv1 ");
up->port.type = PORT_16650;
return;
}
/*
* Maybe it requires 0xbf to be written to the LCR.
* (other ST16C650V2 UARTs, TI16C752A, etc)
*/
serial_outp(up, UART_LCR, 0xBF);
if (serial_in(up, UART_EFR) == 0) {
DEBUG_AUTOCONF("EFRv2 ");
autoconfig_has_efr(up);
return;
}
/*
* No EFR. Try to detect a TI16750, which only sets bit 5 of
* the IIR when 64 byte FIFO mode is enabled when DLAB is set.
* Try setting it with and without DLAB set. Cheap clones
* set bit 5 without DLAB set.
*/
serial_outp(up, UART_LCR, 0);
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
status1 = serial_in(up, UART_IIR) >> 5;
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
serial_outp(up, UART_LCR, UART_LCR_DLAB);
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
status2 = serial_in(up, UART_IIR) >> 5;
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2);
if (status1 == 6 && status2 == 7) {
up->port.type = PORT_16750;
return;
}
}
/*
* This routine is called by rs_init() to initialize a specific serial
* port. It determines what type of UART chip this serial port is
......@@ -438,16 +513,16 @@ autoconfig_startech_uarts(struct uart_8250_port *up)
*/
static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
{
unsigned char status1, status2, scratch, scratch2, scratch3;
unsigned char status1, scratch, scratch2, scratch3;
unsigned char save_lcr, save_mcr;
unsigned long flags;
DEBUG_AUTOCONF("Testing ttyS%d (0x%04x, 0x%08lx)...\n",
up->port.line, up->port.iobase, up->port.membase);
if (!up->port.iobase && !up->port.membase)
return;
DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%08lx): ",
up->port.line, up->port.iobase, up->port.membase);
/*
* We really do need global IRQs disabled here - we're going to
* be frobbing the chips IRQ enable register to see if it exists.
......@@ -455,7 +530,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
spin_lock_irqsave(&up->port.lock, flags);
// save_flags(flags); cli();
if (!(up->port.flags & ASYNC_BUGGY_UART)) {
if (!(up->port.flags & UPF_BUGGY_UART)) {
/*
* Do a simple existence test first; if we fail this,
* there's no point trying anything else.
......@@ -465,6 +540,9 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
* assumption is that 0x80 is a non-existent port;
* which should be safe since include/asm/io.h also
* makes this assumption.
*
* Note: this is safe as long as MCR bit 4 is clear
* and the device is in "PC" mode.
*/
scratch = serial_inp(up, UART_IER);
serial_outp(up, UART_IER, 0);
......@@ -482,9 +560,8 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
/*
* We failed; there's nothing here
*/
DEBUG_AUTOCONF("serial: ttyS%d: simple autoconfig "
"failed (%02x, %02x)\n",
up->port.line, scratch2, scratch3);
DEBUG_AUTOCONF("IER test failed (%02x, %02x) ",
scratch2, scratch3);
goto out;
}
}
......@@ -501,69 +578,50 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
* manufacturer would be stupid enough to design a board
* that conflicts with COM 1-4 --- we hope!
*/
if (!(up->port.flags & ASYNC_SKIP_TEST)) {
if (!(up->port.flags & UPF_SKIP_TEST)) {
serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A);
status1 = serial_inp(up, UART_MSR) & 0xF0;
serial_outp(up, UART_MCR, save_mcr);
if (status1 != 0x90) {
DEBUG_AUTOCONF("serial: ttyS%d: no UART loopback "
"failed\n", up->port.line);
DEBUG_AUTOCONF("LOOP test failed (%02x) ",
status1);
goto out;
}
}
serial_outp(up, UART_LCR, 0xBF); /* set up for StarTech test */
serial_outp(up, UART_EFR, 0); /* EFR is the same as FCR */
/*
* We're pretty sure there's a port here. Lets find out what
* type of port it is. The IIR top two bits allows us to find
* out if its 8250 or 16450, 16550, 16550A or later. This
* determines what we test for next.
*
* We also initialise the EFR (if any) to zero for later. The
* EFR occupies the same register location as the FCR and IIR.
*/
serial_outp(up, UART_LCR, 0xBF);
serial_outp(up, UART_EFR, 0);
serial_outp(up, UART_LCR, 0);
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
scratch = serial_in(up, UART_IIR) >> 6;
DEBUG_AUTOCONF("iir=%d ", scratch);
switch (scratch) {
case 0:
up->port.type = PORT_16450;
break;
case 1:
up->port.type = PORT_UNKNOWN;
break;
case 2:
up->port.type = PORT_16550;
break;
case 3:
up->port.type = PORT_16550A;
break;
}
if (up->port.type == PORT_16550A) {
/* Check for Startech UART's */
serial_outp(up, UART_LCR, UART_LCR_DLAB);
if (serial_in(up, UART_EFR) == 0) {
up->port.type = PORT_16650;
} else {
serial_outp(up, UART_LCR, 0xBF);
if (serial_in(up, UART_EFR) == 0)
autoconfig_startech_uarts(up);
}
}
if (up->port.type == PORT_16550A) {
/* Check for TI 16750 */
serial_outp(up, UART_LCR, save_lcr | UART_LCR_DLAB);
serial_outp(up, UART_FCR,
UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
scratch = serial_in(up, UART_IIR) >> 5;
if (scratch == 7) {
/*
* If this is a 16750, and not a cheap UART
* clone, then it should only go into 64 byte
* mode if the UART_FCR7_64BYTE bit was set
* while UART_LCR_DLAB was latched.
*/
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
serial_outp(up, UART_LCR, 0);
serial_outp(up, UART_FCR,
UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
scratch = serial_in(up, UART_IIR) >> 5;
if (scratch == 6)
up->port.type = PORT_16750;
}
serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
case 0:
autoconfig_8250(up);
break;
case 1:
up->port.type = PORT_UNKNOWN;
break;
case 2:
up->port.type = PORT_16550;
break;
case 3:
autoconfig_16550a(up);
break;
}
#if defined(CONFIG_SERIAL_8250_RSA) && defined(MODULE)
/*
* Only probe for RSA ports if we got the region.
......@@ -586,17 +644,6 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
}
#endif
serial_outp(up, UART_LCR, save_lcr);
if (up->port.type == PORT_16450) {
scratch = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, 0xa5);
status1 = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, 0x5a);
status2 = serial_in(up, UART_SCR);
serial_outp(up, UART_SCR, scratch);
if ((status1 != 0xa5) || (status2 != 0x5a))
up->port.type = PORT_8250;
}
up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size;
......@@ -628,6 +675,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
"serial_rsa");
}
#endif
DEBUG_AUTOCONF("type=%s\n", uart_config[up->port.type].name);
}
static void autoconfig_irq(struct uart_8250_port *up)
......@@ -638,7 +686,7 @@ static void autoconfig_irq(struct uart_8250_port *up)
unsigned long irqs;
int irq;
if (up->port.flags & ASYNC_FOURPORT) {
if (up->port.flags & UPF_FOURPORT) {
ICP = (up->port.iobase & 0xfe0) | 0x1f;
save_ICP = inb_p(ICP);
outb_p(0x80, ICP);
......@@ -654,7 +702,7 @@ static void autoconfig_irq(struct uart_8250_port *up)
irqs = probe_irq_on();
serial_outp(up, UART_MCR, 0);
udelay (10);
if (up->port.flags & ASYNC_FOURPORT) {
if (up->port.flags & UPF_FOURPORT) {
serial_outp(up, UART_MCR,
UART_MCR_DTR | UART_MCR_RTS);
} else {
......@@ -673,7 +721,7 @@ static void autoconfig_irq(struct uart_8250_port *up)
serial_outp(up, UART_MCR, save_mcr);
serial_outp(up, UART_IER, save_ier);
if (up->port.flags & ASYNC_FOURPORT)
if (up->port.flags & UPF_FOURPORT)
outb_p(save_ICP, ICP);
up->port.irq = (irq > 0) ? irq : 0;
......@@ -839,7 +887,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(&up->port, EVT_WRITE_WAKEUP);
uart_write_wakeup(&up->port);
DEBUG_INTR("THRE...");
......@@ -948,10 +996,26 @@ static void serial8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
* line being stuck active, and, since ISA irqs are edge triggered,
* no more IRQs will be seen.
*/
static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up)
{
spin_lock_irq(&i->lock);
if (!list_empty(i->head)) {
if (i->head == &up->list)
i->head = i->head->next;
list_del(&up->list);
} else {
BUG_ON(i->head != &up->list);
i->head = NULL;
}
spin_unlock_irq(&i->lock);
}
static int serial_link_irq_chain(struct uart_8250_port *up)
{
struct irq_info *i = irq_lists + up->port.irq;
int ret, irq_flags = share_irqs ? SA_SHIRQ : 0;
int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? SA_SHIRQ : 0;
spin_lock_irq(&i->lock);
......@@ -967,6 +1031,8 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
ret = request_irq(up->port.irq, serial8250_interrupt,
irq_flags, "serial", i);
if (ret)
serial_do_unlink(i, up);
}
return ret;
......@@ -981,18 +1047,7 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up)
if (list_empty(i->head))
free_irq(up->port.irq, i);
spin_lock_irq(&i->lock);
if (!list_empty(i->head)) {
if (i->head == &up->list)
i->head = i->head->next;
list_del(&up->list);
} else {
BUG_ON(i->head != &up->list);
i->head = NULL;
}
spin_unlock_irq(&i->lock);
serial_do_unlink(i, up);
}
/*
......@@ -1058,7 +1113,7 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port)
static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
struct uart_8250_port *up = (struct uart_8250_port *)port;
unsigned char mcr = ALPHA_KLUDGE_MCR;
unsigned char mcr = 0;
if (mctrl & TIOCM_RTS)
mcr |= UART_MCR_RTS;
......@@ -1071,6 +1126,8 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
if (mctrl & TIOCM_LOOP)
mcr |= UART_MCR_LOOP;
mcr = (mcr & up->mcr_mask) | up->mcr_force;
serial_out(up, UART_MCR, mcr);
}
......@@ -1139,7 +1196,7 @@ static int serial8250_startup(struct uart_port *port)
* if it is, then bail out, because there's likely no UART
* here.
*/
if (!(up->port.flags & ASYNC_BUGGY_UART) &&
if (!(up->port.flags & UPF_BUGGY_UART) &&
(serial_inp(up, UART_LSR) == 0xff)) {
printk("ttyS%d: LSR safety check engaged!\n", up->port.line);
return -ENODEV;
......@@ -1169,7 +1226,7 @@ static int serial8250_startup(struct uart_port *port)
serial_outp(up, UART_LCR, UART_LCR_WLEN8);
spin_lock_irqsave(&up->port.lock, flags);
if (up->port.flags & ASYNC_FOURPORT) {
if (up->port.flags & UPF_FOURPORT) {
if (!is_real_interrupt(up->port.irq))
up->port.mctrl |= TIOCM_OUT1;
} else
......@@ -1190,7 +1247,7 @@ static int serial8250_startup(struct uart_port *port)
up->ier = UART_IER_RLSI | UART_IER_RDI;
serial_outp(up, UART_IER, up->ier);
if (up->port.flags & ASYNC_FOURPORT) {
if (up->port.flags & UPF_FOURPORT) {
unsigned int icp;
/*
* Enable interrupts on the AST Fourport board
......@@ -1223,7 +1280,7 @@ static void serial8250_shutdown(struct uart_port *port)
serial_outp(up, UART_IER, 0);
spin_lock_irqsave(&up->port.lock, flags);
if (up->port.flags & ASYNC_FOURPORT) {
if (up->port.flags & UPF_FOURPORT) {
/* reset interrupts on the AST Fourport board */
inb((up->port.iobase & 0xfe0) | 0x1f);
up->port.mctrl |= TIOCM_OUT1;
......@@ -1604,7 +1661,7 @@ static void serial8250_config_port(struct uart_port *port, int flags)
/*
* Don't probe for MCA ports on non-MCA machines.
*/
if (up->port.flags & ASYNC_BOOT_ONLYMCA && !MCA_bus)
if (up->port.flags & UPF_BOOT_ONLYMCA && !MCA_bus)
return;
#endif
......@@ -1704,6 +1761,8 @@ static void __init serial8250_isa_init_ports(void)
up->port.iotype = old_serial_port[i].io_type;
up->port.regshift = old_serial_port[i].iomem_reg_shift;
up->port.ops = &serial8250_pops;
if (share_irqs)
up->port.flags |= UPF_SHARE_IRQ;
}
}
......@@ -1714,11 +1773,20 @@ static void __init serial8250_register_ports(struct uart_driver *drv)
serial8250_isa_init_ports();
for (i = 0; i < UART_NR; i++) {
serial8250_ports[i].port.line = i;
serial8250_ports[i].port.ops = &serial8250_pops;
init_timer(&serial8250_ports[i].timer);
serial8250_ports[i].timer.function = serial8250_timeout;
uart_add_one_port(drv, &serial8250_ports[i].port);
struct uart_8250_port *up = &serial8250_ports[i];
up->port.line = i;
up->port.ops = &serial8250_pops;
init_timer(&up->timer);
up->timer.function = serial8250_timeout;
/*
* ALPHA_KLUDGE_MCR needs to be killed.
*/
up->mcr_mask = ~ALPHA_KLUDGE_MCR;
up->mcr_force = ALPHA_KLUDGE_MCR;
uart_add_one_port(drv, &up->port);
}
}
......@@ -1746,7 +1814,7 @@ static inline void wait_for_xmitr(struct uart_8250_port *up)
} while ((status & BOTH_EMPTY) != BOTH_EMPTY);
/* Wait up to 1s for flow control if necessary */
if (up->port.flags & ASYNC_CONS_FLOW) {
if (up->port.flags & UPF_CONS_FLOW) {
tmout = 1000000;
while (--tmout &&
((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0))
......@@ -1857,7 +1925,7 @@ static struct uart_driver serial8250_reg = {
#ifdef CONFIG_DEVFS_FS
.dev_name = "tts/%d",
#else
.dev_name = "ttyS",
.dev_name = "ttyS%d",
#endif
.major = TTY_MAJOR,
.minor = 64,
......@@ -1881,9 +1949,12 @@ static int __register_serial(struct serial_struct *req, int line)
port.fifosize = req->xmit_fifo_size;
port.regshift = req->iomem_reg_shift;
port.iotype = req->io_type;
port.flags = req->flags | ASYNC_BOOT_AUTOCONF;
port.flags = req->flags | UPF_BOOT_AUTOCONF;
port.line = line;
if (share_irqs)
port.flags |= UPF_SHARE_IRQ;
if (HIGH_BITS_OFFSET)
port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
......
......@@ -41,6 +41,7 @@
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/major.h>
#include <linux/workqueue.h>
#include <asm/io.h>
......@@ -306,7 +307,7 @@ static int setup_serial(serial_info_t * info, ioaddr_t port, int irq)
memset(&serial, 0, sizeof (serial));
serial.port = port;
serial.irq = irq;
serial.flags = ASYNC_SKIP_TEST | ASYNC_SHARE_IRQ;
serial.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ;
line = register_serial(&serial);
if (line < 0) {
printk(KERN_NOTICE "serial_cs: register_serial() at 0x%04lx,"
......
/*
* Serial Device Initialisation for Lasi/Asp/Wax/Dino
*
* (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/serial.h>
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/serial.h>
static void setup_parisc_serial(struct serial_struct *serial,
unsigned long address, int irq, int line)
{
memset(serial, 0, sizeof(struct serial_struct));
/* autoconfig() sets state->type. This sets info->type */
serial->type = PORT_16550A;
serial->line = line;
serial->iomem_base = ioremap(address, 0x8);
serial->irq = irq;
serial->io_type = SERIAL_IO_MEM; /* define access method */
serial->flags = 0;
serial->xmit_fifo_size = 16;
serial->custom_divisor = 0;
serial->baud_base = LASI_BASE_BAUD;
}
static int __init
serial_init_chip(struct parisc_device *dev)
{
static int serial_line_nr;
unsigned long address;
int err;
struct serial_struct *serial;
if (!dev->irq) {
/* We find some unattached serial ports by walking native
* busses. These should be silently ignored. Otherwise,
* what we have here is a missing parent device, so tell
* the user what they're missing.
*/
if (dev->parent->id.hw_type != HPHW_IOA) {
printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
"Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa);
}
return -ENODEV;
}
serial = kmalloc(sizeof(*serial), GFP_KERNEL);
if (!serial)
return -ENOMEM;
address = dev->hpa;
if (dev->id.sversion != 0x8d) {
address += 0x800;
}
setup_parisc_serial(serial, address, dev->irq, serial_line_nr++);
err = register_serial(serial);
if (err < 0) {
printk(KERN_WARNING "register_serial returned error %d\n", err);
kfree(serial);
return -ENODEV;
}
return 0;
}
static struct parisc_device_id serial_tbl[] = {
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
{ 0 }
};
/* Hack. Dino's serial port will get listed first on some machines.
* So we register this driver first which knows about Lasi's serial port.
* This needs to get fixed properly somehow.
*/
static struct parisc_device_id serial1_tbl[] = {
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
{ 0 }
};
MODULE_DEVICE_TABLE(parisc, serial_tbl);
static struct parisc_driver serial1_driver = {
name: "Serial RS232",
id_table: serial1_tbl,
probe: serial_init_chip,
};
static struct parisc_driver serial_driver = {
name: "Serial RS232",
id_table: serial_tbl,
probe: serial_init_chip,
};
int __init probe_serial_gsc(void)
{
register_parisc_driver(&serial1_driver);
register_parisc_driver(&serial_driver);
return 0;
}
module_init(probe_serial_gsc);
......@@ -11,7 +11,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* $Id: 8250_pci.c,v 1.24 2002/07/29 14:39:56 rmk Exp $
* $Id: 8250_pci.c,v 1.28 2002/11/02 11:14:18 rmk Exp $
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -21,7 +21,6 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/serial.h>
#include <linux/serialP.h>
#include <asm/bitops.h>
......@@ -55,14 +54,19 @@ struct serial_private {
int line[0];
};
/*
* init_fn returns:
* > 0 - number of ports
* = 0 - use board->num_ports
* < 0 - error
*/
struct pci_board {
int flags;
int num_ports;
int base_baud;
int uart_offset;
int reg_shift;
int (*init_fn)(struct pci_dev *dev, struct pci_board *board,
int enable);
int (*init_fn)(struct pci_dev *dev, int enable);
int first_uart_offset;
};
......@@ -201,8 +205,7 @@ get_pci_irq(struct pci_dev *dev, struct pci_board *board, int idx)
* seems to be mainly needed on card using the PLX which also use I/O
* mapped memory.
*/
static int __devinit
pci_plx9050_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_plx9050_fn(struct pci_dev *dev, int enable)
{
u8 *p, irq_config = 0;
......@@ -264,8 +267,7 @@ pci_plx9050_fn(struct pci_dev *dev, struct pci_board *board, int enable)
#define PCI_DEVICE_ID_SIIG_1S_10x (PCI_DEVICE_ID_SIIG_1S_10x_550 & 0xfffc)
#define PCI_DEVICE_ID_SIIG_2S_10x (PCI_DEVICE_ID_SIIG_2S_10x_550 & 0xfff8)
static int __devinit
pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_siig10x_fn(struct pci_dev *dev, int enable)
{
u16 data, *p;
......@@ -296,8 +298,7 @@ pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
#define PCI_DEVICE_ID_SIIG_2S_20x (PCI_DEVICE_ID_SIIG_2S_20x_550 & 0xfffc)
#define PCI_DEVICE_ID_SIIG_2S1P_20x (PCI_DEVICE_ID_SIIG_2S1P_20x_550 & 0xfffc)
static int __devinit
pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_siig20x_fn(struct pci_dev *dev, int enable)
{
u8 data;
......@@ -318,8 +319,7 @@ pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
}
/* Added for EKF Intel i960 serial boards */
static int __devinit
pci_inteli960ni_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_inteli960ni_fn(struct pci_dev *dev, int enable)
{
unsigned long oldval;
......@@ -378,8 +378,7 @@ static struct timedia_struct {
{ 0, 0 }
};
static int __devinit
pci_timedia_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_timedia_fn(struct pci_dev *dev, int enable)
{
int i, j;
unsigned short *ids;
......@@ -389,12 +388,9 @@ pci_timedia_fn(struct pci_dev *dev, struct pci_board *board, int enable)
for (i = 0; timedia_data[i].num; i++) {
ids = timedia_data[i].ids;
for (j = 0; ids[j]; j++) {
if (pci_get_subdevice(dev) == ids[j]) {
board->num_ports = timedia_data[i].num;
return 0;
}
}
for (j = 0; ids[j]; j++)
if (pci_get_subdevice(dev) == ids[j])
return timedia_data[i].num;
}
return 0;
}
......@@ -406,9 +402,10 @@ pci_timedia_fn(struct pci_dev *dev, struct pci_board *board, int enable)
* and Keystone have one Diva chip with 3 UARTs. Some later machines have
* one Diva chip, but it has been expanded to 5 UARTs.
*/
static int __devinit
pci_hp_diva(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_hp_diva(struct pci_dev *dev, int enable)
{
int rc = 0;
if (!enable)
return 0;
......@@ -417,25 +414,24 @@ pci_hp_diva(struct pci_dev *dev, struct pci_board *board, int enable)
case PCI_DEVICE_ID_HP_DIVA_HALFDOME:
case PCI_DEVICE_ID_HP_DIVA_KEYSTONE:
case PCI_DEVICE_ID_HP_DIVA_EVEREST:
board->num_ports = 3;
rc = 3;
break;
case PCI_DEVICE_ID_HP_DIVA_TOSCA2:
board->num_ports = 2;
rc = 2;
break;
case PCI_DEVICE_ID_HP_DIVA_MAESTRO:
board->num_ports = 4;
rc = 4;
break;
case PCI_DEVICE_ID_HP_DIVA_POWERBAR:
board->num_ports = 1;
rc = 1;
break;
}
return 0;
return rc;
}
static int __devinit
pci_xircom_fn(struct pci_dev *dev, struct pci_board *board, int enable)
static int __devinit pci_xircom_fn(struct pci_dev *dev, int enable)
{
__set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ/10);
......@@ -579,8 +575,11 @@ static struct pci_board pci_boards[] __devinitdata = {
0x400, 7, pci_plx9050_fn },
{ SPCI_FL_BASE2, 4, 921600, /* pbn_plx_romulus */
0x20, 2, pci_plx9050_fn, 0x03 },
/* This board uses the size of PCI Base region 0 to
* signal now many ports are available */
/*
* This board uses the size of PCI Base region 0 to
* signal now many ports are available
*/
{ SPCI_FL_BASE0 | SPCI_FL_REGION_SZ_CAP, 32, 115200 }, /* pbn_oxsemi */
{ SPCI_FL_BASE_TABLE, 1, 921600, /* pbn_timedia */
0, 0, pci_timedia_fn },
......@@ -645,9 +644,9 @@ serial_pci_guess_board(struct pci_dev *dev, struct pci_board *board)
* later?)
*/
if ((((dev->class >> 8) != PCI_CLASS_COMMUNICATION_SERIAL) &&
((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) ||
((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) ||
(dev->class & 0xff) > 6)
return 1;
return -ENODEV;
for (i = 0; i < 6; i++) {
if (IS_PCI_REGION_IOPORT(dev, i)) {
......@@ -667,20 +666,31 @@ serial_pci_guess_board(struct pci_dev *dev, struct pci_board *board)
board->flags = first_port;
return 0;
}
return 1;
return -ENODEV;
}
static inline int
serial_pci_matches(struct pci_board *board, int index)
{
return
board->base_baud == pci_boards[index].base_baud &&
board->num_ports == pci_boards[index].num_ports &&
board->uart_offset == pci_boards[index].uart_offset &&
board->reg_shift == pci_boards[index].reg_shift &&
board->first_uart_offset == pci_boards[index].first_uart_offset;
}
/*
* return an error code to refuse.
*
* serial_struct is 60 bytes.
* Probe one serial board. Unfortunately, there is no rhyme nor reason
* to the arrangement of serial ports on a PCI card.
*/
static int __devinit pci_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
static int __devinit
pci_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
{
struct serial_private *priv;
struct pci_board *board, tmp;
struct serial_struct serial_req;
int base_baud, rc, k;
int base_baud, rc, nr_ports, i;
if (ent->driver_data >= ARRAY_SIZE(pci_boards)) {
printk(KERN_ERR "pci_init_one: invalid driver_data: %ld\n",
......@@ -694,67 +704,98 @@ static int __devinit pci_init_one(struct pci_dev *dev, const struct pci_device_i
if (rc)
return rc;
if (ent->driver_data == pbn_default &&
serial_pci_guess_board(dev, board)) {
pci_disable_device(dev);
return -ENODEV;
} else if (serial_pci_guess_board(dev, &tmp) == 0) {
printk(KERN_INFO "Redundant entry in serial pci_table. "
"Please send the output of\n"
"lspci -vv, this message (%d,%d,%d,%d)\n"
"and the manufacturer and name of "
"serial board or modem board\n"
"to serial-pci-info@lists.sourceforge.net.\n",
dev->vendor, dev->device,
pci_get_subvendor(dev), pci_get_subdevice(dev));
if (ent->driver_data == pbn_default) {
/*
* Use a copy of the pci_board entry for this;
* avoid changing entries in the table.
*/
memcpy(&tmp, board, sizeof(struct pci_board));
board = &tmp;
/*
* We matched one of our class entries. Try to
* determine the parameters of this board.
*/
rc = serial_pci_guess_board(dev, board);
if (rc)
goto disable;
} else {
/*
* We matched an explicit entry. If we are able to
* detect this boards settings with our heuristic,
* then we no longer need this entry.
*/
rc = serial_pci_guess_board(dev, &tmp);
if (rc == 0 && serial_pci_matches(board, pbn_default)) {
printk(KERN_INFO
"Redundant entry in serial pci_table. Please send the output\n"
"of lspci -vv, this message (0x%04x,0x%04x,0x%04x,0x%04x),\n"
"the manufacturer and name of serial board or modem board to\n"
"rmk@arm.linux.org.uk.\n",
dev->vendor, dev->device,
pci_get_subvendor(dev), pci_get_subdevice(dev));
}
}
priv = kmalloc(sizeof(struct serial_private) +
sizeof(unsigned int) * board->num_ports,
GFP_KERNEL);
if (!priv) {
pci_disable_device(dev);
return -ENOMEM;
}
nr_ports = board->num_ports;
/*
* Run the initialization function, if any
* Run the initialization function, if any. The initialization
* function returns:
* <0 - error
* 0 - use board->num_ports
* >0 - number of ports
*/
if (board->init_fn) {
rc = board->init_fn(dev, board, 1);
if (rc != 0) {
pci_disable_device(dev);
kfree(priv);
return rc;
}
rc = board->init_fn(dev, 1);
if (rc < 0)
goto disable;
if (rc)
nr_ports = rc;
}
priv = kmalloc(sizeof(struct serial_private) +
sizeof(unsigned int) * nr_ports,
GFP_KERNEL);
if (!priv) {
rc = -ENOMEM;
goto deinit;
}
base_baud = board->base_baud;
if (!base_baud)
base_baud = BASE_BAUD;
memset(&serial_req, 0, sizeof(serial_req));
for (k = 0; k < board->num_ports; k++) {
serial_req.irq = get_pci_irq(dev, board, k);
if (get_pci_port(dev, board, &serial_req, k))
for (i = 0; i < nr_ports; i++) {
serial_req.irq = get_pci_irq(dev, board, i);
if (get_pci_port(dev, board, &serial_req, i))
break;
#ifdef SERIAL_DEBUG_PCI
printk("Setup PCI/PNP port: port %x, irq %d, type %d\n",
printk("Setup PCI port: port %x, irq %d, type %d\n",
serial_req.port, serial_req.irq, serial_req.io_type);
#endif
serial_req.flags = ASYNC_SKIP_TEST | ASYNC_AUTOPROBE;
serial_req.baud_base = base_baud;
priv->line[k] = register_serial(&serial_req);
if (priv->line[k] < 0)
priv->line[i] = register_serial(&serial_req);
if (priv->line[i] < 0)
break;
}
priv->board = board;
priv->nr = k;
priv->nr = i;
pci_set_drvdata(dev, priv);
return 0;
deinit:
if (board->init_fn)
board->init_fn(dev, 0);
disable:
pci_disable_device(dev);
return rc;
}
static void __devexit pci_remove_one(struct pci_dev *dev)
......@@ -769,7 +810,7 @@ static void __devexit pci_remove_one(struct pci_dev *dev)
unregister_serial(priv->line[i]);
if (priv->board->init_fn)
priv->board->init_fn(dev, priv->board, 0);
priv->board->init_fn(dev, 0);
pci_disable_device(dev);
......@@ -1160,18 +1201,23 @@ static struct pci_device_id serial_pci_tbl[] __devinitdata = {
PCI_ANY_ID, PCI_ANY_ID, 0, 0,
pbn_dci_pccom8 },
/*
* These entries match devices with class
* COMMUNICATION_SERIAL, COMMUNICATION_MODEM
* or COMMUNICATION_MULTISERIAL
*/
{ PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_COMMUNICATION_SERIAL << 8,
0xffff00, },
0xffff00, pbn_default },
{ PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_COMMUNICATION_MODEM << 8,
0xffff00, },
0xffff00, pbn_default },
{ PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
0xffff00, },
0xffff00, pbn_default },
{ 0, }
};
......
......@@ -7,6 +7,7 @@
export-objs := core.o 8250.o suncore.o
serial-8250-y :=
serial-8250-$(CONFIG_GSC) += 8250_gsc.o
serial-8250-$(CONFIG_PCI) += 8250_pci.o
serial-8250-$(CONFIG_PNP) += 8250_pnp.o
obj-$(CONFIG_SERIAL_CORE) += core.o
......
......@@ -245,7 +245,7 @@ static void ambauart_tx_chars(struct uart_port *port)
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
if (uart_circ_empty(xmit))
ambauart_stop_tx(port);
......@@ -706,11 +706,7 @@ void __init ambauart_console_init(void)
static struct uart_driver amba_reg = {
.owner = THIS_MODULE,
.driver_name = "ttyAM",
#ifdef CONFIG_DEVFS_FS
.dev_name = "ttyAM%d",
#else
.dev_name = "ttyAM",
#endif
.major = SERIAL_AMBA_MAJOR,
.minor = SERIAL_AMBA_MINOR,
.nr = UART_NR,
......
......@@ -161,7 +161,7 @@ anakin_tx_chars(struct uart_port *port)
anakin_transmit_buffer(port);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
}
static void
......
......@@ -50,14 +50,12 @@
#define UART_NR 2
#ifndef CONFIG_SERIAL_CLPS711X_OLD_NAME
#define SERIAL_CLPS711X_NAME "ttyCL"
#define SERIAL_CLPS711X_MAJOR 204
#define SERIAL_CLPS711X_MINOR 40
#define SERIAL_CLPS711X_NR UART_NR
#else
#warning The old names/device number for this driver if compatabity is needed
#define SERIAL_CLPS711X_NAME "ttyAM"
#define SERIAL_CLPS711X_MAJOR 204
#define SERIAL_CLPS711X_MINOR 16
#define SERIAL_CLPS711X_NR UART_NR
......@@ -209,7 +207,7 @@ static void clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
if (uart_circ_empty(xmit))
clps711xuart_stop_tx(port);
......@@ -545,7 +543,7 @@ static int __init clps711xuart_console_setup(struct console *co, char *options)
}
static struct console clps711x_console = {
.name = SERIAL_CLPS711X_NAME,
.name = "ttyCL",
.write = clps711xuart_console_write,
.device = clps711xuart_console_device,
.setup = clps711xuart_console_setup,
......@@ -565,12 +563,7 @@ void __init clps711xuart_console_init(void)
static struct uart_driver clps711x_reg = {
.driver_name = "ttyCL",
#ifdef CONFIG_DEVFS_FS
.dev_name = SERIAL_CLPS711X_NAME,
#else
.dev_name = SERIAL_CLPS711X_NAME,
#endif
.dev_name = "ttyCL%d",
.major = SERIAL_CLPS711X_MAJOR,
.minor = SERIAL_CLPS711X_MINOR,
.nr = UART_NR,
......
......@@ -65,11 +65,9 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
* This routine is used by the interrupt handler to schedule processing in
* the software interrupt portion of the driver.
*/
void uart_event(struct uart_port *port, int event)
void uart_write_wakeup(struct uart_port *port)
{
struct uart_info *info = port->info;
set_bit(0, &info->event);
tasklet_schedule(&info->tlet);
}
......@@ -112,13 +110,12 @@ static void uart_tasklet_action(unsigned long data)
struct tty_struct *tty;
tty = info->tty;
if (!tty || !test_and_clear_bit(EVT_WRITE_WAKEUP, &info->event))
return;
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup)
(tty->ldisc.write_wakeup)(tty);
wake_up_interruptible(&tty->write_wait);
if (tty) {
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup)
tty->ldisc.write_wakeup(tty);
wake_up_interruptible(&tty->write_wait);
}
}
static inline void
......@@ -1981,7 +1978,8 @@ static int uart_pm(struct pm_dev *dev, pm_request_t rqst, void *data)
static inline void
uart_report_port(struct uart_driver *drv, struct uart_port *port)
{
printk("%s%d at ", drv->dev_name, port->line);
printk(drv->dev_name, port->line);
printk(" at ");
switch (port->iotype) {
case UPIO_PORT:
printk("I/O 0x%x", port->iobase);
......@@ -2005,7 +2003,6 @@ __uart_register_port(struct uart_driver *drv, struct uart_state *state,
state->port = port;
spin_lock_init(&port->lock);
port->type = PORT_UNKNOWN;
port->cons = drv->cons;
port->info = state->info;
......@@ -2022,8 +2019,10 @@ __uart_register_port(struct uart_driver *drv, struct uart_state *state,
flags = UART_CONFIG_TYPE;
if (port->flags & UPF_AUTO_IRQ)
flags |= UART_CONFIG_IRQ;
if (port->flags & UPF_BOOT_AUTOCONF)
if (port->flags & UPF_BOOT_AUTOCONF) {
port->type = PORT_UNKNOWN;
port->ops->config_port(port, flags);
}
/*
* Register the port whether it's detected or not. This allows
......@@ -2439,8 +2438,9 @@ void uart_unregister_port(struct uart_driver *drv, int line)
struct uart_state *state;
if (line < 0 || line >= drv->nr) {
printk(KERN_ERR "Attempt to unregister %s%d\n",
drv->dev_name, line);
printk(KERN_ERR "Attempt to unregister ");
printk(drv->dev_name, line);
printk("\n");
return;
}
......@@ -2453,7 +2453,7 @@ void uart_unregister_port(struct uart_driver *drv, int line)
up(&port_sem);
}
EXPORT_SYMBOL(uart_event);
EXPORT_SYMBOL(uart_write_wakeup);
EXPORT_SYMBOL(uart_register_driver);
EXPORT_SYMBOL(uart_unregister_driver);
EXPORT_SYMBOL(uart_register_port);
......
......@@ -305,7 +305,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport)
}
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(&sport->port, EVT_WRITE_WAKEUP);
uart_write_wakeup(&sport->port);
if (uart_circ_empty(xmit))
sa1100_stop_tx(&sport->port, 0);
......@@ -661,7 +661,7 @@ void __init sa1100_register_uart_fns(struct sa1100_port_fns *fns)
void __init sa1100_register_uart(int idx, int port)
{
if (idx >= NR_PORTS) {
printk(KERN_ERR __FUNCTION__ ": bad index number %d\n", idx);
printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx);
return;
}
......@@ -688,7 +688,7 @@ void __init sa1100_register_uart(int idx, int port)
break;
default:
printk(KERN_ERR __FUNCTION__ ": bad port number %d\n", port);
printk(KERN_ERR "%s: bad port number %d\n", __FUNCTION__, port);
}
}
......@@ -827,11 +827,7 @@ void __init sa1100_rs_console_init(void)
static struct uart_driver sa1100_reg = {
.owner = THIS_MODULE,
.driver_name = "ttySA",
#ifdef CONFIG_DEVFS_FS
.dev_name = "ttySA%d",
#else
.dev_name = "ttySA",
#endif
.major = SERIAL_SA1100_MAJOR,
.minor = MINOR_START,
.nr = NR_PORTS,
......
......@@ -266,7 +266,7 @@ static void transmit_chars(struct uart_sunsab_port *up,
writeb(SAB82532_CMDR_XF, &up->regs->w.cmdr);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(&up->port, EVT_WRITE_WAKEUP);
uart_write_wakeup(&up->port);
if (uart_circ_empty(xmit))
sunsab_stop_tx(&up->port, 0);
......@@ -843,7 +843,7 @@ static struct uart_driver sunsab_reg = {
#ifdef CONFIG_DEVFS_FS
.dev_name = "tts/%d",
#else
.dev_name = "ttyS",
.dev_name = "ttyS%d",
#endif
.major = TTY_MAJOR,
};
......
......@@ -431,7 +431,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(&up->port, EVT_WRITE_WAKEUP);
uart_write_wakeup(&up->port);
if (uart_circ_empty(xmit))
sunsu_stop_tx(&up->port, 0);
......@@ -1262,7 +1262,7 @@ static struct uart_driver sunsu_reg = {
#ifdef CONFIG_DEVFS_FS
.dev_name = "tts/%d",
#else
.dev_name = "ttyS",
.dev_name = "ttyS%d",
#endif
.major = TTY_MAJOR,
};
......
......@@ -523,7 +523,7 @@ static void sunzilog_transmit_chars(struct uart_sunzilog_port *up,
up->port.icount.tx++;
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(&up->port, EVT_WRITE_WAKEUP);
uart_write_wakeup(&up->port);
if (!uart_circ_empty(xmit))
return;
......@@ -1003,7 +1003,7 @@ static struct uart_driver sunzilog_reg = {
#ifdef CONFIG_DEVFS_FS
.dev_name = "ttyS%d",
#else
.dev_name = "ttyS",
.dev_name = "ttyS%d",
#endif
.major = TTY_MAJOR,
};
......
......@@ -215,7 +215,7 @@ static void uart00_tx_chars(struct uart_port *port)
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
if (uart_circ_empty(xmit))
uart00_stop_tx(port, 0);
......
......@@ -209,9 +209,7 @@ static void ext2_preread_inode(struct inode *inode)
* For other inodes, search forward from the parent directory\'s block
* group to find a free inode.
*/
#if 0
static int find_group_dir(struct super_block *sb, int parent_group)
static int find_group_dir(struct super_block *sb, struct inode *parent)
{
struct ext2_super_block * es = EXT2_SB(sb)->s_es;
int ngroups = EXT2_SB(sb)->s_groups_count;
......@@ -243,7 +241,6 @@ static int find_group_dir(struct super_block *sb, int parent_group)
mark_buffer_dirty(best_bh);
return best_group;
}
#endif
/*
* Orlov's allocator for directories.
......@@ -289,7 +286,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
struct ext2_group_desc *desc;
struct buffer_head *bh;
if (parent == sb->s_root->d_inode) {
if ((parent == sb->s_root->d_inode) ||
(parent->i_flags & EXT2_TOPDIR_FL)) {
struct ext2_group_desc *best_desc = NULL;
struct buffer_head *best_bh = NULL;
int best_ndir = inodes_per_group;
......@@ -342,7 +340,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
desc = ext2_get_group_desc (sb, group, &bh);
if (!desc || !desc->bg_free_inodes_count)
continue;
if (sbi->debts[group] >= max_debt)
if (sbi->s_debts[group] >= max_debt)
continue;
if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
continue;
......@@ -447,9 +445,12 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
lock_super (sb);
es = EXT2_SB(sb)->s_es;
repeat:
if (S_ISDIR(mode))
group = find_group_orlov(sb, dir);
else
if (S_ISDIR(mode)) {
if (test_opt (sb, OLDALLOC))
group = find_group_dir(sb, dir);
else
group = find_group_orlov(sb, dir);
} else
group = find_group_other(sb, dir);
err = -ENOSPC;
......@@ -488,11 +489,11 @@ struct inode * ext2_new_inode(struct inode * dir, int mode)
cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1);
if (S_ISDIR(mode)) {
if (EXT2_SB(sb)->debts[group] < 255)
EXT2_SB(sb)->debts[group]++;
if (EXT2_SB(sb)->s_debts[group] < 255)
EXT2_SB(sb)->s_debts[group]++;
} else {
if (EXT2_SB(sb)->debts[group])
EXT2_SB(sb)->debts[group]--;
if (EXT2_SB(sb)->s_debts[group])
EXT2_SB(sb)->s_debts[group]--;
}
mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
......
......@@ -140,6 +140,7 @@ static void ext2_put_super (struct super_block * sb)
if (sbi->s_group_desc[i])
brelse (sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
kfree(sbi->s_debts);
brelse (sbi->s_sbh);
sb->s_fs_info = NULL;
kfree(sbi);
......@@ -385,6 +386,10 @@ static int parse_options (char * options,
return 0;
sbi->s_resuid = v;
}
else if (!strcmp (this_char, "oldalloc"))
set_opt (sbi->s_mount_opt, OLDALLOC);
else if (!strcmp (this_char, "orlov"))
clear_opt (sbi->s_mount_opt, OLDALLOC);
/* Silently ignore the quota options */
else if (!strcmp (this_char, "grpquota")
|| !strcmp (this_char, "noquota")
......@@ -756,13 +761,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
printk ("EXT2-fs: not enough memory\n");
goto failed_mount;
}
sbi->debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->debts),
GFP_KERNEL);
if (!sbi->debts) {
sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
GFP_KERNEL);
if (!sbi->s_debts) {
printk ("EXT2-fs: not enough memory\n");
goto failed_mount_group_desc;
}
memset(sbi->debts, 0, sbi->s_groups_count * sizeof(*sbi->debts));
memset(sbi->s_debts, 0, sbi->s_groups_count * sizeof(*sbi->s_debts));
for (i = 0; i < db_count; i++) {
block = descriptor_loc(sb, logic_sb_block, i);
sbi->s_group_desc[i] = sb_bread(sb, block);
......@@ -771,7 +776,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse (sbi->s_group_desc[j]);
kfree(sbi->s_group_desc);
printk ("EXT2-fs: unable to read group descriptors\n");
goto failed_mount;
goto failed_mount_group_desc;
}
}
if (!ext2_check_descriptors (sb)) {
......@@ -808,6 +813,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse(sbi->s_group_desc[i]);
failed_mount_group_desc:
kfree(sbi->s_group_desc);
if (sbi->s_debts)
kfree(sbi->s_debts);
failed_mount:
brelse(bh);
failed_sbi:
......
......@@ -21,6 +21,7 @@
#include <linux/string.h>
#include <linux/quotaops.h>
#include <linux/buffer_head.h>
#include <linux/random.h>
#include <asm/bitops.h>
#include <asm/byteorder.h>
......@@ -191,6 +192,230 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
unlock_super(sb);
}
/*
* There are two policies for allocating an inode. If the new inode is
* a directory, then a forward search is made for a block group with both
* free space and a low directory-to-inode ratio; if that fails, then of
* the groups with above-average free space, that group with the fewest
* directories already is chosen.
*
* For other inodes, search forward from the parent directory\'s block
* group to find a free inode.
*/
static int find_group_dir(struct super_block *sb, struct inode *parent)
{
struct ext3_super_block * es = EXT3_SB(sb)->s_es;
int ngroups = EXT3_SB(sb)->s_groups_count;
int avefreei = le32_to_cpu(es->s_free_inodes_count) / ngroups;
struct ext3_group_desc *desc, *best_desc = NULL;
struct buffer_head *bh, *best_bh = NULL;
int group, best_group = -1;
for (group = 0; group < ngroups; group++) {
desc = ext3_get_group_desc (sb, group, &bh);
if (!desc || !desc->bg_free_inodes_count)
continue;
if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
continue;
if (!best_desc ||
(le16_to_cpu(desc->bg_free_blocks_count) >
le16_to_cpu(best_desc->bg_free_blocks_count))) {
best_group = group;
best_desc = desc;
best_bh = bh;
}
}
if (!best_desc)
return -1;
best_desc->bg_free_inodes_count =
cpu_to_le16(le16_to_cpu(best_desc->bg_free_inodes_count) - 1);
best_desc->bg_used_dirs_count =
cpu_to_le16(le16_to_cpu(best_desc->bg_used_dirs_count) + 1);
mark_buffer_dirty(best_bh);
return best_group;
}
/*
* Orlov's allocator for directories.
*
* We always try to spread first-level directories.
*
* If there are blockgroups with both free inodes and free blocks counts
* not worse than average we return one with smallest directory count.
* Otherwise we simply return a random group.
*
* For the rest rules look so:
*
* It's OK to put directory into a group unless
* it has too many directories already (max_dirs) or
* it has too few free inodes left (min_inodes) or
* it has too few free blocks left (min_blocks) or
* it's already running too large debt (max_debt).
* Parent's group is prefered, if it doesn't satisfy these
* conditions we search cyclically through the rest. If none
* of the groups look good we just look for a group with more
* free inodes than average (starting at parent's group).
*
* Debt is incremented each time we allocate a directory and decremented
* when we allocate an inode, within 0--255.
*/
#define INODE_COST 64
#define BLOCK_COST 256
static int find_group_orlov(struct super_block *sb, struct inode *parent)
{
int parent_group = EXT3_I(parent)->i_block_group;
struct ext3_sb_info *sbi = EXT3_SB(sb);
struct ext3_super_block *es = sbi->s_es;
int ngroups = sbi->s_groups_count;
int inodes_per_group = EXT3_INODES_PER_GROUP(sb);
int avefreei = le32_to_cpu(es->s_free_inodes_count) / ngroups;
int avefreeb = le32_to_cpu(es->s_free_blocks_count) / ngroups;
int blocks_per_dir;
int ndirs = sbi->s_dir_count;
int max_debt, max_dirs, min_blocks, min_inodes;
int group = -1, i;
struct ext3_group_desc *desc;
struct buffer_head *bh;
if ((parent == sb->s_root->d_inode) ||
(parent->i_flags & EXT3_TOPDIR_FL)) {
struct ext3_group_desc *best_desc = NULL;
struct buffer_head *best_bh = NULL;
int best_ndir = inodes_per_group;
int best_group = -1;
get_random_bytes(&group, sizeof(group));
parent_group = (unsigned)group % ngroups;
for (i = 0; i < ngroups; i++) {
group = (parent_group + i) % ngroups;
desc = ext3_get_group_desc (sb, group, &bh);
if (!desc || !desc->bg_free_inodes_count)
continue;
if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
continue;
if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
continue;
if (le16_to_cpu(desc->bg_free_blocks_count) < avefreeb)
continue;
best_group = group;
best_ndir = le16_to_cpu(desc->bg_used_dirs_count);
best_desc = desc;
best_bh = bh;
}
if (best_group >= 0) {
desc = best_desc;
bh = best_bh;
group = best_group;
goto found;
}
goto fallback;
}
blocks_per_dir = (le32_to_cpu(es->s_blocks_count) -
le32_to_cpu(es->s_free_blocks_count)) / ndirs;
max_dirs = ndirs / ngroups + inodes_per_group / 16;
min_inodes = avefreei - inodes_per_group / 4;
min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4;
max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, BLOCK_COST);
if (max_debt * INODE_COST > inodes_per_group)
max_debt = inodes_per_group / INODE_COST;
if (max_debt > 255)
max_debt = 255;
if (max_debt == 0)
max_debt = 1;
for (i = 0; i < ngroups; i++) {
group = (parent_group + i) % ngroups;
desc = ext3_get_group_desc (sb, group, &bh);
if (!desc || !desc->bg_free_inodes_count)
continue;
if (sbi->s_debts[group] >= max_debt)
continue;
if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
continue;
if (le16_to_cpu(desc->bg_free_inodes_count) < min_inodes)
continue;
if (le16_to_cpu(desc->bg_free_blocks_count) < min_blocks)
continue;
goto found;
}
fallback:
for (i = 0; i < ngroups; i++) {
group = (parent_group + i) % ngroups;
desc = ext3_get_group_desc (sb, group, &bh);
if (!desc || !desc->bg_free_inodes_count)
continue;
if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
goto found;
}
return -1;
found:
desc->bg_free_inodes_count =
cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) - 1);
desc->bg_used_dirs_count =
cpu_to_le16(le16_to_cpu(desc->bg_used_dirs_count) + 1);
sbi->s_dir_count++;
mark_buffer_dirty(bh);
return group;
}
static int find_group_other(struct super_block *sb, struct inode *parent)
{
int parent_group = EXT3_I(parent)->i_block_group;
int ngroups = EXT3_SB(sb)->s_groups_count;
struct ext3_group_desc *desc;
struct buffer_head *bh;
int group, i;
/*
* Try to place the inode in its parent directory
*/
group = parent_group;
desc = ext3_get_group_desc (sb, group, &bh);
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
goto found;
/*
* Use a quadratic hash to find a group with a
* free inode
*/
for (i = 1; i < ngroups; i <<= 1) {
group += i;
if (group >= ngroups)
group -= ngroups;
desc = ext3_get_group_desc (sb, group, &bh);
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
goto found;
}
/*
* That failed: try linear search for a free inode
*/
group = parent_group + 1;
for (i = 2; i < ngroups; i++) {
if (++group >= ngroups)
group = 0;
desc = ext3_get_group_desc (sb, group, &bh);
if (desc && le16_to_cpu(desc->bg_free_inodes_count))
goto found;
}
return -1;
found:
desc->bg_free_inodes_count =
cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) - 1);
mark_buffer_dirty(bh);
return group;
}
/*
* There are two policies for allocating an inode. If the new inode is
* a directory, then a forward search is made for a block group with both
......@@ -206,10 +431,10 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
struct super_block *sb;
struct buffer_head *bitmap_bh = NULL;
struct buffer_head *bh2;
int i, j, avefreei;
int group;
ino_t ino;
struct inode * inode;
struct ext3_group_desc * gdp;
struct ext3_group_desc * tmp;
struct ext3_super_block * es;
struct ext3_inode_info *ei;
int err = 0;
......@@ -228,93 +453,35 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
lock_super (sb);
es = EXT3_SB(sb)->s_es;
repeat:
gdp = NULL;
i = 0;
if (S_ISDIR(mode)) {
avefreei = le32_to_cpu(es->s_free_inodes_count) /
EXT3_SB(sb)->s_groups_count;
if (!gdp) {
for (j = 0; j < EXT3_SB(sb)->s_groups_count; j++) {
struct buffer_head *temp_buffer;
tmp = ext3_get_group_desc (sb, j, &temp_buffer);
if (tmp &&
le16_to_cpu(tmp->bg_free_inodes_count) &&
le16_to_cpu(tmp->bg_free_inodes_count) >=
avefreei) {
if (!gdp || (le16_to_cpu(tmp->bg_free_blocks_count) >
le16_to_cpu(gdp->bg_free_blocks_count))) {
i = j;
gdp = tmp;
bh2 = temp_buffer;
}
}
}
}
} else {
/*
* Try to place the inode in its parent directory
*/
i = EXT3_I(dir)->i_block_group;
tmp = ext3_get_group_desc (sb, i, &bh2);
if (tmp && le16_to_cpu(tmp->bg_free_inodes_count))
gdp = tmp;
if (test_opt (sb, OLDALLOC))
group = find_group_dir(sb, dir);
else
{
/*
* Use a quadratic hash to find a group with a
* free inode
*/
for (j = 1; j < EXT3_SB(sb)->s_groups_count; j <<= 1) {
i += j;
if (i >= EXT3_SB(sb)->s_groups_count)
i -= EXT3_SB(sb)->s_groups_count;
tmp = ext3_get_group_desc (sb, i, &bh2);
if (tmp &&
le16_to_cpu(tmp->bg_free_inodes_count)) {
gdp = tmp;
break;
}
}
}
if (!gdp) {
/*
* That failed: try linear search for a free inode
*/
i = EXT3_I(dir)->i_block_group + 1;
for (j = 2; j < EXT3_SB(sb)->s_groups_count; j++) {
if (++i >= EXT3_SB(sb)->s_groups_count)
i = 0;
tmp = ext3_get_group_desc (sb, i, &bh2);
if (tmp &&
le16_to_cpu(tmp->bg_free_inodes_count)) {
gdp = tmp;
break;
}
}
}
}
group = find_group_orlov(sb, dir);
} else
group = find_group_other(sb, dir);
err = -ENOSPC;
if (!gdp)
if (group == -1)
goto out;
err = -EIO;
brelse(bitmap_bh);
bitmap_bh = read_inode_bitmap(sb, i);
bitmap_bh = read_inode_bitmap(sb, group);
if (!bitmap_bh)
goto fail;
gdp = ext3_get_group_desc (sb, group, &bh2);
if ((j = ext3_find_first_zero_bit((unsigned long *)bitmap_bh->b_data,
if ((ino = ext3_find_first_zero_bit((unsigned long *)bitmap_bh->b_data,
EXT3_INODES_PER_GROUP(sb))) <
EXT3_INODES_PER_GROUP(sb)) {
BUFFER_TRACE(bitmap_bh, "get_write_access");
err = ext3_journal_get_write_access(handle, bitmap_bh);
if (err) goto fail;
if (ext3_set_bit(j, bitmap_bh->b_data)) {
if (ext3_set_bit(ino, bitmap_bh->b_data)) {
ext3_error (sb, "ext3_new_inode",
"bit already set for inode %d", j);
"bit already set for inode %lu", ino);
goto repeat;
}
BUFFER_TRACE(bitmap_bh, "call ext3_journal_dirty_metadata");
......@@ -324,7 +491,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
if (le16_to_cpu(gdp->bg_free_inodes_count) != 0) {
ext3_error (sb, "ext3_new_inode",
"Free inodes count corrupted in group %d",
i);
group);
/* Is it really ENOSPC? */
err = -ENOSPC;
if (sb->s_flags & MS_RDONLY)
......@@ -340,11 +507,11 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
}
goto repeat;
}
j += i * EXT3_INODES_PER_GROUP(sb) + 1;
if (j < EXT3_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) {
ino += group * EXT3_INODES_PER_GROUP(sb) + 1;
if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
ext3_error (sb, "ext3_new_inode",
"reserved inode or inode > inodes count - "
"block_group = %d,inode=%d", i, j);
"block_group = %d, inode=%lu", group, ino);
err = -EIO;
goto fail;
}
......@@ -382,7 +549,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
inode->i_gid = current->fsgid;
inode->i_mode = mode;
inode->i_ino = j;
inode->i_ino = ino;
/* This is the optimal IO size (for stat), not the fs block size */
inode->i_blksize = PAGE_SIZE;
inode->i_blocks = 0;
......@@ -412,7 +579,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
ei->i_prealloc_block = 0;
ei->i_prealloc_count = 0;
#endif
ei->i_block_group = i;
ei->i_block_group = group;
if (ei->i_flags & EXT3_SYNC_FL)
inode->i_flags |= S_SYNC;
......@@ -562,6 +729,21 @@ unsigned long ext3_count_free_inodes (struct super_block * sb)
#endif
}
/* Called at mount-time, super-block is locked */
unsigned long ext3_count_dirs (struct super_block * sb)
{
unsigned long count = 0;
int i;
for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
struct ext3_group_desc *gdp = ext3_get_group_desc (sb, i, NULL);
if (!gdp)
continue;
count += le16_to_cpu(gdp->bg_used_dirs_count);
}
return count;
}
#ifdef CONFIG_EXT3_CHECK
/* Called at mount-time, super-block is locked */
void ext3_check_inodes_bitmap (struct super_block * sb)
......
......@@ -390,6 +390,7 @@ void ext3_put_super (struct super_block * sb)
for (i = 0; i < sbi->s_gdb_count; i++)
brelse(sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
kfree(sbi->s_debts);
brelse(sbi->s_sbh);
/* Debugging code just in case the in-memory inode orphan list
......@@ -1221,6 +1222,13 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
printk (KERN_ERR "EXT3-fs: not enough memory\n");
goto failed_mount;
}
sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
GFP_KERNEL);
if (!sbi->s_debts) {
printk ("EXT3-fs: not enough memory\n");
goto failed_mount2;
}
memset(sbi->s_debts, 0, sbi->s_groups_count * sizeof(*sbi->s_debts));
for (i = 0; i < db_count; i++) {
block = descriptor_loc(sb, logic_sb_block, i);
sbi->s_group_desc[i] = sb_bread(sb, block);
......@@ -1236,6 +1244,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
sbi->s_dir_count = ext3_count_dirs(sb);
/*
* set up enough so that it can read an inode
*/
......@@ -1339,6 +1348,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
failed_mount3:
journal_destroy(sbi->s_journal);
failed_mount2:
if (sbi->s_debts)
kfree(sbi->s_debts);
for (i = 0; i < db_count; i++)
brelse(sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
......
......@@ -92,6 +92,7 @@ struct request {
/*
* when request is used as a packet command carrier
*/
unsigned int cmd_len;
unsigned char cmd[16];
unsigned int data_len;
......
......@@ -191,10 +191,11 @@ struct ext2_group_desc
#define EXT2_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
#define EXT2_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
#define EXT2_FL_USER_VISIBLE 0x00011FFF /* User visible flags */
#define EXT2_FL_USER_MODIFIABLE 0x000100FF /* User modifiable flags */
#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
#define EXT2_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
/*
* ioctl commands
......@@ -300,6 +301,7 @@ struct ext2_inode {
* Mount flags
*/
#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
#define EXT2_MOUNT_OLDALLOC 0x0002 /* Don't use the new Orlov allocator */
#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
......
......@@ -44,7 +44,7 @@ struct ext2_sb_info {
int s_first_ino;
u32 s_next_generation;
unsigned long s_dir_count;
u8 *debts;
u8 *s_debts;
};
#endif /* _LINUX_EXT2_FS_SB */
......@@ -186,10 +186,11 @@ struct ext3_group_desc
#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
#define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
#define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
#define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
#define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
#define EXT3_FL_USER_VISIBLE 0x00015FFF /* User visible flags */
#define EXT3_FL_USER_MODIFIABLE 0x000100FF /* User modifiable flags */
#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
/*
* Inode dynamic state flags
......@@ -308,6 +309,7 @@ struct ext3_inode {
* Mount flags
*/
#define EXT3_MOUNT_CHECK 0x0001 /* Do mount-time checks */
#define EXT3_MOUNT_OLDALLOC 0x0002 /* Don't use the new Orlov allocator */
#define EXT3_MOUNT_GRPID 0x0004 /* Create files with directory's group */
#define EXT3_MOUNT_DEBUG 0x0008 /* Some debugging messages */
#define EXT3_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
......@@ -704,6 +706,7 @@ extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
extern void ext3_free_inode (handle_t *, struct inode *);
extern struct inode * ext3_orphan_get (struct super_block *, ino_t);
extern unsigned long ext3_count_free_inodes (struct super_block *);
extern unsigned long ext3_count_dirs (struct super_block *);
extern void ext3_check_inodes_bitmap (struct super_block *);
extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
......
......@@ -50,6 +50,8 @@ struct ext3_sb_info {
u32 s_next_generation;
u32 s_hash_seed[4];
int s_def_hash_version;
unsigned long s_dir_count;
u8 *s_debts;
/* Journaling */
struct inode * s_journal_inode;
......
......@@ -196,7 +196,7 @@ int isapnp_proc_init(void);
int isapnp_proc_done(void);
#else
static inline isapnp_proc_init(void) { return 0; }
static inline isapnp_proc_done(void) { return 0; )
static inline isapnp_proc_done(void) { return 0; }
#endif
/* misc */
......
......@@ -154,6 +154,7 @@ struct uart_port {
unsigned int flags;
#define UPF_HUP_NOTIFY (1 << 0)
#define UPF_FOURPORT (1 << 1)
#define UPF_SAK (1 << 2)
#define UPF_SPD_MASK (0x1030)
#define UPF_SPD_HI (0x0010)
......@@ -167,6 +168,9 @@ struct uart_port {
#define UPF_LOW_LATENCY (1 << 13)
#define UPF_BUGGY_UART (1 << 14)
#define UPF_AUTOPROBE (1 << 15)
#define UPF_BOOT_ONLYMCA (1 << 22)
#define UPF_CONS_FLOW (1 << 23)
#define UPF_SHARE_IRQ (1 << 24)
#define UPF_BOOT_AUTOCONF (1 << 28)
#define UPF_RESOURCES (1 << 30)
#define UPF_IOREMAP (1 << 31)
......@@ -247,8 +251,6 @@ struct uart_info {
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
#define EVT_WRITE_WAKEUP 0
struct module;
struct tty_driver;
......@@ -269,7 +271,7 @@ struct uart_driver {
struct tty_driver *tty_driver;
};
void uart_event(struct uart_port *port, int event);
void uart_write_wakeup(struct uart_port *port);
struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
void uart_parse_options(char *options, int *baud, int *parity, int *bits,
......@@ -380,7 +382,7 @@ uart_handle_cts_change(struct uart_port *port, unsigned int status)
if (status) {
tty->hw_stopped = 0;
port->ops->start_tx(port, 0);
uart_event(port, EVT_WRITE_WAKEUP);
uart_write_wakeup(port);
}
} else {
if (!status) {
......
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