Merge git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/netdev-2.6
authorLinus Torvalds <torvalds@g5.osdl.org>
Wed, 17 May 2006 23:13:25 +0000 (16:13 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 17 May 2006 23:13:25 +0000 (16:13 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/netdev-2.6:
  sky2: prevent dual port receiver problems
  x86_64: Check for bad dma address in b44 1GB DMA workaround
  The ixp2000 driver for the enp2611 was developed on a board with

94 files changed:
CREDITS
Documentation/devices.txt
Documentation/memory-barriers.txt
Documentation/spi/pxa2xx [new file with mode: 0644]
Documentation/spi/spi-summary
MAINTAINERS
arch/arm/kernel/asm-offsets.c
arch/arm/kernel/dma-isa.c
arch/arm/kernel/process.c
arch/arm/lib/backtrace.S
arch/arm/lib/div64.S
arch/arm/mach-realview/realview_eb.c
arch/arm/mm/ioremap.c
arch/i386/Kconfig
arch/i386/kernel/acpi/boot.c
arch/i386/oprofile/nmi_int.c
arch/ia64/configs/sn2_defconfig
arch/ia64/kernel/iosapic.c
arch/ia64/kernel/irq.c
arch/powerpc/kernel/prom_init.c
arch/powerpc/platforms/pseries/setup.c
arch/s390/kernel/compat_wrapper.S
arch/s390/kernel/syscalls.S
arch/s390/kernel/time.c
arch/x86_64/kernel/pci-nommu.c
arch/x86_64/kernel/traps.c
arch/x86_64/mm/srat.c
drivers/char/Kconfig
drivers/char/rio/host.h
drivers/char/rio/rioboot.c
drivers/char/rio/rioctrl.c
drivers/char/rio/rioioctl.h
drivers/char/tpm/Kconfig
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm_tis.c
drivers/ide/legacy/ide-cs.c
drivers/isdn/capi/capi.c
drivers/isdn/gigaset/usb-gigaset.c
drivers/leds/Kconfig
drivers/leds/led-class.c
drivers/leds/ledtrig-timer.c
drivers/net/dl2k.c
drivers/pci/quirks.c
drivers/pcmcia/pcmcia_ioctl.c
drivers/s390/net/lcs.c
drivers/serial/serial_core.c
drivers/spi/Kconfig
drivers/spi/Makefile
drivers/spi/pxa2xx_spi.c [new file with mode: 0644]
drivers/spi/spi.c
drivers/spi/spi_bitbang.c
drivers/video/backlight/backlight.c
drivers/video/backlight/lcd.c
fs/9p/fcall.c
fs/9p/mux.c
fs/9p/mux.h
fs/9p/vfs_file.c
fs/9p/vfs_inode.c
fs/Makefile
fs/autofs4/autofs_i.h
fs/autofs4/root.c
fs/autofs4/waitq.c
fs/compat.c
fs/configfs/dir.c
fs/jffs2/nodelist.c
fs/namespace.c
fs/ocfs2/aops.c
fs/ocfs2/aops.h
fs/ocfs2/extent_map.c
fs/ocfs2/file.c
fs/ocfs2/journal.c
fs/ocfs2/uptodate.c
fs/ocfs2/vote.c
fs/open.c
fs/smbfs/dir.c
fs/smbfs/request.c
include/asm-arm/arch-pxa/pxa2xx_spi.h [new file with mode: 0644]
include/asm-arm/procinfo.h
include/asm-s390/unistd.h
include/linux/kernel.h
include/linux/rcupdate.h
include/linux/slab.h
include/linux/spi/spi.h
include/linux/spi/spi_bitbang.h
include/linux/swap.h
init/do_mounts.c
init/initramfs.c
kernel/extable.c
kernel/module.c
kernel/rcupdate.c
mm/page_alloc.c
mm/slab.c
mm/sparse.c
security/selinux/ss/services.c

diff --git a/CREDITS b/CREDITS
index 6f50be3..9bf714a 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -3241,14 +3241,9 @@ S: 12725 SW Millikan Way, Suite 400
 S: Beaverton, Oregon 97005
 S: USA
 
-N: Marcelo W. Tosatti
-E: marcelo.tosatti@cyclades.com
-D: Miscellaneous kernel hacker
+N: Marcelo Tosatti
+E: marcelo@kvack.org
 D: v2.4 kernel maintainer
-D: Current pc300/cyclades maintainer
-S: Cyclades Corporation
-S: Av Cristovao Colombo, 462. Floresta.
-S: Porto Alegre
 S: Brazil
 
 N: Stefan Traby
index 3c406ac..b369a8c 100644 (file)
@@ -1721,11 +1721,6 @@ Your cooperation is appreciated.
                These devices support the same API as the generic SCSI
                devices.
 
- 97 block      Packet writing for CD/DVD devices
-                 0 = /dev/pktcdvd0     First packet-writing module
-                 1 = /dev/pktcdvd1     Second packet-writing module
-                   ...
-
  98 char       Control and Measurement Device (comedi)
                  0 = /dev/comedi0      First comedi device
                  1 = /dev/comedi1      Second comedi device
index 92f0056..c61d8b8 100644 (file)
@@ -1031,7 +1031,7 @@ conflict on any particular lock.
 LOCKS VS MEMORY ACCESSES
 ------------------------
 
-Consider the following: the system has a pair of spinlocks (N) and (Q), and
+Consider the following: the system has a pair of spinlocks (M) and (Q), and
 three CPUs; then should the following sequence of events occur:
 
        CPU 1                           CPU 2
@@ -1678,7 +1678,7 @@ CPU's caches by some other cache event:
        smp_wmb();
        <A:modify v=2>  <C:busy>
                        <C:queue v=2>
-       p = &b;         q = p;
+       p = &v;         q = p;
                        <D:request p>
        <B:modify p=&v> <D:commit p=&v>
                        <D:read p>
diff --git a/Documentation/spi/pxa2xx b/Documentation/spi/pxa2xx
new file mode 100644 (file)
index 0000000..9c45f3d
--- /dev/null
@@ -0,0 +1,234 @@
+PXA2xx SPI on SSP driver HOWTO
+===================================================
+This a mini howto on the pxa2xx_spi driver.  The driver turns a PXA2xx
+synchronous serial port into a SPI master controller
+(see Documentation/spi/spi_summary). The driver has the following features
+
+- Support for any PXA2xx SSP
+- SSP PIO and SSP DMA data transfers.
+- External and Internal (SSPFRM) chip selects.
+- Per slave device (chip) configuration.
+- Full suspend, freeze, resume support.
+
+The driver is built around a "spi_message" fifo serviced by workqueue and a
+tasklet. The workqueue, "pump_messages", drives message fifo and the tasklet
+(pump_transfer) is responsible for queuing SPI transactions and setting up and
+launching the dma/interrupt driven transfers.
+
+Declaring PXA2xx Master Controllers
+-----------------------------------
+Typically a SPI master is defined in the arch/.../mach-*/board-*.c as a
+"platform device".  The master configuration is passed to the driver via a table
+found in include/asm-arm/arch-pxa/pxa2xx_spi.h:
+
+struct pxa2xx_spi_master {
+       enum pxa_ssp_type ssp_type;
+       u32 clock_enable;
+       u16 num_chipselect;
+       u8 enable_dma;
+};
+
+The "pxa2xx_spi_master.ssp_type" field must have a value between 1 and 3 and
+informs the driver which features a particular SSP supports.
+
+The "pxa2xx_spi_master.clock_enable" field is used to enable/disable the
+corresponding SSP peripheral block in the "Clock Enable Register (CKEN"). See
+the "PXA2xx Developer Manual" section "Clocks and Power Management".
+
+The "pxa2xx_spi_master.num_chipselect" field is used to determine the number of
+slave device (chips) attached to this SPI master.
+
+The "pxa2xx_spi_master.enable_dma" field informs the driver that SSP DMA should
+be used.  This caused the driver to acquire two DMA channels: rx_channel and
+tx_channel.  The rx_channel has a higher DMA service priority the tx_channel.
+See the "PXA2xx Developer Manual" section "DMA Controller".
+
+NSSP MASTER SAMPLE
+------------------
+Below is a sample configuration using the PXA255 NSSP.
+
+static struct resource pxa_spi_nssp_resources[] = {
+       [0] = {
+               .start  = __PREG(SSCR0_P(2)), /* Start address of NSSP */
+               .end    = __PREG(SSCR0_P(2)) + 0x2c, /* Range of registers */
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = IRQ_NSSP, /* NSSP IRQ */
+               .end    = IRQ_NSSP,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct pxa2xx_spi_master pxa_nssp_master_info = {
+       .ssp_type = PXA25x_NSSP, /* Type of SSP */
+       .clock_enable = CKEN9_NSSP, /* NSSP Peripheral clock */
+       .num_chipselect = 1, /* Matches the number of chips attached to NSSP */
+       .enable_dma = 1, /* Enables NSSP DMA */
+};
+
+static struct platform_device pxa_spi_nssp = {
+       .name = "pxa2xx-spi", /* MUST BE THIS VALUE, so device match driver */
+       .id = 2, /* Bus number, MUST MATCH SSP number 1..n */
+       .resource = pxa_spi_nssp_resources,
+       .num_resources = ARRAY_SIZE(pxa_spi_nssp_resources),
+       .dev = {
+               .platform_data = &pxa_nssp_master_info, /* Passed to driver */
+       },
+};
+
+static struct platform_device *devices[] __initdata = {
+       &pxa_spi_nssp,
+};
+
+static void __init board_init(void)
+{
+       (void)platform_add_device(devices, ARRAY_SIZE(devices));
+}
+
+Declaring Slave Devices
+-----------------------
+Typically each SPI slave (chip) is defined in the arch/.../mach-*/board-*.c
+using the "spi_board_info" structure found in "linux/spi/spi.h". See
+"Documentation/spi/spi_summary" for additional information.
+
+Each slave device attached to the PXA must provide slave specific configuration
+information via the structure "pxa2xx_spi_chip" found in
+"include/asm-arm/arch-pxa/pxa2xx_spi.h".  The pxa2xx_spi master controller driver
+will uses the configuration whenever the driver communicates with the slave
+device.
+
+struct pxa2xx_spi_chip {
+       u8 tx_threshold;
+       u8 rx_threshold;
+       u8 dma_burst_size;
+       u32 timeout_microsecs;
+       u8 enable_loopback;
+       void (*cs_control)(u32 command);
+};
+
+The "pxa2xx_spi_chip.tx_threshold" and "pxa2xx_spi_chip.rx_threshold" fields are
+used to configure the SSP hardware fifo.  These fields are critical to the
+performance of pxa2xx_spi driver and misconfiguration will result in rx
+fifo overruns (especially in PIO mode transfers). Good default values are
+
+       .tx_threshold = 12,
+       .rx_threshold = 4,
+
+The "pxa2xx_spi_chip.dma_burst_size" field is used to configure PXA2xx DMA
+engine and is related the "spi_device.bits_per_word" field.  Read and understand
+the PXA2xx "Developer Manual" sections on the DMA controller and SSP Controllers
+to determine the correct value. An SSP configured for byte-wide transfers would
+use a value of 8.
+
+The "pxa2xx_spi_chip.timeout_microsecs" fields is used to efficiently handle
+trailing bytes in the SSP receiver fifo.  The correct value for this field is
+dependent on the SPI bus speed ("spi_board_info.max_speed_hz") and the specific
+slave device.  Please note the the PXA2xx SSP 1 does not support trailing byte
+timeouts and must busy-wait any trailing bytes.
+
+The "pxa2xx_spi_chip.enable_loopback" field is used to place the SSP porting
+into internal loopback mode.  In this mode the SSP controller internally
+connects the SSPTX pin the the SSPRX pin.  This is useful for initial setup
+testing.
+
+The "pxa2xx_spi_chip.cs_control" field is used to point to a board specific
+function for asserting/deasserting a slave device chip select.  If the field is
+NULL, the pxa2xx_spi master controller driver assumes that the SSP port is
+configured to use SSPFRM instead.
+
+NSSP SALVE SAMPLE
+-----------------
+The pxa2xx_spi_chip structure is passed to the pxa2xx_spi driver in the
+"spi_board_info.controller_data" field. Below is a sample configuration using
+the PXA255 NSSP.
+
+/* Chip Select control for the CS8415A SPI slave device */
+static void cs8415a_cs_control(u32 command)
+{
+       if (command & PXA2XX_CS_ASSERT)
+               GPCR(2) = GPIO_bit(2);
+       else
+               GPSR(2) = GPIO_bit(2);
+}
+
+/* Chip Select control for the CS8405A SPI slave device */
+static void cs8405a_cs_control(u32 command)
+{
+       if (command & PXA2XX_CS_ASSERT)
+               GPCR(3) = GPIO_bit(3);
+       else
+               GPSR(3) = GPIO_bit(3);
+}
+
+static struct pxa2xx_spi_chip cs8415a_chip_info = {
+       .tx_threshold = 12, /* SSP hardward FIFO threshold */
+       .rx_threshold = 4, /* SSP hardward FIFO threshold */
+       .dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
+       .timeout_microsecs = 64, /* Wait at least 64usec to handle trailing */
+       .cs_control = cs8415a_cs_control, /* Use external chip select */
+};
+
+static struct pxa2xx_spi_chip cs8405a_chip_info = {
+       .tx_threshold = 12, /* SSP hardward FIFO threshold */
+       .rx_threshold = 4, /* SSP hardward FIFO threshold */
+       .dma_burst_size = 8, /* Byte wide transfers used so 8 byte bursts */
+       .timeout_microsecs = 64, /* Wait at least 64usec to handle trailing */
+       .cs_control = cs8405a_cs_control, /* Use external chip select */
+};
+
+static struct spi_board_info streetracer_spi_board_info[] __initdata = {
+       {
+               .modalias = "cs8415a", /* Name of spi_driver for this device */
+               .max_speed_hz = 3686400, /* Run SSP as fast a possbile */
+               .bus_num = 2, /* Framework bus number */
+               .chip_select = 0, /* Framework chip select */
+               .platform_data = NULL; /* No spi_driver specific config */
+               .controller_data = &cs8415a_chip_info, /* Master chip config */
+               .irq = STREETRACER_APCI_IRQ, /* Slave device interrupt */
+       },
+       {
+               .modalias = "cs8405a", /* Name of spi_driver for this device */
+               .max_speed_hz = 3686400, /* Run SSP as fast a possbile */
+               .bus_num = 2, /* Framework bus number */
+               .chip_select = 1, /* Framework chip select */
+               .controller_data = &cs8405a_chip_info, /* Master chip config */
+               .irq = STREETRACER_APCI_IRQ, /* Slave device interrupt */
+       },
+};
+
+static void __init streetracer_init(void)
+{
+       spi_register_board_info(streetracer_spi_board_info,
+                               ARRAY_SIZE(streetracer_spi_board_info));
+}
+
+
+DMA and PIO I/O Support
+-----------------------
+The pxa2xx_spi driver support both DMA and interrupt driven PIO message
+transfers.  The driver defaults to PIO mode and DMA transfers must enabled by
+setting the "enable_dma" flag in the "pxa2xx_spi_master" structure and and
+ensuring that the "pxa2xx_spi_chip.dma_burst_size" field is non-zero.  The DMA
+mode support both coherent and stream based DMA mappings.
+
+The following logic is used to determine the type of I/O to be used on
+a per "spi_transfer" basis:
+
+if !enable_dma or dma_burst_size == 0 then
+       always use PIO transfers
+
+if spi_message.is_dma_mapped and rx_dma_buf != 0 and tx_dma_buf != 0 then
+       use coherent DMA mode
+
+if rx_buf and tx_buf are aligned on 8 byte boundary then
+       use streaming DMA mode
+
+otherwise
+       use PIO transfer
+
+THANKS TO
+---------
+
+David Brownell and others for mentoring the development of this driver.
+
index a5ffba3..068732d 100644 (file)
@@ -414,7 +414,33 @@ to get the driver-private data allocated for that device.
 The driver will initialize the fields of that spi_master, including the
 bus number (maybe the same as the platform device ID) and three methods
 used to interact with the SPI core and SPI protocol drivers.  It will
-also initialize its own internal state.
+also initialize its own internal state.  (See below about bus numbering
+and those methods.)
+
+After you initialize the spi_master, then use spi_register_master() to
+publish it to the rest of the system.  At that time, device nodes for
+the controller and any predeclared spi devices will be made available,
+and the driver model core will take care of binding them to drivers.
+
+If you need to remove your SPI controller driver, spi_unregister_master()
+will reverse the effect of spi_register_master().
+
+
+BUS NUMBERING
+
+Bus numbering is important, since that's how Linux identifies a given
+SPI bus (shared SCK, MOSI, MISO).  Valid bus numbers start at zero.  On
+SOC systems, the bus numbers should match the numbers defined by the chip
+manufacturer.  For example, hardware controller SPI2 would be bus number 2,
+and spi_board_info for devices connected to it would use that number.
+
+If you don't have such hardware-assigned bus number, and for some reason
+you can't just assign them, then provide a negative bus number.  That will
+then be replaced by a dynamically assigned number. You'd then need to treat
+this as a non-static configuration (see above).
+
+
+SPI MASTER METHODS
 
     master->setup(struct spi_device *spi)
        This sets up the device clock rate, SPI mode, and word sizes.
@@ -431,6 +457,9 @@ also initialize its own internal state.
        state it dynamically associates with that device.  If you do that,
        be sure to provide the cleanup() method to free that state.
 
+
+SPI MESSAGE QUEUE
+
 The bulk of the driver will be managing the I/O queue fed by transfer().
 
 That queue could be purely conceptual.  For example, a driver used only
@@ -440,6 +469,9 @@ But the queue will probably be very real, using message->queue, PIO,
 often DMA (especially if the root filesystem is in SPI flash), and
 execution contexts like IRQ handlers, tasklets, or workqueues (such
 as keventd).  Your driver can be as fancy, or as simple, as you need.
+Such a transfer() method would normally just add the message to a
+queue, and then start some asynchronous transfer engine (unless it's
+already running).
 
 
 THANKS TO
index 5e33558..753584c 100644 (file)
@@ -1603,6 +1603,11 @@ M:       James.Bottomley@HansenPartnership.com
 L:     linux-scsi@vger.kernel.org
 S:     Maintained
 
+LED SUBSYSTEM
+P:     Richard Purdie
+M:     rpurdie@rpsys.net
+S:     Maintained
+
 LEGO USB Tower driver
 P:     Juergen Stuber
 M:     starblue@users.sourceforge.net
@@ -1662,7 +1667,7 @@ S:        Maintained
 
 LINUX FOR POWERPC EMBEDDED PPC8XX
 P:     Marcelo Tosatti
-M:     marcelo.tosatti@cyclades.com
+M:     marcelo@kvack.org
 W:     http://www.penguinppc.org/
 L:     linuxppc-embedded@ozlabs.org
 S:     Maintained
@@ -2513,6 +2518,12 @@ M:       perex@suse.cz
 L:     alsa-devel@alsa-project.org
 S:     Maintained
 
+SPI SUBSYSTEM
+P:     David Brownell
+M:     dbrownell@users.sourceforge.net
+L:     spi-devel-general@lists.sourceforge.net
+S:     Maintained
+
 TPM DEVICE DRIVER
 P:     Kylene Hall
 M:     kjhall@us.ibm.com
index 45fdf4a..396efba 100644 (file)
@@ -99,6 +99,8 @@ int main(void)
   DEFINE(MACHINFO_NAME,                offsetof(struct machine_desc, name));
   DEFINE(MACHINFO_PHYSIO,      offsetof(struct machine_desc, phys_io));
   DEFINE(MACHINFO_PGOFFIO,     offsetof(struct machine_desc, io_pg_offst));
+  BLANK();
+  DEFINE(PROC_INFO_SZ,         sizeof(struct proc_info_list));
   DEFINE(PROCINFO_INITFUNC,    offsetof(struct proc_info_list, __cpu_flush));
   DEFINE(PROCINFO_MMUFLAGS,    offsetof(struct proc_info_list, __cpu_mmu_flags));
   return 0; 
index 0353276..0a3e9ad 100644 (file)
@@ -143,12 +143,23 @@ static struct dma_ops isa_dma_ops = {
        .residue        = isa_get_dma_residue,
 };
 
-static struct resource dma_resources[] = {
-       { "dma1",               0x0000, 0x000f },
-       { "dma low page",       0x0080, 0x008f },
-       { "dma2",               0x00c0, 0x00df },
-       { "dma high page",      0x0480, 0x048f }
-};
+static struct resource dma_resources[] = { {
+       .name   = "dma1",
+       .start  = 0x0000,
+       .end    = 0x000f
+}, {
+       .name   = "dma low page",
+       .start  = 0x0080,
+       .end    = 0x008f
+}, {
+       .name   = "dma2",
+       .start  = 0x00c0,
+       .end    = 0x00df
+}, {
+       .name   = "dma high page",
+       .start  = 0x0480,
+       .end    = 0x048f
+} };
 
 void __init isa_init_dma(dma_t *dma)
 {
index 1a1539e..7df6e1a 100644 (file)
@@ -311,7 +311,7 @@ void free_thread_info(struct thread_info *thread)
                struct thread_info_list *th = &get_cpu_var(thread_info_list);
                if (th->nr < EXTRA_TASK_STRUCT) {
                        unsigned long *p = (unsigned long *)thread;
-                       p[0] = th->head;
+                       p[0] = (unsigned long)th->head;
                        th->head = p;
                        th->nr += 1;
                        put_cpu_var(thread_info_list);
index 3bdc8c6..16153c8 100644 (file)
@@ -122,7 +122,7 @@ ENTRY(c_backtrace)
 #define reg   r5
 #define stack r6
 
-.Ldumpstm:     stmfd   sp!, {instr, reg, stack, r7, lr}
+.Ldumpstm:     stmfd   sp!, {instr, reg, stack, r7, r8, lr}
                mov     stack, r0
                mov     instr, r1
                mov     reg, #9
@@ -145,7 +145,7 @@ ENTRY(c_backtrace)
                adrne   r0, .Lcr
                blne    printk
                mov     r0, stack
-               LOADREGS(fd, sp!, {instr, reg, stack, r7, pc})
+               LOADREGS(fd, sp!, {instr, reg, stack, r7, r8, pc})
 
 .Lfp:          .asciz  " r%d = %08X%c"
 .Lcr:          .asciz  "\n"
index ec9a1cd..58eef66 100644 (file)
@@ -189,12 +189,12 @@ ENTRY(__do_div64)
        moveq   pc, lr
 
        @ Division by 0:
-       str     lr, [sp, #-4]!
+       str     lr, [sp, #-8]!
        bl      __div0
 
        @ as wrong as it could be...
        mov     yl, #0
        mov     yh, #0
        mov     xh, #0
-       ldr     pc, [sp], #4
+       ldr     pc, [sp], #8
 
index d4a586e..693fb1e 100644 (file)
@@ -137,8 +137,11 @@ static struct amba_device *amba_devs[] __initdata = {
 static void __init gic_init_irq(void)
 {
 #ifdef CONFIG_REALVIEW_MPCORE
+       unsigned int pldctrl;
        writel(0x0000a05f, __io_address(REALVIEW_SYS_LOCK));
-       writel(0x008003c0, __io_address(REALVIEW_SYS_BASE) + 0xd8);
+       pldctrl = readl(__io_address(REALVIEW_SYS_BASE) + 0xd8);
+       pldctrl |= 0x00800000;  /* New irq mode */
+       writel(pldctrl, __io_address(REALVIEW_SYS_BASE) + 0xd8);
        writel(0x00000000, __io_address(REALVIEW_SYS_LOCK));
 #endif
        gic_dist_init(__io_address(REALVIEW_GIC_DIST_BASE));
index 25e0ca3..c1f7180 100644 (file)
@@ -141,7 +141,7 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
                return NULL;
        addr = (unsigned long)area->addr;
        if (remap_area_pages(addr, pfn, size, flags)) {
-               vfree((void *)addr);
+               vunmap((void *)addr);
                return NULL;
        }
        return (void __iomem *) (offset + (char *)addr);
@@ -173,7 +173,7 @@ EXPORT_SYMBOL(__ioremap);
 
 void __iounmap(void __iomem *addr)
 {
-       vfree((void *) (PAGE_MASK & (unsigned long) addr));
+       vunmap((void *)(PAGE_MASK & (unsigned long)addr));
 }
 EXPORT_SYMBOL(__iounmap);
 
index c6fe99e..8dfa305 100644 (file)
@@ -758,10 +758,10 @@ config HOTPLUG_CPU
        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
        depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER
        ---help---
-         Say Y here to experiment with turning CPUs off and on.  CPUs
-         can be controlled through /sys/devices/system/cpu.
+         Say Y here to experiment with turning CPUs off and on, and to
+         enable suspend on SMP systems. CPUs can be controlled through
+         /sys/devices/system/cpu.
 
-         Say N.
 
 endmenu
 
index 40e5aba..daee695 100644 (file)
@@ -1066,6 +1066,14 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
                     DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
                     },
         },
+       {
+        .callback = disable_acpi_pci,
+        .ident = "HP xw9300",
+        .matches = {
+                   DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+                   DMI_MATCH(DMI_PRODUCT_NAME, "HP xw9300 Workstation"),
+                   },
+       },
        {}
 };
 
index 1a2076c..ec0fd3c 100644 (file)
@@ -332,10 +332,11 @@ static int __init ppro_init(char ** cpu_type)
 {
        __u8 cpu_model = boot_cpu_data.x86_model;
 
-       if (cpu_model > 0xd)
+       if (cpu_model == 14)
+               *cpu_type = "i386/core";
+       else if (cpu_model > 0xd)
                return 0;
-
-       if (cpu_model == 9) {
+       else if (cpu_model == 9) {
                *cpu_type = "i386/p6_mobile";
        } else if (cpu_model > 5) {
                *cpu_type = "i386/piii";
index f6a8853..9ea3539 100644 (file)
@@ -134,7 +134,7 @@ CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
 CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
 CONFIG_NUMA=y
-CONFIG_NODES_SHIFT=8
+CONFIG_NODES_SHIFT=10
 CONFIG_VIRTUAL_MEM_MAP=y
 CONFIG_HOLES_IN_ZONE=y
 CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
@@ -1159,7 +1159,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_DEBUG_SLAB is not set
 CONFIG_DEBUG_PREEMPT=y
-CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_MUTEXES is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_KOBJECT is not set
index 7956eb9..d58c1c5 100644 (file)
@@ -416,7 +416,7 @@ iosapic_end_level_irq (unsigned int irq)
        ia64_vector vec = irq_to_vector(irq);
        struct iosapic_rte_info *rte;
 
-       move_irq(irq);
+       move_native_irq(irq);
        list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list)
                iosapic_eoi(rte->addr, vec);
 }
@@ -458,7 +458,7 @@ iosapic_ack_edge_irq (unsigned int irq)
 {
        irq_desc_t *idesc = irq_descp(irq);
 
-       move_irq(irq);
+       move_native_irq(irq);
        /*
         * Once we have recorded IRQ_PENDING already, we can mask the
         * interrupt for real. This prevents IRQ storms from unhandled
index 5ce908e..9c72ea3 100644 (file)
@@ -101,7 +101,6 @@ void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
 
        if (irq < NR_IRQS) {
                irq_affinity[irq] = mask;
-               set_irq_info(irq, mask);
                irq_redir[irq] = (char) (redir & 0xff);
        }
 }
index 078fb55..2d80653 100644 (file)
@@ -1636,7 +1636,7 @@ static int __init prom_find_machine_type(void)
                           compat, sizeof(compat)-1);
        if (len <= 0)
                return PLATFORM_GENERIC;
-       if (strncmp(compat, RELOC("chrp"), 4))
+       if (strcmp(compat, RELOC("chrp")))
                return PLATFORM_GENERIC;
 
        /* Default to pSeries. We need to know if we are running LPAR */
index 5eb55ef..5f79f01 100644 (file)
@@ -255,7 +255,7 @@ static int __init pSeries_init_panel(void)
 {
        /* Manually leave the kernel version on the panel. */
        ppc_md.progress("Linux ppc64\n", 0);
-       ppc_md.progress(system_utsname.version, 0);
+       ppc_md.progress(system_utsname.release, 0);
 
        return 0;
 }
index ef5b9c4..4d53b27 100644 (file)
@@ -1650,3 +1650,11 @@ sys_tee_wrapper:
        llgfr   %r4,%r4                 # size_t
        llgfr   %r5,%r5                 # unsigned int
        jg      sys_tee
+
+       .globl compat_sys_vmsplice_wrapper
+compat_sys_vmsplice_wrapper:
+       lgfr    %r2,%r2                 # int
+       llgtr   %r3,%r3                 # compat_iovec *
+       llgfr   %r4,%r4                 # unsigned int
+       llgfr   %r5,%r5                 # unsigned int
+       jg      compat_sys_vmsplice
index fc2c076..93be1d5 100644 (file)
@@ -317,3 +317,4 @@ SYSCALL(sys_get_robust_list,sys_get_robust_list,compat_sys_get_robust_list_wrapp
 SYSCALL(sys_splice,sys_splice,sys_splice_wrapper)
 SYSCALL(sys_sync_file_range,sys_sync_file_range,sys_sync_file_range_wrapper)
 SYSCALL(sys_tee,sys_tee,sys_tee_wrapper)
+SYSCALL(sys_vmsplice,sys_vmsplice,compat_sys_vmsplice_wrapper)
index fea043b..029f099 100644 (file)
@@ -249,18 +249,19 @@ static inline void stop_hz_timer(void)
        unsigned long flags;
        unsigned long seq, next;
        __u64 timer, todval;
+       int cpu = smp_processor_id();
 
        if (sysctl_hz_timer != 0)
                return;
 
-       cpu_set(smp_processor_id(), nohz_cpu_mask);
+       cpu_set(cpu, nohz_cpu_mask);
 
        /*
         * Leave the clock comparator set up for the next timer
         * tick if either rcu or a softirq is pending.
         */
-       if (rcu_pending(smp_processor_id()) || local_softirq_pending()) {
-               cpu_clear(smp_processor_id(), nohz_cpu_mask);
+       if (rcu_needs_cpu(cpu) || local_softirq_pending()) {
+               cpu_clear(cpu, nohz_cpu_mask);
                return;
        }
 
index 44adcc2..1f6ecc6 100644 (file)
@@ -12,9 +12,10 @@ static int
 check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
 {
         if (hwdev && bus + size > *hwdev->dma_mask) {
-               printk(KERN_ERR
-                   "nommu_%s: overflow %Lx+%lu of device mask %Lx\n",
-              name, (long long)bus, size, (long long)*hwdev->dma_mask);
+               if (*hwdev->dma_mask >= 0xffffffffULL)
+                       printk(KERN_ERR
+                           "nommu_%s: overflow %Lx+%lu of device mask %Lx\n",
+                               name, (long long)bus, size, (long long)*hwdev->dma_mask);
                return 0;
        }
        return 1;
index 6b87268..cea335e 100644 (file)
@@ -102,6 +102,8 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
 {
        if (regs->eflags & X86_EFLAGS_IF)
                local_irq_disable();
+       /* Make sure to not schedule here because we could be running
+          on an exception stack. */
        preempt_enable_no_resched();
 }
 
@@ -483,8 +485,6 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
 {
        struct task_struct *tsk = current;
 
-       conditional_sti(regs);
-
        tsk->thread.error_code = error_code;
        tsk->thread.trap_no = trapnr;
 
@@ -521,6 +521,7 @@ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
        if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
                                                        == NOTIFY_STOP) \
                return; \
+       conditional_sti(regs);                                          \
        do_trap(trapnr, signr, str, regs, error_code, NULL); \
 }
 
@@ -535,6 +536,7 @@ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
        if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
                                                        == NOTIFY_STOP) \
                return; \
+       conditional_sti(regs);                                          \
        do_trap(trapnr, signr, str, regs, error_code, &info); \
 }
 
@@ -548,7 +550,17 @@ DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
 DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
 DO_ERROR(18, SIGSEGV, "reserved", reserved)
-DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
+
+/* Runs on IST stack */
+asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
+{
+       if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
+                       12, SIGBUS) == NOTIFY_STOP)
+               return;
+       preempt_conditional_sti(regs);
+       do_trap(12, SIGBUS, "stack segment", regs, error_code, NULL);
+       preempt_conditional_cli(regs);
+}
 
 asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
 {
@@ -682,8 +694,9 @@ asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
        if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
                return;
        }
+       preempt_conditional_sti(regs);
        do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
-       return;
+       preempt_conditional_cli(regs);
 }
 
 /* Help handler running on IST stack to switch back to user stack
index 15ae9fc..e151353 100644 (file)
@@ -34,7 +34,10 @@ static nodemask_t nodes_found __initdata;
 static struct bootnode nodes[MAX_NUMNODES] __initdata;
 static struct bootnode nodes_add[MAX_NUMNODES] __initdata;
 static int found_add_area __initdata;
-int hotadd_percent __initdata = 10;
+int hotadd_percent __initdata = 0;
+#ifndef RESERVE_HOTADD
+#define hotadd_percent 0       /* Ignore all settings */
+#endif
 static u8 pxm2node[256] = { [0 ... 255] = 0xff };
 
 /* Too small nodes confuse the VM badly. Usually they result
@@ -103,6 +106,7 @@ static __init void bad_srat(void)
        int i;
        printk(KERN_ERR "SRAT: SRAT not used.\n");
        acpi_numa = -1;
+       found_add_area = 0;
        for (i = 0; i < MAX_LOCAL_APIC; i++)
                apicid_to_node[i] = NUMA_NO_NODE;
        for (i = 0; i < MAX_NUMNODES; i++)
@@ -154,7 +158,8 @@ acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
        int pxm, node;
        if (srat_disabled())
                return;
-       if (pa->header.length != sizeof(struct acpi_table_processor_affinity)) {                bad_srat();
+       if (pa->header.length != sizeof(struct acpi_table_processor_affinity)) {
+               bad_srat();
                return;
        }
        if (pa->flags.enabled == 0)
@@ -191,15 +196,17 @@ static int hotadd_enough_memory(struct bootnode *nd)
        allowed = (end_pfn - e820_hole_size(0, end_pfn)) * PAGE_SIZE;
        allowed = (allowed / 100) * hotadd_percent;
        if (allocated + mem > allowed) {
+               unsigned long range;
                /* Give them at least part of their hotadd memory upto hotadd_percent
                   It would be better to spread the limit out
                   over multiple hotplug areas, but that is too complicated
                   right now */
                if (allocated >= allowed)
                        return 0;
-               pages = (allowed - allocated + mem) / sizeof(struct page);
+               range = allowed - allocated;
+               pages = (range / PAGE_SIZE);
                mem = pages * sizeof(struct page);
-               nd->end = nd->start + pages*PAGE_SIZE;
+               nd->end = nd->start + range;
        }
        /* Not completely fool proof, but a good sanity check */
        addr = find_e820_area(last_area_end, end_pfn<<PAGE_SHIFT, mem);
index 4022966..78d928f 100644 (file)
@@ -291,7 +291,7 @@ config SX
 
 config RIO
        tristate "Specialix RIO system support"
-       depends on SERIAL_NONSTANDARD && !64BIT
+       depends on SERIAL_NONSTANDARD
        help
          This is a driver for the Specialix RIO, a smart serial card which
          drives an outboard box that can support up to 128 ports.  Product
index 3ec73d1..179cdbe 100644 (file)
 #ifndef __rio_host_h__
 #define __rio_host_h__
 
-#ifdef SCCS_LABELS
-#ifndef lint
-static char *_host_h_sccs_ = "@(#)host.h       1.2";
-#endif
-#endif
-
 /*
 ** the host structure - one per host card in the system.
 */
@@ -77,9 +71,6 @@ struct Host {
 #define RC_STARTUP            1
 #define RC_RUNNING            2
 #define RC_STUFFED            3
-#define RC_SOMETHING          4
-#define RC_SOMETHING_NEW      5
-#define RC_SOMETHING_ELSE     6
 #define RC_READY              7
 #define RUN_STATE             7
 /*
index acda932..290143a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/slab.h>
 #include <linux/termios.h>
 #include <linux/serial.h>
+#include <linux/vmalloc.h>
 #include <asm/semaphore.h>
 #include <linux/generic_serial.h>
 #include <linux/errno.h>
index d31aba6..75b2557 100644 (file)
@@ -1394,14 +1394,17 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
                return RIO_FAIL;
        }
 
-       if (((int) ((char) PortP->InUse) == -1) || !(CmdBlkP = RIOGetCmdBlk())) {
-               rio_dprintk(RIO_DEBUG_CTRL, "Cannot allocate command block for command %d on port %d\n", Cmd, PortP->PortNum);
+       if ((PortP->InUse == (typeof(PortP->InUse))-1) ||
+                       !(CmdBlkP = RIOGetCmdBlk())) {
+               rio_dprintk(RIO_DEBUG_CTRL, "Cannot allocate command block "
+                       "for command %d on port %d\n", Cmd, PortP->PortNum);
                return RIO_FAIL;
        }
 
-       rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse);
+       rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n",
+                       CmdBlkP, PortP->InUse);
 
-       PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
+       PktCmdP = (struct PktCmd_M *)&CmdBlkP->Packet.data[0];
 
        CmdBlkP->Packet.src_unit = 0;
        if (PortP->SecondBlock)
@@ -1425,38 +1428,46 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
 
        switch (Cmd) {
        case MEMDUMP:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p "
+                               "(addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
                PktCmdP->SubCommand = MEMDUMP;
                PktCmdP->SubAddr = SubCmd.Addr;
                break;
        case FCLOSE:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n",
+                               CmdBlkP);
                break;
        case READ_REGISTER:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) "
+                               "command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
                PktCmdP->SubCommand = READ_REGISTER;
                PktCmdP->SubAddr = SubCmd.Addr;
                break;
        case RESUME:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n",
+                               CmdBlkP);
                break;
        case RFLUSH:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n",
+                               CmdBlkP);
                CmdBlkP->PostFuncP = RIORFlushEnable;
                break;
        case SUSPEND:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n",
+                               CmdBlkP);
                break;
 
        case MGET:
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n",
+                               CmdBlkP);
                break;
 
        case MSET:
        case MBIC:
        case MBIS:
                CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
-               rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP);
+               rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command "
+                               "blk %p\n", CmdBlkP);
                break;
 
        case WFLUSH:
@@ -1465,12 +1476,14 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
                 ** allowed then we should not bother sending any more to the
                 ** RTA.
                 */
-               if ((int) ((char) PortP->WflushFlag) == (int) -1) {
-                       rio_dprintk(RIO_DEBUG_CTRL, "Trashed WFLUSH, WflushFlag about to wrap!");
+               if (PortP->WflushFlag == (typeof(PortP->WflushFlag))-1) {
+                       rio_dprintk(RIO_DEBUG_CTRL, "Trashed WFLUSH, "
+                                       "WflushFlag about to wrap!");
                        RIOFreeCmdBlk(CmdBlkP);
                        return (RIO_FAIL);
                } else {
-                       rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP);
+                       rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command "
+                                       "blk %p\n", CmdBlkP);
                        CmdBlkP->PostFuncP = RIOWFlushMark;
                }
                break;
index 14b83fa..e8af5b3 100644 (file)
 #ifndef        __rioioctl_h__
 #define        __rioioctl_h__
 
-#ifdef SCCS_LABELS
-static char *_rioioctl_h_sccs_ = "@(#)rioioctl.h       1.2";
-#endif
-
 /*
 ** RIO device driver - user ioctls and associated structures.
 */
@@ -44,55 +40,13 @@ static char *_rioioctl_h_sccs_ = "@(#)rioioctl.h    1.2";
 struct portStats {
        int port;
        int gather;
-       ulong txchars;
-       ulong rxchars;
-       ulong opens;
-       ulong closes;
-       ulong ioctls;
+       unsigned long txchars;
+       unsigned long rxchars;
+       unsigned long opens;
+       unsigned long closes;
+       unsigned long ioctls;
 };
 
-
-#define rIOC   ('r'<<8)
-#define        TCRIOSTATE      (rIOC | 1)
-#define        TCRIOXPON       (rIOC | 2)
-#define        TCRIOXPOFF      (rIOC | 3)
-#define        TCRIOXPCPS      (rIOC | 4)
-#define        TCRIOXPRINT     (rIOC | 5)
-#define TCRIOIXANYON   (rIOC | 6)
-#define        TCRIOIXANYOFF   (rIOC | 7)
-#define TCRIOIXONON    (rIOC | 8)
-#define        TCRIOIXONOFF    (rIOC | 9)
-#define        TCRIOMBIS       (rIOC | 10)
-#define        TCRIOMBIC       (rIOC | 11)
-#define        TCRIOTRIAD      (rIOC | 12)
-#define TCRIOTSTATE    (rIOC | 13)
-
-/*
-** 15.10.1998 ARG - ESIL 0761 part fix
-** Add RIO ioctls for manipulating RTS and CTS flow control, (as LynxOS
-** appears to not support hardware flow control).
-*/
-#define TCRIOCTSFLOWEN (rIOC | 14)     /* enable CTS flow control */
-#define TCRIOCTSFLOWDIS        (rIOC | 15)     /* disable CTS flow control */
-#define TCRIORTSFLOWEN (rIOC | 16)     /* enable RTS flow control */
-#define TCRIORTSFLOWDIS        (rIOC | 17)     /* disable RTS flow control */
-
-/*
-** 09.12.1998 ARG - ESIL 0776 part fix
-** Definition for 'RIOC' also appears in daemon.h, so we'd better do a
-** #ifndef here first.
-** 'RIO_QUICK_CHECK' also #define'd here as this ioctl is now
-** allowed to be used by customers.
-**
-** 05.02.1999 ARG -
-** This is what I've decied to do with ioctls etc., which are intended to be
-** invoked from users applications :
-** Anything that needs to be defined here will be removed from daemon.h, that
-** way it won't end up having to be defined/maintained in two places. The only
-** consequence of this is that this file should now be #include'd by daemon.h
-**
-** 'stats' ioctls now #define'd here as they are to be used by customers.
-*/
 #define        RIOC    ('R'<<8)|('i'<<16)|('o'<<24)
 
 #define        RIO_QUICK_CHECK         (RIOC | 105)
index 1efde3b..fe00c7d 100644 (file)
@@ -22,7 +22,7 @@ config TCG_TPM
 
 config TCG_TIS
        tristate "TPM Interface Specification 1.2 Interface"
-       depends on TCG_TPM
+       depends on TCG_TPM && PNPACPI
        ---help---
          If you have a TPM security chip that is compliant with the
          TCG TIS 1.2 TPM specification say Yes and it will be accessible
index 54a4c80..050ced2 100644 (file)
@@ -140,7 +140,7 @@ extern int tpm_pm_resume(struct device *);
 extern struct dentry ** tpm_bios_log_setup(char *);
 extern void tpm_bios_log_teardown(struct dentry **);
 #else
-static inline struct dentry* tpm_bios_log_setup(char *name)
+static inline struct dentry ** tpm_bios_log_setup(char *name)
 {
        return NULL;
 }
index b9cae9a..f621168 100644 (file)
@@ -55,7 +55,7 @@ enum tis_int_flags {
 };
 
 enum tis_defaults {
-       TIS_MEM_BASE = 0xFED4000,
+       TIS_MEM_BASE = 0xFED40000,
        TIS_MEM_LEN = 0x5000,
        TIS_SHORT_TIMEOUT = 750,        /* ms */
        TIS_LONG_TIMEOUT = 2000,        /* 2 sec */
index 4961f1e..602797a 100644 (file)
@@ -392,6 +392,7 @@ static struct pcmcia_device_id ide_ids[] = {
        PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e),
        PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae),
        PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178),
+       PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178),
        PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753),
        PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2      ", 0x547e66dc, 0x8671043b),
        PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149),
