summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-03-20 23:12:14 +0000
committerthompsa <thompsa@FreeBSD.org>2009-03-20 23:12:14 +0000
commit1f8835dc17f7687ea23fd70df12fc29ec7a052a1 (patch)
tree3033567942b232e2dd3b416b9ea983de102b02a5 /sys/dev/usb
parent9f723b539089d6eef4ea8986738d45f1833e37fa (diff)
downloadFreeBSD-src-1f8835dc17f7687ea23fd70df12fc29ec7a052a1.zip
FreeBSD-src-1f8835dc17f7687ea23fd70df12fc29ec7a052a1.tar.gz
Fix compile with USB_HAVE_BUSDMA/USB_HAVE_UGEN/USB_HAVE_STRINGS.
Submitted by: Hans Petter Selasky
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/usb_bus.h3
-rw-r--r--sys/dev/usb/usb_busdma.h19
-rw-r--r--sys/dev/usb/usb_dev.c3
-rw-r--r--sys/dev/usb/usb_device.c75
-rw-r--r--sys/dev/usb/usb_device.h11
-rw-r--r--sys/dev/usb/usb_generic.c5
-rw-r--r--sys/dev/usb/usb_hub.c4
-rw-r--r--sys/dev/usb/usb_util.c2
8 files changed, 68 insertions, 54 deletions
diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h
index 126b2c7..8a4575f 100644
--- a/sys/dev/usb/usb_bus.h
+++ b/sys/dev/usb/usb_bus.h
@@ -75,9 +75,10 @@ struct usb2_bus {
device_t parent;
device_t bdev; /* filled by HC driver */
+#if USB_HAVE_BUSDMA
struct usb2_dma_parent_tag dma_parent_tag[1];
struct usb2_dma_tag dma_tags[USB_BUS_DMA_TAG_MAX];
-
+#endif
struct usb2_bus_methods *methods; /* filled by HC driver */
struct usb2_device **devices;
diff --git a/sys/dev/usb/usb_busdma.h b/sys/dev/usb/usb_busdma.h
index 26a6588..9653006 100644
--- a/sys/dev/usb/usb_busdma.h
+++ b/sys/dev/usb/usb_busdma.h
@@ -48,6 +48,7 @@
struct usb2_xfer_root;
struct usb2_dma_parent_tag;
+struct usb2_dma_tag;
/*
* The following typedef defines the USB DMA load done callback.
@@ -115,11 +116,11 @@ struct usb2_page_cache {
/*
* The following structure describes the parent USB DMA tag.
*/
+#if USB_HAVE_BUSDMA
struct usb2_dma_parent_tag {
-#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
+#if defined(__FreeBSD__)
struct cv cv[1]; /* internal condition variable */
#endif
-#if USB_HAVE_BUSDMA
bus_dma_tag_t tag; /* always set */
struct mtx *mtx; /* private mutex, always set */
@@ -128,27 +129,31 @@ struct usb2_dma_parent_tag {
uint8_t dma_error; /* set if DMA load operation failed */
uint8_t dma_bits; /* number of DMA address lines */
uint8_t utag_max; /* number of USB DMA tags */
-#endif
};
+#else
+struct usb2_dma_parent_tag {}; /* empty struct */
+#endif
/*
* The following structure describes an USB DMA tag.
*/
+#if USB_HAVE_BUSDMA
struct usb2_dma_tag {
-#if USB_HAVE_BUSDMA && defined(__NetBSD__)
+#if defined(__NetBSD__)
bus_dma_segment_t *p_seg;
#endif
-#if USB_HAVE_BUSDMA
struct usb2_dma_parent_tag *tag_parent;
bus_dma_tag_t tag;
usb2_size_t align;
usb2_size_t size;
-#endif
-#if USB_HAVE_BUSDMA && defined(__NetBSD__)
+#if defined(__NetBSD__)
usb2_size_t n_seg;
#endif
};
+#else
+struct usb2_dma_tag {}; /* empty struct */
+#endif
/* function prototypes */
diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c
index 29e8b42..97fbebd 100644
--- a/sys/dev/usb/usb_dev.c
+++ b/sys/dev/usb/usb_dev.c
@@ -54,6 +54,8 @@
#include <machine/stdarg.h>
+#if USB_HAVE_UGEN
+
#if USB_DEBUG
static int usb2_fifo_debug = 0;
@@ -2195,3 +2197,4 @@ usb2_fifo_set_close_zlp(struct usb2_fifo *f, uint8_t onoff)
/* send a Zero Length Packet, ZLP, before close */
f->flag_short = onoff;
}
+#endif /* USB_HAVE_UGEN */
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index d08e8b9..b0790b4 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -75,9 +75,8 @@ static void usb2_check_strings(struct usb2_device *);
#endif
static usb2_error_t usb2_fill_iface_data(struct usb2_device *, uint8_t,
uint8_t);
-static void usb2_notify_addq(const char *type, struct usb2_device *);
-
#if USB_HAVE_UGEN
+static void usb2_notify_addq(const char *type, struct usb2_device *);
static void usb2_fifo_free_wrap(struct usb2_device *, uint8_t, uint8_t);
static struct cdev *usb2_make_dev(struct usb2_device *, int, int);
static void usb2_cdev_create(struct usb2_device *);
@@ -738,7 +737,6 @@ usb2_set_alt_interface_index(struct usb2_device *udev,
*/
usb2_fifo_free_wrap(udev, iface_index, 0);
#endif
-
err = usb2_fill_iface_data(udev, iface_index, alt_index);
if (err) {
goto done;
@@ -1378,8 +1376,6 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
usb2_cv_init(udev->default_cv, "WCTRL");
usb2_cv_init(udev->default_cv + 1, "UGONE");
- LIST_INIT(&udev->pd_list);
-
/* initialise our mutex */
mtx_init(udev->default_mtx, "USB device mutex", NULL, MTX_DEF);
@@ -1449,18 +1445,19 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
/* set device index */
udev->device_index = device_index;
+#if USB_HAVE_UGEN
/* Create ugen name */
snprintf(udev->ugen_name, sizeof(udev->ugen_name),
USB_GENERIC_NAME "%u.%u", device_get_unit(bus->bdev),
device_index);
-#if USB_HAVE_UGEN
+ LIST_INIT(&udev->pd_list);
+
/* Create the control endpoint device */
udev->default_dev = usb2_make_dev(udev, 0, FREAD|FWRITE);
/* Create a link from /dev/ugenX.X to the default endpoint */
make_dev_alias(udev->default_dev, udev->ugen_name);
#endif
-
if (udev->flags.usb2_mode == USB_MODE_HOST) {
err = usb2_req_set_address(udev, NULL, device_index);
@@ -1713,14 +1710,17 @@ repeat_set_config:
usb2_bus_port_set_device(bus, parent_hub ?
parent_hub->hub->ports + port_index : NULL, udev, device_index);
- /* Link and announce the ugen device name */
#if USB_HAVE_UGEN
+ /* Symlink the ugen device name */
udev->ugen_symlink = usb2_alloc_symlink(udev->ugen_name);
-#endif
+
+ /* Announce device */
+#if USB_HAVE_STRINGS
printf("%s: <%s> at %s\n", udev->ugen_name, udev->manufacturer,
device_get_nameunit(udev->bus->bdev));
-
+#endif
usb2_notify_addq("+", udev);
+#endif
done:
if (err) {
/* free device */
@@ -1824,7 +1824,6 @@ usb2_cdev_free(struct usb2_device *udev)
while ((pd = LIST_FIRST(&udev->pd_list)) != NULL) {
KASSERT(pd->cdev->si_drv1 == pd, ("privdata corrupt"));
- KASSERT(pd->ep_addr > 0, ("freeing EP0"));
destroy_dev_sched_cb(pd->cdev, usb2_cdev_cleanup, pd);
pd->cdev = NULL;
@@ -1851,18 +1850,20 @@ usb2_free_device(struct usb2_device *udev)
DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no);
+#if USB_HAVE_UGEN
usb2_notify_addq("-", udev);
+#if USB_HAVE_STRINGS
printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name,
udev->manufacturer, device_get_nameunit(bus->bdev));
+#endif
/* Destroy UGEN symlink, if any */
if (udev->ugen_symlink) {
-#if USB_HAVE_UGEN
usb2_free_symlink(udev->ugen_symlink);
-#endif
udev->ugen_symlink = NULL;
}
+#endif
/*
* Unregister our device first which will prevent any further
* references:
@@ -1873,7 +1874,6 @@ usb2_free_device(struct usb2_device *udev)
#if USB_HAVE_UGEN
/* wait for all pending references to go away: */
-
mtx_lock(&usb2_ref_lock);
udev->refcount--;
while (udev->refcount != 0) {
@@ -1923,7 +1923,9 @@ usb2_free_device(struct usb2_device *udev)
usb2_cv_destroy(udev->default_cv + 1);
mtx_destroy(udev->default_mtx);
+#if USB_HAVE_UGEN
KASSERT(LIST_FIRST(&udev->pd_list) == NULL, ("leaked cdev entries"));
+#endif
/* free device */
free(udev, M_USB);
@@ -2026,14 +2028,24 @@ usb2_devinfo(struct usb2_device *udev, char *dst_ptr, uint16_t dst_len)
if (udd->bDeviceClass != 0xFF) {
snprintf(dst_ptr, dst_len, "%s %s, class %d/%d, rev %x.%02x/"
- "%x.%02x, addr %d", udev->manufacturer, udev->product,
+ "%x.%02x, addr %d",
+#if USB_HAVE_STRINGS
+ udev->manufacturer, udev->product,
+#else
+ "-", "-",
+#endif
udd->bDeviceClass, udd->bDeviceSubClass,
(bcdUSB >> 8), bcdUSB & 0xFF,
(bcdDevice >> 8), bcdDevice & 0xFF,
udev->address);
} else {
snprintf(dst_ptr, dst_len, "%s %s, rev %x.%02x/"
- "%x.%02x, addr %d", udev->manufacturer, udev->product,
+ "%x.%02x, addr %d",
+#if USB_HAVE_STRINGS
+ udev->manufacturer, udev->product,
+#else
+ "-", "-",
+#endif
(bcdUSB >> 8), bcdUSB & 0xFF,
(bcdDevice >> 8), bcdDevice & 0xFF,
udev->address);
@@ -2230,6 +2242,7 @@ usb2_get_device_index(struct usb2_device *udev)
return (udev->device_index);
}
+#if USB_HAVE_UGEN
/*------------------------------------------------------------------------*
* usb2_notify_addq
*
@@ -2271,35 +2284,19 @@ usb2_notify_addq(const char *type, struct usb2_device *udev)
UGETW(udev->ddesc.idProduct),
udev->ddesc.bDeviceClass,
udev->ddesc.bDeviceSubClass,
+#if USB_HAVE_STRINGS
udev->serial,
+#else
+ "",
+#endif
udev->port_no,
- udev->parent_hub->ugen_name);
- } else {
- snprintf(data, 1024,
- "%s"
- "%s "
- "vendor=0x%04x "
- "product=0x%04x "
- "devclass=0x%02x "
- "devsubclass=0x%02x "
- "sernum=\"%s\" "
- "at port=%u "
- "on "
- "%s\n",
- type,
- udev->ugen_name,
- UGETW(udev->ddesc.idVendor),
- UGETW(udev->ddesc.idProduct),
- udev->ddesc.bDeviceClass,
- udev->ddesc.bDeviceSubClass,
- udev->serial,
- udev->port_no,
- device_get_nameunit(device_get_parent(udev->bus->bdev)));
+ udev->parent_hub != NULL ?
+ udev->parent_hub->ugen_name :
+ device_get_nameunit(device_get_parent(udev->bus->bdev)));
}
devctl_queue_data(data);
}
-#if USB_HAVE_UGEN
/*------------------------------------------------------------------------*
* usb2_fifo_free_wrap
*
diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h
index 29d3aa9..85216f0 100644
--- a/sys/dev/usb/usb_device.h
+++ b/sys/dev/usb/usb_device.h
@@ -27,7 +27,7 @@
#ifndef _USB2_DEVICE_H_
#define _USB2_DEVICE_H_
-struct usb2_symlink;
+struct usb2_symlink; /* UGEN */
struct usb_device; /* linux compat */
#define USB_DEFAULT_XFER_MAX 2
@@ -121,13 +121,12 @@ struct usb2_device {
struct usb2_xfer *default_xfer[USB_DEFAULT_XFER_MAX];
struct usb2_temp_data *usb2_template_ptr;
struct usb2_pipe *pipe_curr; /* current clear stall pipe */
+#if USB_HAVE_UGEN
struct usb2_fifo *fifo[USB_FIFO_MAX];
-
- char ugen_name[20]; /* name of ugenX.X device */
struct usb2_symlink *ugen_symlink; /* our generic symlink */
-
LIST_HEAD(,usb2_fs_privdata) pd_list;
-
+ char ugen_name[20]; /* name of ugenX.X device */
+#endif
usb2_ticks_t plugtime; /* copy of "ticks" */
uint16_t refcount;
@@ -156,9 +155,11 @@ struct usb2_device {
struct usb2_endpoint_descriptor default_ep_desc; /* for pipe 0 */
struct usb2_device_descriptor ddesc; /* device descriptor */
+#if USB_HAVE_STRINGS
char serial[64]; /* serial number */
char manufacturer[64]; /* manufacturer string */
char product[64]; /* product string */
+#endif
};
/* globals */
diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c
index bdb19ba..f401022 100644
--- a/sys/dev/usb/usb_generic.c
+++ b/sys/dev/usb/usb_generic.c
@@ -47,6 +47,8 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
+#if USB_HAVE_UGEN
+
/* defines */
#define UGEN_BULK_FS_BUFFER_SIZE (64*32) /* bytes */
@@ -799,12 +801,14 @@ usb2_gen_fill_deviceinfo(struct usb2_fifo *f, struct usb2_device_info *di)
di->udi_bus = device_get_unit(udev->bus->bdev);
di->udi_addr = udev->address;
di->udi_index = udev->device_index;
+#if USB_HAVE_STRINGS
strlcpy(di->udi_serial, udev->serial,
sizeof(di->udi_serial));
strlcpy(di->udi_vendor, udev->manufacturer,
sizeof(di->udi_vendor));
strlcpy(di->udi_product, udev->product,
sizeof(di->udi_product));
+#endif
usb2_printBCD(di->udi_release, sizeof(di->udi_release),
UGETW(udev->ddesc.bcdDevice));
di->udi_vendorNo = UGETW(udev->ddesc.idVendor);
@@ -2183,3 +2187,4 @@ ugen_default_fs_callback(struct usb2_xfer *xfer)
break;
}
}
+#endif /* USB_HAVE_UGEN */
diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c
index e08f492..a720261 100644
--- a/sys/dev/usb/usb_hub.c
+++ b/sys/dev/usb/usb_hub.c
@@ -978,7 +978,11 @@ uhub_child_pnpinfo_string(device_t parent, device_t child,
UGETW(res.udev->ddesc.idProduct),
res.udev->ddesc.bDeviceClass,
res.udev->ddesc.bDeviceSubClass,
+#if USB_HAVE_STRINGS
res.udev->serial,
+#else
+ "",
+#endif
iface->idesc->bInterfaceClass,
iface->idesc->bInterfaceSubClass);
} else {
diff --git a/sys/dev/usb/usb_util.c b/sys/dev/usb/usb_util.c
index b07630f..5eba73c 100644
--- a/sys/dev/usb/usb_util.c
+++ b/sys/dev/usb/usb_util.c
@@ -167,7 +167,6 @@ usb2_pause_mtx(struct mtx *mtx, int _ticks)
* pointed to by "p" having a maximum length of "p_len" bytes
* including the terminating zero.
*------------------------------------------------------------------------*/
-#if USB_HAVE_STRINGS
void
usb2_printBCD(char *p, uint16_t p_len, uint16_t bcd)
{
@@ -175,7 +174,6 @@ usb2_printBCD(char *p, uint16_t p_len, uint16_t bcd)
/* ignore any errors */
}
}
-#endif
/*------------------------------------------------------------------------*
* usb2_trim_spaces
OpenPOWER on IntegriCloud