PERFORCE change 128798 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Nov 7 15:59:01 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=128798
Change 128798 by hselasky at hselasky_laptop001 on 2007/11/07 23:58:17
Style all of the USB code according to the following script.
I've added a new option to "indent", "-ta", that automatically
will recognise all keywords ending in "_t" or "_T" like
typedefs.
Changes in object files after this commit are due to new
line numbers following the use of __LINE__ in the code.
indent -Toss_mixerinfo -TFILE -Tu_char -Tu_int -Tu_long \
-Tu_short -Tfd_set -ta -st -bad -bap -nbbb -nbc -br -nbs \
-c41 -cd41 -cdb -ce -ci4 -cli0 -d0 -di8 -ndj -ei -nfc1 \
-nfcb -i8 -ip8 -l79 -lc77 -ldi0 -nlp -npcs -psl -sc \
-nsob -nv |
sed -e "s/ __packed/ __packed/g" |
sed -e "s/ __aligned/ __aligned/g"
Affected files ...
.. //depot/projects/usb/src/sys/arm/at91/ohci_atmelarm.c#5 edit
.. //depot/projects/usb/src/sys/dev/ata/ata-usb.c#21 edit
.. //depot/projects/usb/src/sys/dev/if_ndis/if_ndis_usb.c#5 edit
.. //depot/projects/usb/src/sys/dev/sound/usb/uaudio.c#20 edit
.. //depot/projects/usb/src/sys/dev/sound/usb/uaudio.h#6 edit
.. //depot/projects/usb/src/sys/dev/sound/usb/uaudio_pcm.c#8 edit
.. //depot/projects/usb/src/sys/dev/sound/usb/uaudioreg.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/ehci.c#45 edit
.. //depot/projects/usb/src/sys/dev/usb/ehci.h#18 edit
.. //depot/projects/usb/src/sys/dev/usb/ehci_pci.c#23 edit
.. //depot/projects/usb/src/sys/dev/usb/if_aue.c#33 edit
.. //depot/projects/usb/src/sys/dev/usb/if_auereg.h#13 edit
.. //depot/projects/usb/src/sys/dev/usb/if_axe.c#34 edit
.. //depot/projects/usb/src/sys/dev/usb/if_axereg.h#16 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#27 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cdcereg.h#13 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cue.c#29 edit
.. //depot/projects/usb/src/sys/dev/usb/if_cuereg.h#12 edit
.. //depot/projects/usb/src/sys/dev/usb/if_kue.c#31 edit
.. //depot/projects/usb/src/sys/dev/usb/if_kuefw.h#6 edit
.. //depot/projects/usb/src/sys/dev/usb/if_kuereg.h#11 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rue.c#29 edit
.. //depot/projects/usb/src/sys/dev/usb/if_ruereg.h#12 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rum.c#13 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rumfw.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rumreg.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/if_rumvar.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/if_udav.c#30 edit
.. //depot/projects/usb/src/sys/dev/usb/if_udavreg.h#10 edit
.. //depot/projects/usb/src/sys/dev/usb/if_ural.c#37 edit
.. //depot/projects/usb/src/sys/dev/usb/if_uralreg.h#15 edit
.. //depot/projects/usb/src/sys/dev/usb/if_uralvar.h#19 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zyd.c#19 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zydfw.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/if_zydreg.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/ohci.c#35 edit
.. //depot/projects/usb/src/sys/dev/usb/ohci.h#14 edit
.. //depot/projects/usb/src/sys/dev/usb/ohci_pci.c#23 edit
.. //depot/projects/usb/src/sys/dev/usb/rio500_usb.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/uark.c#10 edit
.. //depot/projects/usb/src/sys/dev/usb/ubsa.c#27 edit
.. //depot/projects/usb/src/sys/dev/usb/ubser.c#19 edit
.. //depot/projects/usb/src/sys/dev/usb/ucom.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/ucomvar.h#14 edit
.. //depot/projects/usb/src/sys/dev/usb/ucycom.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/udbp.c#16 edit
.. //depot/projects/usb/src/sys/dev/usb/udbp.h#8 edit
.. //depot/projects/usb/src/sys/dev/usb/ufm.c#16 edit
.. //depot/projects/usb/src/sys/dev/usb/ufoma.c#26 edit
.. //depot/projects/usb/src/sys/dev/usb/uftdi.c#24 edit
.. //depot/projects/usb/src/sys/dev/usb/uftdireg.h#6 edit
.. //depot/projects/usb/src/sys/dev/usb/ugen.c#26 edit
.. //depot/projects/usb/src/sys/dev/usb/ugensa.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/uhci.c#37 edit
.. //depot/projects/usb/src/sys/dev/usb/uhci.h#15 edit
.. //depot/projects/usb/src/sys/dev/usb/uhci_pci.c#22 edit
.. //depot/projects/usb/src/sys/dev/usb/uhid.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/uhub.c#20 edit
.. //depot/projects/usb/src/sys/dev/usb/uipaq.c#10 edit
.. //depot/projects/usb/src/sys/dev/usb/ukbd.c#25 edit
.. //depot/projects/usb/src/sys/dev/usb/ulpt.c#26 edit
.. //depot/projects/usb/src/sys/dev/usb/umass.c#28 edit
.. //depot/projects/usb/src/sys/dev/usb/umct.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/umodem.c#30 edit
.. //depot/projects/usb/src/sys/dev/usb/umoscom.c#8 edit
.. //depot/projects/usb/src/sys/dev/usb/ums.c#26 edit
.. //depot/projects/usb/src/sys/dev/usb/uplcom.c#28 edit
.. //depot/projects/usb/src/sys/dev/usb/urio.c#16 edit
.. //depot/projects/usb/src/sys/dev/usb/usb.c#21 edit
.. //depot/projects/usb/src/sys/dev/usb/usb.h#18 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_cdc.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_cdev.c#18 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_compat_linux.c#9 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_compat_linux.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_hid.c#8 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_hid.h#8 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_port.h#19 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_quirks.c#14 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_quirks.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_requests.c#9 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#46 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#48 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#37 edit
.. //depot/projects/usb/src/sys/dev/usb/usbhid.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/uscanner.c#13 edit
.. //depot/projects/usb/src/sys/dev/usb/uss820_dci.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb/uss820_dci.h#3 edit
.. //depot/projects/usb/src/sys/dev/usb/uss820_dci_pci.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb/uvisor.c#22 edit
.. //depot/projects/usb/src/sys/dev/usb/uvscom.c#27 edit
.. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c#17 edit
.. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h#10 edit
.. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c#13 edit
.. //depot/projects/usb/src/sys/sys/videodev.h#5 edit
.. //depot/projects/usb/src/sys/sys/videokern.h#5 edit
Differences ...
==== //depot/projects/usb/src/sys/arm/at91/ohci_atmelarm.c#5 (text) ====
@@ -38,7 +38,7 @@
#include <dev/usb/usb_port.h>
#include <dev/usb/usb.h>
#include <dev/usb/usb_subr.h>
-#include <dev/usb/ohci.h>
+#include <dev/usb/ohci.h>
#include <arm/at91/at91_pmcvar.h>
@@ -49,7 +49,7 @@
static device_detach_t ohci_atmelarm_detach;
struct at91_ohci_softc {
- struct ohci_softc sc_ohci; /* must be first */
+ struct ohci_softc sc_ohci; /* must be first */
struct at91_pmc_clock *iclk;
struct at91_pmc_clock *fclk;
};
@@ -71,31 +71,28 @@
if (sc == NULL) {
return ENXIO;
}
-
sc->sc_ohci.sc_hw_ptr =
- usbd_mem_alloc(device_get_dma_tag(dev),
+ usbd_mem_alloc(device_get_dma_tag(dev),
&(sc->sc_ohci.sc_hw_page), sizeof(*(sc->sc_ohci.sc_hw_ptr)),
LOG2(OHCI_HCCA_ALIGN));
if (sc->sc_ohci.sc_hw_ptr == NULL) {
return ENXIO;
}
-
- sc->iclk = at91_pmc_clock_ref("ohci_clk");
+ sc->iclk = at91_pmc_clock_ref("ohci_clk");
sc->fclk = at91_pmc_clock_ref("uhpck");
mtx_init(&(sc->sc_ohci.sc_bus.mtx), "usb lock",
- NULL, MTX_DEF|MTX_RECURSE);
+ NULL, MTX_DEF | MTX_RECURSE);
sc->sc_ohci.sc_dev = dev;
sc->sc_ohci.sc_bus.dma_tag = usbd_dma_tag_alloc(device_get_dma_tag(dev),
- USB_PAGE_SIZE, USB_PAGE_SIZE);
+ USB_PAGE_SIZE, USB_PAGE_SIZE);
if (sc->sc_ohci.sc_bus.dma_tag == NULL) {
goto error;
}
-
rid = MEM_RID;
sc->sc_ohci.sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&rid, RF_ACTIVE);
@@ -114,34 +111,31 @@
if (!(sc->sc_ohci.sc_irq_res)) {
goto error;
}
-
sc->sc_ohci.sc_bus.bdev = device_add_child(dev, "usb", -1);
if (!(sc->sc_ohci.sc_bus.bdev)) {
goto error;
}
-
device_set_ivars(sc->sc_ohci.sc_bus.bdev, &(sc->sc_ohci.sc_bus));
device_set_softc(sc->sc_ohci.sc_bus.bdev, &(sc->sc_ohci.sc_bus));
strlcpy(sc->sc_ohci.sc_vendor, "Atmel", sizeof(sc->sc_ohci.sc_vendor));
#if (__FreeBSD_version >= 700031)
- err = bus_setup_intr(dev, sc->sc_ohci.sc_irq_res, INTR_TYPE_BIO|INTR_MPSAFE,
+ err = bus_setup_intr(dev, sc->sc_ohci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
NULL, (void *)(void *)ohci_interrupt, sc, &(sc->sc_ohci.sc_intr_hdl));
#else
- err = bus_setup_intr(dev, sc->sc_ohci.sc_irq_res, INTR_TYPE_BIO|INTR_MPSAFE,
+ err = bus_setup_intr(dev, sc->sc_ohci.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
(void *)(void *)ohci_interrupt, sc, &(sc->sc_ohci.sc_intr_hdl));
#endif
if (err) {
sc->sc_ohci.sc_intr_hdl = NULL;
goto error;
}
-
/*
* turn on the clocks from the AT91's point of view. Keep the unit in reset.
*/
-// bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
-// OHCI_CONTROL, 0);
+ //bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
+ //OHCI_CONTROL, 0);
at91_pmc_clock_enable(sc->iclk);
at91_pmc_clock_enable(sc->fclk);
bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
@@ -151,13 +145,12 @@
if (!err) {
err = device_probe_and_attach(sc->sc_ohci.sc_bus.bdev);
}
-
if (err) {
goto error;
}
return 0;
- error:
+error:
ohci_atmelarm_detach(dev);
return ENXIO;
}
@@ -173,7 +166,6 @@
device_delete_child(dev, sc->sc_ohci.sc_bus.bdev);
sc->sc_ohci.sc_bus.bdev = NULL;
}
-
/* during module unload there are lots of children leftover */
device_delete_all_children(dev);
@@ -186,7 +178,7 @@
* clocks after we disable them, so the system could, in
* theory, reuse them.
*/
- bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
+ bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
OHCI_CONTROL, 0);
at91_pmc_clock_disable(sc->fclk);
@@ -195,30 +187,26 @@
at91_pmc_clock_deref(sc->iclk);
if (sc->sc_ohci.sc_irq_res && sc->sc_ohci.sc_intr_hdl) {
- /* only call ohci_detach()
- * after ohci_init()
+ /*
+ * only call ohci_detach() after ohci_init()
*/
ohci_detach(&(sc->sc_ohci));
err = bus_teardown_intr(dev, sc->sc_ohci.sc_irq_res, sc->sc_ohci.sc_intr_hdl);
sc->sc_ohci.sc_intr_hdl = NULL;
}
-
if (sc->sc_ohci.sc_irq_res) {
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_ohci.sc_irq_res);
sc->sc_ohci.sc_irq_res = NULL;
}
-
if (sc->sc_ohci.sc_io_res) {
bus_release_resource(dev, SYS_RES_MEMORY, MEM_RID,
sc->sc_ohci.sc_io_res);
sc->sc_ohci.sc_io_res = NULL;
}
-
if (sc->sc_ohci.sc_bus.dma_tag) {
usbd_dma_tag_free(sc->sc_ohci.sc_bus.dma_tag);
}
-
mtx_destroy(&(sc->sc_ohci.sc_bus.mtx));
usbd_mem_free(&(sc->sc_ohci.sc_hw_page));
==== //depot/projects/usb/src/sys/dev/ata/ata-usb.c#21 (text) ====
@@ -52,44 +52,44 @@
/* Command Block Wrapper */
struct bbb_cbw {
- uint8_t signature[4];
+ uint8_t signature[4];
#define CBWSIGNATURE 0x43425355
- uint8_t tag[4];
- uint8_t transfer_length[4];
- uint8_t flags;
+ uint8_t tag[4];
+ uint8_t transfer_length[4];
+ uint8_t flags;
#define CBWFLAGS_OUT 0x00
#define CBWFLAGS_IN 0x80
- uint8_t lun;
- uint8_t length;
+ uint8_t lun;
+ uint8_t length;
#define CBWCDBLENGTH 16
- uint8_t cdb[CBWCDBLENGTH];
-} UPACKED;
+ uint8_t cdb[CBWCDBLENGTH];
+} UPACKED;
/* Command Status Wrapper */
struct bbb_csw {
- uint8_t signature[4];
+ uint8_t signature[4];
#define CSWSIGNATURE 0x53425355
- uint8_t tag[4];
- uint8_t residue[4];
- uint8_t status;
+ uint8_t tag[4];
+ uint8_t residue[4];
+ uint8_t status;
#define CSWSTATUS_GOOD 0x0
#define CSWSTATUS_FAILED 0x1
#define CSWSTATUS_PHASE 0x2
-} UPACKED;
+} UPACKED;
/* USB-ATA 'controller' softc */
struct atausb_softc {
- struct bbb_cbw cbw;
- struct bbb_csw csw;
- struct mtx locked_mtx;
+ struct bbb_cbw cbw;
+ struct bbb_csw csw;
+ struct mtx locked_mtx;
- struct ata_channel *locked_ch;
- struct ata_channel *restart_ch;
- struct ata_request *ata_request;
+ struct ata_channel *locked_ch;
+ struct ata_channel *restart_ch;
+ struct ata_request *ata_request;
#define ATAUSB_T_BBB_RESET1 0
#define ATAUSB_T_BBB_RESET2 1
@@ -104,20 +104,20 @@
#define ATAUSB_T_MAX ATAUSB_T_BBB_MAX
- struct usbd_xfer * xfer[ATAUSB_T_MAX];
- caddr_t ata_data;
- device_t dev;
+ struct usbd_xfer *xfer[ATAUSB_T_MAX];
+ caddr_t ata_data;
+ device_t dev;
- uint32_t timeout;
- uint32_t ata_donecount;
- uint32_t ata_bytecount;
+ uint32_t timeout;
+ uint32_t ata_donecount;
+ uint32_t ata_bytecount;
- uint8_t last_xfer_no;
- uint8_t usb_speed;
- uint8_t intr_stalled;
- uint8_t maxlun;
- uint8_t iface_no;
- uint8_t status_try;
+ uint8_t last_xfer_no;
+ uint8_t usb_speed;
+ uint8_t intr_stalled;
+ uint8_t maxlun;
+ uint8_t iface_no;
+ uint8_t status_try;
};
static const int atausbdebug = 0;
@@ -142,17 +142,17 @@
static void atausb_cancel_request(struct atausb_softc *sc);
static void
-atausb_transfer_start(struct atausb_softc *sc, uint8_t xfer_no);
+ atausb_transfer_start(struct atausb_softc *sc, uint8_t xfer_no);
static void
atausb_t_bbb_data_clear_stall_callback(struct usbd_xfer *xfer,
- uint8_t next_xfer,
- uint8_t stall_xfer);
+ uint8_t next_xfer,
+ uint8_t stall_xfer);
static int
-ata_usbchannel_begin_transaction(struct ata_request *request);
+ ata_usbchannel_begin_transaction(struct ata_request *request);
static int
-ata_usbchannel_end_transaction(struct ata_request *request);
+ ata_usbchannel_end_transaction(struct ata_request *request);
static device_probe_t ata_usbchannel_probe;
static device_attach_t ata_usbchannel_attach;
@@ -167,113 +167,113 @@
struct usbd_config atausb_config[ATAUSB_T_BBB_MAX] = {
- [ATAUSB_T_BBB_RESET1] = {
- .type = UE_CONTROL,
- .endpoint = 0x00, /* Control pipe */
- .direction = UE_DIR_ANY,
- .bufsize = sizeof(usb_device_request_t),
- .flags = { },
- .callback = &atausb_t_bbb_reset1_callback,
- .timeout = 5000, /* 5 seconds */
- .interval = 500, /* 500 milliseconds */
- },
+ [ATAUSB_T_BBB_RESET1] = {
+ .type = UE_CONTROL,
+ .endpoint = 0x00, /* Control pipe */
+ .direction = UE_DIR_ANY,
+ .bufsize = sizeof(usb_device_request_t),
+ .flags = {},
+ .callback = &atausb_t_bbb_reset1_callback,
+ .timeout = 5000, /* 5 seconds */
+ .interval = 500, /* 500 milliseconds */
+ },
- [ATAUSB_T_BBB_RESET2] = {
- .type = UE_CONTROL,
- .endpoint = 0x00, /* Control pipe */
- .direction = UE_DIR_ANY,
- .bufsize = sizeof(usb_device_request_t),
- .flags = { },
- .callback = &atausb_t_bbb_reset2_callback,
- .timeout = 5000, /* 5 seconds */
- .interval = 50, /* 50 milliseconds */
- },
+ [ATAUSB_T_BBB_RESET2] = {
+ .type = UE_CONTROL,
+ .endpoint = 0x00, /* Control pipe */
+ .direction = UE_DIR_ANY,
+ .bufsize = sizeof(usb_device_request_t),
+ .flags = {},
+ .callback = &atausb_t_bbb_reset2_callback,
+ .timeout = 5000, /* 5 seconds */
+ .interval = 50, /* 50 milliseconds */
+ },
- [ATAUSB_T_BBB_RESET3] = {
- .type = UE_CONTROL,
- .endpoint = 0x00, /* Control pipe */
- .direction = UE_DIR_ANY,
- .bufsize = sizeof(usb_device_request_t),
- .flags = { },
- .callback = &atausb_t_bbb_reset3_callback,
- .timeout = 5000, /* 5 seconds */
- .interval = 50, /* 50 milliseconds */
- },
+ [ATAUSB_T_BBB_RESET3] = {
+ .type = UE_CONTROL,
+ .endpoint = 0x00, /* Control pipe */
+ .direction = UE_DIR_ANY,
+ .bufsize = sizeof(usb_device_request_t),
+ .flags = {},
+ .callback = &atausb_t_bbb_reset3_callback,
+ .timeout = 5000, /* 5 seconds */
+ .interval = 50, /* 50 milliseconds */
+ },
- [ATAUSB_T_BBB_COMMAND] = {
- .type = UE_BULK,
- .endpoint = UE_ADDR_ANY,
- .direction = UE_DIR_OUT,
- .bufsize = sizeof(struct bbb_cbw),
- .flags = { },
- .callback = &atausb_t_bbb_command_callback,
- .timeout = 5000, /* 5 seconds */
- },
+ [ATAUSB_T_BBB_COMMAND] = {
+ .type = UE_BULK,
+ .endpoint = UE_ADDR_ANY,
+ .direction = UE_DIR_OUT,
+ .bufsize = sizeof(struct bbb_cbw),
+ .flags = {},
+ .callback = &atausb_t_bbb_command_callback,
+ .timeout = 5000, /* 5 seconds */
+ },
- [ATAUSB_T_BBB_DATA_READ] = {
- .type = UE_BULK,
- .endpoint = UE_ADDR_ANY,
- .direction = UE_DIR_IN,
- .bufsize = ATAUSB_BULK_SIZE,
- .flags = { .proxy_buffer = 1, .short_xfer_ok = 1, },
- .callback = &atausb_t_bbb_data_read_callback,
- .timeout = 0, /* overwritten later */
- },
+ [ATAUSB_T_BBB_DATA_READ] = {
+ .type = UE_BULK,
+ .endpoint = UE_ADDR_ANY,
+ .direction = UE_DIR_IN,
+ .bufsize = ATAUSB_BULK_SIZE,
+ .flags = {.proxy_buffer = 1,.short_xfer_ok = 1,},
+ .callback = &atausb_t_bbb_data_read_callback,
+ .timeout = 0, /* overwritten later */
+ },
- [ATAUSB_T_BBB_DATA_RD_CS] = {
- .type = UE_CONTROL,
- .endpoint = 0x00, /* Control pipe */
- .direction = UE_DIR_ANY,
- .bufsize = sizeof(usb_device_request_t),
- .flags = { },
- .callback = &atausb_t_bbb_data_rd_cs_callback,
- .timeout = 5000, /* 5 seconds */
- },
+ [ATAUSB_T_BBB_DATA_RD_CS] = {
+ .type = UE_CONTROL,
+ .endpoint = 0x00, /* Control pipe */
+ .direction = UE_DIR_ANY,
+ .bufsize = sizeof(usb_device_request_t),
+ .flags = {},
+ .callback = &atausb_t_bbb_data_rd_cs_callback,
+ .timeout = 5000, /* 5 seconds */
+ },
- [ATAUSB_T_BBB_DATA_WRITE] = {
- .type = UE_BULK,
- .endpoint = UE_ADDR_ANY,
- .direction = UE_DIR_OUT,
- .bufsize = ATAUSB_BULK_SIZE,
- .flags = { .proxy_buffer = 1, .short_xfer_ok = 1, },
- .callback = &atausb_t_bbb_data_write_callback,
- .timeout = 0, /* overwritten later */
- },
+ [ATAUSB_T_BBB_DATA_WRITE] = {
+ .type = UE_BULK,
+ .endpoint = UE_ADDR_ANY,
+ .direction = UE_DIR_OUT,
+ .bufsize = ATAUSB_BULK_SIZE,
+ .flags = {.proxy_buffer = 1,.short_xfer_ok = 1,},
+ .callback = &atausb_t_bbb_data_write_callback,
+ .timeout = 0, /* overwritten later */
+ },
- [ATAUSB_T_BBB_DATA_WR_CS] = {
- .type = UE_CONTROL,
- .endpoint = 0x00, /* Control pipe */
- .direction = UE_DIR_ANY,
- .bufsize = sizeof(usb_device_request_t),
- .flags = { },
- .callback = &atausb_t_bbb_data_wr_cs_callback,
- .timeout = 5000, /* 5 seconds */
- },
+ [ATAUSB_T_BBB_DATA_WR_CS] = {
+ .type = UE_CONTROL,
+ .endpoint = 0x00, /* Control pipe */
+ .direction = UE_DIR_ANY,
+ .bufsize = sizeof(usb_device_request_t),
+ .flags = {},
+ .callback = &atausb_t_bbb_data_wr_cs_callback,
+ .timeout = 5000, /* 5 seconds */
+ },
- [ATAUSB_T_BBB_STATUS] = {
- .type = UE_BULK,
- .endpoint = UE_ADDR_ANY,
- .direction = UE_DIR_IN,
- .bufsize = sizeof(struct bbb_csw),
- .flags = { .short_xfer_ok = 1, },
- .callback = &atausb_t_bbb_status_callback,
- .timeout = 5000, /* ms */
- },
+ [ATAUSB_T_BBB_STATUS] = {
+ .type = UE_BULK,
+ .endpoint = UE_ADDR_ANY,
+ .direction = UE_DIR_IN,
+ .bufsize = sizeof(struct bbb_csw),
+ .flags = {.short_xfer_ok = 1,},
+ .callback = &atausb_t_bbb_status_callback,
+ .timeout = 5000, /* ms */
+ },
};
static devclass_t atausb_devclass;
static device_method_t atausb_methods[] = {
- DEVMETHOD(device_probe, atausb_probe),
- DEVMETHOD(device_attach, atausb_attach),
- DEVMETHOD(device_detach, atausb_detach),
- { 0, 0 }
+ DEVMETHOD(device_probe, atausb_probe),
+ DEVMETHOD(device_attach, atausb_attach),
+ DEVMETHOD(device_detach, atausb_detach),
+ {0, 0}
};
static driver_t atausb_driver = {
- .name = "atausb",
- .methods = atausb_methods,
- .size = sizeof(struct atausb_softc),
+ .name = "atausb",
+ .methods = atausb_methods,
+ .size = sizeof(struct atausb_softc),
};
DRIVER_MODULE(atausb, uhub, atausb_driver, atausb_devclass, 0, 0);
@@ -283,854 +283,832 @@
static int
atausb_probe(device_t dev)
{
- struct usb_attach_arg *uaa = device_get_ivars(dev);
- usb_interface_descriptor_t *id;
+ struct usb_attach_arg *uaa = device_get_ivars(dev);
+ usb_interface_descriptor_t *id;
- if (uaa->iface == NULL) {
- return UMATCH_NONE;
- }
-
- id = usbd_get_interface_descriptor(uaa->iface);
- if ((!id) || (id->bInterfaceClass != UICLASS_MASS)) {
- return UMATCH_NONE;
- }
-
- switch (id->bInterfaceSubClass) {
- case UISUBCLASS_QIC157:
- case UISUBCLASS_RBC:
- case UISUBCLASS_SCSI:
- case UISUBCLASS_SFF8020I:
- case UISUBCLASS_SFF8070I:
- case UISUBCLASS_UFI:
- switch (id->bInterfaceProtocol) {
- case UIPROTO_MASS_CBI:
- case UIPROTO_MASS_CBI_I:
- case UIPROTO_MASS_BBB:
- case UIPROTO_MASS_BBB_OLD:
- return UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+ if (uaa->iface == NULL) {
+ return UMATCH_NONE;
+ }
+ id = usbd_get_interface_descriptor(uaa->iface);
+ if ((!id) || (id->bInterfaceClass != UICLASS_MASS)) {
+ return UMATCH_NONE;
+ }
+ switch (id->bInterfaceSubClass) {
+ case UISUBCLASS_QIC157:
+ case UISUBCLASS_RBC:
+ case UISUBCLASS_SCSI:
+ case UISUBCLASS_SFF8020I:
+ case UISUBCLASS_SFF8070I:
+ case UISUBCLASS_UFI:
+ switch (id->bInterfaceProtocol) {
+ case UIPROTO_MASS_CBI:
+ case UIPROTO_MASS_CBI_I:
+ case UIPROTO_MASS_BBB:
+ case UIPROTO_MASS_BBB_OLD:
+ return UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+ default:
+ return UMATCH_IFACECLASS_IFACESUBCLASS;
+ }
+ break;
default:
- return UMATCH_IFACECLASS_IFACESUBCLASS;
+ return UMATCH_IFACECLASS;
}
- break;
- default:
- return UMATCH_IFACECLASS;
- }
}
static int
atausb_attach(device_t dev)
{
- struct atausb_softc *sc = device_get_softc(dev);
- struct usb_attach_arg *uaa = device_get_ivars(dev);
- usb_interface_descriptor_t *id;
- const char *proto, *subclass;
- usb_device_request_t request;
- uint16_t i;
- uint8_t maxlun;
- uint8_t has_intr;
- int err;
+ struct atausb_softc *sc = device_get_softc(dev);
+ struct usb_attach_arg *uaa = device_get_ivars(dev);
+ usb_interface_descriptor_t *id;
+ const char *proto, *subclass;
+ usb_device_request_t request;
+ uint16_t i;
+ uint8_t maxlun;
+ uint8_t has_intr;
+ int err;
- if (sc == NULL) {
- return ENOMEM;
- }
+ if (sc == NULL) {
+ return ENOMEM;
+ }
+ usbd_set_desc(dev, uaa->device);
- usbd_set_desc(dev, uaa->device);
+ sc->dev = dev;
+ sc->maxlun = 0;
+ sc->locked_ch = NULL;
+ sc->restart_ch = NULL;
+ sc->usb_speed = usbd_get_speed(uaa->device);
+ mtx_init(&(sc->locked_mtx), "ATAUSB lock", NULL, (MTX_DEF | MTX_RECURSE));
- sc->dev = dev;
- sc->maxlun = 0;
- sc->locked_ch = NULL;
- sc->restart_ch = NULL;
- sc->usb_speed = usbd_get_speed(uaa->device);
- mtx_init(&(sc->locked_mtx), "ATAUSB lock", NULL, (MTX_DEF|MTX_RECURSE));
+ id = usbd_get_interface_descriptor(uaa->iface);
+ switch (id->bInterfaceProtocol) {
+ case UIPROTO_MASS_BBB:
+ case UIPROTO_MASS_BBB_OLD:
+ proto = "Bulk-Only";
+ break;
+ case UIPROTO_MASS_CBI:
+ proto = "CBI";
+ break;
+ case UIPROTO_MASS_CBI_I:
+ proto = "CBI with CCI";
+ break;
+ default:
+ proto = "Unknown";
+ }
- id = usbd_get_interface_descriptor(uaa->iface);
- switch (id->bInterfaceProtocol) {
- case UIPROTO_MASS_BBB:
- case UIPROTO_MASS_BBB_OLD:
- proto = "Bulk-Only";
- break;
- case UIPROTO_MASS_CBI:
- proto = "CBI";
- break;
- case UIPROTO_MASS_CBI_I:
- proto = "CBI with CCI";
- break;
- default:
- proto = "Unknown";
- }
+ switch (id->bInterfaceSubClass) {
+ case UISUBCLASS_RBC:
+ subclass = "RBC";
+ break;
+ case UISUBCLASS_QIC157:
+ case UISUBCLASS_SFF8020I:
+ case UISUBCLASS_SFF8070I:
+ subclass = "ATAPI";
+ break;
+ case UISUBCLASS_SCSI:
+ subclass = "SCSI";
+ break;
+ case UISUBCLASS_UFI:
+ subclass = "UFI";
+ break;
+ default:
+ subclass = "Unknown";
+ }
- switch (id->bInterfaceSubClass) {
- case UISUBCLASS_RBC:
- subclass = "RBC";
- break;
- case UISUBCLASS_QIC157:
- case UISUBCLASS_SFF8020I:
- case UISUBCLASS_SFF8070I:
- subclass = "ATAPI";
- break;
- case UISUBCLASS_SCSI:
- subclass = "SCSI";
- break;
- case UISUBCLASS_UFI:
- subclass = "UFI";
- break;
- default:
- subclass = "Unknown";
- }
+ has_intr = (id->bInterfaceProtocol == UIPROTO_MASS_CBI_I);
+ sc->iface_no = id->bInterfaceNumber;
- has_intr = (id->bInterfaceProtocol == UIPROTO_MASS_CBI_I);
- sc->iface_no = id->bInterfaceNumber;
+ device_printf(dev, "using %s over %s\n", subclass, proto);
+ if (strcmp(proto, "Bulk-Only") ||
+ (strcmp(subclass, "ATAPI") && strcmp(subclass, "SCSI"))) {
+ goto detach;
+ }
+ err = usbd_transfer_setup(uaa->device, uaa->iface_index, sc->xfer,
+ atausb_config,
+ ATAUSB_T_BBB_MAX, sc,
+ &(sc->locked_mtx));
+ /* skip reset first time */
+ sc->last_xfer_no = ATAUSB_T_BBB_COMMAND;
- device_printf(dev, "using %s over %s\n", subclass, proto);
- if (strcmp(proto, "Bulk-Only") ||
- (strcmp(subclass, "ATAPI") && strcmp(subclass, "SCSI"))) {
- goto detach;
- }
+ if (err) {
+ device_printf(sc->dev, "could not setup required "
+ "transfers, %s\n", usbd_errstr(err));
+ goto detach;
+ }
+ /* get number of devices so we can add matching channels */
+ request.bmRequestType = UT_READ_CLASS_INTERFACE;
+ request.bRequest = 0xfe; /* GET_MAX_LUN; */
+ USETW(request.wValue, 0);
+ USETW(request.wIndex, sc->iface_no);
+ USETW(request.wLength, sizeof(maxlun));
+ err = usbd_do_request(uaa->device, &usb_global_lock, &request, &maxlun);
- err = usbd_transfer_setup(uaa->device, uaa->iface_index, sc->xfer,
- atausb_config,
- ATAUSB_T_BBB_MAX, sc,
- &(sc->locked_mtx));
- /* skip reset first time */
- sc->last_xfer_no = ATAUSB_T_BBB_COMMAND;
-
- if (err) {
- device_printf(sc->dev, "could not setup required "
- "transfers, %s\n", usbd_errstr(err));
- goto detach;
- }
-
- /* get number of devices so we can add matching channels */
- request.bmRequestType = UT_READ_CLASS_INTERFACE;
- request.bRequest = 0xfe; /* GET_MAX_LUN; */
- USETW(request.wValue, 0);
- USETW(request.wIndex, sc->iface_no);
- USETW(request.wLength, sizeof(maxlun));
- err = usbd_do_request(uaa->device, &usb_global_lock, &request, &maxlun);
-
- if (err) {
- if (bootverbose) {
- device_printf(sc->dev, "get maxlun not supported %s\n",
- usbd_errstr(err));
- }
- } else {
- sc->maxlun = maxlun;
- if (bootverbose) {
- device_printf(sc->dev, "maxlun=%d\n", sc->maxlun);
+ if (err) {
+ if (bootverbose) {
+ device_printf(sc->dev, "get maxlun not supported %s\n",
+ usbd_errstr(err));
+ }
+ } else {
+ sc->maxlun = maxlun;
+ if (bootverbose) {
+ device_printf(sc->dev, "maxlun=%d\n", sc->maxlun);
+ }
}
- }
- /* ata channels are children to this USB control device */
- for (i = 0; i <= sc->maxlun; i++) {
- if (!device_add_child(sc->dev, "ata",
- devclass_find_free_unit(ata_devclass, 2))) {
- device_printf(sc->dev, "failed to attach ata child device\n");
- goto detach;
+ /* ata channels are children to this USB control device */
+ for (i = 0; i <= sc->maxlun; i++) {
+ if (!device_add_child(sc->dev, "ata",
+ devclass_find_free_unit(ata_devclass, 2))) {
+ device_printf(sc->dev, "failed to attach ata child device\n");
+ goto detach;
+ }
}
- }
- bus_generic_attach(sc->dev);
+ bus_generic_attach(sc->dev);
- return 0;
+ return 0;
- detach:
- atausb_detach(dev);
- return ENXIO;
+detach:
+ atausb_detach(dev);
+ return ENXIO;
}
static int
atausb_detach(device_t dev)
{
- struct atausb_softc *sc = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
+ struct atausb_softc *sc = device_get_softc(dev);
+ device_t *children;
+ int nchildren, i;
- /* teardown our statemachine */
+ /* teardown our statemachine */
- usbd_transfer_unsetup(sc->xfer, ATAUSB_T_MAX);
+ usbd_transfer_unsetup(sc->xfer, ATAUSB_T_MAX);
- /* detach & delete all children, if any */
+ /* detach & delete all children, if any */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++) {
- device_delete_child(dev, children[i]);
+ if (!device_get_children(dev, &children, &nchildren)) {
+ for (i = 0; i < nchildren; i++) {
+ device_delete_child(dev, children[i]);
+ }
+ free(children, M_TEMP);
}
- free(children, M_TEMP);
- }
-
- mtx_destroy(&sc->locked_mtx);
- return 0;
+ mtx_destroy(&sc->locked_mtx);
+ return 0;
}
static void
atausb_transfer_start(struct atausb_softc *sc, uint8_t xfer_no)
{
- if (atausbdebug) {
- device_printf(sc->dev, "BBB transfer %d\n", xfer_no);
- }
-
- if (sc->xfer[xfer_no]) {
- sc->last_xfer_no = xfer_no;
- usbd_transfer_start(sc->xfer[xfer_no]);
- } else {
- atausb_cancel_request(sc);
- }
- return;
+ if (atausbdebug) {
+ device_printf(sc->dev, "BBB transfer %d\n", xfer_no);
+ }
+ if (sc->xfer[xfer_no]) {
+ sc->last_xfer_no = xfer_no;
+ usbd_transfer_start(sc->xfer[xfer_no]);
+ } else {
+ atausb_cancel_request(sc);
+ }
+ return;
}
static void
atausb_t_bbb_reset1_callback(struct usbd_xfer *xfer)
{
- struct atausb_softc *sc = xfer->priv_sc;
- usb_device_request_t req;
+ struct atausb_softc *sc = xfer->priv_sc;
+ usb_device_request_t req;
- switch (USBD_GET_STATE(xfer)) {
- case USBD_ST_TRANSFERRED:
- atausb_transfer_start(sc, ATAUSB_T_BBB_RESET2);
- return;
+ switch (USBD_GET_STATE(xfer)) {
+ case USBD_ST_TRANSFERRED:
+ atausb_transfer_start(sc, ATAUSB_T_BBB_RESET2);
+ return;
- case USBD_ST_SETUP:
- req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
- req.bRequest = 0xff; /* bulk-only reset */
- USETW(req.wValue, 0);
- req.wIndex[0] = sc->iface_no;
- req.wIndex[1] = 0;
- USETW(req.wLength, 0);
+ case USBD_ST_SETUP:
+ req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+ req.bRequest = 0xff; /* bulk-only reset */
+ USETW(req.wValue, 0);
+ req.wIndex[0] = sc->iface_no;
+ req.wIndex[1] = 0;
+ USETW(req.wLength, 0);
- usbd_copy_in(xfer->frbuffers + 0, 0, &req, sizeof(req));
+ usbd_copy_in(xfer->frbuffers + 0, 0, &req, sizeof(req));
- xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = 0;
+ xfer->frlengths[0] = sizeof(req);
+ xfer->frlengths[1] = 0;
- usbd_start_hardware(xfer);
- return;
+ usbd_start_hardware(xfer);
+ return;
- default: /* Error */
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list