index 9b493f0..173c899 100644 (file)
@@ -1499,7 +1499,6 @@ static int __init capi_init(void)
                printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
                return major_ret;
        }
-       capi_major = major_ret;
        capi_class = class_create(THIS_MODULE, "capi");
        if (IS_ERR(capi_class)) {
                unregister_chrdev(capi_major, "capi20");
index bfb73fd..d86ab68 100644 (file)
@@ -710,8 +710,8 @@ static int gigaset_probe(struct usb_interface *interface,
        retval = -ENODEV; //FIXME
 
        /* See if the device offered us matches what we can accept */
-       if ((le16_to_cpu(udev->descriptor.idVendor  != USB_M105_VENDOR_ID)) ||
-           (le16_to_cpu(udev->descriptor.idProduct != USB_M105_PRODUCT_ID)))
+       if ((le16_to_cpu(udev->descriptor.idVendor)  != USB_M105_VENDOR_ID) ||
+           (le16_to_cpu(udev->descriptor.idProduct) != USB_M105_PRODUCT_ID))
                return -ENODEV;
 
        /* this starts to become ascii art... */
index 3f5b647..6265062 100644 (file)
@@ -4,8 +4,11 @@ menu "LED devices"
 config NEW_LEDS
        bool "LED Support"
        help
-         Say Y to enable Linux LED support.  This is not related to standard
-         keyboard LEDs which are controlled via the input system.
+         Say Y to enable Linux LED support.  This allows control of supported
+         LEDs from both userspace and optionally, by kernel events (triggers).
+
+         This is not related to standard keyboard LEDs which are controlled
+         via the input system.
 
 config LEDS_CLASS
        tristate "LED Class Support"
index b0b5d05..c75d0ef 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/sysdev.h>
 #include <linux/timer.h>
 #include <linux/err.h>
+#include <linux/ctype.h>
 #include <linux/leds.h>
 #include "leds.h"
 
@@ -43,9 +44,13 @@ static ssize_t led_brightness_store(struct class_device *dev,
        ssize_t ret = -EINVAL;
        char *after;
        unsigned long state = simple_strtoul(buf, &after, 10);
+       size_t count = after - buf;
 
-       if (after - buf > 0) {
-               ret = after - buf;
+       if (*after && isspace(*after))
+               count++;
+
+       if (count == size) {
+               ret = count;
                led_set_brightness(led_cdev, state);
        }
 
index f484b5d..fbf141e 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/sysdev.h>
 #include <linux/timer.h>
+#include <linux/ctype.h>
 #include <linux/leds.h>
 #include "leds.h"
 
@@ -69,11 +70,15 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf,
        int ret = -EINVAL;
        char *after;
        unsigned long state = simple_strtoul(buf, &after, 10);
+       size_t count = after - buf;
 
-       if (after - buf > 0) {
+       if (*after && isspace(*after))
+               count++;
+
+       if (count == size) {
                timer_data->delay_on = state;
                mod_timer(&timer_data->timer, jiffies + 1);
-               ret = after - buf;
+               ret = count;
        }
 
        return ret;
@@ -97,11 +102,15 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf,
        int ret = -EINVAL;
        char *after;
        unsigned long state = simple_strtoul(buf, &after, 10);
+       size_t count = after - buf;
+
+       if (*after && isspace(*after))
+               count++;
 
-       if (after - buf > 0) {
+       if (count == size) {
                timer_data->delay_off = state;
                mod_timer(&timer_data->timer, jiffies + 1);
-               ret = after - buf;
+               ret = count;
        }
 
        return ret;
index 1ddefd2..038447f 100644 (file)
@@ -53,6 +53,7 @@
 #define DRV_VERSION    "v1.17b"
 #define DRV_RELDATE    "2006/03/10"
 #include "dl2k.h"
+#include <linux/dma-mapping.h>
 
 static char version[] __devinitdata =
       KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n"; 
index 19e2b17..d378478 100644 (file)
@@ -634,6 +634,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4,     quirk_vi
  * non-x86 architectures (yes Via exists on PPC among other places),
  * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get
  * interrupts delivered properly.
+ *
+ * Some of the on-chip devices are actually '586 devices' so they are
+ * listed here.
  */
 static void quirk_via_irq(struct pci_dev *dev)
 {
@@ -648,6 +651,10 @@ static void quirk_via_irq(struct pci_dev *dev)
                pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
        }
 }
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_via_irq);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, quirk_via_irq);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, quirk_via_irq);
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_irq);
 DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq);
 DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq);
 DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq);
