patch-2.3.36 linux/drivers/usb/usb.c
Next file: linux/drivers/usb/usb.h
Previous file: linux/drivers/usb/usb-serial.c
Back to the patch index
Back to the overall index
- Lines: 116
- Date:
Tue Jan 4 11:17:50 2000
- Orig file:
v2.3.35/linux/drivers/usb/usb.c
- Orig date:
Wed Dec 29 13:13:19 1999
diff -u --recursive --new-file v2.3.35/linux/drivers/usb/usb.c linux/drivers/usb/usb.c
@@ -18,10 +18,6 @@
* $Id: usb.c,v 1.39 1999/12/27 15:17:47 acher Exp $
*/
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
-
#define USB_DEBUG 1
#include <linux/config.h>
@@ -1179,6 +1175,34 @@
}
/*
+ * __usb_get_extra_descriptor() finds a descriptor of specific type in the
+ * extra field of the interface and endpoint descriptor structs.
+ */
+
+int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, void **ptr)
+{
+ struct usb_descriptor_header *header;
+
+ while (size >= sizeof(struct usb_descriptor_header)) {
+ header = (struct usb_descriptor_header *)buffer;
+
+ if (header->bLength < 2) {
+ printk(KERN_ERR "usb: invalid descriptor length of %d\n", header->bLength);
+ return -1;
+ }
+
+ if (header->bDescriptorType == type) {
+ *ptr = header;
+ return 0;
+ }
+
+ buffer += header->bLength;
+ size -= header->bLength;
+ }
+ return -1;
+}
+
+/*
* Something got disconnected. Get rid of it, and all of its children.
*/
void usb_disconnect(struct usb_device **pdev)
@@ -1268,6 +1292,14 @@
return result;
}
+int usb_get_class_descriptor(struct usb_device *dev, unsigned char type,
+ unsigned char id, unsigned char index, void *buf, int size)
+{
+ return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+ USB_REQ_GET_DESCRIPTOR, USB_RT_INTERFACE | USB_DIR_IN,
+ (type << 8) + id, index, buf, size, HZ * GET_TIMEOUT);
+}
+
int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
{
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
@@ -1313,8 +1345,6 @@
USB_REQ_SET_PROTOCOL, USB_RT_HIDD, protocol, 1, NULL, 0, HZ * SET_TIMEOUT);
}
-/* keyboards want a nonzero duration according to HID spec, but
- mice should use infinity (0) -keryan */
int usb_set_idle(struct usb_device *dev, int duration, int report_id)
{
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_IDLE,
@@ -1446,6 +1476,13 @@
(type << 8) + id, index, buf, size, HZ * GET_TIMEOUT);
}
+int usb_set_report(struct usb_device *dev, unsigned char type, unsigned char id, unsigned char index, void *buf, int size)
+{
+ return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+ USB_REQ_SET_REPORT, USB_RT_HIDD,
+ (type << 8) + id, index, buf, size, HZ);
+}
+
int usb_get_configuration(struct usb_device *dev)
{
int result;
@@ -1683,12 +1720,13 @@
NULL /* release */
};
-void usb_major_init(void)
+int usb_major_init(void)
{
if (register_chrdev(USB_MAJOR,"usb",&usb_fops)) {
- printk("unable to get major %d for usb devices\n",
- USB_MAJOR);
+ printk("unable to get major %d for usb devices\n", USB_MAJOR);
+ return -EBUSY;
}
+ return 0;
}
void usb_major_cleanup(void)
@@ -1737,11 +1775,14 @@
EXPORT_SYMBOL(usb_set_address);
EXPORT_SYMBOL(usb_get_descriptor);
+EXPORT_SYMBOL(usb_get_class_descriptor);
+EXPORT_SYMBOL(__usb_get_extra_descriptor);
EXPORT_SYMBOL(usb_get_string);
EXPORT_SYMBOL(usb_string);
EXPORT_SYMBOL(usb_get_protocol);
EXPORT_SYMBOL(usb_set_protocol);
EXPORT_SYMBOL(usb_get_report);
+EXPORT_SYMBOL(usb_set_report);
EXPORT_SYMBOL(usb_set_idle);
EXPORT_SYMBOL(usb_clear_halt);
EXPORT_SYMBOL(usb_set_interface);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)