include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[sfrench/cifs-2.6.git] / drivers / char / nozomi.c
index cd405bcf53a652a28e081d948d8bb545da8057ba..a6638003f530ff55688231f2acf09b3e12262b05 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/init.h>
 #include <linux/kfifo.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include <linux/delay.h>
@@ -136,10 +137,6 @@ static int debug;
 #define RECEIVE_BUF_MAX                4
 
 
-/* Define all types of vendors and devices to support */
-#define VENDOR1                0x1931  /* Vendor Option */
-#define DEVICE1                0x000c  /* HSDPA card */
-
 #define R_IIR          0x0000  /* Interrupt Identity Register */
 #define R_FCR          0x0000  /* Flow Control Register */
 #define R_IER          0x0004  /* Interrupt Enable Register */
@@ -407,7 +404,7 @@ struct buffer {
 
 /*    Global variables */
 static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = {
-       {PCI_DEVICE(VENDOR1, DEVICE1)},
+       {PCI_DEVICE(0x1931, 0x000c)},   /* Nozomi HSDPA */
        {},
 };
 
@@ -857,8 +854,6 @@ static int receive_data(enum port_type index, struct nozomi *dc)
                goto put;
        }
 
-       tty_buffer_request_room(tty, size);
-
        while (size > 0) {
                read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX);
 
@@ -1693,15 +1688,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
        if (!dc || !port)
                return -ENODEV;
 
-       if (unlikely(!mutex_trylock(&port->tty_sem))) {
-               /*
-                * must test lock as tty layer wraps calls
-                * to this function with BKL
-                */
-               dev_err(&dc->pdev->dev, "Would have deadlocked - "
-                       "return EAGAIN\n");
-               return -EAGAIN;
-       }
+       mutex_lock(&port->tty_sem);
 
        if (unlikely(!port->port.count)) {
                DBG1(" ");
@@ -1741,25 +1728,23 @@ exit:
  * This method is called by the upper tty layer.
  *   #according to sources N_TTY.c it expects a value >= 0 and
  *    does not check for negative values.
+ *
+ * If the port is unplugged report lots of room and let the bits
+ * dribble away so we don't block anything.
  */
 static int ntty_write_room(struct tty_struct *tty)
 {
        struct port *port = tty->driver_data;
-       int room = 0;
+       int room = 4096;
        const struct nozomi *dc = get_dc_by_tty(tty);
 
-       if (!dc || !port)
-               return 0;
-       if (!mutex_trylock(&port->tty_sem))
-               return 0;
-
-       if (!port->port.count)
-               goto exit;
-
-       room = port->fifo_ul.size - kfifo_len(&port->fifo_ul);
-
-exit:
-       mutex_unlock(&port->tty_sem);
+       if (dc) {
+               mutex_lock(&port->tty_sem);
+               if (port->port.count)
+                       room = port->fifo_ul.size -
+                                       kfifo_len(&port->fifo_ul);
+               mutex_unlock(&port->tty_sem);
+       }
        return room;
 }