@@ -895,6 +902,7 @@ static void __init k8t_sound_hostbridge(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_hostbridge);
 
+#ifndef CONFIG_ACPI_SLEEP
 /*
  * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge
  * is not activated. The myth is that Asus said that they do not want the
@@ -906,8 +914,12 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_ho
  * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it 
  * becomes necessary to do this tweak in two steps -- I've chosen the Host
  * bridge as trigger.
+ *
+ * Actually, leaving it unhidden and not redoing the quirk over suspend2ram
+ * will cause thermal management to break down, and causing machine to
+ * overheat.
  */
-static int __initdata asus_hides_smbus = 0;
+static int __initdata asus_hides_smbus;
 
 static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
 {
@@ -1050,6 +1062,8 @@ static void __init asus_hides_smbus_lpc_ich6(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,  PCI_DEVICE_ID_INTEL_ICH6_1,     asus_hides_smbus_lpc_ich6 );
 
+#endif
+
 /*
  * SiS 96x south bridge: BIOS typically hides SMBus device...
  */
index c53db7c..738b1ef 100644 (file)
@@ -426,7 +426,7 @@ static int ds_open(struct inode *inode, struct file *file)
 
     if (!warning_printed) {
            printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl "
-                       "usage.\n");
+                       "usage from process: %s.\n", current->comm);
            printk(KERN_INFO "pcmcia: This interface will soon be removed from "
                        "the kernel; please expect breakage unless you upgrade "
                        "to new tools.\n");
@@ -601,8 +601,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
            ret = CS_BAD_ARGS;
        else {
            struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
-           ret = pccard_get_configuration_info(s, p_dev, &buf->config);
-           pcmcia_put_dev(p_dev);
+           if (p_dev == NULL)
+                   ret = CS_BAD_ARGS;
+           else {
+                   ret = pccard_get_configuration_info(s, p_dev, &buf->config);
+                   pcmcia_put_dev(p_dev);
+           }
        }
        break;
     case DS_GET_FIRST_TUPLE:
@@ -632,8 +636,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
                    ret = CS_BAD_ARGS;
            else {
                    struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
-                   ret = pccard_get_status(s, p_dev, &buf->status);
-                   pcmcia_put_dev(p_dev);
+                   if (p_dev == NULL)
+                           ret = CS_BAD_ARGS;
+                   else {
+                           ret = pccard_get_status(s, p_dev, &buf->status);
+                           pcmcia_put_dev(p_dev);
+                   }
            }
            break;
     case DS_VALIDATE_CIS:
@@ -665,9 +673,10 @@ static int ds_ioctl(struct inode * inode, struct file * file,
        if (!(buf->conf_reg.Function &&
             (buf->conf_reg.Function >= s->functions))) {
                struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function);
-               if (p_dev)
+               if (p_dev) {
                        ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg);
-               pcmcia_put_dev(p_dev);
+                       pcmcia_put_dev(p_dev);
+               }
        }
        break;
     case DS_GET_FIRST_REGION:
index 5d6b7a5..e65da92 100644 (file)
@@ -1348,7 +1348,7 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
                index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) 
                        - channel->ccws;
                if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) ||
