Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
u_serial.c File Reference
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/slab.h>
#include <linux/export.h>
#include "u_serial.h"

Go to the source code of this file.

Data Structures

struct  gs_buf
struct  gs_port
struct  portmaster


#define PREFIX   "ttyGS"
#define QUEUE_SIZE   16
#define WRITE_BUF_SIZE   8192 /* TX only */
#define N_PORTS   4
#define GS_CLOSE_TIMEOUT   15 /* seconds */
#define pr_vdebug(fmt, arg...)   ({ if (0) pr_debug(fmt, ##arg); })


struct usb_requestgs_alloc_req (struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
void gs_free_req (struct usb_ep *ep, struct usb_request *req)
int gserial_setup (struct usb_gadget *g, unsigned count)
void gserial_cleanup (void)
int gserial_connect (struct gserial *gser, u8 port_num)
void gserial_disconnect (struct gserial *gser)

Macro Definition Documentation

#define GS_CLOSE_TIMEOUT   15 /* seconds */

Definition at line 130 of file u_serial.c.

#define N_PORTS   4

Definition at line 123 of file u_serial.c.

#define pr_vdebug (   fmt,
)    ({ if (0) pr_debug(fmt, ##arg); })

Definition at line 141 of file u_serial.c.

#define PREFIX   "ttyGS"

Definition at line 58 of file u_serial.c.

#define QUEUE_SIZE   16

Definition at line 81 of file u_serial.c.

#define WRITE_BUF_SIZE   8192 /* TX only */

Definition at line 82 of file u_serial.c.

Function Documentation

struct usb_request* gs_alloc_req ( struct usb_ep ep,
unsigned  len,
gfp_t  kmalloc_flags 

Definition at line 295 of file u_serial.c.

void gs_free_req ( struct usb_ep ep,
struct usb_request req 

Definition at line 318 of file u_serial.c.

void gserial_cleanup ( void  )

gserial_cleanup - remove TTY-over-USB driver and devices Context: may sleep

This is called to free all resources allocated by (). Accordingly, it may need to wait until some open /dev/ files have closed.

The caller must have issued () for any ports that had previously been connected, so that there is never any I/O pending when it's called.

Definition at line 1177 of file u_serial.c.

int gserial_connect ( struct gserial gser,
u8  port_num 

gserial_connect - notify TTY I/O glue that USB link is active : the function, set up with endpoints and descriptors : which port is active Context: any (usually from irq)

This is called activate endpoints and let the TTY layer know that the connection is active ... not unlike "carrier detect". It won't necessarily start I/O queues; unless the TTY is held open by any task, there would be no point. However, the endpoints will be activated so the USB host can perform I/O, subject to basic USB hardware flow control.

Caller needs to have set up the endpoints and USB function in before calling this, as well as the appropriate (speed-specific) endpoint descriptors, and also have set up the TTY driver by calling ().

Returns negative errno or zero. On success, ep->driver_data will be overwritten.

Definition at line 1235 of file u_serial.c.

void gserial_disconnect ( struct gserial gser)

gserial_disconnect - notify TTY I/O glue that USB link is inactive : the function, on which gserial_connect() was called Context: any (usually from irq)

This is called to deactivate endpoints and let the TTY layer know that the connection went inactive ... not unlike "hangup".

On return, the state is as if gserial_connect() had never been called; there is no active USB I/O on these endpoints.

Definition at line 1304 of file u_serial.c.

int gserial_setup ( struct usb_gadget g,
unsigned  count 

gserial_setup - initialize TTY driver for one or more ports : gadget to associate with these ports : how many ports to support Context: may sleep

The TTY stack needs to know in advance how many devices it should plan to manage. Use this call to set up the ports you will be exporting through USB. Later, connect them to functions based on what configuration is activated by the USB host; and disconnect them as appropriate.

An example would be a two-configuration device in which both configurations expose port 0, but through different functions. One configuration could even expose port 1 while the other one doesn't.

Returns negative errno or zero.

Definition at line 1075 of file u_serial.c.