git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
usb
/
core
/
config.c
diff --git
a/drivers/usb/core/config.c
b/drivers/usb/core/config.c
index
ae7ec74
..
bfb3731
100644
(file)
--- a/
drivers/usb/core/config.c
+++ b/
drivers/usb/core/config.c
@@
-1,16
+1,11
@@
-#include <linux/config.h>
-
-#ifdef CONFIG_USB_DEBUG
-#define DEBUG
-#endif
-
#include <linux/usb.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <asm/byteorder.h>
#include <linux/usb.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <asm/byteorder.h>
-
+#include "usb.h"
+#include "hcd.h"
#define USB_MAXALTSETTING 128 /* Hard limit */
#define USB_MAXENDPOINTS 30 /* Hard limit */
#define USB_MAXALTSETTING 128 /* Hard limit */
#define USB_MAXENDPOINTS 30 /* Hard limit */
@@
-87,7
+82,7
@@
static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
++ifp->desc.bNumEndpoints;
memcpy(&endpoint->desc, d, n);
++ifp->desc.bNumEndpoints;
memcpy(&endpoint->desc, d, n);
-
le16_to_cpus(&endpoint->desc.wMaxPacketSize
);
+
INIT_LIST_HEAD(&endpoint->urb_list
);
/* Skip over any Class Specific or Vendor Specific descriptors;
* find the next endpoint or interface descriptor */
/* Skip over any Class Specific or Vendor Specific descriptors;
* find the next endpoint or interface descriptor */
@@
-106,13
+101,17
@@
skip_to_next_endpoint_or_interface_descriptor:
return buffer - buffer0 + i;
}
return buffer - buffer0 + i;
}
-
static
void usb_release_interface_cache(struct kref *ref)
+void usb_release_interface_cache(struct kref *ref)
{
struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref);
int j;
{
struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref);
int j;
- for (j = 0; j < intfc->num_altsetting; j++)
- kfree(intfc->altsetting[j].endpoint);
+ for (j = 0; j < intfc->num_altsetting; j++) {
+ struct usb_host_interface *alt = &intfc->altsetting[j];
+
+ kfree(alt->endpoint);
+ kfree(alt->string);
+ }
kfree(intfc);
}
kfree(intfc);
}
@@
-187,10
+186,9
@@
static int usb_parse_interface(struct device *ddev, int cfgno,
}
len = sizeof(struct usb_host_endpoint) * num_ep;
}
len = sizeof(struct usb_host_endpoint) * num_ep;
- alt->endpoint = k
m
alloc(len, GFP_KERNEL);
+ alt->endpoint = k
z
alloc(len, GFP_KERNEL);
if (!alt->endpoint)
return -ENOMEM;
if (!alt->endpoint)
return -ENOMEM;
- memset(alt->endpoint, 0, len);
/* Parse all the endpoint descriptors */
n = 0;
/* Parse all the endpoint descriptors */
n = 0;
@@
-221,7
+219,7
@@
skip_to_next_interface_descriptor:
return buffer - buffer0 + i;
}
return buffer - buffer0 + i;
}
-int usb_parse_configuration(struct device *ddev, int cfgidx,
+
static
int usb_parse_configuration(struct device *ddev, int cfgidx,
struct usb_host_config *config, unsigned char *buffer, int size)
{
unsigned char *buffer0 = buffer;
struct usb_host_config *config, unsigned char *buffer, int size)
{
unsigned char *buffer0 = buffer;
@@
-319,7
+317,7
@@
int usb_parse_configuration(struct device *ddev, int cfgidx,
} /* for ((buffer2 = buffer, size2 = size); ...) */
size = buffer2 - buffer;
} /* for ((buffer2 = buffer, size2 = size); ...) */
size = buffer2 - buffer;
- config->desc.wTotalLength =
buffer2 - buffer0
;
+ config->desc.wTotalLength =
cpu_to_le16(buffer2 - buffer0)
;
if (n != nintf)
dev_warn(ddev, "config %d has %d interface%s, different from "
if (n != nintf)
dev_warn(ddev, "config %d has %d interface%s, different from "
@@
-352,11
+350,10
@@
int usb_parse_configuration(struct device *ddev, int cfgidx,
}
len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
}
len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
- config->intf_cache[i] = intfc = k
m
alloc(len, GFP_KERNEL);
+ config->intf_cache[i] = intfc = k
z
alloc(len, GFP_KERNEL);
if (!intfc)
return -ENOMEM;
if (!intfc)
return -ENOMEM;
- memset(intfc, 0, len);
- kref_init(&intfc->ref, usb_release_interface_cache);
+ kref_init(&intfc->ref);
}
/* Skip over any Class Specific or Vendor Specific descriptors;
}
/* Skip over any Class Specific or Vendor Specific descriptors;
@@
-420,9
+417,11
@@
void usb_destroy_configuration(struct usb_device *dev)
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
struct usb_host_config *cf = &dev->config[c];
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
struct usb_host_config *cf = &dev->config[c];
+ kfree(cf->string);
for (i = 0; i < cf->desc.bNumInterfaces; i++) {
if (cf->intf_cache[i])
for (i = 0; i < cf->desc.bNumInterfaces; i++) {
if (cf->intf_cache[i])
- kref_put(&cf->intf_cache[i]->ref);
+ kref_put(&cf->intf_cache[i]->ref,
+ usb_release_interface_cache);
}
}
kfree(dev->config);
}
}
kfree(dev->config);
@@
-454,16
+453,14
@@
int usb_get_configuration(struct usb_device *dev)
}
length = ncfg * sizeof(struct usb_host_config);
}
length = ncfg * sizeof(struct usb_host_config);
- dev->config = k
m
alloc(length, GFP_KERNEL);
+ dev->config = k
z
alloc(length, GFP_KERNEL);
if (!dev->config)
goto err2;
if (!dev->config)
goto err2;
- memset(dev->config, 0, length);
length = ncfg * sizeof(char *);
length = ncfg * sizeof(char *);
- dev->rawdescriptors = k
m
alloc(length, GFP_KERNEL);
+ dev->rawdescriptors = k
z
alloc(length, GFP_KERNEL);
if (!dev->rawdescriptors)
goto err2;
if (!dev->rawdescriptors)
goto err2;
- memset(dev->rawdescriptors, 0, length);
buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
if (!buffer)
buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
if (!buffer)
@@
-478,7
+475,9
@@
int usb_get_configuration(struct usb_device *dev)
if (result < 0) {
dev_err(ddev, "unable to read config index %d "
"descriptor/%s\n", cfgno, "start");
if (result < 0) {
dev_err(ddev, "unable to read config index %d "
"descriptor/%s\n", cfgno, "start");
- goto err;
+ dev_err(ddev, "chopping to %d config(s)\n", cfgno);
+ dev->descriptor.bNumConfigurations = cfgno;
+ break;
} else if (result < 4) {
dev_err(ddev, "config index %d descriptor too short "
"(expected %i, got %i)\n", cfgno,
} else if (result < 4) {
dev_err(ddev, "config index %d descriptor too short "
"(expected %i, got %i)\n", cfgno,