-                   (irb->scsw.cstat | SCHN_STAT_PCI))
+                   (irb->scsw.cstat & SCHN_STAT_PCI))
                        /* Bloody io subsystem tells us lies about cpa... */
                        index = (index - 1) & (LCS_NUM_BUFFS - 1);
                while (channel->io_idx != index) {
index aeb8153..17839e7 100644 (file)
@@ -1907,9 +1907,12 @@ uart_set_options(struct uart_port *port, struct console *co,
 static void uart_change_pm(struct uart_state *state, int pm_state)
 {
        struct uart_port *port = state->port;
-       if (port->ops->pm)
-               port->ops->pm(port, pm_state, state->pm_state);
-       state->pm_state = pm_state;
+
+       if (state->pm_state != pm_state) {
+               if (port->ops->pm)
+                       port->ops->pm(port, pm_state, state->pm_state);
+               state->pm_state = pm_state;
+       }
 }
 
 int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
index 7a75fae..9ce1d01 100644 (file)
@@ -75,6 +75,14 @@ config SPI_BUTTERFLY
          inexpensive battery powered microcontroller evaluation board.
          This same cable can be used to flash new firmware.
 
+config SPI_PXA2XX
+       tristate "PXA2xx SSP SPI master"
+       depends on SPI_MASTER && ARCH_PXA && EXPERIMENTAL
+       help
+         This enables using a PXA2xx SSP port as a SPI master controller.
+         The driver can be configured to use any SSP port and additional
+         documentation can be found a Documentation/spi/pxa2xx.
+
 #
 # Add new SPI master controllers in alphabetical order above this line
 #
index c2c87e8..1bca5f9 100644 (file)
@@ -13,6 +13,7 @@ obj-$(CONFIG_SPI_MASTER)              += spi.o
 # SPI master controller drivers (bus)
 obj-$(CONFIG_SPI_BITBANG)              += spi_bitbang.o
 obj-$(CONFIG_SPI_BUTTERFLY)            += spi_butterfly.o
+obj-$(CONFIG_SPI_PXA2XX)               += pxa2xx_spi.o
 #      ... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
new file mode 100644 (file)
index 0000000..596bf82
--- /dev/null
@@ -0,0 +1,1467 @@
+/*
+ * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/spi/spi.h>
+#include <linux/workqueue.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/delay.h>
+#include <asm/dma.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/pxa2xx_spi.h>
+
+MODULE_AUTHOR("Stephen Street");
+MODULE_DESCRIPTION("PXA2xx SSP SPI Contoller");
+MODULE_LICENSE("GPL");
+
+#define MAX_BUSES 3
+
+#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
+#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK)
+#define IS_DMA_ALIGNED(x) (((u32)(x)&0x07)==0)
+
+#define DEFINE_SSP_REG(reg, off) \
+static inline u32 read_##reg(void *p) { return __raw_readl(p + (off)); } \
+static inline void write_##reg(u32 v, void *p) { __raw_writel(v, p + (off)); }
+
+DEFINE_SSP_REG(SSCR0, 0x00)
+DEFINE_SSP_REG(SSCR1, 0x04)
+DEFINE_SSP_REG(SSSR, 0x08)
+DEFINE_SSP_REG(SSITR, 0x0c)
+DEFINE_SSP_REG(SSDR, 0x10)
+DEFINE_SSP_REG(SSTO, 0x28)
+DEFINE_SSP_REG(SSPSP, 0x2c)
+
+#define START_STATE ((void*)0)
+#define RUNNING_STATE ((void*)1)
+#define DONE_STATE ((void*)2)
+#define ERROR_STATE ((void*)-1)
+
+#define QUEUE_RUNNING 0
+#define QUEUE_STOPPED 1
+
+struct driver_data {
+       /* Driver model hookup */
+       struct platform_device *pdev;
+
+       /* SPI framework hookup */
+       enum pxa_ssp_type ssp_type;
+       struct spi_master *master;
+
+       /* PXA hookup */
+       struct pxa2xx_spi_master *master_info;
+
+       /* DMA setup stuff */
+       int rx_channel;
+       int tx_channel;
+       u32 *null_dma_buf;
+
+       /* SSP register addresses */
+       void *ioaddr;
+       u32 ssdr_physical;
+
+       /* SSP masks*/
+       u32 dma_cr1;
+       u32 int_cr1;
+       u32 clear_sr;
+       u32 mask_sr;
+
+       /* Driver message queue */
+       struct workqueue_struct *workqueue;
+       struct work_struct pump_messages;
+       spinlock_t lock;
+       struct list_head queue;
+       int busy;
+       int run;
+
+       /* Message Transfer pump */
+       struct tasklet_struct pump_transfers;
+
+       /* Current message transfer state info */
+       struct spi_message* cur_msg;
+       struct spi_transfer* cur_transfer;
+       struct chip_data *cur_chip;
+       size_t len;
+       void *tx;
+       void *tx_end;
+       void *rx;
+       void *rx_end;
+       int dma_mapped;
+       dma_addr_t rx_dma;
+       dma_addr_t tx_dma;
+       size_t rx_map_len;
+       size_t tx_map_len;
+       u8 n_bytes;
+       u32 dma_width;
+       int cs_change;
+       void (*write)(struct driver_data *drv_data);
+       void (*read)(struct driver_data *drv_data);
+       irqreturn_t (*transfer_handler)(struct driver_data *drv_data);
+       void (*cs_control)(u32 command);
+};
+
+struct chip_data {
+       u32 cr0;
+       u32 cr1;
+       u32 to;
+       u32 psp;
+       u32 timeout;
+       u8 n_bytes;
+       u32 dma_width;
+       u32 dma_burst_size;
+       u32 threshold;
+       u32 dma_threshold;
+       u8 enable_dma;
+       u8 bits_per_word;
+       u32 speed_hz;
+       void (*write)(struct driver_data *drv_data);
+       void (*read)(struct driver_data *drv_data);
+       void (*cs_control)(u32 command);
+};
+
+static void pump_messages(void *data);
+
+static int flush(struct driver_data *drv_data)
+{
+       unsigned long limit = loops_per_jiffy << 1;
+
+       void *reg = drv_data->ioaddr;
+
+       do {
+               while (read_SSSR(reg) & SSSR_RNE) {
+                       read_SSDR(reg);
+               }
+       } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
+       write_SSSR(SSSR_ROR, reg);
+
+       return limit;
+}
+
+static void restore_state(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       /* Clear status and disable clock */
+       write_SSSR(drv_data->clear_sr, reg);
+       write_SSCR0(drv_data->cur_chip->cr0 & ~SSCR0_SSE, reg);
+
+       /* Load the registers */
+       write_SSCR1(drv_data->cur_chip->cr1, reg);
+       write_SSCR0(drv_data->cur_chip->cr0, reg);
+       if (drv_data->ssp_type != PXA25x_SSP) {
+               write_SSTO(0, reg);
+               write_SSPSP(drv_data->cur_chip->psp, reg);
+       }
+}
+
+static void null_cs_control(u32 command)
+{
+}
+
+static void null_writer(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+       u8 n_bytes = drv_data->n_bytes;
+
+       while ((read_SSSR(reg) & SSSR_TNF)
+                       && (drv_data->tx < drv_data->tx_end)) {
+               write_SSDR(0, reg);
+               drv_data->tx += n_bytes;
+       }
+}
+
+static void null_reader(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+       u8 n_bytes = drv_data->n_bytes;
+
+       while ((read_SSSR(reg) & SSSR_RNE)
+                       && (drv_data->rx < drv_data->rx_end)) {
+               read_SSDR(reg);
+               drv_data->rx += n_bytes;
+       }
+}
+
+static void u8_writer(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_TNF)
+                       && (drv_data->tx < drv_data->tx_end)) {
+               write_SSDR(*(u8 *)(drv_data->tx), reg);
+               ++drv_data->tx;
+       }
+}
+
+static void u8_reader(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_RNE)
+                       && (drv_data->rx < drv_data->rx_end)) {
+               *(u8 *)(drv_data->rx) = read_SSDR(reg);
+               ++drv_data->rx;
+       }
+}
+
+static void u16_writer(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_TNF)
+                       && (drv_data->tx < drv_data->tx_end)) {
+               write_SSDR(*(u16 *)(drv_data->tx), reg);
+               drv_data->tx += 2;
+       }
+}
+
+static void u16_reader(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_RNE)
+                       && (drv_data->rx < drv_data->rx_end)) {
+               *(u16 *)(drv_data->rx) = read_SSDR(reg);
+               drv_data->rx += 2;
+       }
+}
+static void u32_writer(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_TNF)
+                       && (drv_data->tx < drv_data->tx_end)) {
+               write_SSDR(*(u32 *)(drv_data->tx), reg);
+               drv_data->tx += 4;
+       }
+}
+
+static void u32_reader(struct driver_data *drv_data)
+{
+       void *reg = drv_data->ioaddr;
+
+       while ((read_SSSR(reg) & SSSR_RNE)
+                       && (drv_data->rx < drv_data->rx_end)) {
+               *(u32 *)(drv_data->rx) = read_SSDR(reg);
+               drv_data->rx += 4;
+       }
+}
+
+static void *next_transfer(struct driver_data *drv_data)
+{
+       struct spi_message *msg = drv_data->cur_msg;
+       struct spi_transfer *trans = drv_data->cur_transfer;
+
+       /* Move to next transfer */
+       if (trans->transfer_list.next != &msg->transfers) {
+               drv_data->cur_transfer =
+                       list_entry(trans->transfer_list.next,
+                                       struct spi_transfer,
+                                       transfer_list);
+               return RUNNING_STATE;
+       } else
+               return DONE_STATE;
+}
+
+static int map_dma_buffers(struct driver_data *drv_data)
+{
+       struct spi_message *msg = drv_data->cur_msg;
+       struct device *dev = &msg->spi->dev;
+
+       if (!drv_data->cur_chip->enable_dma)
+               return 0;
+
+       if (msg->is_dma_mapped)
+               return  drv_data->rx_dma && drv_data->tx_dma;
+
+       if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx))
+               return 0;
+
+       /* Modify setup if rx buffer is null */
+       if (drv_data->rx == NULL) {
+               *drv_data->null_dma_buf = 0;
+               drv_data->rx = drv_data->null_dma_buf;
+               drv_data->rx_map_len = 4;
+       } else
+               drv_data->rx_map_len = drv_data->len;
+
+
+       /* Modify setup if tx buffer is null */
+       if (drv_data->tx == NULL) {
+               *drv_data->null_dma_buf = 0;
+               drv_data->tx = drv_data->null_dma_buf;
+               drv_data->tx_map_len = 4;
+       } else
+               drv_data->tx_map_len = drv_data->len;
+
+       /* Stream map the rx buffer */
+       drv_data->rx_dma = dma_map_single(dev, drv_data->rx,
+                                               drv_data->rx_map_len,
+                                               DMA_FROM_DEVICE);
+       if (dma_mapping_error(drv_data->rx_dma))
+               return 0;
+
+       /* Stream map the tx buffer */
+       drv_data->tx_dma = dma_map_single(dev, drv_data->tx,
+                                               drv_data->tx_map_len,
+                                               DMA_TO_DEVICE);
+
+       if (dma_mapping_error(drv_data->tx_dma)) {
+               dma_unmap_single(dev, drv_data->rx_dma,
+                                       drv_data->rx_map_len, DMA_FROM_DEVICE);
+               return 0;
+       }
+
+       return 1;
+}
+
+static void unmap_dma_buffers(struct driver_data *drv_data)
+{
+       struct device *dev;
+
+       if (!drv_data->dma_mapped)
+               return;
+
+       if (!drv_data->cur_msg->is_dma_mapped) {
+               dev = &drv_data->cur_msg->spi->dev;
+               dma_unmap_single(dev, drv_data->rx_dma,
+                                       drv_data->rx_map_len, DMA_FROM_DEVICE);
+               dma_unmap_single(dev, drv_data->tx_dma,
+                                       drv_data->tx_map_len, DMA_TO_DEVICE);
+       }
+
+       drv_data->dma_mapped = 0;
+}
+
+/* caller already set message->status; dma and pio irqs are blocked */
+static void giveback(struct spi_message *message, struct driver_data *drv_data)
+{
+       struct spi_transfer* last_transfer;
+
+       last_transfer = list_entry(message->transfers.prev,
+                                       struct spi_transfer,
+                                       transfer_list);
+
+       if (!last_transfer->cs_change)
+               drv_data->cs_control(PXA2XX_CS_DEASSERT);
+
+       message->state = NULL;
+       if (message->complete)
+               message->complete(message->context);
+
+       drv_data->cur_msg = NULL;
+       drv_data->cur_transfer = NULL;
+       drv_data->cur_chip = NULL;
+       queue_work(drv_data->workqueue, &drv_data->pump_messages);
+}
+
+static int wait_ssp_rx_stall(void *ioaddr)
+{
+       unsigned long limit = loops_per_jiffy << 1;
+
+       while ((read_SSSR(ioaddr) & SSSR_BSY) && limit--)
+               cpu_relax();
+
+       return limit;
+}
+
+static int wait_dma_channel_stop(int channel)
+{
+       unsigned long limit = loops_per_jiffy << 1;
+
+       while (!(DCSR(channel) & DCSR_STOPSTATE) && limit--)
+               cpu_relax();
+
+       return limit;
+}
+
+static void dma_handler(int channel, void *data, struct pt_regs *regs)
+{
+       struct driver_data *drv_data = data;
+       struct spi_message *msg = drv_data->cur_msg;
+       void *reg = drv_data->ioaddr;
+       u32 irq_status = DCSR(channel) & DMA_INT_MASK;
+       u32 trailing_sssr = 0;
+
+       if (irq_status & DCSR_BUSERR) {
+
+               /* Disable interrupts, clear status and reset DMA */
+               if (drv_data->ssp_type != PXA25x_SSP)
+                       write_SSTO(0, reg);
+               write_SSSR(drv_data->clear_sr, reg);
+               write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
+               DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
+               DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
+
+               if (flush(drv_data) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                                       "dma_handler: flush fail\n");
+
+               unmap_dma_buffers(drv_data);
+
+               if (channel == drv_data->tx_channel)
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_handler: bad bus address on "
+                               "tx channel %d, source %x target = %x\n",
+                               channel, DSADR(channel), DTADR(channel));
+               else
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_handler: bad bus address on "
+                               "rx channel %d, source %x target = %x\n",
+                               channel, DSADR(channel), DTADR(channel));
+
+               msg->state = ERROR_STATE;
+               tasklet_schedule(&drv_data->pump_transfers);
+       }
+
+       /* PXA255x_SSP has no timeout interrupt, wait for tailing bytes */
+       if ((drv_data->ssp_type == PXA25x_SSP)
+               && (channel == drv_data->tx_channel)
+               && (irq_status & DCSR_ENDINTR)) {
+
+               /* Wait for rx to stall */
+               if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_handler: ssp rx stall failed\n");
+
+               /* Clear and disable interrupts on SSP and DMA channels*/
+               write_SSSR(drv_data->clear_sr, reg);
+               write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
+               DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
+               DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
+               if (wait_dma_channel_stop(drv_data->rx_channel) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_handler: dma rx channel stop failed\n");
+
+               unmap_dma_buffers(drv_data);
+
+               /* Read trailing bytes */
+               /* Calculate number of trailing bytes, read them */
+               trailing_sssr = read_SSSR(reg);
+               if ((trailing_sssr & 0xf008) != 0xf000) {
+                       drv_data->rx = drv_data->rx_end -
+                                       (((trailing_sssr >> 12) & 0x0f) + 1);
+                       drv_data->read(drv_data);
+               }
+               msg->actual_length += drv_data->len;
+
+               /* Release chip select if requested, transfer delays are
+                * handled in pump_transfers */
+               if (drv_data->cs_change)
+                       drv_data->cs_control(PXA2XX_CS_DEASSERT);
+
+               /* Move to next transfer */
+               msg->state = next_transfer(drv_data);
+
+               /* Schedule transfer tasklet */
+               tasklet_schedule(&drv_data->pump_transfers);
+       }
+}
+
+static irqreturn_t dma_transfer(struct driver_data *drv_data)
+{
+       u32 irq_status;
+       u32 trailing_sssr = 0;
+       struct spi_message *msg = drv_data->cur_msg;
+       void *reg = drv_data->ioaddr;
+
+       irq_status = read_SSSR(reg) & drv_data->mask_sr;
+       if (irq_status & SSSR_ROR) {
+               /* Clear and disable interrupts on SSP and DMA channels*/
+               if (drv_data->ssp_type != PXA25x_SSP)
+                       write_SSTO(0, reg);
+               write_SSSR(drv_data->clear_sr, reg);
+               write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
+               DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
+               DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
+               unmap_dma_buffers(drv_data);
+
+               if (flush(drv_data) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                                       "dma_transfer: flush fail\n");
+
+               dev_warn(&drv_data->pdev->dev, "dma_transfer: fifo overun\n");
+
+               drv_data->cur_msg->state = ERROR_STATE;
+               tasklet_schedule(&drv_data->pump_transfers);
+
+               return IRQ_HANDLED;
+       }
+
+       /* Check for false positive timeout */
+       if ((irq_status & SSSR_TINT) && DCSR(drv_data->tx_channel) & DCSR_RUN) {
+               write_SSSR(SSSR_TINT, reg);
+               return IRQ_HANDLED;
+       }
+
+       if (irq_status & SSSR_TINT || drv_data->rx == drv_data->rx_end) {
+
+               /* Clear and disable interrupts on SSP and DMA channels*/
+               if (drv_data->ssp_type != PXA25x_SSP)
+                       write_SSTO(0, reg);
+               write_SSSR(drv_data->clear_sr, reg);
+               write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
+               DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
+               DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
+
+               if (wait_dma_channel_stop(drv_data->rx_channel) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_transfer: dma rx channel stop failed\n");
+
+               if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
+                       dev_err(&drv_data->pdev->dev,
+                               "dma_transfer: ssp rx stall failed\n");
+
+               unmap_dma_buffers(drv_data);
+
+               /* Calculate number of trailing bytes, read them */
+               trailing_sssr = read_SSSR(reg);
+               if ((trailing_sssr & 0xf008) != 0xf000) {
+                       drv_data->rx = drv_data->rx_end -
+                                       (((trailing_sssr >> 12) & 0x0f) + 1);
+                       drv_data->read(drv_data);
+               }
+               msg->actual_length += drv_data->len;
+
+               /* Release chip select if requested, transfer delays are
+                * handled in pump_transfers */
+               if (drv_data->cs_change)
+                       drv_data->cs_control(PXA2XX_CS_DEASSERT);
+
+               /* Move to next transfer */
+               msg->state = next_transfer(drv_data);
+
+               /* Schedule transfer tasklet */
+               tasklet_schedule(&drv_data->pump_transfers);
+
+               return IRQ_HANDLED;
+       }
+
+       /* Opps problem detected */
+       return IRQ_NONE;
+}
+
+static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
+{
+       u32 irq_status;
+       struct spi_message *msg = drv_data->cur_msg;
+       void *reg = drv_data->ioaddr;
+       irqreturn_t handled = IRQ_NONE;
+       unsigned long limit = loops_per_jiffy << 1;
+
+       while ((irq_status = (read_SSSR(reg) & drv_data->mask_sr))) {
+
+               if (irq_status & SSSR_ROR) {
+
+                       /* Clear and disable interrupts */
+                       if (drv_data->ssp_type != PXA25x_SSP)
+                               write_SSTO(0, reg);
+                       write_SSSR(drv_data->clear_sr, reg);
+                       write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
+
+                       if (flush(drv_data) == 0)
+                               dev_err(&drv_data->pdev->dev,
+                                       "interrupt_transfer: flush fail\n");
+
+                       dev_warn(&drv_data->pdev->dev,
+                                       "interrupt_transfer: fifo overun\n");
+
+                       msg->state = ERROR_STATE;
+                       tasklet_schedule(&drv_data->pump_transfers);
+
+                       return IRQ_HANDLED;
+               }
+
+               /* Look for false positive timeout */
+               if ((irq_status & SSSR_TINT)
+                               && (drv_data->rx < drv_data->rx_end))
+                       write_SSSR(SSSR_TINT, reg);
+
+               /* Pump data */
+               drv_data->read(drv_data);
+               drv_data->write(drv_data);
+
+               if (drv_data->tx == drv_data->tx_end) {
+                       /* Disable tx interrupt */
+                       write_SSCR1(read_SSCR1(reg) & ~SSCR1_TIE, reg);
+
+                       /* PXA25x_SSP has no timeout, read trailing bytes */
+                       if (drv_data->ssp_type == PXA25x_SSP) {
+                               while ((read_SSSR(reg) & SSSR_BSY) && limit--)
+                                       drv_data->read(drv_data);
+
+                               if (limit == 0)
+                                       dev_err(&drv_data->pdev->dev,
+                                               "interrupt_transfer: "
+                                               "trailing byte read failed\n");
+                       }
+               }
+
+               if ((irq_status & SSSR_TINT)
+                               || (drv_data->rx == drv_data->rx_end)) {
+
+                       /* Clear timeout */
+                       if (drv_data->ssp_type != PXA25x_SSP)
+                               write_SSTO(0, reg);
+                       write_SSSR(drv_data->clear_sr, reg);
+                       write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
+
+                       /* Update total byte transfered */
+                       msg->actual_length += drv_data->len;
+
+                       /* Release chip select if requested, transfer delays are
+                        * handled in pump_transfers */
+                       if (drv_data->cs_change)
+                               drv_data->cs_control(PXA2XX_CS_DEASSERT);
+
+                       /* Move to next transfer */
+                       msg->state = next_transfer(drv_data);
+
+                       /* Schedule transfer tasklet */
+                       tasklet_schedule(&drv_data->pump_transfers);
+
+                       return IRQ_HANDLED;
+               }
+
+               /* We did something */
+               handled = IRQ_HANDLED;
+       }
+
+       return handled;
+}
+
+static irqreturn_t ssp_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct driver_data *drv_data = (struct driver_data *)dev_id;
+
+       if (!drv_data->cur_msg) {
+               dev_err(&drv_data->pdev->dev, "bad message state "
+                               "in interrupt handler\n");
+               /* Never fail */
+               return IRQ_HANDLED;
+       }
+
+       return drv_data->transfer_handler(drv_data);
+}
+
+static void pump_transfers(unsigned long data)
+{
+       struct driver_data *drv_data = (struct driver_data *)data;
+       struct spi_message *message = NULL;
+       struct spi_transfer *transfer = NULL;
+       struct spi_transfer *previous = NULL;
+       struct chip_data *chip = NULL;
+       void *reg = drv_data->ioaddr;
+       u32 clk_div = 0;
+       u8 bits = 0;
+       u32 speed = 0;
+       u32 cr0;
+
+       /* Get current state information */
+       message = drv_data->cur_msg;
+       transfer = drv_data->cur_transfer;
+       chip = drv_data->cur_chip;
+
+       /* Handle for abort */
+       if (message->state == ERROR_STATE) {
+               message->status = -EIO;
+               giveback(message, drv_data);
+               return;
+       }
+
+       /* Handle end of message */
+       if (message->state == DONE_STATE) {
+               message->status = 0;
+               giveback(message, drv_data);
+               return;
+       }
+
+       /* Delay if requested at end of transfer*/
+       if (message->state == RUNNING_STATE) {
+               previous = list_entry(transfer->transfer_list.prev,
+                                       struct spi_transfer,
+                                       transfer_list);
+               if (previous->delay_usecs)
+                       udelay(previous->delay_usecs);
+       }
+
+       /* Setup the transfer state based on the type of transfer */
+       if (flush(drv_data) == 0) {
+               dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
+               message->status = -EIO;
+               giveback(message, drv_data);
+               return;
+       }
+       drv_data->n_bytes = chip->n_bytes;
+       drv_data->dma_width = chip->dma_width;
+       drv_data->cs_control = chip->cs_control;
+       drv_data->tx = (void *)transfer->tx_buf;
+       drv_data->tx_end = drv_data->tx + transfer->len;
+       drv_data->rx = transfer->rx_buf;
+       drv_data->rx_end = drv_data->rx + transfer->len;
+       drv_data->rx_dma = transfer->rx_dma;
+       drv_data->tx_dma = transfer->tx_dma;
+       drv_data->len = transfer->len;
+       drv_data->write = drv_data->tx ? chip->write : null_writer;
+       drv_data->read = drv_data->rx ? chip->read : null_reader;
+       drv_data->cs_change = transfer->cs_change;
+
+       /* Change speed and bit per word on a per transfer */
+       if (transfer->speed_hz || transfer->bits_per_word) {
+
+               /* Disable clock */
+               write_SSCR0(chip->cr0 & ~SSCR0_SSE, reg);
+               cr0 = chip->cr0;
+               bits = chip->bits_per_word;
+               speed = chip->speed_hz;
+
+               if (transfer->speed_hz)
+                       speed = transfer->speed_hz;
+
+               if (transfer->bits_per_word)
+                       bits = transfer->bits_per_word;
+
+               if (reg == SSP1_VIRT)
+                       clk_div = SSP1_SerClkDiv(speed);
+               else if (reg == SSP2_VIRT)
+                       clk_div = SSP2_SerClkDiv(speed);
+               else if (reg == SSP3_VIRT)
+                       clk_div = SSP3_SerClkDiv(speed);
+
+               if (bits <= 8) {
+                       drv_data->n_bytes = 1;
+                       drv_data->dma_width = DCMD_WIDTH1;
+                       drv_data->read = drv_data->read != null_reader ?
+                                               u8_reader : null_reader;
+                       drv_data->write = drv_data->write != null_writer ?
+                                               u8_writer : null_writer;
+               } else if (bits <= 16) {
+                       drv_data->n_bytes = 2;
+                       drv_data->dma_width = DCMD_WIDTH2;
+                       drv_data->read = drv_data->read != null_reader ?
+                                               u16_reader : null_reader;
+                       drv_data->write = drv_data->write != null_writer ?
+                                               u16_writer : null_writer;
+               } else if (bits <= 32) {
+                       drv_data->n_bytes = 4;
+                       drv_data->dma_width = DCMD_WIDTH4;
+                       drv_data->read = drv_data->read != null_reader ?
+                                               u32_reader : null_reader;
+                       drv_data->write = drv_data->write != null_writer ?
+                                               u32_writer : null_writer;
+               }
+
+               cr0 = clk_div
+                       | SSCR0_Motorola
+                       | SSCR0_DataSize(bits & 0x0f)
+                       | SSCR0_SSE
+                       | (bits > 16 ? SSCR0_EDSS : 0);
+
+               /* Start it back up */
+               write_SSCR0(cr0, reg);
+       }
+
+       message->state = RUNNING_STATE;
+
+       /* Try to map dma buffer and do a dma transfer if successful */
+       if ((drv_data->dma_mapped = map_dma_buffers(drv_data))) {
+
+               /* Ensure we have the correct interrupt handler */
+               drv_data->transfer_handler = dma_transfer;
+
+               /* Setup rx DMA Channel */
+               DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
+               DSADR(drv_data->rx_channel) = drv_data->ssdr_physical;
+               DTADR(drv_data->rx_channel) = drv_data->rx_dma;
+               if (drv_data->rx == drv_data->null_dma_buf)
+                       /* No target address increment */
+                       DCMD(drv_data->rx_channel) = DCMD_FLOWSRC
+                                                       | drv_data->dma_width
+                                                       | chip->dma_burst_size
+                                                       | drv_data->len;
+               else
+                       DCMD(drv_data->rx_channel) = DCMD_INCTRGADDR
+                                                       | DCMD_FLOWSRC
+                                                       | drv_data->dma_width
+                                                       | chip->dma_burst_size
+                                                       | drv_data->len;
+
+               /* Setup tx DMA Channel */
+               DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
+               DSADR(drv_data->tx_channel) = drv_data->tx_dma;
+               DTADR(drv_data->tx_channel) = drv_data->ssdr_physical;
+               if (drv_data->tx == drv_data->null_dma_buf)
+                       /* No source address increment */
+                       DCMD(drv_data->tx_channel) = DCMD_FLOWTRG
+                                                       | drv_data->dma_width
+                                                       | chip->dma_burst_size
+                                                       | drv_data->len;
+               else
+                       DCMD(drv_data->tx_channel) = DCMD_INCSRCADDR
+                                                       | DCMD_FLOWTRG
+                                                       | drv_data->dma_width
+                                                       | chip->dma_burst_size
+                                                       | drv_data->len;
+
+               /* Enable dma end irqs on SSP to detect end of transfer */
+               if (drv_data->ssp_type == PXA25x_SSP)
+                       DCMD(drv_data->tx_channel) |= DCMD_ENDIRQEN;
+
+               /* Fix me, need to handle cs polarity */
+               drv_data->cs_control(PXA2XX_CS_ASSERT);
+
+               /* Go baby, go */
+               write_SSSR(drv_data->clear_sr, reg);
+               DCSR(drv_data->rx_channel) |= DCSR_RUN;
+               DCSR(drv_data->tx_channel) |= DCSR_RUN;
+               if (drv_data->ssp_type != PXA25x_SSP)
+                       write_SSTO(chip->timeout, reg);
+               write_SSCR1(chip->cr1
+                               | chip->dma_threshold
+                               | drv_data->dma_cr1,
+                               reg);
+       } else {
+               /* Ensure we have the correct interrupt handler */
+               drv_data->transfer_handler = interrupt_transfer;
+
+               /* Fix me, need to handle cs polarity */
+               drv_data->cs_control(PXA2XX_CS_ASSERT);
+
+               /* Go baby, go */
+               write_SSSR(drv_data->clear_sr, reg);
+               if (drv_data->ssp_type != PXA25x_SSP)
+                       write_SSTO(chip->timeout, reg);
+               write_SSCR1(chip->cr1
+                               | chip->threshold
+                               | drv_data->int_cr1,
+                               reg);
+       }
+}
+
+static void pump_messages(void *data)
+{
+       struct driver_data *drv_data = data;
+       unsigned long flags;
+
+       /* Lock queue and check for queue work */
+       spin_lock_irqsave(&drv_data->lock, flags);
+       if (list_empty(&drv_data->queue) || drv_data->run == QUEUE_STOPPED) {
+               drv_data->busy = 0;
+               spin_unlock_irqrestore(&drv_data->lock, flags);
+               return;
+       }
+
+       /* Make sure we are not already running a message */
+       if (drv_data->cur_msg) {
+               spin_unlock_irqrestore(&drv_data->lock, flags);
+               return;
+       }
+
+       /* Extract head of queue */
+       drv_data->cur_msg = list_entry(drv_data->queue.next,
+                                       struct spi_message, queue);
+       list_del_init(&drv_data->cur_msg->queue);
+       drv_data->busy = 1;
+       spin_unlock_irqrestore(&drv_data->lock, flags);
+
+       /* Initial message state*/
+       drv_data->cur_msg->state = START_STATE;
+       drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next,
+                                               struct spi_transfer,
+                                               transfer_list);
+
+       /* Setup the SSP using the per chip configuration */
+       drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi);
+       restore_state(drv_data);
+
+       /* Mark as busy and launch transfers */
+       tasklet_schedule(&drv_data->pump_transfers);
+}
+
+static int transfer(struct spi_device *spi, struct spi_message *msg)
+{
+       struct driver_data *drv_data = spi_master_get_devdata(spi->master);
+       unsigned long flags;
+
+       spin_lock_irqsave(&drv_data->lock, flags);
+
+       if (drv_data->run == QUEUE_STOPPED) {
+               spin_unlock_irqrestore(&drv_data->lock, flags);
+               return -ESHUTDOWN;
+       }
+
+       msg->actual_length = 0;
+       msg->status = -EINPROGRESS;
+       msg->state = START_STATE;
+
+       list_add_tail(&msg->queue, &drv_data->queue);
+
+       if (drv_data->run == QUEUE_RUNNING && !drv_data->busy)
+               queue_work(drv_data->workqueue, &drv_data->pump_messages);
+
+       spin_unlock_irqrestore(&drv_data->lock, flags);
+
+       return 0;
+}
+
+static int setup(struct spi_device *spi)
+{
+       struct pxa2xx_spi_chip *chip_info = NULL;
+       struct chip_data *chip;
+       struct driver_data *drv_data = spi_master_get_devdata(spi->master);
+       unsigned int clk_div;
+
+       if (!spi->bits_per_word)
+               spi->bits_per_word = 8;
+
+       if (drv_data->ssp_type != PXA25x_SSP
+                       && (spi->bits_per_word < 4 || spi->bits_per_word > 32))
+               return -EINVAL;
+       else if (spi->bits_per_word < 4 || spi->bits_per_word > 16)
+               return -EINVAL;
+
+       /* Only alloc (or use chip_info) on first setup */
+       chip = spi_get_ctldata(spi);
+       if (chip == NULL) {
+               chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
+               if (!chip)
+                       return -ENOMEM;
+
+               chip->cs_control = null_cs_control;
+               chip->enable_dma = 0;
+               chip->timeout = 5;
+               chip->threshold = SSCR1_RxTresh(1) | SSCR1_TxTresh(1);
+               chip->dma_burst_size = drv_data->master_info->enable_dma ?
+                                       DCMD_BURST8 : 0;
+
+               chip_info = spi->controller_data;
+       }
+
+       /* chip_info isn't always needed */
+       if (chip_info) {
+               if (chip_info->cs_control)
+                       chip->cs_control = chip_info->cs_control;
+
+               chip->timeout = (chip_info->timeout_microsecs * 10000) / 2712;
+
+               chip->threshold = SSCR1_RxTresh(chip_info->rx_threshold)
+                                       | SSCR1_TxTresh(chip_info->tx_threshold);
+
+               chip->enable_dma = chip_info->dma_burst_size != 0
+                                       && drv_data->master_info->enable_dma;
+               chip->dma_threshold = 0;
+
+               if (chip->enable_dma) {
+                       if (chip_info->dma_burst_size <= 8) {
+                               chip->dma_threshold = SSCR1_RxTresh(8)
+                                                       | SSCR1_TxTresh(8);
+                               chip->dma_burst_size = DCMD_BURST8;
+                       } else if (chip_info->dma_burst_size <= 16) {
+                               chip->dma_threshold = SSCR1_RxTresh(16)
+                                                       | SSCR1_TxTresh(16);
+                               chip->dma_burst_size = DCMD_BURST16;
+                       } else {
+                               chip->dma_threshold = SSCR1_RxTresh(32)
+                                                       | SSCR1_TxTresh(32);
+                               chip->dma_burst_size = DCMD_BURST32;
+                       }
+               }
+
+
+               if (chip_info->enable_loopback)
+                       chip->cr1 = SSCR1_LBM;
+       }
+
+       if (drv_data->ioaddr == SSP1_VIRT)
+               clk_div = SSP1_SerClkDiv(spi->max_speed_hz);
+       else if (drv_data->ioaddr == SSP2_VIRT)
+               clk_div = SSP2_SerClkDiv(spi->max_speed_hz);
+       else if (drv_data->ioaddr == SSP3_VIRT)
+               clk_div = SSP3_SerClkDiv(spi->max_speed_hz);
+       else
+               return -ENODEV;
+       chip->speed_hz = spi->max_speed_hz;
+
+       chip->cr0 = clk_div
+                       | SSCR0_Motorola
+                       | SSCR0_DataSize(spi->bits_per_word & 0x0f)
+                       | SSCR0_SSE
+                       | (spi->bits_per_word > 16 ? SSCR0_EDSS : 0);
+       chip->cr1 |= (((spi->mode & SPI_CPHA) != 0) << 4)
+                       | (((spi->mode & SPI_CPOL) != 0) << 3);
+
+       /* NOTE:  PXA25x_SSP _could_ use external clocking ... */
+       if (drv_data->ssp_type != PXA25x_SSP)
+               dev_dbg(&spi->dev, "%d bits/word, %d Hz, mode %d\n",
+                               spi->bits_per_word,
+                               (CLOCK_SPEED_HZ)
+                                       / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)),
+                               spi->mode & 0x3);
+       else
+               dev_dbg(&spi->dev, "%d bits/word, %d Hz, mode %d\n",
+                               spi->bits_per_word,
+                               (CLOCK_SPEED_HZ/2)
+                                       / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)),
+                               spi->mode & 0x3);
+
+       if (spi->bits_per_word <= 8) {
+               chip->n_bytes = 1;
+               chip->dma_width = DCMD_WIDTH1;
+               chip->read = u8_reader;
+               chip->write = u8_writer;
+       } else if (spi->bits_per_word <= 16) {
+               chip->n_bytes = 2;
+               chip->dma_width = DCMD_WIDTH2;
+               chip->read = u16_reader;
+               chip->write = u16_writer;
+       } else if (spi->bits_per_word <= 32) {
+               chip->cr0 |= SSCR0_EDSS;
+               chip->n_bytes = 4;
+               chip->dma_width = DCMD_WIDTH4;
+               chip->read = u32_reader;
+               chip->write = u32_writer;
+       } else {
+               dev_err(&spi->dev, "invalid wordsize\n");
+               kfree(chip);
+               return -ENODEV;
+       }
+       chip->bits_per_word = spi->bits_per_word;
+
+       spi_set_ctldata(spi, chip);
+
+       return 0;
+}
+
+static void cleanup(const struct spi_device *spi)
+{
+       struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
+
+       kfree(chip);
+}
+
+static int init_queue(struct driver_data *drv_data)
+{
+       INIT_LIST_HEAD(&drv_data->queue);
+       spin_lock_init(&drv_data->lock);
+
+       drv_data->run = QUEUE_STOPPED;
+       drv_data->busy = 0;
+
+       tasklet_init(&drv_data->pump_transfers,
+                       pump_transfers, (unsigned long)drv_data);
+
+       INIT_WORK(&drv_data->pump_messages, pump_messages, drv_data);
+       drv_data->workqueue = create_singlethread_workqueue(
+                                       drv_data->master->cdev.dev->bus_id);
+       if (drv_data->workqueue == NULL)
+               return -EBUSY;
+
+       return 0;
+}
+
+static int start_queue(struct driver_data *drv_data)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&drv_data->lock, flags);
+
+       if (drv_data->run == QUEUE_RUNNING || drv_data->busy) {
+               spin_unlock_irqrestore(&drv_data->lock, flags);
+               return -EBUSY;
+       }
+
+       drv_data->run = QUEUE_RUNNING;
+       drv_data->cur_msg = NULL;
+       drv_data->cur_transfer = NULL;
+       drv_data->cur_chip = NULL;
+       spin_unlock_irqrestore(&drv_data->lock, flags);
+
+       queue_work(drv_data->workqueue, &drv_data->pump_messages);
+
+       return 0;
+}
+
+static int stop_queue(struct driver_data *drv_data)
+{
+       unsigned long flags;
+       unsigned limit = 500;
+       int status = 0;
+
+       spin_lock_irqsave(&drv_data->lock, flags);
+
+       /* This is a bit lame, but is optimized for the common execution path.
+        * A wait_queue on the drv_data->busy could be used, but then the common
+        * execution path (pump_messages) would be required to call wake_up or
+        * friends on every SPI message. Do this instead */
+       drv_data->run = QUEUE_STOPPED;
+       while (!list_empty(&drv_data->queue) && drv_data->busy && limit--) {
+               spin_unlock_irqrestore(&drv_data->lock, flags);
+               msleep(10);
+               spin_lock_irqsave(&drv_data->lock, flags);
+       }
+
+       if (!list_empty(&drv_data->queue) || drv_data->busy)
+               status = -EBUSY;
+
+       spin_unlock_irqrestore(&drv_data->lock, flags);
+
+       return status;
+}
+
+static int destroy_queue(struct driver_data *drv_data)
+{
+       int status;
+
+       status = stop_queue(drv_data);
+       if (status != 0)
+               return status;
+
+       destroy_workqueue(drv_data->workqueue);
+
+       return 0;
+}
+
+static int pxa2xx_spi_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct pxa2xx_spi_master *platform_info;
+       struct spi_master *master;
+       struct driver_data *drv_data = 0;
+       struct resource *memory_resource;
+       int irq;
+       int status = 0;
+
+       platform_info = dev->platform_data;
+
+       if (platform_info->ssp_type == SSP_UNDEFINED) {
+               dev_err(&pdev->dev, "undefined SSP\n");
+               return -ENODEV;
+       }
+
+       /* Allocate master with space for drv_data and null dma buffer */
+       master = spi_alloc_master(dev, sizeof(struct driver_data) + 16);
+       if (!master) {
+               dev_err(&pdev->dev, "can not alloc spi_master\n");
+               return -ENOMEM;
+       }
+       drv_data = spi_master_get_devdata(master);
+       drv_data->master = master;
+       drv_data->master_info = platform_info;
+       drv_data->pdev = pdev;
+
+       master->bus_num = pdev->id;
+       master->num_chipselect = platform_info->num_chipselect;
+       master->cleanup = cleanup;
+       master->setup = setup;
+       master->transfer = transfer;
+
+       drv_data->ssp_type = platform_info->ssp_type;
+       drv_data->null_dma_buf = (u32 *)ALIGN((u32)(drv_data +
+                                               sizeof(struct driver_data)), 8);
+
+       /* Setup register addresses */
+       memory_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!memory_resource) {
+               dev_err(&pdev->dev, "memory resources not defined\n");
+               status = -ENODEV;
+               goto out_error_master_alloc;
+       }
+
+       drv_data->ioaddr = (void *)io_p2v(memory_resource->start);
+       drv_data->ssdr_physical = memory_resource->start + 0x00000010;
+       if (platform_info->ssp_type == PXA25x_SSP) {
+               drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE;
+               drv_data->dma_cr1 = 0;
+               drv_data->clear_sr = SSSR_ROR;
+               drv_data->mask_sr = SSSR_RFS | SSSR_TFS | SSSR_ROR;
+       } else {
+               drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE | SSCR1_TINTE;
+               drv_data->dma_cr1 = SSCR1_TSRE | SSCR1_RSRE | SSCR1_TINTE;
+               drv_data->clear_sr = SSSR_ROR | SSSR_TINT;
+               drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR;
+       }
+
+       /* Attach to IRQ */
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0) {
+               dev_err(&pdev->dev, "irq resource not defined\n");
+               status = -ENODEV;
+               goto out_error_master_alloc;
+       }
+
+       status = request_irq(irq, ssp_int, SA_INTERRUPT, dev->bus_id, drv_data);
+       if (status < 0) {
+               dev_err(&pdev->dev, "can not get IRQ\n");
+               goto out_error_master_alloc;
+       }
+
+       /* Setup DMA if requested */
+       drv_data->tx_channel = -1;
+       drv_data->rx_channel = -1;
+       if (platform_info->enable_dma) {
+
+               /* Get two DMA channels (rx and tx) */
+               drv_data->rx_channel = pxa_request_dma("pxa2xx_spi_ssp_rx",
+                                                       DMA_PRIO_HIGH,
+                                                       dma_handler,
+                                                       drv_data);
+               if (drv_data->rx_channel < 0) {
+                       dev_err(dev, "problem (%d) requesting rx channel\n",
+                               drv_data->rx_channel);
+                       status = -ENODEV;
+                       goto out_error_irq_alloc;
+               }
+               drv_data->tx_channel = pxa_request_dma("pxa2xx_spi_ssp_tx",
+                                                       DMA_PRIO_MEDIUM,
+                                                       dma_handler,
+                                                       drv_data);
+               if (drv_data->tx_channel < 0) {
+                       dev_err(dev, "problem (%d) requesting tx channel\n",
+                               drv_data->tx_channel);
+                       status = -ENODEV;
+                       goto out_error_dma_alloc;
+               }
+
+               if (drv_data->ioaddr == SSP1_VIRT) {
+                               DRCMRRXSSDR = DRCMR_MAPVLD
+                                               | drv_data->rx_channel;
+                               DRCMRTXSSDR = DRCMR_MAPVLD
+                                               | drv_data->tx_channel;
+               } else if (drv_data->ioaddr == SSP2_VIRT) {
+                               DRCMRRXSS2DR = DRCMR_MAPVLD
+                                               | drv_data->rx_channel;
+                               DRCMRTXSS2DR = DRCMR_MAPVLD
+                                               | drv_data->tx_channel;
+               } else if (drv_data->ioaddr == SSP3_VIRT) {
+                               DRCMRRXSS3DR = DRCMR_MAPVLD
+                                               | drv_data->rx_channel;
+                               DRCMRTXSS3DR = DRCMR_MAPVLD
+                                               | drv_data->tx_channel;
+               } else {
+                       dev_err(dev, "bad SSP type\n");
+                       goto out_error_dma_alloc;
+               }
+       }
+
+       /* Enable SOC clock */
+       pxa_set_cken(platform_info->clock_enable, 1);
+
+       /* Load default SSP configuration */
+       write_SSCR0(0, drv_data->ioaddr);
+       write_SSCR1(SSCR1_RxTresh(4) | SSCR1_TxTresh(12), drv_data->ioaddr);
+       write_SSCR0(SSCR0_SerClkDiv(2)
+                       | SSCR0_Motorola
+                       | SSCR0_DataSize(8),
+                       drv_data->ioaddr);
+       if (drv_data->ssp_type != PXA25x_SSP)
+               write_SSTO(0, drv_data->ioaddr);
+       write_SSPSP(0, drv_data->ioaddr);
+
+       /* Initial and start queue */
+       status = init_queue(drv_data);
+       if (status != 0) {
+               dev_err(&pdev->dev, "problem initializing queue\n");
+               goto out_error_clock_enabled;
+       }
+       status = start_queue(drv_data);
+       if (status != 0) {
+               dev_err(&pdev->dev, "problem starting queue\n");
+               goto out_error_clock_enabled;
+       }
+
+       /* Register with the SPI framework */
+       platform_set_drvdata(pdev, drv_data);
+       status = spi_register_master(master);
+       if (status != 0) {
+               dev_err(&pdev->dev, "problem registering spi master\n");
+               goto out_error_queue_alloc;
+       }
+
+       return status;
+
+out_error_queue_alloc:
+       destroy_queue(drv_data);
+
+out_error_clock_enabled:
+       pxa_set_cken(platform_info->clock_enable, 0);
+
+out_error_dma_alloc:
+       if (drv_data->tx_channel != -1)
+               pxa_free_dma(drv_data->tx_channel);
+       if (drv_data->rx_channel != -1)
+               pxa_free_dma(drv_data->rx_channel);
+
+out_error_irq_alloc:
+       free_irq(irq, drv_data);
+
+out_error_master_alloc:
+       spi_master_put(master);
+       return status;
+}
+
+static int pxa2xx_spi_remove(struct platform_device *pdev)
+{
+       struct driver_data *drv_data = platform_get_drvdata(pdev);
+       int irq;
+       int status = 0;
+
+       if (!drv_data)
+               return 0;
+
+       /* Remove the queue */
+       status = destroy_queue(drv_data);
+       if (status != 0)
+               return status;
+
+       /* Disable the SSP at the peripheral and SOC level */
+       write_SSCR0(0, drv_data->ioaddr);
+       pxa_set_cken(drv_data->master_info->clock_enable, 0);
+
+       /* Release DMA */
+       if (drv_data->master_info->enable_dma) {
+               if (drv_data->ioaddr == SSP1_VIRT) {
+                       DRCMRRXSSDR = 0;
+                       DRCMRTXSSDR = 0;
+               } else if (drv_data->ioaddr == SSP2_VIRT) {
+                       DRCMRRXSS2DR = 0;
+                       DRCMRTXSS2DR = 0;
+               } else if (drv_data->ioaddr == SSP3_VIRT) {
+                       DRCMRRXSS3DR = 0;
+                       DRCMRTXSS3DR = 0;
+               }
+               pxa_free_dma(drv_data->tx_channel);
+               pxa_free_dma(drv_data->rx_channel);
+       }
+
+       /* Release IRQ */
+       irq = platform_get_irq(pdev, 0);
+       if (irq >= 0)
+               free_irq(irq, drv_data);
+
+       /* Disconnect from the SPI framework */
+       spi_unregister_master(drv_data->master);
+
+       /* Prevent double remove */
+       platform_set_drvdata(pdev, NULL);
+
+       return 0;
+}
+
+static void pxa2xx_spi_shutdown(struct platform_device *pdev)
+{
+       int status = 0;
+
+       if ((status = pxa2xx_spi_remove(pdev)) != 0)
+               dev_err(&pdev->dev, "shutdown failed with %d\n", status);
+}
+
+#ifdef CONFIG_PM
+static int suspend_devices(struct device *dev, void *pm_message)
+{
+       pm_message_t *state = pm_message;
+
+       if (dev->power.power_state.event != state->event) {
+               dev_warn(dev, "pm state does not match request\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int pxa2xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct driver_data *drv_data = platform_get_drvdata(pdev);
+       int status = 0;
+
+       /* Check all childern for current power state */
+       if (device_for_each_child(&pdev->dev, &state, suspend_devices) != 0) {
+               dev_warn(&pdev->dev, "suspend aborted\n");
+               return -1;
+       }
+
+       status = stop_queue(drv_data);
+       if (status != 0)
+               return status;
+       write_SSCR0(0, drv_data->ioaddr);
+       pxa_set_cken(drv_data->master_info->clock_enable, 0);
+
+       return 0;
+}
+
+static int pxa2xx_spi_resume(struct platform_device *pdev)
+{
+       struct driver_data *drv_data = platform_get_drvdata(pdev);
+       int status = 0;
+
+       /* Enable the SSP clock */
+       pxa_set_cken(drv_data->master_info->clock_enable, 1);
+
+       /* Start the queue running */
+       status = start_queue(drv_data);
+       if (status != 0) {
+               dev_err(&pdev->dev, "problem starting queue (%d)\n", status);
+               return status;
+       }
+
+       return 0;
+}
+#else
+#define pxa2xx_spi_suspend NULL
+#define pxa2xx_spi_resume NULL
+#endif /* CONFIG_PM */
+
+static struct platform_driver driver = {
+       .driver = {
+               .name = "pxa2xx-spi",
+               .bus = &platform_bus_type,
+               .owner = THIS_MODULE,
+       },
+       .probe = pxa2xx_spi_probe,
+       .remove = __devexit_p(pxa2xx_spi_remove),
+       .shutdown = pxa2xx_spi_shutdown,
+       .suspend = pxa2xx_spi_suspend,
+       .resume = pxa2xx_spi_resume,
+};
+
+static int __init pxa2xx_spi_init(void)
+{
+       platform_driver_register(&driver);
+
+       return 0;
+}
+module_init(pxa2xx_spi_init);
+
+static void __exit pxa2xx_spi_exit(void)
+{
+       platform_driver_unregister(&driver);
+}
+module_exit(pxa2xx_spi_exit);
index 94f5e8e..7a3f733 100644 (file)
@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
 int __init_or_module
 spi_register_master(struct spi_master *master)
 {
-       static atomic_t         dyn_bus_id = ATOMIC_INIT(0);
+       static atomic_t         dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
        struct device           *dev = master->cdev.dev;
        int                     status = -ENODEV;
        int                     dynamic = 0;
@@ -404,7 +404,7 @@ spi_register_master(struct spi_master *master)
                return -ENODEV;
 
        /* convention:  dynamically assigned bus IDs count down from the max */
-       if (master->bus_num == 0) {
+       if (master->bus_num < 0) {
                master->bus_num = atomic_dec_return(&dyn_bus_id);
                dynamic = 1;
        }
@@ -522,7 +522,8 @@ int spi_sync(struct spi_device *spi, struct spi_message *message)
 }
 EXPORT_SYMBOL_GPL(spi_sync);
 
-#define        SPI_BUFSIZ      (SMP_CACHE_BYTES)
+/* portable code must never pass more than 32 bytes */
+#define        SPI_BUFSIZ      max(32,SMP_CACHE_BYTES)
 
 static u8      *buf;
 
index f037e55..dd2f950 100644 (file)
@@ -138,6 +138,45 @@ static unsigned bitbang_txrx_32(
        return t->len - count;
 }
 
+int spi_bitbang_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
+{
+       struct spi_bitbang_cs   *cs = spi->controller_state;
+       u8                      bits_per_word;
+       u32                     hz;
+
+       if (t) {
+               bits_per_word = t->bits_per_word;
+               hz = t->speed_hz;
+       } else {
+               bits_per_word = 0;
+               hz = 0;
+       }
+
+       /* spi_transfer level calls that work per-word */
+       if (!bits_per_word)
+               bits_per_word = spi->bits_per_word;
+       if (bits_per_word <= 8)
+               cs->txrx_bufs = bitbang_txrx_8;
+       else if (bits_per_word <= 16)
+               cs->txrx_bufs = bitbang_txrx_16;
+       else if (bits_per_word <= 32)
+               cs->txrx_bufs = bitbang_txrx_32;
+       else
+               return -EINVAL;
+
+       /* nsecs = (clock period)/2 */
+       if (!hz)
+               hz = spi->max_speed_hz;
+       if (hz) {
+               cs->nsecs = (1000000000/2) / hz;
+               if (cs->nsecs > (MAX_UDELAY_MS * 1000 * 1000))
+                       return -EINVAL;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(spi_bitbang_setup_transfer);
+
 /**
  * spi_bitbang_setup - default setup for per-word I/O loops
  */
@@ -145,8 +184,16 @@ int spi_bitbang_setup(struct spi_device *spi)
 {
        struct spi_bitbang_cs   *cs = spi->controller_state;
        struct spi_bitbang      *bitbang;
+       int                     retval;
 
-       if (!spi->max_speed_hz)
+       bitbang = spi_master_get_devdata(spi->master);
+
+       /* REVISIT: some systems will want to support devices using lsb-first
+        * bit encodings on the wire.  In pure software that would be trivial,
+        * just bitbang_txrx_le_cphaX() routines shifting the other way, and
+        * some hardware controllers also have this support.
+        */
+       if ((spi->mode & SPI_LSB_FIRST) != 0)
                return -EINVAL;
 
        if (!cs) {
@@ -155,32 +202,20 @@ int spi_bitbang_setup(struct spi_device *spi)
                        return -ENOMEM;
                spi->controller_state = cs;
        }
-       bitbang = spi_master_get_devdata(spi->master);
 
        if (!spi->bits_per_word)
                spi->bits_per_word = 8;
 
-       /* spi_transfer level calls that work per-word */
-       if (spi->bits_per_word <= 8)
-               cs->txrx_bufs = bitbang_txrx_8;
-       else if (spi->bits_per_word <= 16)
-               cs->txrx_bufs = bitbang_txrx_16;
-       else if (spi->bits_per_word <= 32)
-               cs->txrx_bufs = bitbang_txrx_32;
-       else
-               return -EINVAL;
-
        /* per-word shift register access, in hardware or bitbanging */
        cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)];
        if (!cs->txrx_word)
                return -EINVAL;
 
-       /* nsecs = (clock period)/2 */
-       cs->nsecs = (1000000000/2) / (spi->max_speed_hz);
-       if (cs->nsecs > MAX_UDELAY_MS * 1000)
-               return -EINVAL;
+       retval = spi_bitbang_setup_transfer(spi, NULL);
+       if (retval < 0)
+               return retval;
 
-       dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n",
+       dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n",
                        __FUNCTION__, spi->mode & (SPI_CPOL | SPI_CPHA),
                        spi->bits_per_word, 2 * cs->nsecs);
 
@@ -246,6 +281,8 @@ static void bitbang_work(void *_bitbang)
                unsigned                tmp;
                unsigned                cs_change;
                int                     status;
+               int                     (*setup_transfer)(struct spi_device *,
+                                               struct spi_transfer *);
 
                m = container_of(bitbang->queue.next, struct spi_message,
                                queue);
@@ -262,6 +299,7 @@ static void bitbang_work(void *_bitbang)
                tmp = 0;
                cs_change = 1;
                status = 0;
+               setup_transfer = NULL;
 
                list_for_each_entry (t, &m->transfers, transfer_list) {
                        if (bitbang->shutdown) {
@@ -269,6 +307,20 @@ static void bitbang_work(void *_bitbang)
                                break;
                        }
 
+                       /* override or restore speed and wordsize */
+                       if (t->speed_hz || t->bits_per_word) {
+                               setup_transfer = bitbang->setup_transfer;
+                               if (!setup_transfer) {
+                                       status = -ENOPROTOOPT;
+                                       break;
+                               }
+                       }
+                       if (setup_transfer) {
+                               status = setup_transfer(spi, t);
+                               if (status < 0)
+                                       break;
+                       }
+
                        /* set up default clock polarity, and activate chip;
                         * this implicitly updates clock and spi modes as
                         * previously recorded for this device via setup().
@@ -325,6 +377,10 @@ static void bitbang_work(void *_bitbang)
                m->status = status;
                m->complete(m->context);
 
+               /* restore speed and wordsize */
+               if (setup_transfer)
+                       setup_transfer(spi, NULL);
+
                /* normally deactivate chipselect ... unless no error and
                 * cs_change has hinted that the next message will probably
                 * be for this chip too.
@@ -348,6 +404,7 @@ int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m)
 {
        struct spi_bitbang      *bitbang;
        unsigned long           flags;
+       int                     status = 0;
 
        m->actual_length = 0;
        m->status = -EINPROGRESS;
@@ -357,11 +414,15 @@ int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m)
                return -ESHUTDOWN;
 
        spin_lock_irqsave(&bitbang->lock, flags);
-       list_add_tail(&m->queue, &bitbang->queue);
-       queue_work(bitbang->workqueue, &bitbang->work);
+       if (!spi->max_speed_hz)
+               status = -ENETDOWN;
+       else {
+               list_add_tail(&m->queue, &bitbang->queue);
+               queue_work(bitbang->workqueue, &bitbang->work);
+       }
        spin_unlock_irqrestore(&bitbang->lock, flags);
 
-       return 0;
+       return status;
 }
 EXPORT_SYMBOL_GPL(spi_bitbang_transfer);
 
@@ -406,6 +467,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
                bitbang->use_dma = 0;
                bitbang->txrx_bufs = spi_bitbang_bufs;
                if (!bitbang->master->setup) {
+                       if (!bitbang->setup_transfer)
+                               bitbang->setup_transfer =
+                                        spi_bitbang_setup_transfer;
                        bitbang->master->setup = spi_bitbang_setup;
                        bitbang->master->cleanup = spi_bitbang_cleanup;
                }
index 334b1db..27597c5 100644 (file)
@@ -29,12 +29,15 @@ static ssize_t backlight_show_power(struct class_device *cdev, char *buf)
 
 static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count)
 {
-       int rc = -ENXIO, power;
+       int rc = -ENXIO;
        char *endp;
        struct backlight_device *bd = to_backlight_device(cdev);
+       int power = simple_strtoul(buf, &endp, 0);
+       size_t size = endp - buf;
 
-       power = simple_strtoul(buf, &endp, 0);
-       if (*endp && !isspace(*endp))
+       if (*endp && isspace(*endp))
+               size++;
+       if (size != count)
                return -EINVAL;
 
        down(&bd->sem);
@@ -65,12 +68,15 @@ static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf)
 
 static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count)
 {
-       int rc = -ENXIO, brightness;
+       int rc = -ENXIO;
        char *endp;
        struct backlight_device *bd = to_backlight_device(cdev);
+       int brightness = simple_strtoul(buf, &endp, 0);
+       size_t size = endp - buf;
 
-       brightness = simple_strtoul(buf, &endp, 0);
-       if (*endp && !isspace(*endp))
+       if (*endp && isspace(*endp))
+               size++;
+       if (size != count)
                return -EINVAL;
 
        down(&bd->sem);
index 86908a6..bc8ab00 100644 (file)
@@ -31,12 +31,15 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
 
 static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_t count)
 {
-       int rc, power;
+       int rc = -ENXIO;
        char *endp;
        struct lcd_device *ld = to_lcd_device(cdev);
+       int power = simple_strtoul(buf, &endp, 0);
+       size_t size = endp - buf;
 
-       power = simple_strtoul(buf, &endp, 0);
-       if (*endp && !isspace(*endp))
+       if (*endp && isspace(*endp))
+               size++;
+       if (size != count)
                return -EINVAL;
 
        down(&ld->sem);
@@ -44,8 +47,7 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
                pr_debug("lcd: set power to %d\n", power);
                ld->props->set_power(ld, power);
                rc = count;
-       } else
-               rc = -ENXIO;
+       }
        up(&ld->sem);
 
        return rc;
@@ -53,14 +55,12 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
 
 static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
 {
-       int rc;
+       int rc = -ENXIO;
        struct lcd_device *ld = to_lcd_device(cdev);
 
        down(&ld->sem);
        if (likely(ld->props && ld->props->get_contrast))
                rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld));
-       else
-               rc = -ENXIO;
        up(&ld->sem);
 
        return rc;
@@ -68,12 +68,15 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
 
 static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, size_t count)
 {
-       int rc, contrast;
+       int rc = -ENXIO;
        char *endp;
        struct lcd_device *ld = to_lcd_device(cdev);
+       int contrast = simple_strtoul(buf, &endp, 0);
+       size_t size = endp - buf;
 
-       contrast = simple_strtoul(buf, &endp, 0);
-       if (*endp && !isspace(*endp))
+       if (*endp && isspace(*endp))
+               size++;
+       if (size != count)
                return -EINVAL;
 
        down(&ld->sem);
@@ -81,8 +84,7 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
                pr_debug("lcd: set contrast to %d\n", contrast);
                ld->props->set_contrast(ld, contrast);
                rc = count;
-       } else
-               rc = -ENXIO;
+       }
        up(&ld->sem);
 
        return rc;
@@ -90,14 +92,12 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
 
 static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf)
 {
-       int rc;
+       int rc = -ENXIO;
        struct lcd_device *ld = to_lcd_device(cdev);
 
        down(&ld->sem);
        if (likely(ld->props))
                rc = sprintf(buf, "%d\n", ld->props->max_contrast);
-       else
-               rc = -ENXIO;
        up(&ld->sem);
 
        return rc;
index 71742ba..6f26178 100644 (file)
@@ -98,23 +98,20 @@ v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname,
 static void v9fs_t_clunk_cb(void *a, struct v9fs_fcall *tc,
        struct v9fs_fcall *rc, int err)
 {
-       int fid;
+       int fid, id;
        struct v9fs_session_info *v9ses;
 
-       if (err)
-               return;
-
+       id = 0;
        fid = tc->params.tclunk.fid;
-       kfree(tc);
-
-       if (!rc)
-               return;
-
-       v9ses = a;
-       if (rc->id == RCLUNK)
-               v9fs_put_idpool(fid, &v9ses->fidpool);
+       if (rc)
+               id = rc->id;
 
+       kfree(tc);
        kfree(rc);
+       if (id == RCLUNK) {
+               v9ses = a;
+               v9fs_put_idpool(fid, &v9ses->fidpool);
+       }
 }
 
 /**
index 3e5b124..f4407eb 100644 (file)
@@ -50,15 +50,23 @@ enum {
        Wpending = 8,           /* can write */
 };
 
+enum {
+       None,
+       Flushing,
+       Flushed,
+};
+
 struct v9fs_mux_poll_task;
 
 struct v9fs_req {
+       spinlock_t lock;
        int tag;
        struct v9fs_fcall *tcall;
        struct v9fs_fcall *rcall;
        int err;
        v9fs_mux_req_callback cb;
        void *cba;
+       int flush;
        struct list_head req_list;
 };
 
@@ -96,8 +104,8 @@ struct v9fs_mux_poll_task {
 
 struct v9fs_mux_rpc {
        struct v9fs_mux_data *m;
-       struct v9fs_req *req;
        int err;
+       struct v9fs_fcall *tcall;
        struct v9fs_fcall *rcall;
        wait_queue_head_t wqueue;
 };
@@ -524,10 +532,9 @@ again:
 
 static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
 {
-       int ecode, tag;
+       int ecode;
        struct v9fs_str *ename;
 
-       tag = req->tag;
        if (!req->err && req->rcall->id == RERROR) {
                ecode = req->rcall->params.rerror.errno;
                ename = &req->rcall->params.rerror.error;
@@ -553,23 +560,6 @@ static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
                if (!req->err)
                        req->err = -EIO;
        }
-
-       if (req->err == ERREQFLUSH)
-               return;
-
-       if (req->cb) {
-               dprintk(DEBUG_MUX, "calling callback tcall %p rcall %p\n",
-                       req->tcall, req->rcall);
-
-               (*req->cb) (req->cba, req->tcall, req->rcall, req->err);
-               req->cb = NULL;
-       } else
-               kfree(req->rcall);
-
-       v9fs_mux_put_tag(m, tag);
-
-       wake_up(&m->equeue);
-       kfree(req);
 }
 
 /**
@@ -669,17 +659,26 @@ static void v9fs_read_work(void *a)
                list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
                        if (rreq->tag == rcall->tag) {
                                req = rreq;
-                               req->rcall = rcall;
-                               list_del(&req->req_list);
-                               spin_unlock(&m->lock);
-                               process_request(m, req);
+                               if (req->flush != Flushing)
+                                       list_del(&req->req_list);
                                break;
                        }
-
                }
+               spin_unlock(&m->lock);
 
-               if (!req) {
-                       spin_unlock(&m->lock);
+               if (req) {
+                       req->rcall = rcall;
+                       process_request(m, req);
+
+                       if (req->flush != Flushing) {
+                               if (req->cb)
+                                       (*req->cb) (req, req->cba);
+                               else
+                                       kfree(req->rcall);
+
+                               wake_up(&m->equeue);
+                       }
+               } else {
                        if (err >= 0 && rcall->id != RFLUSH)
                                dprintk(DEBUG_ERROR,
                                        "unexpected response mux %p id %d tag %d\n",
@@ -746,7 +745,6 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
                return ERR_PTR(-ENOMEM);
 
        v9fs_set_tag(tc, n);
-
        if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
                char buf[150];
 
@@ -754,12 +752,14 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
                printk(KERN_NOTICE "<<< %p %s\n", m, buf);
        }
 
+       spin_lock_init(&req->lock);
        req->tag = n;
        req->tcall = tc;
        req->rcall = NULL;
        req->err = 0;
        req->cb = cb;
        req->cba = cba;
+       req->flush = None;
 
        spin_lock(&m->lock);
        list_add_tail(&req->req_list, &m->unsent_req_list);
@@ -776,72 +776,108 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
        return req;
 }
 
-static void v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc,
-                             struct v9fs_fcall *rc, int err)
+static void v9fs_mux_free_request(struct v9fs_mux_data *m, struct v9fs_req *req)
+{
+       v9fs_mux_put_tag(m, req->tag);
+       kfree(req);
+}
+
+static void v9fs_mux_flush_cb(struct v9fs_req *freq, void *a)
 {
        v9fs_mux_req_callback cb;
        int tag;
        struct v9fs_mux_data *m;
-       struct v9fs_req *req, *rptr;
+       struct v9fs_req *req, *rreq, *rptr;
 
        m = a;
-       dprintk(DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m, tc,
-               rc, err, tc->params.tflush.oldtag);
+       dprintk(DEBUG_MUX, "mux %p tc %p rc %p err %d oldtag %d\n", m,
+               freq->tcall, freq->rcall, freq->err,
+               freq->tcall->params.tflush.oldtag);
 
        spin_lock(&m->lock);
        cb = NULL;
-       tag = tc->params.tflush.oldtag;
-       list_for_each_entry_safe(req, rptr, &m->req_list, req_list) {
-               if (req->tag == tag) {
+       tag = freq->tcall->params.tflush.oldtag;
+       req = NULL;
+       list_for_each_entry_safe(rreq, rptr, &m->req_list, req_list) {
+               if (rreq->tag == tag) {
+                       req = rreq;
                        list_del(&req->req_list);
-                       if (req->cb) {
-                               cb = req->cb;
-                               req->cb = NULL;
-                               spin_unlock(&m->lock);
-                               (*cb) (req->cba, req->tcall, req->rcall,
-                                      req->err);
-                       }
-                       kfree(req);
-                       wake_up(&m->equeue);
                        break;
                }
        }
+       spin_unlock(&m->lock);
 
-       if (!cb)
-               spin_unlock(&m->lock);
+       if (req) {
+               spin_lock(&req->lock);
+               req->flush = Flushed;
+               spin_unlock(&req->lock);
+
+               if (req->cb)
+                       (*req->cb) (req, req->cba);
+               else
+                       kfree(req->rcall);
+
+               wake_up(&m->equeue);
+       }
 
-       v9fs_mux_put_tag(m, tag);
-       kfree(tc);
-       kfree(rc);
+       kfree(freq->tcall);
+       kfree(freq->rcall);
+       v9fs_mux_free_request(m, freq);
 }
 
-static void
+static int
 v9fs_mux_flush_request(struct v9fs_mux_data *m, struct v9fs_req *req)
 {
        struct v9fs_fcall *fc;
+       struct v9fs_req *rreq, *rptr;
 
        dprintk(DEBUG_MUX, "mux %p req %p tag %d\n", m, req, req->tag);
 
+       /* if a response was received for a request, do nothing */
+       spin_lock(&req->lock);
+       if (req->rcall || req->err) {
+               spin_unlock(&req->lock);
+               dprintk(DEBUG_MUX, "mux %p req %p response already received\n", m, req);
+               return 0;
+       }
+
+       req->flush = Flushing;
+       spin_unlock(&req->lock);
+
+       spin_lock(&m->lock);
+       /* if the request is not sent yet, just remove it from the list */
+       list_for_each_entry_safe(rreq, rptr, &m->unsent_req_list, req_list) {
+               if (rreq->tag == req->tag) {
+                       dprintk(DEBUG_MUX, "mux %p req %p request is not sent yet\n", m, req);
+                       list_del(&rreq->req_list);
+                       req->flush = Flushed;
+                       spin_unlock(&m->lock);
+                       if (req->cb)
+                               (*req->cb) (req, req->cba);
+                       return 0;
+               }
+       }
+       spin_unlock(&m->lock);
+
+       clear_thread_flag(TIF_SIGPENDING);
        fc = v9fs_create_tflush(req->tag);
        v9fs_send_request(m, fc, v9fs_mux_flush_cb, m);
+       return 1;
 }
 
 static void
-v9fs_mux_rpc_cb(void *a, struct v9fs_fcall *tc, struct v9fs_fcall *rc, int err)
+v9fs_mux_rpc_cb(struct v9fs_req *req, void *a)
 {
        struct v9fs_mux_rpc *r;
 
-       if (err == ERREQFLUSH) {
-               kfree(rc);
-               dprintk(DEBUG_MUX, "err req flush\n");
-               return;
-       }
-
+       dprintk(DEBUG_MUX, "req %p r %p\n", req, a);
        r = a;
-       dprintk(DEBUG_MUX, "mux %p req %p tc %p rc %p err %d\n", r->m, r->req,
-               tc, rc, err);
-       r->rcall = rc;
-       r->err = err;
+       r->rcall = req->rcall;
+       r->err = req->err;
+
+       if (req->flush!=None && !req->err)
+               r->err = -ERESTARTSYS;
+
        wake_up(&r->wqueue);
 }
 
@@ -856,12 +892,13 @@ int
 v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
             struct v9fs_fcall **rc)
 {
-       int err;
+       int err, sigpending;
        unsigned long flags;
        struct v9fs_req *req;
        struct v9fs_mux_rpc r;
 
        r.err = 0;
+       r.tcall = tc;
        r.rcall = NULL;
        r.m = m;
        init_waitqueue_head(&r.wqueue);
@@ -869,48 +906,50 @@ v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
        if (rc)
                *rc = NULL;
 
+       sigpending = 0;
+       if (signal_pending(current)) {
+               sigpending = 1;
+               clear_thread_flag(TIF_SIGPENDING);
+       }
+
        req = v9fs_send_request(m, tc, v9fs_mux_rpc_cb, &r);
        if (IS_ERR(req)) {
                err = PTR_ERR(req);
                dprintk(DEBUG_MUX, "error %d\n", err);
-               return PTR_ERR(req);
+               return err;
        }
 
-       r.req = req;
-       dprintk(DEBUG_MUX, "mux %p tc %p tag %d rpc %p req %p\n", m, tc,
-               req->tag, &r, req);
        err = wait_event_interruptible(r.wqueue, r.rcall != NULL || r.err < 0);
        if (r.err < 0)
                err = r.err;
 
        if (err == -ERESTARTSYS && m->trans->status == Connected && m->err == 0) {
-               spin_lock(&m->lock);
-               req->tcall = NULL;
-               req->err = ERREQFLUSH;
-               spin_unlock(&m->lock);
+               if (v9fs_mux_flush_request(m, req)) {
+                       /* wait until we get response of the flush message */
+                       do {
+                               clear_thread_flag(TIF_SIGPENDING);
+                               err = wait_event_interruptible(r.wqueue,
+                                       r.rcall || r.err);
+                       } while (!r.rcall && !r.err && err==-ERESTARTSYS &&
+                               m->trans->status==Connected && !m->err);
+               }
+               sigpending = 1;
+       }
 
-               clear_thread_flag(TIF_SIGPENDING);
-               v9fs_mux_flush_request(m, req);
+       if (sigpending) {
                spin_lock_irqsave(&current->sighand->siglock, flags);
                recalc_sigpending();
                spin_unlock_irqrestore(&current->sighand->siglock, flags);
        }
 
-       if (!err) {
-               if (r.rcall)
-                       dprintk(DEBUG_MUX, "got response id %d tag %d\n",
-                               r.rcall->id, r.rcall->tag);
-
-               if (rc)
-                       *rc = r.rcall;
-               else
-                       kfree(r.rcall);
-       } else {
+       if (rc)
+               *rc = r.rcall;
+       else
                kfree(r.rcall);
-               dprintk(DEBUG_MUX, "got error %d\n", err);
-               if (err > 0)
-                       err = -EIO;
-       }
+
+       v9fs_mux_free_request(m, req);
+       if (err > 0)
+               err = -EIO;
 
        return err;
 }
@@ -951,12 +990,15 @@ void v9fs_mux_cancel(struct v9fs_mux_data *m, int err)
        struct v9fs_req *req, *rtmp;
        LIST_HEAD(cancel_list);
 
-       dprintk(DEBUG_MUX, "mux %p err %d\n", m, err);
+       dprintk(DEBUG_ERROR, "mux %p err %d\n", m, err);
        m->err = err;
        spin_lock(&m->lock);
        list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) {
                list_move(&req->req_list, &cancel_list);
        }
+       list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) {
+               list_move(&req->req_list, &cancel_list);
+       }
        spin_unlock(&m->lock);
 
        list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) {
@@ -965,11 +1007,9 @@ void v9fs_mux_cancel(struct v9fs_mux_data *m, int err)
                        req->err = err;
 
                if (req->cb)
-                       (*req->cb) (req->cba, req->tcall, req->rcall, req->err);
+                       (*req->cb) (req, req->cba);
                else
                        kfree(req->rcall);
-
-               kfree(req);
        }
 
        wake_up(&m->equeue);
