usb: gadget: remove build warnings
[profile/mobile/platform/kernel/u-boot-tm1.git] / drivers / usb / gadget / u_serial.c
index 82b71db..9e1d73b 100644 (file)
 #define pr_warning(fmt, args...) printf(fmt, ##args)
 #endif
 
+#ifndef __maybe_unused
+#define __maybe_unused         __attribute__((unused))
+#endif
+
 /*
  * This component encapsulates the TTY layer glue needed to provide basic
  * "serial port" functionality through the USB gadget stack.  Each such
@@ -366,7 +370,6 @@ __acquires(&port->port_lock)
        struct list_head        *pool = &port->write_pool;
        struct usb_ep           *in = NULL;
        int                     status = 0;
-       bool                    do_tty_wake = false;
 
        if (!port->port_usb){
                return status;
@@ -386,7 +389,6 @@ __acquires(&port->port_lock)
                        wake_up_interruptible(&port->drain_wait);
                        break;
                }
-               do_tty_wake = true;
 
                req->length = len;
                list_del(&req->list);
@@ -422,8 +424,6 @@ __acquires(&port->port_lock)
                }
        }
 
-       //if (do_tty_wake && port->port_tty)
-       //      tty_wakeup(port->port_tty);
        return status;
 }
 
@@ -734,7 +734,7 @@ exit:
 //buf: the buf address where data put
 //*count: read length wanted, when return store actually read count
 //return: weather read really done
-int gs_read(const unsigned char *buf, int *count)
+int gs_read(unsigned char *buf, int *count)
 {
        struct gs_port *port = ports[vcom_port].port;
        struct list_head *queue = &port->read_queue;
@@ -785,7 +785,7 @@ int gs_read(const unsigned char *buf, int *count)
                        }
                        port->n_read = 0;
                }
-recycle:
+
                list_move(&req->list, &port->read_pool);
                port->read_started--;
        }
@@ -805,7 +805,7 @@ int gs_write(const unsigned char *buf, int count)
 {
        struct gs_port  *port = ports[vcom_port].port;
        if (count)
-               count = gs_buf_put(&port->port_write_buf, buf, count);
+               count = gs_buf_put(&port->port_write_buf, (const char *)buf, count);
        /* treat count == 0 as flush_chars() */
        if (port->port_usb)
                usb_trans_status = gs_start_tx(port);
@@ -1188,7 +1188,7 @@ exit:
 static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
        struct gs_port  *port = tty->driver_data;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
        int             status;
 
        pr_vdebug("gs_write: ttyGS%d (%p) writing %d bytes\n",
@@ -1196,7 +1196,7 @@ static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count)
 
        spin_lock_irqsave(&port->port_lock, flags);
        if (count)
-               count = gs_buf_put(&port->port_write_buf, buf, count);
+               count = gs_buf_put(&port->port_write_buf, (const char *)buf, count);
        /* treat count == 0 as flush_chars() */
        if (port->port_usb)
                status = gs_start_tx(port);
@@ -1208,7 +1208,7 @@ static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count)
 static int gs_put_char(struct tty_struct *tty, unsigned char ch)
 {
        struct gs_port  *port = tty->driver_data;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
        int             status;
 
        pr_vdebug("gs_put_char: (%d,%p) char=0x%x, called from %p\n",
@@ -1224,7 +1224,7 @@ static int gs_put_char(struct tty_struct *tty, unsigned char ch)
 static void gs_flush_chars(struct tty_struct *tty)
 {
        struct gs_port  *port = tty->driver_data;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
 
        pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty);
 
@@ -1237,7 +1237,7 @@ static void gs_flush_chars(struct tty_struct *tty)
 static int gs_write_room(struct tty_struct *tty)
 {
        struct gs_port  *port = tty->driver_data;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
        int             room = 0;
 
        spin_lock_irqsave(&port->port_lock, flags);
@@ -1254,7 +1254,7 @@ static int gs_write_room(struct tty_struct *tty)
 static int gs_chars_in_buffer(struct tty_struct *tty)
 {
        struct gs_port  *port = tty->driver_data;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
        int             chars = 0;
 
        spin_lock_irqsave(&port->port_lock, flags);
@@ -1271,7 +1271,7 @@ static int gs_chars_in_buffer(struct tty_struct *tty)
 static void gs_unthrottle(struct tty_struct *tty)
 {
        struct gs_port          *port = tty->driver_data;
-       unsigned long           flags;
+       __maybe_unused unsigned long    flags;
 
        spin_lock_irqsave(&port->port_lock, flags);
        if (port->port_usb) {
@@ -1453,6 +1453,7 @@ fail:
        return status;
 }
 
+#if 0
 static int gs_closed(struct gs_port *port)
 {
        int cond;
@@ -1462,6 +1463,7 @@ static int gs_closed(struct gs_port *port)
        spin_unlock_irq(&port->port_lock);
        return cond;
 }
+#endif
 
 /**
  * gserial_cleanup - remove TTY-over-USB driver and devices
@@ -1497,8 +1499,10 @@ void gserial_cleanup(void)
 
 //             tasklet_kill(&port->push);
 
+#if 0
                /* wait for old opens to finish */
-//             wait_event(port->close_wait, gs_closed(port));
+               wait_event(port->close_wait, gs_closed(port));
+#endif
 
                //WARN_ON(port->port_usb != NULL);
 
@@ -1537,7 +1541,7 @@ void gserial_cleanup(void)
 int gserial_connect(struct gserial *gser, u8 port_num)
 {
        struct gs_port  *port;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
        int             status;
 #if 0
        if (!gs_tty_driver || port_num >= n_ports)
@@ -1611,7 +1615,7 @@ fail_out:
 void gserial_disconnect(struct gserial *gser)
 {
        struct gs_port  *port = gser->ioport;
-       unsigned long   flags;
+       __maybe_unused unsigned long    flags;
 
        if (!port)
                return;