Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36403
b: refs/heads/master
c: b7cfaaa
h: refs/heads/master
i:
  36401: ec4ae15
  36399: 6809700
v: v3
  • Loading branch information
Luiz Fernando N. Capitulino authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent 0341c00 commit d8278d6
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3d5b2510f6e361e2203e163c03b93d0026de5629
refs/heads/master: b7cfaaaf86571732c7728e95a2231a860385463c
144 changes: 144 additions & 0 deletions trunk/drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,138 @@ int usb_get_current_frame_number(struct usb_device *dev)
return dev->bus->op->get_frame_number (dev);
}

/**
* usb_endpoint_dir_in - check if the endpoint has IN direction
* @epd: endpoint to be checked
*
* Returns true if the endpoint is of type IN, otherwise it returns false.
*/
int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
}

/**
* usb_endpoint_dir_out - check if the endpoint has OUT direction
* @epd: endpoint to be checked
*
* Returns true if the endpoint is of type OUT, otherwise it returns false.
*/
int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
}

/**
* usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
* @epd: endpoint to be checked
*
* Returns true if the endpoint is of type bulk, otherwise it returns false.
*/
int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_BULK);
}

/**
* usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
* @epd: endpoint to be checked
*
* Returns true if the endpoint is of type interrupt, otherwise it returns
* false.
*/
int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_INT);
}

/**
* usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
* @epd: endpoint to be checked
*
* Returns true if the endpoint is of type isochronous, otherwise it returns
* false.
*/
int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_ISOC);
}

/**
* usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
* @epd: endpoint to be checked
*
* Returns true if the endpoint has bulk transfer type and IN direction,
* otherwise it returns false.
*/
int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
}

/**
* usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
* @epd: endpoint to be checked
*
* Returns true if the endpoint has bulk transfer type and OUT direction,
* otherwise it returns false.
*/
int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
}

/**
* usb_endpoint_is_int_in - check if the endpoint is interrupt IN
* @epd: endpoint to be checked
*
* Returns true if the endpoint has interrupt transfer type and IN direction,
* otherwise it returns false.
*/
int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
}

/**
* usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
* @epd: endpoint to be checked
*
* Returns true if the endpoint has interrupt transfer type and OUT direction,
* otherwise it returns false.
*/
int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
}

/**
* usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
* @epd: endpoint to be checked
*
* Returns true if the endpoint has isochronous transfer type and IN direction,
* otherwise it returns false.
*/
int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
}

/**
* usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
* @epd: endpoint to be checked
*
* Returns true if the endpoint has isochronous transfer type and OUT direction,
* otherwise it returns false.
*/
int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
{
return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
}

/*-------------------------------------------------------------------*/
/*
* __usb_get_extra_descriptor() finds a descriptor of specific type in the
Expand Down Expand Up @@ -909,6 +1041,18 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor);
EXPORT_SYMBOL(usb_find_device);
EXPORT_SYMBOL(usb_get_current_frame_number);

EXPORT_SYMBOL_GPL(usb_endpoint_dir_in);
EXPORT_SYMBOL_GPL(usb_endpoint_dir_out);
EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk);
EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int);
EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc);
EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in);
EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out);
EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in);
EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out);
EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in);
EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out);

EXPORT_SYMBOL (usb_buffer_alloc);
EXPORT_SYMBOL (usb_buffer_free);

Expand Down
14 changes: 14 additions & 0 deletions trunk/include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,20 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,

/*-------------------------------------------------------------------------*/

extern int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd);
extern int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd);

/*-------------------------------------------------------------------------*/

#define USB_DEVICE_ID_MATCH_DEVICE \
(USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
#define USB_DEVICE_ID_MATCH_DEV_RANGE \
Expand Down

0 comments on commit d8278d6

Please sign in to comment.