index e90bfd3..fb10c50 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 struct v9fs_mux_data;
+struct v9fs_req;
 
 /**
  * v9fs_mux_req_callback - callback function that is called when the
@@ -36,8 +37,7 @@ struct v9fs_mux_data;
  * @rc - response call
  * @err - error code (non-zero if error occured)
  */
-typedef void (*v9fs_mux_req_callback)(void *a, struct v9fs_fcall *tc,
-       struct v9fs_fcall *rc, int err);
+typedef void (*v9fs_mux_req_callback)(struct v9fs_req *req, void *a);
 
 int v9fs_mux_global_init(void);
 void v9fs_mux_global_exit(void);
index 083dcfc..1a8e460 100644 (file)
@@ -72,11 +72,17 @@ int v9fs_file_open(struct inode *inode, struct file *file)
                return -ENOSPC;
        }
 
-       err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL);
+       err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, &fcall);
        if (err < 0) {
                dprintk(DEBUG_ERROR, "rewalk didn't work\n");
-               goto put_fid;
+               if (fcall && fcall->id == RWALK)
+                       goto clunk_fid;
+               else {
+                       v9fs_put_idpool(fid, &v9ses->fidpool);
+                       goto free_fcall;
+               }
        }
+       kfree(fcall);
 
        /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
        /* translate open mode appropriately */
