···70 *71 * Bulk endpoints can use any size buffers, and can also be used for interrupt72 * transfers. interrupt-only endpoints can be much less functional.00073 */74- // NOTE this is analagous to 'struct urb' on the host side,75- // except that it's thinner and promotes more pre-allocation.7677struct usb_request {78 void *buf;···169 *170 * returns zero, or a negative error code.171 */172-static inline int173-usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)174{175- return ep->ops->enable (ep, desc);176}177178/**···187 *188 * returns zero, or a negative error code.189 */190-static inline int191-usb_ep_disable (struct usb_ep *ep)192{193- return ep->ops->disable (ep);194}195196/**···206 *207 * Returns the request, or null if one could not be allocated.208 */209-static inline struct usb_request *210-usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)211{212- return ep->ops->alloc_request (ep, gfp_flags);213}214215/**···221 * Caller guarantees the request is not queued, and that it will222 * no longer be requeued (or otherwise used).223 */224-static inline void225-usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)226{227- ep->ops->free_request (ep, req);228}229230/**···281 * report errors; errors will also be282 * reported when the usb peripheral is disconnected.283 */284-static inline int285-usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)286{287- return ep->ops->queue (ep, req, gfp_flags);288}289290/**···301 * restrictions prevent drivers from supporting configuration changes,302 * even to configuration zero (a "chapter 9" requirement).303 */304-static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)305{306- return ep->ops->dequeue (ep, req);307}308309/**···327 * transfer requests are still queued, or if the controller hardware328 * (usually a FIFO) still holds bytes that the host hasn't collected.329 */330-static inline int331-usb_ep_set_halt (struct usb_ep *ep)332{333- return ep->ops->set_halt (ep, 1);334}335336/**···345 * Note that some hardware can't support this request (like pxa2xx_udc),346 * and accordingly can't correctly implement interface altsettings.347 */348-static inline int349-usb_ep_clear_halt (struct usb_ep *ep)350{351- return ep->ops->set_halt (ep, 0);352}353354/**···365 * errno if the endpoint doesn't use a FIFO or doesn't support such366 * precise handling.367 */368-static inline int369-usb_ep_fifo_status (struct usb_ep *ep)370{371 if (ep->ops->fifo_status)372- return ep->ops->fifo_status (ep);373 else374 return -EOPNOTSUPP;375}···382 * must never be used except when endpoint is not being used for any383 * protocol translation.384 */385-static inline void386-usb_ep_fifo_flush (struct usb_ep *ep)387{388 if (ep->ops->fifo_flush)389- ep->ops->fifo_flush (ep);390}391392···465 struct device dev;466};467468-static inline void set_gadget_data (struct usb_gadget *gadget, void *data)469- { dev_set_drvdata (&gadget->dev, data); }470-static inline void *get_gadget_data (struct usb_gadget *gadget)471- { return dev_get_drvdata (&gadget->dev); }472473/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */474#define gadget_for_each_ep(tmp,gadget) \···507#endif508}509510-511/**512 * usb_gadget_frame_number - returns the current frame number513 * @gadget: controller that reports the frame number···514 * Returns the usb frame number, normally eleven bits from a SOF packet,515 * or negative errno if this device doesn't support this capability.516 */517-static inline int usb_gadget_frame_number (struct usb_gadget *gadget)518{519- return gadget->ops->get_frame (gadget);520}521522/**···532 * even if OTG isn't otherwise in use. OTG devices may also start533 * remote wakeup even when hosts don't explicitly enable it.534 */535-static inline int usb_gadget_wakeup (struct usb_gadget *gadget)536{537 if (!gadget->ops->wakeup)538 return -EOPNOTSUPP;539- return gadget->ops->wakeup (gadget);540}541542/**···548 *549 * returns zero on success, else negative errno.550 */551-static inline int552-usb_gadget_set_selfpowered (struct usb_gadget *gadget)553{554 if (!gadget->ops->set_selfpowered)555 return -EOPNOTSUPP;556- return gadget->ops->set_selfpowered (gadget, 1);557}558559/**···565 *566 * returns zero on success, else negative errno.567 */568-static inline int569-usb_gadget_clear_selfpowered (struct usb_gadget *gadget)570{571 if (!gadget->ops->set_selfpowered)572 return -EOPNOTSUPP;573- return gadget->ops->set_selfpowered (gadget, 0);574}575576/**···584 *585 * Returns zero on success, else negative errno.586 */587-static inline int588-usb_gadget_vbus_connect(struct usb_gadget *gadget)589{590 if (!gadget->ops->vbus_session)591 return -EOPNOTSUPP;592- return gadget->ops->vbus_session (gadget, 1);593}594595/**···603 *604 * Returns zero on success, else negative errno.605 */606-static inline int607-usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)608{609 if (!gadget->ops->vbus_draw)610 return -EOPNOTSUPP;611- return gadget->ops->vbus_draw (gadget, mA);612}613614/**···620 *621 * Returns zero on success, else negative errno.622 */623-static inline int624-usb_gadget_vbus_disconnect(struct usb_gadget *gadget)625{626 if (!gadget->ops->vbus_session)627 return -EOPNOTSUPP;628- return gadget->ops->vbus_session (gadget, 0);629}630631/**···638 *639 * Returns zero on success, else negative errno.640 */641-static inline int642-usb_gadget_connect (struct usb_gadget *gadget)643{644 if (!gadget->ops->pullup)645 return -EOPNOTSUPP;646- return gadget->ops->pullup (gadget, 1);647}648649/**···660 *661 * Returns zero on success, else negative errno.662 */663-static inline int664-usb_gadget_disconnect (struct usb_gadget *gadget)665{666 if (!gadget->ops->pullup)667 return -EOPNOTSUPP;668- return gadget->ops->pullup (gadget, 0);669}670-671672673/*-------------------------------------------------------------------------*/···751 void (*suspend)(struct usb_gadget *);752 void (*resume)(struct usb_gadget *);753754- // FIXME support safe rmmod755 struct device_driver driver;756};757···777 * the bind() functions will be in init sections.778 * This function must be called in a context that can sleep.779 */780-int usb_gadget_register_driver (struct usb_gadget_driver *driver);781782/**783 * usb_gadget_unregister_driver - unregister a gadget driver···792 * will in in exit sections, so may not be linked in some kernels.793 * This function must be called in a context that can sleep.794 */795-int usb_gadget_unregister_driver (struct usb_gadget_driver *driver);796797/*-------------------------------------------------------------------------*/798···825};826827/* put descriptor for string with that id into buf (buflen >= 256) */828-int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf);829830/*-------------------------------------------------------------------------*/831···843844/* utility wrapping a simple endpoint selection policy */845846-extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *,847 struct usb_endpoint_descriptor *) __devinit;848849-extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit;850851#endif /* __KERNEL__ */852
···70 *71 * Bulk endpoints can use any size buffers, and can also be used for interrupt72 * transfers. interrupt-only endpoints can be much less functional.73+ *74+ * NOTE: this is analagous to 'struct urb' on the host side, except that75+ * it's thinner and promotes more pre-allocation.76 */007778struct usb_request {79 void *buf;···168 *169 * returns zero, or a negative error code.170 */171+static inline int usb_ep_enable(struct usb_ep *ep,172+ const struct usb_endpoint_descriptor *desc)173{174+ return ep->ops->enable(ep, desc);175}176177/**···186 *187 * returns zero, or a negative error code.188 */189+static inline int usb_ep_disable(struct usb_ep *ep)0190{191+ return ep->ops->disable(ep);192}193194/**···206 *207 * Returns the request, or null if one could not be allocated.208 */209+static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,210+ gfp_t gfp_flags)211{212+ return ep->ops->alloc_request(ep, gfp_flags);213}214215/**···221 * Caller guarantees the request is not queued, and that it will222 * no longer be requeued (or otherwise used).223 */224+static inline void usb_ep_free_request(struct usb_ep *ep,225+ struct usb_request *req)226{227+ ep->ops->free_request(ep, req);228}229230/**···281 * report errors; errors will also be282 * reported when the usb peripheral is disconnected.283 */284+static inline int usb_ep_queue(struct usb_ep *ep,285+ struct usb_request *req, gfp_t gfp_flags)286{287+ return ep->ops->queue(ep, req, gfp_flags);288}289290/**···301 * restrictions prevent drivers from supporting configuration changes,302 * even to configuration zero (a "chapter 9" requirement).303 */304+static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)305{306+ return ep->ops->dequeue(ep, req);307}308309/**···327 * transfer requests are still queued, or if the controller hardware328 * (usually a FIFO) still holds bytes that the host hasn't collected.329 */330+static inline int usb_ep_set_halt(struct usb_ep *ep)0331{332+ return ep->ops->set_halt(ep, 1);333}334335/**···346 * Note that some hardware can't support this request (like pxa2xx_udc),347 * and accordingly can't correctly implement interface altsettings.348 */349+static inline int usb_ep_clear_halt(struct usb_ep *ep)0350{351+ return ep->ops->set_halt(ep, 0);352}353354/**···367 * errno if the endpoint doesn't use a FIFO or doesn't support such368 * precise handling.369 */370+static inline int usb_ep_fifo_status(struct usb_ep *ep)0371{372 if (ep->ops->fifo_status)373+ return ep->ops->fifo_status(ep);374 else375 return -EOPNOTSUPP;376}···385 * must never be used except when endpoint is not being used for any386 * protocol translation.387 */388+static inline void usb_ep_fifo_flush(struct usb_ep *ep)0389{390 if (ep->ops->fifo_flush)391+ ep->ops->fifo_flush(ep);392}393394···469 struct device dev;470};471472+static inline void set_gadget_data(struct usb_gadget *gadget, void *data)473+ { dev_set_drvdata(&gadget->dev, data); }474+static inline void *get_gadget_data(struct usb_gadget *gadget)475+ { return dev_get_drvdata(&gadget->dev); }476477/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */478#define gadget_for_each_ep(tmp,gadget) \···511#endif512}5130514/**515 * usb_gadget_frame_number - returns the current frame number516 * @gadget: controller that reports the frame number···519 * Returns the usb frame number, normally eleven bits from a SOF packet,520 * or negative errno if this device doesn't support this capability.521 */522+static inline int usb_gadget_frame_number(struct usb_gadget *gadget)523{524+ return gadget->ops->get_frame(gadget);525}526527/**···537 * even if OTG isn't otherwise in use. OTG devices may also start538 * remote wakeup even when hosts don't explicitly enable it.539 */540+static inline int usb_gadget_wakeup(struct usb_gadget *gadget)541{542 if (!gadget->ops->wakeup)543 return -EOPNOTSUPP;544+ return gadget->ops->wakeup(gadget);545}546547/**···553 *554 * returns zero on success, else negative errno.555 */556+static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)0557{558 if (!gadget->ops->set_selfpowered)559 return -EOPNOTSUPP;560+ return gadget->ops->set_selfpowered(gadget, 1);561}562563/**···571 *572 * returns zero on success, else negative errno.573 */574+static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)0575{576 if (!gadget->ops->set_selfpowered)577 return -EOPNOTSUPP;578+ return gadget->ops->set_selfpowered(gadget, 0);579}580581/**···591 *592 * Returns zero on success, else negative errno.593 */594+static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)0595{596 if (!gadget->ops->vbus_session)597 return -EOPNOTSUPP;598+ return gadget->ops->vbus_session(gadget, 1);599}600601/**···611 *612 * Returns zero on success, else negative errno.613 */614+static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)0615{616 if (!gadget->ops->vbus_draw)617 return -EOPNOTSUPP;618+ return gadget->ops->vbus_draw(gadget, mA);619}620621/**···629 *630 * Returns zero on success, else negative errno.631 */632+static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)0633{634 if (!gadget->ops->vbus_session)635 return -EOPNOTSUPP;636+ return gadget->ops->vbus_session(gadget, 0);637}638639/**···648 *649 * Returns zero on success, else negative errno.650 */651+static inline int usb_gadget_connect(struct usb_gadget *gadget)0652{653 if (!gadget->ops->pullup)654 return -EOPNOTSUPP;655+ return gadget->ops->pullup(gadget, 1);656}657658/**···671 *672 * Returns zero on success, else negative errno.673 */674+static inline int usb_gadget_disconnect(struct usb_gadget *gadget)0675{676 if (!gadget->ops->pullup)677 return -EOPNOTSUPP;678+ return gadget->ops->pullup(gadget, 0);679}0680681682/*-------------------------------------------------------------------------*/···764 void (*suspend)(struct usb_gadget *);765 void (*resume)(struct usb_gadget *);766767+ /* FIXME support safe rmmod */768 struct device_driver driver;769};770···790 * the bind() functions will be in init sections.791 * This function must be called in a context that can sleep.792 */793+int usb_gadget_register_driver(struct usb_gadget_driver *driver);794795/**796 * usb_gadget_unregister_driver - unregister a gadget driver···805 * will in in exit sections, so may not be linked in some kernels.806 * This function must be called in a context that can sleep.807 */808+int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);809810/*-------------------------------------------------------------------------*/811···838};839840/* put descriptor for string with that id into buf (buflen >= 256) */841+int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf);842843/*-------------------------------------------------------------------------*/844···856857/* utility wrapping a simple endpoint selection policy */858859+extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,860 struct usb_endpoint_descriptor *) __devinit;861862+extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit;863864#endif /* __KERNEL__ */865
+12-10
include/linux/usb/gadgetfs.h
···36 GADGETFS_DISCONNECT,37 GADGETFS_SETUP,38 GADGETFS_SUSPEND,39- // and likely more !40};4142/* NOTE: this structure must stay the same size and layout on···44 */45struct usb_gadgetfs_event {46 union {47- // NOP, DISCONNECT, SUSPEND: nothing48- // ... some hardware can't report disconnection04950- // CONNECT: just the speed51 enum usb_device_speed speed;5253- // SETUP: packet; DATA phase i/o precedes next event54- // (setup.bmRequestType & USB_DIR_IN) flags direction55- // ... includes SET_CONFIGURATION, SET_INTERFACE056 struct usb_ctrlrequest setup;57 } u;58 enum usb_gadgetfs_event_type type;···75 * THIS returns how many bytes are "unclaimed" in the endpoint fifo76 * (needed for precise fault handling, when the hardware allows it)77 */78-#define GADGETFS_FIFO_STATUS _IO('g',1)7980/* discards any unclaimed data in the fifo. */81-#define GADGETFS_FIFO_FLUSH _IO('g',2)8283/* resets endpoint halt+toggle; used to implement set_interface.84 * some hardware (like pxa2xx) can't support this.85 */86-#define GADGETFS_CLEAR_HALT _IO('g',3)8788#endif /* __LINUX_USB_GADGETFS_H */
···36 GADGETFS_DISCONNECT,37 GADGETFS_SETUP,38 GADGETFS_SUSPEND,39+ /* and likely more ! */40};4142/* NOTE: this structure must stay the same size and layout on···44 */45struct usb_gadgetfs_event {46 union {47+ /* NOP, DISCONNECT, SUSPEND: nothing48+ * ... some hardware can't report disconnection49+ */5051+ /* CONNECT: just the speed */52 enum usb_device_speed speed;5354+ /* SETUP: packet; DATA phase i/o precedes next event55+ *(setup.bmRequestType & USB_DIR_IN) flags direction56+ * ... includes SET_CONFIGURATION, SET_INTERFACE57+ */58 struct usb_ctrlrequest setup;59 } u;60 enum usb_gadgetfs_event_type type;···73 * THIS returns how many bytes are "unclaimed" in the endpoint fifo74 * (needed for precise fault handling, when the hardware allows it)75 */76+#define GADGETFS_FIFO_STATUS _IO('g', 1)7778/* discards any unclaimed data in the fifo. */79+#define GADGETFS_FIFO_FLUSH _IO('g', 2)8081/* resets endpoint halt+toggle; used to implement set_interface.82 * some hardware (like pxa2xx) can't support this.83 */84+#define GADGETFS_CLEAR_HALT _IO('g', 3)8586#endif /* __LINUX_USB_GADGETFS_H */
+17-8
include/linux/usb/iowarrior.h
···14 this information.15*/16struct iowarrior_info {17- __u32 vendor; /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */18- __u32 product; /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_XXXXX) */19- __u8 serial[9]; /* the serial number of our chip (if a serial-number is not available this is empty string) */20- __u32 revision; /* revision number of the chip */21- __u32 speed; /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */22- __u32 power; /* power consumption of the device in mA */23- __u32 if_num; /* the number of the endpoint */24- __u32 report_size; /* size of the data-packets on this interface */00000000025};2627/*
···14 this information.15*/16struct iowarrior_info {17+ /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */18+ __u32 vendor;19+ /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_X) */20+ __u32 product;21+ /* the serial number of our chip (if a serial-number is not available22+ * this is empty string) */23+ __u8 serial[9];24+ /* revision number of the chip */25+ __u32 revision;26+ /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */27+ __u32 speed;28+ /* power consumption of the device in mA */29+ __u32 power;30+ /* the number of the endpoint */31+ __u32 if_num;32+ /* size of the data-packets on this interface */33+ __u32 report_size;34};3536/*
+1-1
include/linux/usb/isp116x.h
···25 300ns delay between access to ADDR_REG and DATA_REG26 OE, WE MUST NOT be changed during these intervals27 */28- void (*delay) (struct device * dev, int delay);29};
···25 300ns delay between access to ADDR_REG and DATA_REG26 OE, WE MUST NOT be changed during these intervals27 */28+ void (*delay) (struct device *dev, int delay);29};
···1-// include/linux/usb/otg.h23/*4 * These APIs may be used between USB controllers. USB device drivers
···1+/* USB OTG (On The Go) defines */23/*4 * These APIs may be used between USB controllers. USB device drivers
+86-69
include/linux/usb/serial.h
···20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */2223-#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */02425/* parity check flag */26#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))···62 * ports of a device.63 */64struct usb_serial_port {65- struct usb_serial * serial;66- struct tty_struct * tty;67 spinlock_t lock;68 struct mutex mutex;69 unsigned char number;7071- unsigned char * interrupt_in_buffer;72- struct urb * interrupt_in_urb;73 __u8 interrupt_in_endpointAddress;7475- unsigned char * interrupt_out_buffer;76 int interrupt_out_size;77- struct urb * interrupt_out_urb;78 __u8 interrupt_out_endpointAddress;7980- unsigned char * bulk_in_buffer;81 int bulk_in_size;82- struct urb * read_urb;83 __u8 bulk_in_endpointAddress;8485- unsigned char * bulk_out_buffer;86 int bulk_out_size;87- struct urb * write_urb;88 int write_urb_busy;89 __u8 bulk_out_endpointAddress;90···99#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)100101/* get and set the port private data pointer helper functions */102-static inline void *usb_get_serial_port_data (struct usb_serial_port *port)103{104 return dev_get_drvdata(&port->dev);105}106107-static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data)0108{109 dev_set_drvdata(&port->dev, data);110}···128 * usb_set_serial_data() to access this.129 */130struct usb_serial {131- struct usb_device * dev;132- struct usb_serial_driver * type;133- struct usb_interface * interface;134 unsigned char disconnected;135 unsigned char minor;136 unsigned char num_ports;···139 char num_interrupt_out;140 char num_bulk_in;141 char num_bulk_out;142- struct usb_serial_port * port[MAX_NUM_PORTS];143 struct kref kref;144 struct mutex disc_mutex;145- void * private;146};147#define to_usb_serial(d) container_of(d, struct usb_serial, kref)148149#define NUM_DONT_CARE 99150151/* get and set the serial private data pointer helper functions */152-static inline void *usb_get_serial_data (struct usb_serial *serial)153{154 return serial->private;155}156157-static inline void usb_set_serial_data (struct usb_serial *serial, void *data)158{159 serial->private = data;160}161162/**163 * usb_serial_driver - describes a usb serial driver164- * @description: pointer to a string that describes this driver. This string used165- * in the syslog messages when a device is inserted or removed.166 * @id_table: pointer to a list of usb_device_id structures that define all167 * of the devices this structure can support.168 * @num_interrupt_in: If a device doesn't have this many interrupt-in···223 struct usb_driver *usb_driver;224 struct usb_dynids dynids;225226- int (*probe) (struct usb_serial *serial, const struct usb_device_id *id);227- int (*attach) (struct usb_serial *serial);228 int (*calc_num_ports) (struct usb_serial *serial);229230- void (*shutdown) (struct usb_serial *serial);231232- int (*port_probe) (struct usb_serial_port *port);233- int (*port_remove) (struct usb_serial_port *port);234235- int (*suspend) (struct usb_serial *serial, pm_message_t message);236- int (*resume) (struct usb_serial *serial);237238 /* serial function calls */239- int (*open) (struct usb_serial_port *port, struct file * filp);240- void (*close) (struct usb_serial_port *port, struct file * filp);241- int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count);242- int (*write_room) (struct usb_serial_port *port);243- int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);244- void (*set_termios) (struct usb_serial_port *port, struct ktermios * old);245- void (*break_ctl) (struct usb_serial_port *port, int break_state);246- int (*chars_in_buffer) (struct usb_serial_port *port);247- void (*throttle) (struct usb_serial_port *port);248- void (*unthrottle) (struct usb_serial_port *port);249- int (*tiocmget) (struct usb_serial_port *port, struct file *file);250- int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);000251252 void (*read_int_callback)(struct urb *urb);253 void (*write_int_callback)(struct urb *urb);254 void (*read_bulk_callback)(struct urb *urb);255 void (*write_bulk_callback)(struct urb *urb);256};257-#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver)0258259extern int usb_serial_register(struct usb_serial_driver *driver);260extern void usb_serial_deregister(struct usb_serial_driver *driver);261extern void usb_serial_port_softint(struct usb_serial_port *port);262263-extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);0264extern void usb_serial_disconnect(struct usb_interface *iface);265266extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);267extern int usb_serial_resume(struct usb_interface *intf);268269-extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest);270-extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);0271272/* USB Serial console functions */273#ifdef CONFIG_USB_SERIAL_CONSOLE274-extern void usb_serial_console_init (int debug, int minor);275-extern void usb_serial_console_exit (void);276extern void usb_serial_console_disconnect(struct usb_serial *serial);277#else278-static inline void usb_serial_console_init (int debug, int minor) { }279-static inline void usb_serial_console_exit (void) { }280static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}281#endif282283/* Functions needed by other parts of the usbserial core */284-extern struct usb_serial *usb_serial_get_by_index (unsigned int minor);285extern void usb_serial_put(struct usb_serial *serial);286-extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);287-extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);288-extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);289-extern int usb_serial_generic_resume (struct usb_serial *serial);290-extern int usb_serial_generic_write_room (struct usb_serial_port *port);291-extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port);292-extern void usb_serial_generic_read_bulk_callback (struct urb *urb);293-extern void usb_serial_generic_write_bulk_callback (struct urb *urb);294-extern void usb_serial_generic_throttle (struct usb_serial_port *port);295-extern void usb_serial_generic_unthrottle (struct usb_serial_port *port);296-extern void usb_serial_generic_shutdown (struct usb_serial *serial);297-extern int usb_serial_generic_register (int debug);298-extern void usb_serial_generic_deregister (void);000299300-extern int usb_serial_bus_register (struct usb_serial_driver *device);301-extern void usb_serial_bus_deregister (struct usb_serial_driver *device);302303extern struct usb_serial_driver usb_serial_generic_device;304extern struct bus_type usb_serial_bus_type;···321 int i;322323 if (debug) {324- dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size);0325 for (i = 0; i < size; ++i)326- printk ("%.2x ", data[i]);327- printk ("\n");328 }329}330331/* Use our own dbg macro */332#undef dbg333-#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0)00000334335336
···20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */2223+/* The maximum number of ports one device can grab at once */24+#define MAX_NUM_PORTS 82526/* parity check flag */27#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))···61 * ports of a device.62 */63struct usb_serial_port {64+ struct usb_serial *serial;65+ struct tty_struct *tty;66 spinlock_t lock;67 struct mutex mutex;68 unsigned char number;6970+ unsigned char *interrupt_in_buffer;71+ struct urb *interrupt_in_urb;72 __u8 interrupt_in_endpointAddress;7374+ unsigned char *interrupt_out_buffer;75 int interrupt_out_size;76+ struct urb *interrupt_out_urb;77 __u8 interrupt_out_endpointAddress;7879+ unsigned char *bulk_in_buffer;80 int bulk_in_size;81+ struct urb *read_urb;82 __u8 bulk_in_endpointAddress;8384+ unsigned char *bulk_out_buffer;85 int bulk_out_size;86+ struct urb *write_urb;87 int write_urb_busy;88 __u8 bulk_out_endpointAddress;89···98#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)99100/* get and set the port private data pointer helper functions */101+static inline void *usb_get_serial_port_data(struct usb_serial_port *port)102{103 return dev_get_drvdata(&port->dev);104}105106+static inline void usb_set_serial_port_data(struct usb_serial_port *port,107+ void *data)108{109 dev_set_drvdata(&port->dev, data);110}···126 * usb_set_serial_data() to access this.127 */128struct usb_serial {129+ struct usb_device *dev;130+ struct usb_serial_driver *type;131+ struct usb_interface *interface;132 unsigned char disconnected;133 unsigned char minor;134 unsigned char num_ports;···137 char num_interrupt_out;138 char num_bulk_in;139 char num_bulk_out;140+ struct usb_serial_port *port[MAX_NUM_PORTS];141 struct kref kref;142 struct mutex disc_mutex;143+ void *private;144};145#define to_usb_serial(d) container_of(d, struct usb_serial, kref)146147#define NUM_DONT_CARE 99148149/* get and set the serial private data pointer helper functions */150+static inline void *usb_get_serial_data(struct usb_serial *serial)151{152 return serial->private;153}154155+static inline void usb_set_serial_data(struct usb_serial *serial, void *data)156{157 serial->private = data;158}159160/**161 * usb_serial_driver - describes a usb serial driver162+ * @description: pointer to a string that describes this driver. This string163+ * used in the syslog messages when a device is inserted or removed.164 * @id_table: pointer to a list of usb_device_id structures that define all165 * of the devices this structure can support.166 * @num_interrupt_in: If a device doesn't have this many interrupt-in···221 struct usb_driver *usb_driver;222 struct usb_dynids dynids;223224+ int (*probe)(struct usb_serial *serial, const struct usb_device_id *id);225+ int (*attach)(struct usb_serial *serial);226 int (*calc_num_ports) (struct usb_serial *serial);227228+ void (*shutdown)(struct usb_serial *serial);229230+ int (*port_probe)(struct usb_serial_port *port);231+ int (*port_remove)(struct usb_serial_port *port);232233+ int (*suspend)(struct usb_serial *serial, pm_message_t message);234+ int (*resume)(struct usb_serial *serial);235236 /* serial function calls */237+ int (*open)(struct usb_serial_port *port, struct file *filp);238+ void (*close)(struct usb_serial_port *port, struct file *filp);239+ int (*write)(struct usb_serial_port *port, const unsigned char *buf,240+ int count);241+ int (*write_room)(struct usb_serial_port *port);242+ int (*ioctl)(struct usb_serial_port *port, struct file *file,243+ unsigned int cmd, unsigned long arg);244+ void (*set_termios)(struct usb_serial_port *port, struct ktermios *old);245+ void (*break_ctl)(struct usb_serial_port *port, int break_state);246+ int (*chars_in_buffer)(struct usb_serial_port *port);247+ void (*throttle)(struct usb_serial_port *port);248+ void (*unthrottle)(struct usb_serial_port *port);249+ int (*tiocmget)(struct usb_serial_port *port, struct file *file);250+ int (*tiocmset)(struct usb_serial_port *port, struct file *file,251+ unsigned int set, unsigned int clear);252253 void (*read_int_callback)(struct urb *urb);254 void (*write_int_callback)(struct urb *urb);255 void (*read_bulk_callback)(struct urb *urb);256 void (*write_bulk_callback)(struct urb *urb);257};258+#define to_usb_serial_driver(d) \259+ container_of(d, struct usb_serial_driver, driver)260261extern int usb_serial_register(struct usb_serial_driver *driver);262extern void usb_serial_deregister(struct usb_serial_driver *driver);263extern void usb_serial_port_softint(struct usb_serial_port *port);264265+extern int usb_serial_probe(struct usb_interface *iface,266+ const struct usb_device_id *id);267extern void usb_serial_disconnect(struct usb_interface *iface);268269extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);270extern int usb_serial_resume(struct usb_interface *intf);271272+extern int ezusb_writememory(struct usb_serial *serial, int address,273+ unsigned char *data, int length, __u8 bRequest);274+extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit);275276/* USB Serial console functions */277#ifdef CONFIG_USB_SERIAL_CONSOLE278+extern void usb_serial_console_init(int debug, int minor);279+extern void usb_serial_console_exit(void);280extern void usb_serial_console_disconnect(struct usb_serial *serial);281#else282+static inline void usb_serial_console_init(int debug, int minor) { }283+static inline void usb_serial_console_exit(void) { }284static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}285#endif286287/* Functions needed by other parts of the usbserial core */288+extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);289extern void usb_serial_put(struct usb_serial *serial);290+extern int usb_serial_generic_open(struct usb_serial_port *port,291+ struct file *filp);292+extern int usb_serial_generic_write(struct usb_serial_port *port,293+ const unsigned char *buf, int count);294+extern void usb_serial_generic_close(struct usb_serial_port *port,295+ struct file *filp);296+extern int usb_serial_generic_resume(struct usb_serial *serial);297+extern int usb_serial_generic_write_room(struct usb_serial_port *port);298+extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port);299+extern void usb_serial_generic_read_bulk_callback(struct urb *urb);300+extern void usb_serial_generic_write_bulk_callback(struct urb *urb);301+extern void usb_serial_generic_throttle(struct usb_serial_port *port);302+extern void usb_serial_generic_unthrottle(struct usb_serial_port *port);303+extern void usb_serial_generic_shutdown(struct usb_serial *serial);304+extern int usb_serial_generic_register(int debug);305+extern void usb_serial_generic_deregister(void);306307+extern int usb_serial_bus_register(struct usb_serial_driver *device);308+extern void usb_serial_bus_deregister(struct usb_serial_driver *device);309310extern struct usb_serial_driver usb_serial_generic_device;311extern struct bus_type usb_serial_bus_type;···310 int i;311312 if (debug) {313+ dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ",314+ function, size);315 for (i = 0; i < size; ++i)316+ printk("%.2x ", data[i]);317+ printk("\n");318 }319}320321/* Use our own dbg macro */322#undef dbg323+#define dbg(format, arg...) \324+ do { \325+ if (debug) \326+ printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \327+ ## arg); \328+ } while (0)329330331
+3-3
include/linux/usb/sl811.h
···19 /* pulse sl811 nRST (probably with a GPIO) */20 void (*reset)(struct device *dev);2122- // some boards need something like these:23- // int (*check_overcurrent)(struct device *dev);24- // void (*clock_enable)(struct device *dev, int is_on);25};26
···19 /* pulse sl811 nRST (probably with a GPIO) */20 void (*reset)(struct device *dev);2122+ /* some boards need something like these: */23+ /* int (*check_overcurrent)(struct device *dev); */24+ /* void (*clock_enable)(struct device *dev, int is_on); */25};26