fixed some compiler warnings
This commit is contained in:
@@ -528,7 +528,6 @@ struct fb_videomode {
|
|||||||
extern const struct fb_videomode vesa_modes[];
|
extern const struct fb_videomode vesa_modes[];
|
||||||
|
|
||||||
/* timer */
|
/* timer */
|
||||||
extern void udelay(long usec);
|
|
||||||
#ifdef COLDFIRE
|
#ifdef COLDFIRE
|
||||||
#ifdef MCF5445X
|
#ifdef MCF5445X
|
||||||
#define US_TO_TIMER(a) (a)
|
#define US_TO_TIMER(a) (a)
|
||||||
@@ -541,6 +540,7 @@ extern void udelay(long usec);
|
|||||||
#define US_TO_TIMER(a) (((a)*256)/5000)
|
#define US_TO_TIMER(a) (((a)*256)/5000)
|
||||||
#define TIMER_TO_US(a) (((a)*5000)/256)
|
#define TIMER_TO_US(a) (((a)*5000)/256)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void start_timeout(void);
|
extern void start_timeout(void);
|
||||||
extern int end_timeout(long msec);
|
extern int end_timeout(long msec);
|
||||||
extern void mdelay(long msec);
|
extern void mdelay(long msec);
|
||||||
|
|||||||
@@ -75,14 +75,16 @@ extern int sprintD(char *s, const char *fmt, ...);
|
|||||||
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
|
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
|
||||||
|
|
||||||
/* String descriptor */
|
/* String descriptor */
|
||||||
struct usb_string_descriptor {
|
struct usb_string_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint16_t wData[1];
|
uint16_t wData[1];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* device request (setup) */
|
/* device request (setup) */
|
||||||
struct devrequest {
|
struct devrequest
|
||||||
|
{
|
||||||
uint8_t requesttype;
|
uint8_t requesttype;
|
||||||
uint8_t request;
|
uint8_t request;
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
@@ -91,13 +93,15 @@ struct devrequest {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* All standard descriptors have these 2 fields in common */
|
/* All standard descriptors have these 2 fields in common */
|
||||||
struct usb_descriptor_header {
|
struct usb_descriptor_header
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Device descriptor */
|
/* Device descriptor */
|
||||||
struct usb_device_descriptor {
|
struct usb_device_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint16_t bcdUSB;
|
uint16_t bcdUSB;
|
||||||
@@ -115,7 +119,8 @@ struct usb_device_descriptor {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Endpoint descriptor */
|
/* Endpoint descriptor */
|
||||||
struct usb_endpoint_descriptor {
|
struct usb_endpoint_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint8_t bEndpointAddress;
|
uint8_t bEndpointAddress;
|
||||||
@@ -127,7 +132,8 @@ struct usb_endpoint_descriptor {
|
|||||||
} __attribute__ ((packed)) __attribute__ ((aligned(2)));
|
} __attribute__ ((packed)) __attribute__ ((aligned(2)));
|
||||||
|
|
||||||
/* Interface descriptor */
|
/* Interface descriptor */
|
||||||
struct usb_interface_descriptor {
|
struct usb_interface_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint8_t bInterfaceNumber;
|
uint8_t bInterfaceNumber;
|
||||||
@@ -147,7 +153,8 @@ struct usb_interface_descriptor {
|
|||||||
|
|
||||||
|
|
||||||
/* Configuration descriptor information.. */
|
/* Configuration descriptor information.. */
|
||||||
struct usb_config_descriptor {
|
struct usb_config_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint16_t wTotalLength;
|
uint16_t wTotalLength;
|
||||||
@@ -161,7 +168,8 @@ struct usb_config_descriptor {
|
|||||||
struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
|
struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
/* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
|
/* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
|
||||||
PACKET_SIZE_8 = 0,
|
PACKET_SIZE_8 = 0,
|
||||||
PACKET_SIZE_16 = 1,
|
PACKET_SIZE_16 = 1,
|
||||||
@@ -169,7 +177,8 @@ enum {
|
|||||||
PACKET_SIZE_64 = 3,
|
PACKET_SIZE_64 = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_device {
|
struct usb_device
|
||||||
|
{
|
||||||
int devnum; /* Device number on USB bus */
|
int devnum; /* Device number on USB bus */
|
||||||
int speed; /* full/low/high */
|
int speed; /* full/low/high */
|
||||||
char mf[32]; /* manufacturer */
|
char mf[32]; /* manufacturer */
|
||||||
@@ -260,8 +269,6 @@ int drv_usb_mouse_init(void);
|
|||||||
int usb_mouse_register(struct usb_device *dev);
|
int usb_mouse_register(struct usb_device *dev);
|
||||||
int usb_mouse_deregister(struct usb_device *dev);
|
int usb_mouse_deregister(struct usb_device *dev);
|
||||||
|
|
||||||
extern char usb_error_str[256];
|
|
||||||
|
|
||||||
/* memory */
|
/* memory */
|
||||||
void *usb_malloc(long amount);
|
void *usb_malloc(long amount);
|
||||||
int usb_free(void *addr);
|
int usb_free(void *addr);
|
||||||
@@ -391,19 +398,22 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
|||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Hub Stuff
|
* Hub Stuff
|
||||||
*/
|
*/
|
||||||
struct usb_port_status {
|
struct usb_port_status
|
||||||
|
{
|
||||||
uint16_t wPortStatus;
|
uint16_t wPortStatus;
|
||||||
uint16_t wPortChange;
|
uint16_t wPortChange;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct usb_hub_status {
|
struct usb_hub_status
|
||||||
|
{
|
||||||
uint16_t wHubStatus;
|
uint16_t wHubStatus;
|
||||||
uint16_t wHubChange;
|
uint16_t wHubChange;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
/* Hub descriptor */
|
/* Hub descriptor */
|
||||||
struct usb_hub_descriptor {
|
struct usb_hub_descriptor
|
||||||
|
{
|
||||||
uint8_t bLength;
|
uint8_t bLength;
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
uint8_t bNbrPorts;
|
uint8_t bNbrPorts;
|
||||||
@@ -417,7 +427,8 @@ struct usb_hub_descriptor {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
struct usb_hub_device {
|
struct usb_hub_device
|
||||||
|
{
|
||||||
struct usb_device *pusb_dev;
|
struct usb_device *pusb_dev;
|
||||||
struct usb_hub_descriptor desc;
|
struct usb_hub_descriptor desc;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,6 +44,11 @@
|
|||||||
typedef bool (*checker_func)(void);
|
typedef bool (*checker_func)(void);
|
||||||
|
|
||||||
extern void wait(uint32_t);
|
extern void wait(uint32_t);
|
||||||
|
inline static void udelay(long us)
|
||||||
|
{
|
||||||
|
wait((uint32_t) us);
|
||||||
|
}
|
||||||
|
|
||||||
extern bool waitfor(uint32_t us, checker_func condition);
|
extern bool waitfor(uint32_t us, checker_func condition);
|
||||||
extern uint32_t get_timer(void);
|
extern uint32_t get_timer(void);
|
||||||
extern void wait_ms(uint32_t ms);
|
extern void wait_ms(uint32_t ms);
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ __attribute__((interrupt)) void pci_interrupt(void)
|
|||||||
dbg("PCI interrupt\r\n");
|
dbg("PCI interrupt\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Although this pragma stuff should work according to the GCC docs, it doesn't seem to
|
||||||
|
* with m68k-atari-mint-gcc. At least not currently.
|
||||||
|
* I nevertheless keep it here for future reference
|
||||||
|
*/
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
static int32_t pci_get_interrupt_cause(int32_t *handles)
|
static int32_t pci_get_interrupt_cause(int32_t *handles)
|
||||||
{
|
{
|
||||||
int32_t handle;
|
int32_t handle;
|
||||||
@@ -170,6 +177,7 @@ static int32_t pci_call_interrupt_chain(int32_t handle, int32_t data)
|
|||||||
{
|
{
|
||||||
return data; /* unmodified - means: not handled */
|
return data; /* unmodified - means: not handled */
|
||||||
}
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
#ifdef MACHINE_M5484LITE
|
#ifdef MACHINE_M5484LITE
|
||||||
/*
|
/*
|
||||||
@@ -179,7 +187,7 @@ static int32_t pci_call_interrupt_chain(int32_t handle, int32_t data)
|
|||||||
void irq5_handler(void)
|
void irq5_handler(void)
|
||||||
{
|
{
|
||||||
int32_t handle;
|
int32_t handle;
|
||||||
int32_t value;
|
int32_t value = 0;
|
||||||
int32_t newvalue;
|
int32_t newvalue;
|
||||||
|
|
||||||
MCF_EPORT_EPFR |= (1 << 5); /* clear interrupt from edge port */
|
MCF_EPORT_EPFR |= (1 << 5); /* clear interrupt from edge port */
|
||||||
@@ -201,7 +209,7 @@ void irq5_handler(void)
|
|||||||
void irq7_handler(void)
|
void irq7_handler(void)
|
||||||
{
|
{
|
||||||
int32_t handle;
|
int32_t handle;
|
||||||
int32_t value;
|
int32_t value = 0;
|
||||||
int32_t newvalue;
|
int32_t newvalue;
|
||||||
|
|
||||||
MCF_EPORT_EPFR |= (1 << 7);
|
MCF_EPORT_EPFR |= (1 << 7);
|
||||||
@@ -768,6 +776,12 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function)
|
|||||||
static uint32_t io_address = PCI_IO_OFFSET;
|
static uint32_t io_address = PCI_IO_OFFSET;
|
||||||
uint16_t cr;
|
uint16_t cr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* should make compiler happy (these are used only in debug builds)
|
||||||
|
*/
|
||||||
|
(void) value;
|
||||||
|
(void) il;
|
||||||
|
|
||||||
/* determine pci handle from bus, device + function number */
|
/* determine pci handle from bus, device + function number */
|
||||||
handle = PCI_HANDLE(bus, device, function);
|
handle = PCI_HANDLE(bus, device, function);
|
||||||
|
|
||||||
|
|||||||
@@ -1061,8 +1061,6 @@ void clear_bss_segment(void)
|
|||||||
|
|
||||||
void initialize_hardware(void)
|
void initialize_hardware(void)
|
||||||
{
|
{
|
||||||
bool coldboot = true;
|
|
||||||
|
|
||||||
/* Test for FireTOS switch: DIP switch #5 up */
|
/* Test for FireTOS switch: DIP switch #5 up */
|
||||||
#ifdef MACHINE_FIREBEE
|
#ifdef MACHINE_FIREBEE
|
||||||
if (!(DIP_SWITCH & (1 << 6))) {
|
if (!(DIP_SWITCH & (1 << 6))) {
|
||||||
@@ -1181,7 +1179,7 @@ void initialize_hardware(void)
|
|||||||
|
|
||||||
init_slt();
|
init_slt();
|
||||||
init_fbcs();
|
init_fbcs();
|
||||||
coldboot = init_ddram();
|
init_ddram();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* install (preliminary) exception vectors
|
* install (preliminary) exception vectors
|
||||||
@@ -1227,8 +1225,6 @@ void initialize_hardware(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MACHINE_FIREBEE
|
#if MACHINE_FIREBEE
|
||||||
if (coldboot) /* does not work with BDM */
|
|
||||||
;
|
|
||||||
fpga_configured = init_fpga();
|
fpga_configured = init_fpga();
|
||||||
|
|
||||||
init_pll();
|
init_pll();
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ extern uint32_t usb_1st_disk_drive;
|
|||||||
|
|
||||||
#define USB_BUFSIZ 512
|
#define USB_BUFSIZ 512
|
||||||
|
|
||||||
struct hci {
|
struct hci
|
||||||
|
{
|
||||||
/* ------- common part -------- */
|
/* ------- common part -------- */
|
||||||
long handle; /* PCI BIOS */
|
long handle; /* PCI BIOS */
|
||||||
const struct pci_device_id *ent;
|
const struct pci_device_id *ent;
|
||||||
@@ -74,8 +75,6 @@ struct hci {
|
|||||||
/* ---- end of common part ---- */
|
/* ---- end of common part ---- */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void udelay(long usec);
|
|
||||||
|
|
||||||
static struct usb_device *usb_dev;
|
static struct usb_device *usb_dev;
|
||||||
static int bus_index;
|
static int bus_index;
|
||||||
static int dev_index[USB_MAX_BUS];
|
static int dev_index[USB_MAX_BUS];
|
||||||
@@ -85,8 +84,6 @@ static struct devrequest *setup_packet;
|
|||||||
|
|
||||||
char usb_started; /* flag for the started/stopped USB status */
|
char usb_started; /* flag for the started/stopped USB status */
|
||||||
|
|
||||||
char usb_error_str[256];
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int dest;
|
int dest;
|
||||||
@@ -207,7 +204,7 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/*
|
||||||
* Stop USB this stops the LowLevel Part and deregisters USB devices.
|
* Stop USB this stops the LowLevel Part and deregisters USB devices.
|
||||||
*/
|
*/
|
||||||
int usb_stop(void)
|
int usb_stop(void)
|
||||||
@@ -304,18 +301,22 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
void *data, unsigned short size, int timeout)
|
void *data, unsigned short size, int timeout)
|
||||||
{
|
{
|
||||||
struct hci *priv = (struct hci *)dev->priv_hcd;
|
struct hci *priv = (struct hci *)dev->priv_hcd;
|
||||||
|
|
||||||
if ((timeout == 0) && (!asynch_allowed))
|
if ((timeout == 0) && (!asynch_allowed))
|
||||||
{
|
{
|
||||||
/* request for a asynch control pipe is not allowed */
|
/* request for a asynch control pipe is not allowed */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set setup command */
|
/* set setup command */
|
||||||
setup_packet->requesttype = requesttype;
|
setup_packet->requesttype = requesttype;
|
||||||
setup_packet->request = request;
|
setup_packet->request = request;
|
||||||
setup_packet->value = swpw(value);
|
setup_packet->value = swpw(value);
|
||||||
setup_packet->index = swpw(index);
|
setup_packet->index = swpw(index);
|
||||||
setup_packet->length = swpw(size);
|
setup_packet->length = swpw(size);
|
||||||
|
|
||||||
dbg("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size);
|
dbg("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size);
|
||||||
|
|
||||||
switch(priv->ent->class)
|
switch(priv->ent->class)
|
||||||
{
|
{
|
||||||
case PCI_CLASS_SERIAL_USB_OHCI:
|
case PCI_CLASS_SERIAL_USB_OHCI:
|
||||||
@@ -329,8 +330,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
return (int)size;
|
return (int) size;
|
||||||
|
|
||||||
if (dev->status != 0)
|
if (dev->status != 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -343,7 +346,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
return dev->act_len;
|
return dev->act_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------
|
/*
|
||||||
* submits bulk message, and waits for completion. returns 0 if Ok or
|
* submits bulk message, and waits for completion. returns 0 if Ok or
|
||||||
* -1 if Error.
|
* -1 if Error.
|
||||||
* synchronous behavior
|
* synchronous behavior
|
||||||
@@ -351,8 +354,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
|
|||||||
int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
|
int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
|
||||||
{
|
{
|
||||||
struct hci *priv = (struct hci *)dev->priv_hcd;
|
struct hci *priv = (struct hci *)dev->priv_hcd;
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
switch(priv->ent->class)
|
switch(priv->ent->class)
|
||||||
{
|
{
|
||||||
case PCI_CLASS_SERIAL_USB_OHCI:
|
case PCI_CLASS_SERIAL_USB_OHCI:
|
||||||
@@ -366,13 +371,16 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len,
|
|||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(timeout--)
|
while(timeout--)
|
||||||
{
|
{
|
||||||
if (!((volatile uint32_t)dev->status & USB_ST_NOT_PROC))
|
if (!((volatile uint32_t)dev->status & USB_ST_NOT_PROC))
|
||||||
break;
|
break;
|
||||||
wait(1 * 1000);
|
wait(1 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
*actual_length = dev->act_len;
|
*actual_length = dev->act_len;
|
||||||
|
|
||||||
if (dev->status == 0)
|
if (dev->status == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@@ -380,7 +388,7 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------
|
/*
|
||||||
* Max Packet stuff
|
* Max Packet stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -397,18 +405,23 @@ int usb_maxpacket(struct usb_device *dev, uint32_t pipe)
|
|||||||
return dev->epmaxpacketin[((pipe>>15) & 0xf)];
|
return dev->epmaxpacketin[((pipe>>15) & 0xf)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The routine usb_set_maxpacket_ep() is extracted from the loop of routine
|
/*
|
||||||
|
* The routine usb_set_maxpacket_ep() is extracted from the loop of routine
|
||||||
* usb_set_maxpacket(), because the optimizer of GCC 4.x chokes on this routine
|
* usb_set_maxpacket(), because the optimizer of GCC 4.x chokes on this routine
|
||||||
* when it is inlined in 1 single routine. What happens is that the register r3
|
* when it is inlined in 1 single routine. What happens is that the register r3
|
||||||
* is used as loop-count 'i', but gets overwritten later on.
|
* is used as loop-count 'i', but gets overwritten later on.
|
||||||
* This is clearly a compiler bug, but it is easier to workaround it here than
|
* This is clearly a compiler bug, but it is easier to workaround it here than
|
||||||
* to update the compiler (Occurs with at least several GCC 4.{1,2},x
|
* to update the compiler (Occurs with at least several GCC 4.{1,2},x
|
||||||
* CodeSourcery compilers like e.g. 2007q3, 2008q1, 2008q3 lite editions on ARM)
|
* CodeSourcery compilers like e.g. 2007q3, 2008q1, 2008q3 lite editions on ARM)
|
||||||
|
*
|
||||||
|
* We probably do not need that for Coldfire - at least I hope so.
|
||||||
*/
|
*/
|
||||||
static void __attribute__((noinline))usb_set_maxpacket_ep(struct usb_device *dev, struct usb_endpoint_descriptor *ep)
|
static void usb_set_maxpacket_ep(struct usb_device *dev, struct usb_endpoint_descriptor *ep)
|
||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
b = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
b = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||||
|
|
||||||
if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL)
|
if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_CONTROL)
|
||||||
{
|
{
|
||||||
/* Control => bidirectional */
|
/* Control => bidirectional */
|
||||||
@@ -444,27 +457,33 @@ static void __attribute__((noinline))usb_set_maxpacket_ep(struct usb_device *dev
|
|||||||
*/
|
*/
|
||||||
int usb_set_maxpacket(struct usb_device *dev)
|
int usb_set_maxpacket(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
int i, ii;
|
int i;
|
||||||
|
int ii;
|
||||||
|
|
||||||
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
||||||
for (ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++)
|
for (ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++)
|
||||||
usb_set_maxpacket_ep(dev,&dev->config.if_desc[i].ep_desc[ii]);
|
usb_set_maxpacket_ep(dev,&dev->config.if_desc[i].ep_desc[ii]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*
|
||||||
* Parse the config, located in buffer, and fills the dev->config structure.
|
* Parse the config, located in buffer, and fills the dev->config structure.
|
||||||
* Note that all little/big endian swapping are done automatically.
|
* Note that all little/big endian swapping are done automatically.
|
||||||
*/
|
*/
|
||||||
int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
||||||
{
|
{
|
||||||
struct usb_descriptor_header *head;
|
struct usb_descriptor_header *head;
|
||||||
int index, ifno, epno, curr_if_num;
|
int index;
|
||||||
|
int ifno;
|
||||||
|
int epno;
|
||||||
|
int curr_if_num;
|
||||||
|
|
||||||
ifno = -1;
|
ifno = -1;
|
||||||
epno = -1;
|
epno = -1;
|
||||||
curr_if_num = -1;
|
curr_if_num = -1;
|
||||||
dev->configno = cfgno;
|
dev->configno = cfgno;
|
||||||
head = (struct usb_descriptor_header *)&buffer[0];
|
head = (struct usb_descriptor_header *) &buffer[0];
|
||||||
|
|
||||||
if (head->bDescriptorType != USB_DT_CONFIG)
|
if (head->bDescriptorType != USB_DT_CONFIG)
|
||||||
{
|
{
|
||||||
dbg(" ERROR: NOT USB_CONFIG_DESC %x\r\n", head->bDescriptorType);
|
dbg(" ERROR: NOT USB_CONFIG_DESC %x\r\n", head->bDescriptorType);
|
||||||
@@ -474,15 +493,17 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
|||||||
dev->config.wTotalLength = swpw(dev->config.wTotalLength);
|
dev->config.wTotalLength = swpw(dev->config.wTotalLength);
|
||||||
dev->config.no_of_if = 0;
|
dev->config.no_of_if = 0;
|
||||||
index = dev->config.bLength;
|
index = dev->config.bLength;
|
||||||
|
|
||||||
/* Ok the first entry must be a configuration entry,
|
/* Ok the first entry must be a configuration entry,
|
||||||
* now process the others */
|
* now process the others */
|
||||||
head = (struct usb_descriptor_header *) &buffer[index];
|
head = (struct usb_descriptor_header *) &buffer[index];
|
||||||
while(index + 1 < dev->config.wTotalLength)
|
|
||||||
|
while (index + 1 < dev->config.wTotalLength)
|
||||||
{
|
{
|
||||||
switch (head->bDescriptorType)
|
switch (head->bDescriptorType)
|
||||||
{
|
{
|
||||||
case USB_DT_INTERFACE:
|
case USB_DT_INTERFACE:
|
||||||
if (((struct usb_interface_descriptor *)&buffer[index])->bInterfaceNumber != curr_if_num)
|
if (((struct usb_interface_descriptor *) &buffer[index])->bInterfaceNumber != curr_if_num)
|
||||||
{
|
{
|
||||||
/* this is a new interface, copy new desc */
|
/* this is a new interface, copy new desc */
|
||||||
ifno = dev->config.no_of_if;
|
ifno = dev->config.no_of_if;
|
||||||
@@ -498,6 +519,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
|||||||
dev->config.if_desc[ifno].num_altsetting++;
|
dev->config.if_desc[ifno].num_altsetting++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_DT_ENDPOINT:
|
case USB_DT_ENDPOINT:
|
||||||
epno = dev->config.if_desc[ifno].no_of_ep;
|
epno = dev->config.if_desc[ifno].no_of_ep;
|
||||||
/* found an endpoint */
|
/* found an endpoint */
|
||||||
@@ -506,6 +528,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
|||||||
dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize = swpw(dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize);
|
dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize = swpw(dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize);
|
||||||
dbg("if %d, ep %d\r\n", ifno, epno);
|
dbg("if %d, ep %d\r\n", ifno, epno);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (head->bLength == 0)
|
if (head->bLength == 0)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -529,7 +552,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/*
|
||||||
* Clears an endpoint
|
* Clears an endpoint
|
||||||
* endp: endpoint number in bits 0-3;
|
* endp: endpoint number in bits 0-3;
|
||||||
* direction flag in bit 7 (1 = IN, 0 = OUT)
|
* direction flag in bit 7 (1 = IN, 0 = OUT)
|
||||||
@@ -538,33 +561,39 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int endp = usb_pipeendpoint(pipe)|(usb_pipein(pipe)<<7);
|
int endp = usb_pipeendpoint(pipe)|(usb_pipein(pipe)<<7);
|
||||||
|
|
||||||
result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, USB_CNTL_TIMEOUT * 3);
|
USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, USB_CNTL_TIMEOUT * 3);
|
||||||
|
|
||||||
/* don't clear if failed */
|
/* don't clear if failed */
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: we do not get status and verify reset was successful
|
* NOTE: we do not get status and verify reset was successful
|
||||||
* as some devices are reported to lock up upon this check..
|
* as some devices are reported to lock up upon this check..
|
||||||
*/
|
*/
|
||||||
usb_endpoint_running(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
|
usb_endpoint_running(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
|
||||||
|
|
||||||
/* toggle is reset on clear */
|
/* toggle is reset on clear */
|
||||||
usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
|
usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/*
|
||||||
* get_descriptor type
|
* get_descriptor type
|
||||||
*/
|
*/
|
||||||
int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
|
int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
res = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
|
||||||
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CNTL_TIMEOUT);
|
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CNTL_TIMEOUT);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/*
|
||||||
* gets configuration cfgno and store it in the buffer
|
* gets configuration cfgno and store it in the buffer
|
||||||
*/
|
*/
|
||||||
int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int cfgno)
|
||||||
@@ -572,8 +601,10 @@ int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int
|
|||||||
int result;
|
int result;
|
||||||
unsigned int tmp;
|
unsigned int tmp;
|
||||||
struct usb_config_descriptor *config;
|
struct usb_config_descriptor *config;
|
||||||
config = (struct usb_config_descriptor *)&buffer[0];
|
|
||||||
|
config = (struct usb_config_descriptor *) &buffer[0];
|
||||||
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
|
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
|
||||||
|
|
||||||
if (result < 9)
|
if (result < 9)
|
||||||
{
|
{
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
@@ -582,7 +613,9 @@ int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int
|
|||||||
dbg("config descriptor too short (expected %i, got %i)\n", 9, result);
|
dbg("config descriptor too short (expected %i, got %i)\n", 9, result);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = swpw(config->wTotalLength);
|
tmp = swpw(config->wTotalLength);
|
||||||
|
|
||||||
if (tmp > USB_BUFSIZ)
|
if (tmp > USB_BUFSIZ)
|
||||||
{
|
{
|
||||||
dbg("usb_get_configuration_no: failed to get descriptor - too long: %d\r\n", tmp);
|
dbg("usb_get_configuration_no: failed to get descriptor - too long: %d\r\n", tmp);
|
||||||
@@ -590,28 +623,31 @@ int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int
|
|||||||
}
|
}
|
||||||
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, tmp);
|
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, tmp);
|
||||||
dbg("get_conf_no %d Result %d, wLength %d\r\n", cfgno, result, tmp);
|
dbg("get_conf_no %d Result %d, wLength %d\r\n", cfgno, result, tmp);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* set address of a device to the value in dev->devnum.
|
* set address of a device to the value in dev->devnum.
|
||||||
* This can only be done by addressing the device via the default address (0)
|
* This can only be done by addressing the device via the default address (0)
|
||||||
*/
|
*/
|
||||||
int usb_set_address(struct usb_device *dev)
|
int usb_set_address(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
dbg("set address %d\r\n", dev->devnum);
|
dbg("set address %d\r\n", dev->devnum);
|
||||||
res = usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS, 0, (dev->devnum), 0, NULL, 0, USB_CNTL_TIMEOUT);
|
res = usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS, 0, (dev->devnum), 0, NULL, 0, USB_CNTL_TIMEOUT);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* set interface number to interface
|
* set interface number to interface
|
||||||
*/
|
*/
|
||||||
int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
{
|
{
|
||||||
struct usb_interface_descriptor *if_face = NULL;
|
struct usb_interface_descriptor *if_face = NULL;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
for (i = 0; i < dev->config.bNumInterfaces; i++)
|
||||||
{
|
{
|
||||||
if (dev->config.if_desc[i].bInterfaceNumber == interface)
|
if (dev->config.if_desc[i].bInterfaceNumber == interface)
|
||||||
@@ -620,11 +656,13 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!if_face)
|
if (!if_face)
|
||||||
{
|
{
|
||||||
dbg("selecting invalid interface %d", interface);
|
dbg("selecting invalid interface %d", interface);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We should return now for devices with only one alternate setting.
|
* We should return now for devices with only one alternate setting.
|
||||||
* According to 9.4.10 of the Universal Serial Bus Specification
|
* According to 9.4.10 of the Universal Serial Bus Specification
|
||||||
@@ -634,19 +672,22 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||||||
*/
|
*/
|
||||||
if (if_face->num_altsetting == 1)
|
if (if_face->num_altsetting == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, alternate, interface, NULL, 0, USB_CNTL_TIMEOUT * 5);
|
USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, alternate, interface, NULL, 0, USB_CNTL_TIMEOUT * 5);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* set configuration number to configuration
|
* set configuration number to configuration
|
||||||
*/
|
*/
|
||||||
int usb_set_configuration(struct usb_device *dev, int configuration)
|
int usb_set_configuration(struct usb_device *dev, int configuration)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
dbg("set configuration %d\r\n", configuration);
|
dbg("set configuration %d\r\n", configuration);
|
||||||
/* set setup command */
|
/* set setup command */
|
||||||
res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
@@ -661,7 +702,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* set protocol to protocol
|
* set protocol to protocol
|
||||||
*/
|
*/
|
||||||
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
||||||
@@ -671,7 +712,7 @@ int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol)
|
|||||||
protocol, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
protocol, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* set idle
|
* set idle
|
||||||
*/
|
*/
|
||||||
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
||||||
@@ -681,7 +722,7 @@ int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id)
|
|||||||
(duration << 8) | report_id, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
(duration << 8) | report_id, ifnum, NULL, 0, USB_CNTL_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* get report
|
* get report
|
||||||
*/
|
*/
|
||||||
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
||||||
@@ -692,7 +733,7 @@ int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
|
|||||||
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* get class descriptor
|
* get class descriptor
|
||||||
*/
|
*/
|
||||||
int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
|
int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
|
||||||
@@ -703,13 +744,14 @@ int usb_get_class_descriptor(struct usb_device *dev, int ifnum,
|
|||||||
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
(type << 8) + id, ifnum, buf, size, USB_CNTL_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* get string index in buffer
|
* get string index in buffer
|
||||||
*/
|
*/
|
||||||
int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
|
int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char index, void *buf, int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
/* some devices are flaky */
|
/* some devices are flaky */
|
||||||
@@ -723,13 +765,17 @@ int usb_get_string(struct usb_device *dev, unsigned short langid, unsigned char
|
|||||||
|
|
||||||
static void usb_try_string_workarounds(unsigned char *buf, int *length)
|
static void usb_try_string_workarounds(unsigned char *buf, int *length)
|
||||||
{
|
{
|
||||||
int newlength, oldlength = *length;
|
int newlength;
|
||||||
|
int oldlength = *length;
|
||||||
|
|
||||||
for (newlength = 2; newlength + 1 < oldlength; newlength += 2)
|
for (newlength = 2; newlength + 1 < oldlength; newlength += 2)
|
||||||
{
|
{
|
||||||
char c = buf[newlength];
|
char c = buf[newlength];
|
||||||
|
|
||||||
if ((c < ' ') || (c >= 127) || buf[newlength + 1])
|
if ((c < ' ') || (c >= 127) || buf[newlength + 1])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newlength > 2)
|
if (newlength > 2)
|
||||||
{
|
{
|
||||||
buf[0] = newlength;
|
buf[0] = newlength;
|
||||||
@@ -740,9 +786,11 @@ static void usb_try_string_workarounds(unsigned char *buf, int *length)
|
|||||||
static int usb_string_sub(struct usb_device *dev, unsigned int langid, unsigned int index, unsigned char *buf)
|
static int usb_string_sub(struct usb_device *dev, unsigned int langid, unsigned int index, unsigned char *buf)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Try to read the string descriptor by asking for the maximum
|
/* Try to read the string descriptor by asking for the maximum
|
||||||
* possible number of bytes */
|
* possible number of bytes */
|
||||||
rc = usb_get_string(dev, langid, index, buf, 255);
|
rc = usb_get_string(dev, langid, index, buf, 255);
|
||||||
|
|
||||||
/* If that failed try to read the descriptor length, then
|
/* If that failed try to read the descriptor length, then
|
||||||
* ask for just that many bytes */
|
* ask for just that many bytes */
|
||||||
if (rc < 2)
|
if (rc < 2)
|
||||||
@@ -751,6 +799,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, unsigned
|
|||||||
if (rc == 2)
|
if (rc == 2)
|
||||||
rc = usb_get_string(dev, langid, index, buf, buf[0]);
|
rc = usb_get_string(dev, langid, index, buf, buf[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc >= 2)
|
if (rc >= 2)
|
||||||
{
|
{
|
||||||
if (!buf[0] && !buf[1])
|
if (!buf[0] && !buf[1])
|
||||||
@@ -760,12 +809,14 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, unsigned
|
|||||||
rc = buf[0];
|
rc = buf[0];
|
||||||
rc = rc - (rc & 1); /* force a multiple of two */
|
rc = rc - (rc & 1); /* force a multiple of two */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc < 2)
|
if (rc < 2)
|
||||||
rc = -1;
|
rc = -1;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* usb_string:
|
* usb_string:
|
||||||
* Get string index and translate it to ascii.
|
* Get string index and translate it to ascii.
|
||||||
* returns string length (> 0) or error (< 0)
|
* returns string length (> 0) or error (< 0)
|
||||||
@@ -775,15 +826,19 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
unsigned char *tbuf;
|
unsigned char *tbuf;
|
||||||
int err;
|
int err;
|
||||||
unsigned int u, idx;
|
unsigned int u, idx;
|
||||||
|
|
||||||
if (size <= 0 || !buf || !index)
|
if (size <= 0 || !buf || !index)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
tbuf = (unsigned char *)driver_mem_alloc(USB_BUFSIZ);
|
tbuf = (unsigned char *) driver_mem_alloc(USB_BUFSIZ);
|
||||||
|
|
||||||
if (tbuf == NULL)
|
if (tbuf == NULL)
|
||||||
{
|
{
|
||||||
dbg("usb_string: malloc failure\r\n");
|
dbg("usb_string: malloc failure\r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get langid for strings if it's not yet known */
|
/* get langid for strings if it's not yet known */
|
||||||
if (!dev->have_langid)
|
if (!dev->have_langid)
|
||||||
{
|
{
|
||||||
@@ -814,6 +869,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
driver_mem_free(tbuf);
|
driver_mem_free(tbuf);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
size--; /* leave room for trailing NULL char in output buffer */
|
size--; /* leave room for trailing NULL char in output buffer */
|
||||||
for (idx = 0, u = 2; u < err; u += 2)
|
for (idx = 0, u = 2; u < err; u += 2)
|
||||||
{
|
{
|
||||||
@@ -830,7 +886,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/*
|
||||||
* USB device handling:
|
* USB device handling:
|
||||||
* the USB device are static allocated [USB_MAX_DEVICE].
|
* the USB device are static allocated [USB_MAX_DEVICE].
|
||||||
*/
|
*/
|
||||||
@@ -869,7 +925,8 @@ void usb_disconnect(struct usb_device **pdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns a pointer to the device with the index [index].
|
/*
|
||||||
|
* returns a pointer to the device with the index [index].
|
||||||
* if the device is not assigned (dev->devnum==-1) returns NULL
|
* if the device is not assigned (dev->devnum==-1) returns NULL
|
||||||
*/
|
*/
|
||||||
struct usb_device *usb_get_dev_index(int index, int index_bus)
|
struct usb_device *usb_get_dev_index(int index, int index_bus)
|
||||||
@@ -884,7 +941,8 @@ struct usb_device *usb_get_dev_index(int index, int index_bus)
|
|||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns a pointer of a new device structure or NULL, if
|
/*
|
||||||
|
* returns a pointer of a new device structure or NULL, if
|
||||||
* no device struct is available
|
* no device struct is available
|
||||||
*/
|
*/
|
||||||
struct usb_device *usb_alloc_new_device(int bus_index, void *priv)
|
struct usb_device *usb_alloc_new_device(int bus_index, void *priv)
|
||||||
|
|||||||
Reference in New Issue
Block a user