@@ -109,8 +115,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 clunk_fid:
        v9fs_t_clunk(v9ses, fid);
 
-put_fid:
-       v9fs_put_idpool(fid, &v9ses->fidpool);
+free_fcall:
        kfree(fcall);
 
        return err;
index 133db36..2cb87ba 100644 (file)
@@ -270,7 +270,10 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
        err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall);
        if (err < 0) {
                PRINT_FCALL_ERROR("clone error", fcall);
-               goto put_fid;
+               if (fcall && fcall->id == RWALK)
+                       goto clunk_fid;
+               else
+                       goto put_fid;
        }
        kfree(fcall);
 
@@ -322,6 +325,9 @@ v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
                &fcall);
 
        if (err < 0) {
+               if (fcall && fcall->id == RWALK)
+                       goto clunk_fid;
+
                PRINT_FCALL_ERROR("walk error", fcall);
                v9fs_put_idpool(nfid, &v9ses->fidpool);
                goto error;
@@ -640,19 +646,26 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
        }
 
        result = v9fs_t_walk(v9ses, dirfidnum, newfid,
-               (char *)dentry->d_name.name, NULL);
+               (char *)dentry->d_name.name, &fcall);
+
        if (result < 0) {
-               v9fs_put_idpool(newfid, &v9ses->fidpool);
+               if (fcall && fcall->id == RWALK)
+                       v9fs_t_clunk(v9ses, newfid);
+               else
+                       v9fs_put_idpool(newfid, &v9ses->fidpool);
+
                if (result == -ENOENT) {
                        d_add(dentry, NULL);
                        dprintk(DEBUG_VFS,
                                "Return negative dentry %p count %d\n",
                                dentry, atomic_read(&dentry->d_count));
+                       kfree(fcall);
                        return NULL;
                }
                dprintk(DEBUG_ERROR, "walk error:%d\n", result);
                goto FreeFcall;
        }
+       kfree(fcall);
 
        result = v9fs_t_stat(v9ses, newfid, &fcall);
        if (result < 0) {
index 83bf478..078d3d1 100644 (file)
@@ -45,6 +45,7 @@ obj-$(CONFIG_DNOTIFY)         += dnotify.o
 obj-$(CONFIG_PROC_FS)          += proc/
 obj-y                          += partitions/
 obj-$(CONFIG_SYSFS)            += sysfs/
+obj-$(CONFIG_CONFIGFS_FS)      += configfs/
 obj-y                          += devpts/
 
 obj-$(CONFIG_PROFILING)                += dcookies.o
@@ -100,5 +101,4 @@ obj-$(CONFIG_BEFS_FS)               += befs/
 obj-$(CONFIG_HOSTFS)           += hostfs/
 obj-$(CONFIG_HPPFS)            += hppfs/
 obj-$(CONFIG_DEBUG_FS)         += debugfs/
-obj-$(CONFIG_CONFIGFS_FS)      += configfs/
 obj-$(CONFIG_OCFS2_FS)         += ocfs2/
index 57c4903..d6603d0 100644 (file)
@@ -74,8 +74,8 @@ struct autofs_wait_queue {
        struct autofs_wait_queue *next;
        autofs_wqt_t wait_queue_token;
        /* We use the following to see what we are waiting for */
-       int hash;
-       int len;
+       unsigned int hash;
+       unsigned int len;
        char *name;
        u32 dev;
        u64 ino;
@@ -85,7 +85,6 @@ struct autofs_wait_queue {
        pid_t tgid;
        /* This is for status reporting upon return */
        int status;
-       atomic_t notify;
        atomic_t wait_ctr;
 };
 
index 84e030c..5100f98 100644 (file)
@@ -327,6 +327,7 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
 static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
        int oz_mode = autofs4_oz_mode(sbi);
        unsigned int lookup_type;
        int status;
@@ -340,13 +341,8 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
        if (oz_mode || !lookup_type)
                goto done;
 
-       /*
-        * If a request is pending wait for it.
-        * If it's a mount then it won't be expired till at least
-        * a liitle later and if it's an expire then we might need
-        * to mount it again.
-        */
-       if (autofs4_ispending(dentry)) {
+       /* If an expire request is pending wait for it. */
+       if (ino && (ino->flags & AUTOFS_INF_EXPIRING)) {
                DPRINTK("waiting for active request %p name=%.*s",
                        dentry, dentry->d_name.len, dentry->d_name.name);
 
index 142ab6a..ce103e7 100644 (file)
@@ -189,14 +189,30 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,
        return len;
 }
 
+static struct autofs_wait_queue *
+autofs4_find_wait(struct autofs_sb_info *sbi,
+                 char *name, unsigned int hash, unsigned int len)
+{
+       struct autofs_wait_queue *wq;
+
+       for (wq = sbi->queues; wq; wq = wq->next) {
+               if (wq->hash == hash &&
+                   wq->len == len &&
+                   wq->name && !memcmp(wq->name, name, len))
+                       break;
+       }
+       return wq;
+}
+
 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                enum autofs_notify notify)
 {
+       struct autofs_info *ino;
        struct autofs_wait_queue *wq;
        char *name;
        unsigned int len = 0;
        unsigned int hash = 0;
-       int status;
+       int status, type;
 
        /* In catatonic mode, we don't wait for nobody */
        if (sbi->catatonic)
@@ -223,21 +239,41 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                return -EINTR;
        }
 
-       for (wq = sbi->queues ; wq ; wq = wq->next) {
-               if (wq->hash == dentry->d_name.hash &&
-                   wq->len == len &&
-                   wq->name && !memcmp(wq->name, name, len))
-                       break;
-       }
+       wq = autofs4_find_wait(sbi, name, hash, len);
+       ino = autofs4_dentry_ino(dentry);
+       if (!wq && ino && notify == NFY_NONE) {
+               /*
+                * Either we've betean the pending expire to post it's
+                * wait or it finished while we waited on the mutex.
+                * So we need to wait till either, the wait appears
+                * or the expire finishes.
+                */
+
+               while (ino->flags & AUTOFS_INF_EXPIRING) {
+                       mutex_unlock(&sbi->wq_mutex);
+                       schedule_timeout_interruptible(HZ/10);
+                       if (mutex_lock_interruptible(&sbi->wq_mutex)) {
+                               kfree(name);
+                               return -EINTR;
+                       }
+                       wq = autofs4_find_wait(sbi, name, hash, len);
+                       if (wq)
+                               break;
+               }
 
-       if (!wq) {
-               /* Can't wait for an expire if there's no mount */
-               if (notify == NFY_NONE && !d_mountpoint(dentry)) {
+               /*
+                * Not ideal but the status has already gone. Of the two
+                * cases where we wait on NFY_NONE neither depend on the
+                * return status of the wait.
+                */
+               if (!wq) {
                        kfree(name);
                        mutex_unlock(&sbi->wq_mutex);
-                       return -ENOENT;
+                       return 0;
                }
+       }
 
+       if (!wq) {
                /* Create a new wait queue */
                wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
                if (!wq) {
@@ -263,20 +299,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                wq->tgid = current->tgid;
                wq->status = -EINTR; /* Status return if interrupted */
                atomic_set(&wq->wait_ctr, 2);
-               atomic_set(&wq->notify, 1);
-               mutex_unlock(&sbi->wq_mutex);
-       } else {
-               atomic_inc(&wq->wait_ctr);
                mutex_unlock(&sbi->wq_mutex);
-               kfree(name);
-               DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
-                       (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
-       }
-
-       if (notify != NFY_NONE && atomic_read(&wq->notify)) {
-               int type;
-
-               atomic_dec(&wq->notify);
 
                if (sbi->version < 5) {
                        if (notify == NFY_MOUNT)
@@ -299,6 +322,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
 
                /* autofs4_notify_daemon() may block */
                autofs4_notify_daemon(sbi, wq, type);
+       } else {
+               atomic_inc(&wq->wait_ctr);
+               mutex_unlock(&sbi->wq_mutex);
+               kfree(name);
+               DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
+                       (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
        }
 
        /* wq->name is NULL if and only if the lock is already released */
index 970888a..01f39f8 100644 (file)
@@ -1913,7 +1913,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
        }
 
        if (sigmask) {
-               if (sigsetsize |= sizeof(compat_sigset_t))
+               if (sigsetsize != sizeof(compat_sigset_t))
                        return -EINVAL;
                if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
                        return -EFAULT;
index 5638c8f..5f95218 100644 (file)
@@ -505,13 +505,15 @@ static int populate_groups(struct config_group *group)
        int i;
 
        if (group->default_groups) {
-               /* FYI, we're faking mkdir here
+               /*
+                * FYI, we're faking mkdir here
                 * I'm not sure we need this semaphore, as we're called
                 * from our parent's mkdir.  That holds our parent's
                 * i_mutex, so afaik lookup cannot continue through our
                 * parent to find us, let alone mess with our tree.
                 * That said, taking our i_mutex is closer to mkdir
-                * emulation, and shouldn't hurt. */
+                * emulation, and shouldn't hurt.
+                */
                mutex_lock(&dentry->d_inode->i_mutex);
 
                for (i = 0; group->default_groups[i]; i++) {
@@ -546,20 +548,34 @@ static void unlink_obj(struct config_item *item)
 
                item->ci_group = NULL;
                item->ci_parent = NULL;
+
+               /* Drop the reference for ci_entry */
                config_item_put(item);
 
+               /* Drop the reference for ci_parent */
                config_group_put(group);
        }
 }
 
 static void link_obj(struct config_item *parent_item, struct config_item *item)
 {
-       /* Parent seems redundant with group, but it makes certain
-        * traversals much nicer. */
+       /*
+        * Parent seems redundant with group, but it makes certain
+        * traversals much nicer.
+        */
        item->ci_parent = parent_item;
+
+       /*
+        * We hold a reference on the parent for the child's ci_parent
+        * link.
+        */
        item->ci_group = config_group_get(to_config_group(parent_item));
        list_add_tail(&item->ci_entry, &item->ci_group->cg_children);
 
+       /*
+        * We hold a reference on the child for ci_entry on the parent's
+        * cg_children
+        */
        config_item_get(item);
 }
 
@@ -684,6 +700,10 @@ static void client_drop_item(struct config_item *parent_item,
        type = parent_item->ci_type;
        BUG_ON(!type);
 
+       /*
+        * If ->drop_item() exists, it is responsible for the
+        * config_item_put().
+        */
        if (type->ct_group_ops && type->ct_group_ops->drop_item)
                type->ct_group_ops->drop_item(to_config_group(parent_item),
                                                item);
@@ -694,23 +714,28 @@ static void client_drop_item(struct config_item *parent_item,
 
 static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 {
-       int ret;
+       int ret, module_got = 0;
        struct config_group *group;
        struct config_item *item;
        struct config_item *parent_item;
        struct configfs_subsystem *subsys;
        struct configfs_dirent *sd;
        struct config_item_type *type;
-       struct module *owner;
+       struct module *owner = NULL;
        char *name;
 
-       if (dentry->d_parent == configfs_sb->s_root)
-               return -EPERM;
+       if (dentry->d_parent == configfs_sb->s_root) {
+               ret = -EPERM;
+               goto out;
+       }
 
        sd = dentry->d_parent->d_fsdata;
-       if (!(sd->s_type & CONFIGFS_USET_DIR))
-               return -EPERM;
+       if (!(sd->s_type & CONFIGFS_USET_DIR)) {
+               ret = -EPERM;
+               goto out;
+       }
 
+       /* Get a working ref for the duration of this function */
        parent_item = configfs_get_config_item(dentry->d_parent);
        type = parent_item->ci_type;
        subsys = to_config_group(parent_item)->cg_subsys;
@@ -719,15 +744,16 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        if (!type || !type->ct_group_ops ||
            (!type->ct_group_ops->make_group &&
             !type->ct_group_ops->make_item)) {
-               config_item_put(parent_item);
-               return -EPERM;  /* What lack-of-mkdir returns */
+               ret = -EPERM;  /* Lack-of-mkdir returns -EPERM */
+               goto out_put;
        }
 
        name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL);
        if (!name) {
-               config_item_put(parent_item);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out_put;
        }
+
        snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name);
 
        down(&subsys->su_sem);
@@ -748,40 +774,67 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        kfree(name);
        if (!item) {
-               config_item_put(parent_item);
-               return -ENOMEM;
+               /*
+                * If item == NULL, then link_obj() was never called.
+                * There are no extra references to clean up.
+                */
+               ret = -ENOMEM;
+               goto out_put;
        }
 
-       ret = -EINVAL;
+       /*
+        * link_obj() has been called (via link_group() for groups).
+        * From here on out, errors must clean that up.
+        */
+
        type = item->ci_type;
-       if (type) {
-               owner = type->ct_owner;
-               if (try_module_get(owner)) {
-                       if (group) {
-                               ret = configfs_attach_group(parent_item,
-                                                           item,
-                                                           dentry);
-                       } else {
-                               ret = configfs_attach_item(parent_item,
-                                                          item,
-                                                          dentry);
-                       }
+       if (!type) {
+               ret = -EINVAL;
+               goto out_unlink;
+       }
 
-                       if (ret) {
-                               down(&subsys->su_sem);
-                               if (group)
-                                       unlink_group(group);
-                               else
-                                       unlink_obj(item);
-                               client_drop_item(parent_item, item);
-                               up(&subsys->su_sem);
+       owner = type->ct_owner;
+       if (!try_module_get(owner)) {
+               ret = -EINVAL;
+               goto out_unlink;
+       }
 
-                               config_item_put(parent_item);
-                               module_put(owner);
-                       }
-               }
+       /*
+        * I hate doing it this way, but if there is
+        * an error,  module_put() probably should
+        * happen after any cleanup.
+        */
+       module_got = 1;
+
+       if (group)
+               ret = configfs_attach_group(parent_item, item, dentry);
+       else
+               ret = configfs_attach_item(parent_item, item, dentry);
+
+out_unlink:
+       if (ret) {
+               /* Tear down everything we built up */
+               down(&subsys->su_sem);
+               if (group)
+                       unlink_group(group);
+               else
+                       unlink_obj(item);
+               client_drop_item(parent_item, item);
+               up(&subsys->su_sem);
+
+               if (module_got)
+                       module_put(owner);
        }
 
+out_put:
+       /*
+        * link_obj()/link_group() took a reference from child->parent,
+        * so the parent is safely pinned.  We can drop our working
+        * reference.
+        */
+       config_item_put(parent_item);
+
+out:
        return ret;
 }
 
@@ -801,6 +854,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
        if (sd->s_type & CONFIGFS_USET_DEFAULT)
                return -EPERM;
 
+       /* Get a working ref until we have the child */
        parent_item = configfs_get_config_item(dentry->d_parent);
        subsys = to_config_group(parent_item)->cg_subsys;
        BUG_ON(!subsys);
@@ -817,6 +871,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
                return ret;
        }
 
+       /* Get a working ref for the duration of this function */
        item = configfs_get_config_item(dentry);
 
        /* Drop reference from above, item already holds one. */
index d4d0c41..1d46677 100644 (file)
@@ -438,7 +438,8 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
        if (c->mtd->point) {
                err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer);
                if (!err && retlen < tn->csize) {
-                       JFFS2_WARNING("MTD point returned len too short: %u instead of %u.\n", retlen, tn->csize);
+                       JFFS2_WARNING("MTD point returned len too short: %zu "
+                                       "instead of %u.\n", retlen, tn->csize);
                        c->mtd->unpoint(c->mtd, buffer, ofs, len);
                } else if (err)
                        JFFS2_WARNING("MTD point failed: error code %d.\n", err);
@@ -461,7 +462,8 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
                }
 
                if (retlen != len) {
-                       JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len);
+                       JFFS2_ERROR("short read at %#08x: %zd instead of %d.\n",
+                                       ofs, retlen, len);
                        err = -EIO;
                        goto free_out;
                }
index 2c5f1f8..bf478ad 100644 (file)
@@ -899,13 +899,11 @@ static int do_change_type(struct nameidata *nd, int flag)
 /*
  * do loopback mount.
  */
-static int do_loopback(struct nameidata *nd, char *old_name, unsigned long flags, int mnt_flags)
+static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
 {
        struct nameidata old_nd;
        struct vfsmount *mnt = NULL;
-       int recurse = flags & MS_REC;
        int err = mount_is_safe(nd);
-
        if (err)
                return err;
        if (!old_name || !*old_name)
@@ -939,7 +937,6 @@ static int do_loopback(struct nameidata *nd, char *old_name, unsigned long flags
                spin_unlock(&vfsmount_lock);
                release_mounts(&umount_list);
        }
-       mnt->mnt_flags = mnt_flags;
 
 out:
        up_write(&namespace_sem);
@@ -1353,7 +1350,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
                retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
                                    data_page);
        else if (flags & MS_BIND)
-               retval = do_loopback(&nd, dev_name, flags, mnt_flags);
+               retval = do_loopback(&nd, dev_name, flags & MS_REC);
        else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
                retval = do_change_type(&nd, flags);
        else if (flags & MS_MOVE)
index 0d858d0..47152bf 100644 (file)
@@ -276,13 +276,29 @@ static int ocfs2_writepage(struct page *page, struct writeback_control *wbc)
        return ret;
 }
 
+/* This can also be called from ocfs2_write_zero_page() which has done
+ * it's own cluster locking. */
+int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page,
+                              unsigned from, unsigned to)
+{
+       int ret;
+
+       down_read(&OCFS2_I(inode)->ip_alloc_sem);
+
+       ret = block_prepare_write(page, from, to, ocfs2_get_block);
+
+       up_read(&OCFS2_I(inode)->ip_alloc_sem);
+
+       return ret;
+}
+
 /*
  * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called
  * from loopback.  It must be able to perform its own locking around
  * ocfs2_get_block().
  */
-int ocfs2_prepare_write(struct file *file, struct page *page,
-                       unsigned from, unsigned to)
+static int ocfs2_prepare_write(struct file *file, struct page *page,
+                              unsigned from, unsigned to)
 {
        struct inode *inode = page->mapping->host;
        int ret;
@@ -295,11 +311,7 @@ int ocfs2_prepare_write(struct file *file, struct page *page,
                goto out;
        }
 
-       down_read(&OCFS2_I(inode)->ip_alloc_sem);
-
-       ret = block_prepare_write(page, from, to, ocfs2_get_block);
-
-       up_read(&OCFS2_I(inode)->ip_alloc_sem);
+       ret = ocfs2_prepare_write_nolock(inode, page, from, to);
 
        ocfs2_meta_unlock(inode, 0);
 out:
@@ -625,11 +637,31 @@ static ssize_t ocfs2_direct_IO(int rw,
        int ret;
 
        mlog_entry_void();
+
+       /*
+        * We get PR data locks even for O_DIRECT.  This allows
+        * concurrent O_DIRECT I/O but doesn't let O_DIRECT with
+        * extending and buffered zeroing writes race.  If they did
+        * race then the buffered zeroing could be written back after
+        * the O_DIRECT I/O.  It's one thing to tell people not to mix
+        * buffered and O_DIRECT writes, but expecting them to
+        * understand that file extension is also an implicit buffered
+        * write is too much.  By getting the PR we force writeback of
+        * the buffered zeroing before proceeding.
+        */
+       ret = ocfs2_data_lock(inode, 0);
+       if (ret < 0) {
+               mlog_errno(ret);
+               goto out;
+       }
+       ocfs2_data_unlock(inode, 0);
+
        ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
                                            inode->i_sb->s_bdev, iov, offset,
                                            nr_segs, 
                                            ocfs2_direct_IO_get_blocks,
                                            ocfs2_dio_end_io);
+out:
        mlog_exit(ret);
        return ret;
 }
index d40456d..e88c3f0 100644 (file)
@@ -22,8 +22,8 @@
 #ifndef OCFS2_AOPS_H
 #define OCFS2_AOPS_H
 
-int ocfs2_prepare_write(struct file *file, struct page *page,
-                       unsigned from, unsigned to);
+int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page,
+                              unsigned from, unsigned to);
 
 struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode,
                                                         struct page *page,
index 4601fc2..1a5c690 100644 (file)
@@ -569,7 +569,7 @@ static int ocfs2_extent_map_insert(struct inode *inode,
 
        ret = -ENOMEM;
        ctxt.new_ent = kmem_cache_alloc(ocfs2_em_ent_cachep,
-                                       GFP_KERNEL);
+                                       GFP_NOFS);
        if (!ctxt.new_ent) {
                mlog_errno(ret);
                return ret;
@@ -583,14 +583,14 @@ static int ocfs2_extent_map_insert(struct inode *inode,
                if (ctxt.need_left && !ctxt.left_ent) {
                        ctxt.left_ent =
                                kmem_cache_alloc(ocfs2_em_ent_cachep,
-                                                GFP_KERNEL);
+                                                GFP_NOFS);
                        if (!ctxt.left_ent)
                                break;
                }
                if (ctxt.need_right && !ctxt.right_ent) {
                        ctxt.right_ent =
                                kmem_cache_alloc(ocfs2_em_ent_cachep,
-                                                GFP_KERNEL);
+                                                GFP_NOFS);
                        if (!ctxt.right_ent)
                                break;
                }
index 581eb45..a9559c8 100644 (file)
@@ -613,7 +613,8 @@ leave:
 
 /* Some parts of this taken from generic_cont_expand, which turned out
  * to be too fragile to do exactly what we need without us having to
- * worry about recursive locking in ->commit_write(). */
+ * worry about recursive locking in ->prepare_write() and
+ * ->commit_write(). */
 static int ocfs2_write_zero_page(struct inode *inode,
                                 u64 size)
 {
@@ -641,7 +642,7 @@ static int ocfs2_write_zero_page(struct inode *inode,
                goto out;
        }
 
-       ret = ocfs2_prepare_write(NULL, page, offset, offset);
+       ret = ocfs2_prepare_write_nolock(inode, page, offset, offset);
        if (ret < 0) {
                mlog_errno(ret);
                goto out_unlock;
@@ -695,13 +696,26 @@ out:
        return ret;
 }
 
+/* 
+ * A tail_to_skip value > 0 indicates that we're being called from
+ * ocfs2_file_aio_write(). This has the following implications:
+ *
+ * - we don't want to update i_size
+ * - di_bh will be NULL, which is fine because it's only used in the
+ *   case where we want to update i_size.
+ * - ocfs2_zero_extend() will then only be filling the hole created
+ *   between i_size and the start of the write.
+ */
 static int ocfs2_extend_file(struct inode *inode,
                             struct buffer_head *di_bh,
-                            u64 new_i_size)
+                            u64 new_i_size,
+                            size_t tail_to_skip)
 {
        int ret = 0;
        u32 clusters_to_add;
 
+       BUG_ON(!tail_to_skip && !di_bh);
+
        /* setattr sometimes calls us like this. */
        if (new_i_size == 0)
                goto out;
@@ -714,27 +728,44 @@ static int ocfs2_extend_file(struct inode *inode,
                OCFS2_I(inode)->ip_clusters;
 
        if (clusters_to_add) {
-               ret = ocfs2_extend_allocation(inode, clusters_to_add);
+               /* 
+                * protect the pages that ocfs2_zero_extend is going to
+                * be pulling into the page cache.. we do this before the
+                * metadata extend so that we don't get into the situation
+                * where we've extended the metadata but can't get the data
+                * lock to zero.
+                */
+               ret = ocfs2_data_lock(inode, 1);
                if (ret < 0) {
                        mlog_errno(ret);
                        goto out;
                }
 
-               ret = ocfs2_zero_extend(inode, new_i_size);
+               ret = ocfs2_extend_allocation(inode, clusters_to_add);
                if (ret < 0) {
                        mlog_errno(ret);
-                       goto out;
+                       goto out_unlock;
                }
-       } 
 
-       /* No allocation required, we just use this helper to
-        * do a trivial update of i_size. */
-       ret = ocfs2_simple_size_update(inode, di_bh, new_i_size);
-       if (ret < 0) {
-               mlog_errno(ret);
-               goto out;
+               ret = ocfs2_zero_extend(inode, (u64)new_i_size - tail_to_skip);
+               if (ret < 0) {
+                       mlog_errno(ret);
+                       goto out_unlock;
+               }
+       }
+
+       if (!tail_to_skip) {
+               /* We're being called from ocfs2_setattr() which wants
+                * us to update i_size */
+               ret = ocfs2_simple_size_update(inode, di_bh, new_i_size);
+               if (ret < 0)
+                       mlog_errno(ret);
        }
 
+out_unlock:
+       if (clusters_to_add) /* this is the only case in which we lock */
+               ocfs2_data_unlock(inode, 1);
+
 out:
        return ret;
 }
@@ -793,7 +824,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
                if (i_size_read(inode) > attr->ia_size)
                        status = ocfs2_truncate_file(inode, bh, attr->ia_size);
                else
-                       status = ocfs2_extend_file(inode, bh, attr->ia_size);
+                       status = ocfs2_extend_file(inode, bh, attr->ia_size, 0);
                if (status < 0) {
                        if (status != -ENOSPC)
                                mlog_errno(status);
@@ -1049,21 +1080,12 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
                if (!clusters)
                        break;
 
-               ret = ocfs2_extend_allocation(inode, clusters);
+               ret = ocfs2_extend_file(inode, NULL, newsize, count);
                if (ret < 0) {
                        if (ret != -ENOSPC)
                                mlog_errno(ret);
                        goto out;
                }
-
-               /* Fill any holes which would've been created by this
-                * write. If we're O_APPEND, this will wind up
-                * (correctly) being a noop. */
-               ret = ocfs2_zero_extend(inode, (u64) newsize - count);
-               if (ret < 0) {
-                       mlog_errno(ret);
-                       goto out;
-               }
                break;
        }
 
@@ -1146,6 +1168,22 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
                ocfs2_iocb_set_rw_locked(iocb);
        }
 
+       /*
+        * We're fine letting folks race truncates and extending
+        * writes with read across the cluster, just like they can
+        * locally. Hence no rw_lock during read.
+        * 
+        * Take and drop the meta data lock to update inode fields
+        * like i_size. This allows the checks down below
+        * generic_file_aio_read() a chance of actually working. 
+        */
+       ret = ocfs2_meta_lock(inode, NULL, NULL, 0);
+       if (ret < 0) {
+               mlog_errno(ret);
+               goto bail;
+       }
+       ocfs2_meta_unlock(inode, 0);
+
        ret = generic_file_aio_read(iocb, buf, count, iocb->ki_pos);
        if (ret == -EINVAL)
                mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n");
index 6a610ae..eebc3cf 100644 (file)
@@ -117,7 +117,7 @@ struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb)
 {
        struct ocfs2_journal_handle *retval = NULL;
 
-       retval = kcalloc(1, sizeof(*retval), GFP_KERNEL);
+       retval = kcalloc(1, sizeof(*retval), GFP_NOFS);
        if (!retval) {
                mlog(ML_ERROR, "Failed to allocate memory for journal "
                     "handle!\n");
@@ -870,9 +870,11 @@ static int ocfs2_force_read_journal(struct inode *inode)
                if (p_blocks > CONCURRENT_JOURNAL_FILL)
                        p_blocks = CONCURRENT_JOURNAL_FILL;
 
+               /* We are reading journal data which should not
+                * be put in the uptodate cache */
                status = ocfs2_read_blocks(OCFS2_SB(inode->i_sb),
                                           p_blkno, p_blocks, bhs, 0,
-                                          inode);
+                                          NULL);
                if (status < 0) {
                        mlog_errno(status);
                        goto bail;
@@ -982,7 +984,7 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
 {
        struct ocfs2_la_recovery_item *item;
 
-       item = kmalloc(sizeof(struct ocfs2_la_recovery_item), GFP_KERNEL);
+       item = kmalloc(sizeof(struct ocfs2_la_recovery_item), GFP_NOFS);
        if (!item) {
                /* Though we wish to avoid it, we are in fact safe in
                 * skipping local alloc cleanup as fsck.ocfs2 is more
index 04a684d..b8a00a7 100644 (file)
@@ -337,7 +337,7 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi,
             (unsigned long long)oi->ip_blkno,
             (unsigned long long)block, expand_tree);
 
-       new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_KERNEL);
+       new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_NOFS);
        if (!new) {
                mlog_errno(-ENOMEM);
                return;
@@ -349,7 +349,7 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi,
                 * has no way of tracking that. */
                for(i = 0; i < OCFS2_INODE_MAX_CACHE_ARRAY; i++) {
                        tree[i] = kmem_cache_alloc(ocfs2_uptodate_cachep,
-                                                  GFP_KERNEL);
+                                                  GFP_NOFS);
                        if (!tree[i]) {
                                mlog_errno(-ENOMEM);
                                goto out_free;
index 53049a2..ee42765 100644 (file)
@@ -586,7 +586,7 @@ static struct ocfs2_net_wait_ctxt *ocfs2_new_net_wait_ctxt(unsigned int response
 {
        struct ocfs2_net_wait_ctxt *w;
 
-       w = kcalloc(1, sizeof(*w), GFP_KERNEL);
+       w = kcalloc(1, sizeof(*w), GFP_NOFS);
        if (!w) {
                mlog_errno(-ENOMEM);
                goto bail;
@@ -749,7 +749,7 @@ static struct ocfs2_vote_msg * ocfs2_new_vote_request(struct ocfs2_super *osb,
 
        BUG_ON(!ocfs2_is_valid_vote_request(type));
 
-       request = kcalloc(1, sizeof(*request), GFP_KERNEL);
+       request = kcalloc(1, sizeof(*request), GFP_NOFS);
        if (!request) {
                mlog_errno(-ENOMEM);
        } else {
@@ -1129,7 +1129,7 @@ static int ocfs2_handle_vote_message(struct o2net_msg *msg,
        struct ocfs2_super *osb = data;
        struct ocfs2_vote_work *work;
 
-       work = kmalloc(sizeof(struct ocfs2_vote_work), GFP_KERNEL);
+       work = kmalloc(sizeof(struct ocfs2_vote_work), GFP_NOFS);
        if (!work) {
                status = -ENOMEM;
                mlog_errno(status);
index 53ec28c..317b7c7 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -1124,7 +1124,6 @@ asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
        prevent_tail_call(ret);
        return ret;
 }
-EXPORT_SYMBOL_GPL(sys_openat);
 
 #ifndef __alpha__
 
index 34c7a11..70d9c5a 100644 (file)
@@ -434,6 +434,11 @@ smb_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        if (dentry->d_name.len > SMB_MAXNAMELEN)
                goto out;
 
+       /* Do not allow lookup of names with backslashes in */
+       error = -EINVAL;
+       if (memchr(dentry->d_name.name, '\\', dentry->d_name.len))
+               goto out;
+
        lock_kernel();
        error = smb_proc_getattr(dentry, &finfo);
 #ifdef SMBFS_PARANOIA
index c71c375..c71dd27 100644 (file)
@@ -339,9 +339,11 @@ int smb_add_request(struct smb_request *req)
                /*
                 * On timeout or on interrupt we want to try and remove the
                 * request from the recvq/xmitq.
+                * First check if the request is still part of a queue. (May
+                * have been removed by some error condition)
                 */
                smb_lock_server(server);
-               if (!(req->rq_flags & SMB_REQ_RECEIVED)) {
+               if (!list_empty(&req->rq_queue)) {
                        list_del_init(&req->rq_queue);
                        smb_rput(req);
                }
diff --git a/include/asm-arm/arch-pxa/pxa2xx_spi.h b/include/asm-arm/arch-pxa/pxa2xx_spi.h
new file mode 100644 (file)
index 0000000..1e70908
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef PXA2XX_SPI_H_
+#define PXA2XX_SPI_H_
+
+#define PXA2XX_CS_ASSERT (0x01)
+#define PXA2XX_CS_DEASSERT (0x02)
+
+#if defined(CONFIG_PXA25x)
+#define CLOCK_SPEED_HZ 3686400
+#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/2/(x+1))<<8)&0x0000ff00)
+#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
+#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
+#elif defined(CONFIG_PXA27x)
+#define CLOCK_SPEED_HZ 13000000
+#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
+#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
+#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
+#endif
+
+#define SSP1_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(1)))))
+#define SSP2_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(2)))))
+#define SSP3_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(3)))))
+
+enum pxa_ssp_type {
+       SSP_UNDEFINED = 0,
+       PXA25x_SSP,  /* pxa 210, 250, 255, 26x */
+       PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
+       PXA27x_SSP,
+};
+
+/* device.platform_data for SSP controller devices */
+struct pxa2xx_spi_master {
+       enum pxa_ssp_type ssp_type;
+       u32 clock_enable;
+       u16 num_chipselect;
+       u8 enable_dma;
+};
+
+/* spi_board_info.controller_data for SPI slave devices,
+ * copied to spi_device.platform_data ... mostly for dma tuning
+ */
+struct pxa2xx_spi_chip {
+       u8 tx_threshold;
+       u8 rx_threshold;
+       u8 dma_burst_size;
+       u32 timeout_microsecs;
+       u8 enable_loopback;
+       void (*cs_control)(u32 command);
+};
+
+#endif /*PXA2XX_SPI_H_*/
index a9c75b2..8425260 100644 (file)
@@ -45,8 +45,6 @@ extern unsigned int elf_hwcap;
 
 #endif /* __ASSEMBLY__ */
 
-#define PROC_INFO_SZ   48
-
 #define HWCAP_SWP      1
 #define HWCAP_HALF     2
 #define HWCAP_THUMB    4
index 657d582..41c2792 100644 (file)
 #define __NR_pselect6          301
 #define __NR_ppoll             302
 #define __NR_unshare           303
+#define __NR_set_robust_list   304
+#define __NR_get_robust_list   305
+#define __NR_splice            306
+#define __NR_sync_file_range   307
+#define __NR_tee               308
+#define __NR_vmsplice          309
 
-#define NR_syscalls 304
+#define NR_syscalls 310
 
 /* 
  * There are some system calls that are not present on 64 bit, some
index e1bd084..f4fc576 100644 (file)
@@ -124,6 +124,7 @@ extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);
 extern unsigned long long memparse(char *ptr, char **retptr);
 
+extern int core_kernel_text(unsigned long addr);
 extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 extern int session_of_pgrp(int pgrp);
index 5673008..970284f 100644 (file)
@@ -132,6 +132,7 @@ static inline void rcu_bh_qsctr_inc(int cpu)
 }
 
 extern int rcu_pending(int cpu);
+extern int rcu_needs_cpu(int cpu);
 
 /**
  * rcu_read_lock - mark the beginning of an RCU read-side critical section.
index 3af03b1..2d985d5 100644 (file)
@@ -150,6 +150,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
 
 extern void kfree(const void *);
 extern unsigned int ksize(const void *);
+extern int slab_is_available(void);
 
 #ifdef CONFIG_NUMA
 extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
index b05f146..e928c0d 100644 (file)
@@ -31,18 +31,23 @@ extern struct bus_type spi_bus_type;
  * @master: SPI controller used with the device.
  * @max_speed_hz: Maximum clock rate to be used with this chip
  *     (on this board); may be changed by the device's driver.
+ *     The spi_transfer.speed_hz can override this for each transfer.
  * @chip-select: Chipselect, distinguishing chips handled by "master".
  * @mode: The spi mode defines how data is clocked out and in.
  *     This may be changed by the device's driver.
+ *     The "active low" default for chipselect mode can be overridden,
+ *     as can the "MSB first" default for each word in a transfer.
  * @bits_per_word: Data transfers involve one or more words; word sizes
- *     like eight or 12 bits are common.  In-memory wordsizes are
+ *     like eight or 12 bits are common.  In-memory wordsizes are
  *     powers of two bytes (e.g. 20 bit samples use 32 bits).
- *     This may be changed by the device's driver.
+ *     This may be changed by the device's driver, or left at the
+ *     default (0) indicating protocol words are eight bit bytes.
+ *     The spi_transfer.bits_per_word can override this for each transfer.
  * @irq: Negative, or the number passed to request_irq() to receive
- *     interrupts from this device.
+ *     interrupts from this device.
  * @controller_state: Controller's runtime state
  * @controller_data: Board-specific definitions for controller, such as
- *     FIFO initialization parameters; from board_info.controller_data
+ *     FIFO initialization parameters; from board_info.controller_data
  *
  * An spi_device is used to interchange data between an SPI slave
  * (usually a discrete chip) and CPU memory.
@@ -65,6 +70,7 @@ struct spi_device {
 #define        SPI_MODE_2      (SPI_CPOL|0)
 #define        SPI_MODE_3      (SPI_CPOL|SPI_CPHA)
 #define        SPI_CS_HIGH     0x04                    /* chipselect active high? */
+#define        SPI_LSB_FIRST   0x08                    /* per-word bits-on-wire */
        u8                      bits_per_word;
        int                     irq;
        void                    *controller_state;
@@ -73,7 +79,6 @@ struct spi_device {
 
        // likely need more hooks for more protocol options affecting how
        // the controller talks to each chip, like:
-       //  - bit order (default is wordwise msb-first)
        //  - memory packing (12 bit samples into low bits, others zeroed)
        //  - priority
        //  - drop chipselect after each word
@@ -143,13 +148,13 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
  * struct spi_master - interface to SPI master controller
  * @cdev: class interface to this driver
  * @bus_num: board-specific (and often SOC-specific) identifier for a
- *     given SPI controller.
+ *     given SPI controller.
  * @num_chipselect: chipselects are used to distinguish individual
- *     SPI slaves, and are numbered from zero to num_chipselects.
- *     each slave has a chipselect signal, but it's common that not
- *     every chipselect is connected to a slave.
+ *     SPI slaves, and are numbered from zero to num_chipselects.
+ *     each slave has a chipselect signal, but it's common that not
+ *     every chipselect is connected to a slave.
  * @setup: updates the device mode and clocking records used by a
- *     device's SPI controller; protocol code may call this.
+ *     device's SPI controller; protocol code may call this.
  * @transfer: adds a message to the controller's transfer queue.
  * @cleanup: frees controller-specific state
  *
@@ -167,13 +172,13 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
 struct spi_master {
        struct class_device     cdev;
 
-       /* other than zero (== assign one dynamically), bus_num is fully
+       /* other than negative (== assign one dynamically), bus_num is fully
         * board-specific.  usually that simplifies to being SOC-specific.
-        * example:  one SOC has three SPI controllers, numbered 1..3,
+        * example:  one SOC has three SPI controllers, numbered 0..2,
         * and one board's schematics might show it using SPI-2.  software
         * would normally use bus_num=2 for that controller.
         */
-       u16                     bus_num;
+       s16                     bus_num;
 
        /* chipselects will be integral to many controllers; some others
         * might use board-specific GPIOs.
@@ -268,10 +273,14 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum);
  * @tx_dma: DMA address of tx_buf, if spi_message.is_dma_mapped
  * @rx_dma: DMA address of rx_buf, if spi_message.is_dma_mapped
  * @len: size of rx and tx buffers (in bytes)
+ * @speed_hz: Select a speed other then the device default for this
+ *      transfer. If 0 the default (from spi_device) is used.
+ * @bits_per_word: select a bits_per_word other then the device default
+ *      for this transfer. If 0 the default (from spi_device) is used.
  * @cs_change: affects chipselect after this transfer completes
  * @delay_usecs: microseconds to delay after this transfer before
- *     (optionally) changing the chipselect status, then starting
- *     the next transfer or completing this spi_message.
+ *     (optionally) changing the chipselect status, then starting
+ *     the next transfer or completing this spi_message.
  * @transfer_list: transfers are sequenced through spi_message.transfers
  *
  * SPI transfers always write the same number of bytes as they read.
@@ -322,7 +331,9 @@ struct spi_transfer {
        dma_addr_t      rx_dma;
 
        unsigned        cs_change:1;
+       u8              bits_per_word;
        u16             delay_usecs;
+       u32             speed_hz;
 
        struct list_head transfer_list;
 };
@@ -356,7 +367,7 @@ struct spi_transfer {
  * and its transfers, ignore them until its completion callback.
  */
 struct spi_message {
-       struct list_head        transfers;
+       struct list_head        transfers;
 
        struct spi_device       *spi;
 
@@ -374,7 +385,7 @@ struct spi_message {
         */
 
        /* completion is reported through a callback */
-       void                    (*complete)(void *context);
+       void                    (*complete)(void *context);
        void                    *context;
        unsigned                actual_length;
        int                     status;
index c961fe9..16ce178 100644 (file)
@@ -30,6 +30,12 @@ struct spi_bitbang {
 
        struct spi_master       *master;
 
+       /* setup_transfer() changes clock and/or wordsize to match settings
+        * for this transfer; zeroes restore defaults from spi_device.
+        */
+       int     (*setup_transfer)(struct spi_device *spi,
+                       struct spi_transfer *t);
+
        void    (*chipselect)(struct spi_device *spi, int is_on);
 #define        BITBANG_CS_ACTIVE       1       /* normally nCS, active low */
 #define        BITBANG_CS_INACTIVE     0
@@ -51,6 +57,8 @@ struct spi_bitbang {
 extern int spi_bitbang_setup(struct spi_device *spi);
 extern void spi_bitbang_cleanup(const struct spi_device *spi);
 extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
+extern int spi_bitbang_setup_transfer(struct spi_device *spi,
+                                     struct spi_transfer *t);
 
 /* start or stop queue processing */
 extern int spi_bitbang_start(struct spi_bitbang *spi);
index 5b1fdf1..f03c247 100644 (file)
@@ -296,7 +296,7 @@ static inline void disable_swap_token(void)
 #define read_swap_cache_async(swp,vma,addr)    NULL
 #define lookup_swap_cache(swp)                 NULL
 #define valid_swaphandles(swp, off)            0
-#define can_share_swap_page(p)                 0
+#define can_share_swap_page(p)                 (page_mapcount(p) == 1)
 #define move_to_swap_cache(p, swp)             1
 #define move_from_swap_cache(p, i, m)          1
 #define __delete_from_swap_cache(p)            /*NOTHING*/
index adb7cad..f4b7b9d 100644 (file)
@@ -310,6 +310,11 @@ retry:
 
                panic("VFS: Unable to mount root fs on %s", b);
        }
+
+       printk("No filesystem could mount root, tried: ");
+       for (p = fs_names; *p; p += strlen(p)+1)
+               printk(" %s", p);
+       printk("\n");
        panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:
        putname(fs_names);
index 679d870..f81cfa4 100644 (file)
@@ -26,10 +26,12 @@ static void __init free(void *where)
 
 /* link hash */
 
+#define N_ALIGN(len) ((((len) + 1) & ~3) + 2)
+
 static __initdata struct hash {
        int ino, minor, major;
        struct hash *next;
-       char *name;
+       char name[N_ALIGN(PATH_MAX)];
 } *head[32];
 
 static inline int hash(int major, int minor, int ino)
@@ -57,7 +59,7 @@ static char __init *find_link(int major, int minor, int ino, char *name)
        q->ino = ino;
        q->minor = minor;
        q->major = major;
-       q->name = name;
+       strcpy(q->name, name);
        q->next = NULL;
        *p = q;
        return NULL;
@@ -133,8 +135,6 @@ static inline void eat(unsigned n)
        count -= n;
 }
 
-#define N_ALIGN(len) ((((len) + 1) & ~3) + 2)
-
 static __initdata char *collected;
 static __initdata int remains;
 static __initdata char *collect;
index 7501b53..7fe2628 100644 (file)
@@ -40,7 +40,7 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
        return e;
 }
 
-static int core_kernel_text(unsigned long addr)
+int core_kernel_text(unsigned long addr)
 {
        if (addr >= (unsigned long)_stext &&
            addr <= (unsigned long)_etext)
index d24deb0..bbe0486 100644 (file)
@@ -705,14 +705,14 @@ EXPORT_SYMBOL(__symbol_put);
 
 void symbol_put_addr(void *addr)
 {
-       unsigned long flags;
+       struct module *modaddr;
 
-       spin_lock_irqsave(&modlist_lock, flags);
-       if (!kernel_text_address((unsigned long)addr))
-               BUG();
+       if (core_kernel_text((unsigned long)addr))
+               return;
 
-       module_put(module_text_address((unsigned long)addr));
-       spin_unlock_irqrestore(&modlist_lock, flags);
+       if (!(modaddr = module_text_address((unsigned long)addr)))
+               BUG();
+       module_put(modaddr);
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 
index 6d32ff2..2058f88 100644 (file)
@@ -479,12 +479,31 @@ static int __rcu_pending(struct rcu_ctrlblk *rcp, struct rcu_data *rdp)
        return 0;
 }
 
+/*
+ * Check to see if there is any immediate RCU-related work to be done
+ * by the current CPU, returning 1 if so.  This function is part of the
+ * RCU implementation; it is -not- an exported member of the RCU API.
+ */
 int rcu_pending(int cpu)
 {
        return __rcu_pending(&rcu_ctrlblk, &per_cpu(rcu_data, cpu)) ||
                __rcu_pending(&rcu_bh_ctrlblk, &per_cpu(rcu_bh_data, cpu));
 }
 
+/*
+ * Check to see if any future RCU-related work will need to be done
+ * by the current CPU, even if none need be done immediately, returning
+ * 1 if so.  This function is part of the RCU implementation; it is -not-
+ * an exported member of the RCU API.
+ */
+int rcu_needs_cpu(int cpu)
+{
+       struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
+       struct rcu_data *rdp_bh = &per_cpu(rcu_bh_data, cpu);
+
+       return (!!rdp->curlist || !!rdp_bh->curlist || rcu_pending(cpu));
+}
+
 void rcu_check_callbacks(int cpu, int user)
 {
        if (user || 
index ea77c99..813b4ec 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mempolicy.h>
 
 #include <asm/tlbflush.h>
+#include <asm/div64.h>
 #include "internal.h"
 
 /*
@@ -2566,9 +2567,11 @@ void setup_per_zone_pages_min(void)
        }
 
        for_each_zone(zone) {
-               unsigned long tmp;
+               u64 tmp;
+
                spin_lock_irqsave(&zone->lru_lock, flags);
-               tmp = (pages_min * zone->present_pages) / lowmem_pages;
+               tmp = (u64)pages_min * zone->present_pages;
+               do_div(tmp, lowmem_pages);
                if (is_highmem(zone)) {
                        /*
                         * __GFP_HIGH and PF_MEMALLOC allocations usually don't
@@ -2595,8 +2598,8 @@ void setup_per_zone_pages_min(void)
                        zone->pages_min = tmp;
                }
 
-               zone->pages_low   = zone->pages_min + tmp / 4;
-               zone->pages_high  = zone->pages_min + tmp / 2;
+               zone->pages_low   = zone->pages_min + (tmp >> 2);
+               zone->pages_high  = zone->pages_min + (tmp >> 1);
                spin_unlock_irqrestore(&zone->lru_lock, flags);
        }
 
index c32af7e..d31a06b 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -700,6 +700,14 @@ static enum {
        FULL
 } g_cpucache_up;
 
+/*
+ * used by boot code to determine if it can use slab based allocator
+ */
+int slab_is_available(void)
+{
+       return g_cpucache_up == FULL;
+}
+
 static DEFINE_PER_CPU(struct work_struct, reap_work);
 
 static void free_block(struct kmem_cache *cachep, void **objpp, int len,
@@ -2192,11 +2200,14 @@ static void drain_cpu_caches(struct kmem_cache *cachep)
        check_irq_on();
        for_each_online_node(node) {
                l3 = cachep->nodelists[node];
-               if (l3) {
+               if (l3 && l3->alien)
+                       drain_alien_cache(cachep, l3->alien);
+       }
+
+       for_each_online_node(node) {
+               l3 = cachep->nodelists[node];
+               if (l3)
                        drain_array(cachep, l3, l3->shared, 1, node);
-                       if (l3->alien)
-                               drain_alien_cache(cachep, l3->alien);
-               }
        }
 }
 
index d7c32de..c5e89eb 100644 (file)
@@ -32,7 +32,7 @@ static struct mem_section *sparse_index_alloc(int nid)
        unsigned long array_size = SECTIONS_PER_ROOT *
                                   sizeof(struct mem_section);
 
-       if (system_state == SYSTEM_RUNNING)
+       if (slab_is_available())
                section = kmalloc_node(array_size, GFP_KERNEL, nid);
        else
                section = alloc_bootmem_node(NODE_DATA(nid), array_size);
index 7177e98..c284dbb 100644 (file)
@@ -594,6 +594,10 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len)
 
                        *scontext_len = strlen(initial_sid_to_string[sid]) + 1;
                        scontextp = kmalloc(*scontext_len,GFP_ATOMIC);
+                       if (!scontextp) {
+                               rc = -ENOMEM;
+                               goto out;
+                       }
                        strcpy(scontextp, initial_sid_to_string[sid]);
                        *scontext = scontextp;
                        goto out;