summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2014-09-27 16:50:21 +0000
committerkan <kan@FreeBSD.org>2014-09-27 16:50:21 +0000
commitacfad8859d99e436df147d4a7b3da9013e513d9b (patch)
tree591bf7844340fed65d59a16ed4b1829b64b503a2
parente0eb5b421d714e77a02e28fc8058758db9bb0cb1 (diff)
downloadFreeBSD-src-acfad8859d99e436df147d4a7b3da9013e513d9b.zip
FreeBSD-src-acfad8859d99e436df147d4a7b3da9013e513d9b.tar.gz
Remove obsolete compatibility glue and improve firewire code readability.
Commit my version of style(9) pass over the firewire code. Now that other people have started changing the code carrying this is as a local patch is not longer a viable option. MFC after: 1 month
-rw-r--r--sys/boot/i386/libfirewire/fwohcireg.h2
-rw-r--r--sys/dev/firewire/firewire.c675
-rw-r--r--sys/dev/firewire/firewire.h20
-rw-r--r--sys/dev/firewire/firewire_phy.h2
-rw-r--r--sys/dev/firewire/firewirereg.h42
-rw-r--r--sys/dev/firewire/fwcrom.c82
-rw-r--r--sys/dev/firewire/fwdev.c138
-rw-r--r--sys/dev/firewire/fwdma.c30
-rw-r--r--sys/dev/firewire/fwdma.h16
-rw-r--r--sys/dev/firewire/fwmem.c63
-rw-r--r--sys/dev/firewire/fwohci.c522
-rw-r--r--sys/dev/firewire/fwohci_pci.c21
-rw-r--r--sys/dev/firewire/fwohcireg.h29
-rw-r--r--sys/dev/firewire/fwohcivar.h2
-rw-r--r--sys/dev/firewire/iec68113.h2
-rw-r--r--sys/dev/firewire/if_fwe.c23
-rw-r--r--sys/dev/firewire/if_fwip.c23
-rw-r--r--sys/dev/firewire/sbp.c185
-rw-r--r--sys/dev/firewire/sbp.h6
-rw-r--r--sys/dev/firewire/sbp_targ.c72
20 files changed, 940 insertions, 1015 deletions
diff --git a/sys/boot/i386/libfirewire/fwohcireg.h b/sys/boot/i386/libfirewire/fwohcireg.h
index d24f658..d57870c 100644
--- a/sys/boot/i386/libfirewire/fwohcireg.h
+++ b/sys/boot/i386/libfirewire/fwohcireg.h
@@ -235,7 +235,7 @@ struct ohci_registers {
fwohcireg_t config_rom; /* config ROM map 0x34 */
fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */
fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */
- fwohcireg_t vender; /* vender ID 0x40 */
+ fwohcireg_t vendor; /* vendor ID 0x40 */
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c
index ef4758c..c5f5dba 100644
--- a/sys/dev/firewire/firewire.c
+++ b/sys/dev/firewire/firewire.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kthread.h>
#include <sys/kdb.h>
-
#include <sys/bus.h> /* used by smbus and newbus */
#include <machine/bus.h>
@@ -65,7 +64,7 @@ struct crom_src_buf {
struct crom_chunk hw;
};
-int firewire_debug=0, try_bmr=1, hold_count=0;
+int firewire_debug = 0, try_bmr = 1, hold_count = 0;
SYSCTL_INT(_debug, OID_AUTO, firewire_debug, CTLFLAG_RW, &firewire_debug, 0,
"FireWire driver debug flag");
SYSCTL_NODE(_hw, OID_AUTO, firewire, CTLFLAG_RD, 0, "FireWire Subsystem");
@@ -81,19 +80,19 @@ MALLOC_DEFINE(M_FWXFER, "fw_xfer", "XFER/FireWire");
devclass_t firewire_devclass;
-static void firewire_identify (driver_t *, device_t);
-static int firewire_probe (device_t);
-static int firewire_attach (device_t);
-static int firewire_detach (device_t);
-static int firewire_resume (device_t);
+static void firewire_identify(driver_t *, device_t);
+static int firewire_probe(device_t);
+static int firewire_attach(device_t);
+static int firewire_detach(device_t);
+static int firewire_resume(device_t);
static void firewire_xfer_timeout(void *, int);
static device_t firewire_add_child(device_t, u_int, const char *, int);
-static void fw_try_bmr (void *);
-static void fw_try_bmr_callback (struct fw_xfer *);
-static void fw_asystart (struct fw_xfer *);
-static int fw_get_tlabel (struct firewire_comm *, struct fw_xfer *);
-static void fw_bus_probe (struct firewire_comm *);
-static void fw_attach_dev (struct firewire_comm *);
+static void fw_try_bmr(void *);
+static void fw_try_bmr_callback(struct fw_xfer *);
+static void fw_asystart(struct fw_xfer *);
+static int fw_get_tlabel(struct firewire_comm *, struct fw_xfer *);
+static void fw_bus_probe(void *);
+static void fw_attach_dev(struct firewire_comm *);
static void fw_bus_probe_thread(void *);
#ifdef FW_VMACCESS
static void fw_vmaccess (struct fw_xfer *);
@@ -116,6 +115,7 @@ static device_method_t firewire_methods[] = {
DEVMETHOD_END
};
+
char *linkspeed[] = {
"S100", "S200", "S400", "S800",
"S1600", "S3200", "undef", "undef"
@@ -174,8 +174,10 @@ fw_noderesolve_eui64(struct firewire_comm *fc, struct fw_eui64 *eui)
FW_GUNLOCK(fc);
splx(s);
- if(fwdev == NULL) return NULL;
- if(fwdev->status == FWDEVINVAL) return NULL;
+ if (fwdev == NULL)
+ return NULL;
+ if (fwdev->status == FWDEVINVAL)
+ return NULL;
return fwdev;
}
@@ -192,8 +194,9 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer)
int tcode;
struct tcode_info *info;
- if(xfer == NULL) return EINVAL;
- if(xfer->hand == NULL){
+ if (xfer == NULL)
+ return EINVAL;
+ if (xfer->hand == NULL) {
printf("hand == NULL\n");
return EINVAL;
}
@@ -231,17 +234,17 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer)
len = fp->mode.rresb.len;
else
len = 0;
- if (len != xfer->send.pay_len){
+ if (len != xfer->send.pay_len) {
printf("len(%d) != send.pay_len(%d) %s(%x)\n",
len, xfer->send.pay_len, tcode_str[tcode], tcode);
- return EINVAL;
+ return EINVAL;
}
- if(xferq->start == NULL){
+ if (xferq->start == NULL) {
printf("xferq->start == NULL\n");
return EINVAL;
}
- if(!(xferq->queued < xferq->maxq)){
+ if (!(xferq->queued < xferq->maxq)) {
device_printf(fc->bdev, "Discard a packet (queued=%d)\n",
xferq->queued);
return EAGAIN;
@@ -260,6 +263,7 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer)
fw_asystart(xfer);
return err;
}
+
/*
* Wakeup blocked process.
*/
@@ -283,8 +287,8 @@ fw_xferwait(struct fw_xfer *xfer)
int err = 0;
mtx_lock(lock);
- if ((xfer->flag & FWXF_WAKE) == 0)
- err = msleep((void *)xfer, lock, PWAIT|PCATCH, "fw_xferwait", 0);
+ while ((xfer->flag & FWXF_WAKE) == 0)
+ err = msleep(xfer, lock, PWAIT|PCATCH, "fw_xferwait", 0);
mtx_unlock(lock);
return (err);
@@ -298,13 +302,14 @@ fw_asystart(struct fw_xfer *xfer)
{
struct firewire_comm *fc = xfer->fc;
int s;
+
s = splfw();
/* Protect from interrupt/timeout */
FW_GLOCK(fc);
xfer->flag = FWXF_INQ;
STAILQ_INSERT_TAIL(&xfer->q->q, xfer, link);
#if 0
- xfer->q->queued ++;
+ xfer->q->queued++;
#endif
FW_GUNLOCK(fc);
splx(s);
@@ -346,7 +351,7 @@ firewire_xfer_timeout(void *arg, int pending)
s = splfw();
mtx_lock(&fc->tlabel_lock);
- for (i = 0; i < 0x40; i ++) {
+ for (i = 0; i < 0x40; i++) {
while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
if ((xfer->flag & FWXF_SENT) == 0)
/* not sent yet */
@@ -355,8 +360,8 @@ firewire_xfer_timeout(void *arg, int pending)
/* the rests are newer than this */
break;
device_printf(fc->bdev,
- "split transaction timeout: "
- "tl=0x%x flag=0x%02x\n", i, xfer->flag);
+ "split transaction timeout: tl=0x%x flag=0x%02x\n",
+ i, xfer->flag);
fw_dump_hdr(&xfer->send.hdr, "send");
xfer->resp = ETIMEDOUT;
xfer->tl = -1;
@@ -369,7 +374,7 @@ firewire_xfer_timeout(void *arg, int pending)
fc->timeout(fc);
STAILQ_FOREACH_SAFE(xfer, &xfer_timeout, tlabel, txfer)
- xfer->hand(xfer);
+ xfer->hand(xfer);
}
#define WATCHDOG_HZ 10
@@ -379,7 +384,7 @@ firewire_watchdog(void *arg)
struct firewire_comm *fc;
static int watchdog_clock = 0;
- fc = (struct firewire_comm *)arg;
+ fc = arg;
/*
* At boot stage, the device interrupt is disabled and
@@ -389,10 +394,10 @@ firewire_watchdog(void *arg)
if (watchdog_clock > WATCHDOG_HZ * 15)
taskqueue_enqueue(fc->taskqueue, &fc->task_timeout);
else
- watchdog_clock ++;
+ watchdog_clock++;
callout_reset(&fc->timeout_callout, hz / WATCHDOG_HZ,
- (void *)firewire_watchdog, (void *)fc);
+ firewire_watchdog, fc);
}
/*
@@ -406,35 +411,36 @@ firewire_attach(device_t dev)
device_t pa = device_get_parent(dev);
struct firewire_comm *fc;
- fc = (struct firewire_comm *)device_get_softc(pa);
+ fc = device_get_softc(pa);
sc->fc = fc;
fc->status = FWBUSNOTREADY;
unit = device_get_unit(dev);
- if( fc->nisodma > FWMAXNDMA) fc->nisodma = FWMAXNDMA;
+ if (fc->nisodma > FWMAXNDMA)
+ fc->nisodma = FWMAXNDMA;
fwdev_makedev(sc);
- fc->crom_src_buf = (struct crom_src_buf *)malloc(
- sizeof(struct crom_src_buf),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->crom_src_buf = malloc(sizeof(struct crom_src_buf),
+ M_FW, M_NOWAIT | M_ZERO);
if (fc->crom_src_buf == NULL) {
- device_printf(fc->dev, "%s: Malloc Failure crom src buff\n", __func__);
+ device_printf(fc->dev,
+ "%s: unable to allocate crom src buffer\n", __func__);
return ENOMEM;
}
- fc->topology_map = (struct fw_topology_map *)malloc(
- sizeof(struct fw_topology_map),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->topology_map = malloc(sizeof(struct fw_topology_map),
+ M_FW, M_NOWAIT | M_ZERO);
if (fc->topology_map == NULL) {
- device_printf(fc->dev, "%s: Malloc Failure topology map\n", __func__);
+ device_printf(fc->dev, "%s: unable to allocate topology map\n",
+ __func__);
free(fc->crom_src_buf, M_FW);
return ENOMEM;
}
- fc->speed_map = (struct fw_speed_map *)malloc(
- sizeof(struct fw_speed_map),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->speed_map = malloc(sizeof(struct fw_speed_map),
+ M_FW, M_NOWAIT | M_ZERO);
if (fc->speed_map == NULL) {
- device_printf(fc->dev, "%s: Malloc Failure speed map\n", __func__);
+ device_printf(fc->dev, "%s: unable to allocate speed map\n",
+ __func__);
free(fc->crom_src_buf, M_FW);
free(fc->topology_map, M_FW);
return ENOMEM;
@@ -445,14 +451,14 @@ firewire_attach(device_t dev)
CALLOUT_INIT(&fc->timeout_callout);
CALLOUT_INIT(&fc->bmr_callout);
CALLOUT_INIT(&fc->busprobe_callout);
- TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, (void *)fc);
+ TASK_INIT(&fc->task_timeout, 0, firewire_xfer_timeout, fc);
callout_reset(&sc->fc->timeout_callout, hz,
- (void *)firewire_watchdog, (void *)sc->fc);
+ firewire_watchdog, sc->fc);
/* create thread */
- kproc_create(fw_bus_probe_thread, (void *)fc, &fc->probe_thread,
- 0, 0, "fw%d_probe", unit);
+ kproc_create(fw_bus_probe_thread, fc, &fc->probe_thread,
+ 0, 0, "fw%d_probe", unit);
/* Locate our children */
bus_generic_probe(dev);
@@ -475,10 +481,10 @@ firewire_attach(device_t dev)
static device_t
firewire_add_child(device_t dev, u_int order, const char *name, int unit)
{
- device_t child;
+ device_t child;
struct firewire_softc *sc;
- sc = (struct firewire_softc *)device_get_softc(dev);
+ sc = device_get_softc(dev);
child = device_add_child(dev, name, unit);
if (child) {
device_set_ivars(child, sc->fc);
@@ -493,16 +499,16 @@ firewire_resume(device_t dev)
{
struct firewire_softc *sc;
- sc = (struct firewire_softc *)device_get_softc(dev);
+ sc = device_get_softc(dev);
sc->fc->status = FWBUSNOTREADY;
-
+
bus_generic_resume(dev);
- return(0);
+ return (0);
}
/*
- * Dettach it.
+ * Detach it.
*/
static int
firewire_detach(device_t dev)
@@ -512,7 +518,7 @@ firewire_detach(device_t dev)
struct fw_device *fwdev, *fwdev_next;
int err;
- sc = (struct firewire_softc *)device_get_softc(dev);
+ sc = device_get_softc(dev);
fc = sc->fc;
mtx_lock(&fc->wait_lock);
fc->status = FWBUSDETACH;
@@ -521,7 +527,7 @@ firewire_detach(device_t dev)
printf("firewire probe thread didn't die\n");
mtx_unlock(&fc->wait_lock);
- if (fc->arq !=0 && fc->arq->maxq > 0)
+ if (fc->arq != 0 && fc->arq->maxq > 0)
fw_drain_txq(fc);
if ((err = fwdev_destroydev(sc)) != 0)
@@ -536,7 +542,7 @@ firewire_detach(device_t dev)
/* XXX xfer_free and untimeout on all xfers */
for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL;
- fwdev = fwdev_next) {
+ fwdev = fwdev_next) {
fwdev_next = STAILQ_NEXT(fwdev, link);
free(fwdev, M_FW);
}
@@ -546,7 +552,7 @@ firewire_detach(device_t dev)
mtx_destroy(&fc->tlabel_lock);
mtx_destroy(&fc->wait_lock);
- return(0);
+ return (0);
}
static void
@@ -557,7 +563,7 @@ fw_xferq_drain(struct fw_xferq *xferq)
while ((xfer = STAILQ_FIRST(&xferq->q)) != NULL) {
STAILQ_REMOVE_HEAD(&xferq->q, link);
#if 0
- xferq->queued --;
+ xferq->queued--;
#endif
xfer->resp = EAGAIN;
xfer->flag = FWXF_SENTERR;
@@ -577,12 +583,12 @@ fw_drain_txq(struct firewire_comm *fc)
FW_GLOCK(fc);
fw_xferq_drain(fc->atq);
fw_xferq_drain(fc->ats);
- for(i = 0; i < fc->nisodma; i++)
+ for (i = 0; i < fc->nisodma; i++)
fw_xferq_drain(fc->it[i]);
FW_GUNLOCK(fc);
mtx_lock(&fc->tlabel_lock);
- for (i = 0; i < 0x40; i ++)
+ for (i = 0; i < 0x40; i++)
while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
if (firewire_debug)
printf("tl=%d flag=%d\n", i, xfer->flag);
@@ -594,7 +600,7 @@ fw_drain_txq(struct firewire_comm *fc)
mtx_unlock(&fc->tlabel_lock);
STAILQ_FOREACH_SAFE(xfer, &xfer_drain, tlabel, txfer)
- xfer->hand(xfer);
+ xfer->hand(xfer);
}
static void
@@ -603,7 +609,7 @@ fw_reset_csr(struct firewire_comm *fc)
int i;
CSRARC(fc, STATE_CLEAR)
- = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14 ;
+ = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14;
CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR);
CSRARC(fc, NODE_IDS) = 0x3f;
@@ -612,10 +618,10 @@ fw_reset_csr(struct firewire_comm *fc)
fc->max_node = -1;
- for(i = 2; i < 0x100/4 - 2 ; i++){
+ for (i = 2; i < 0x100 / 4 - 2; i++) {
CSRARC(fc, SPED_MAP + i * 4) = 0;
}
- CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14 ;
+ CSRARC(fc, STATE_CLEAR) = 1 << 23 | 0 << 17 | 1 << 16 | 1 << 15 | 1 << 14;
CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR);
CSRARC(fc, RESET_START) = 0;
CSRARC(fc, SPLIT_TIMEOUT_HI) = 0;
@@ -631,14 +637,14 @@ fw_reset_csr(struct firewire_comm *fc)
CSRARC(fc, CONF_ROM) = 0x04 << 24;
CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */
CSRARC(fc, CONF_ROM + 8) = 1 << 31 | 1 << 30 | 1 << 29 |
- 1 << 28 | 0xff << 16 | 0x09 << 8;
+ 1 << 28 | 0xff << 16 | 0x09 << 8;
CSRARC(fc, CONF_ROM + 0xc) = 0;
-/* DV depend CSRs see blue book */
- CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON;
- CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON;
+ /* DV depend CSRs see blue book */
+ CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON;
+ CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON;
- CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14 );
+ CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14);
CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR);
}
@@ -694,13 +700,8 @@ fw_reset_crom(struct firewire_comm *fc)
crom_add_entry(root, CSRKEY_NCAP, 0x0083c0); /* XXX */
/* private company_id */
crom_add_entry(root, CSRKEY_VENDOR, CSRVAL_VENDOR_PRIVATE);
-#ifdef __DragonFly__
- crom_add_simple_text(src, root, &buf->vendor, "DragonFly Project");
- crom_add_entry(root, CSRKEY_HW, __DragonFly_cc_version);
-#else
crom_add_simple_text(src, root, &buf->vendor, "FreeBSD Project");
crom_add_entry(root, CSRKEY_HW, __FreeBSD_version);
-#endif
mtx_lock(&prison0.pr_mtx);
crom_add_simple_text(src, root, &buf->hw, prison0.pr_hostname);
mtx_unlock(&prison0.pr_mtx);
@@ -731,8 +732,8 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status)
fw_reset_crom(fc);
if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) {
- for( i = 0 ; i < devcnt ; i++)
- if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
+ for (i = 0; i < devcnt; i++)
+ if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
fdc = device_get_softc(devlistp[i]);
if (fdc->post_busreset != NULL)
fdc->post_busreset(fdc);
@@ -741,31 +742,30 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status)
}
src = &fc->crom_src_buf->src;
- /*
- * If the old config rom needs to be overwritten,
- * bump the businfo.generation indicator to
- * indicate that we need to be reprobed
- * See 1394a-2000 8.3.2.5.4 for more details.
- * generation starts at 2 and rolls over at 0xF
- * back to 2.
- *
- * A generation of 0 indicates a device
- * that is not 1394a-2000 compliant.
- * A generation of 1 indicates a device that
- * does not change it's Bus Info Block or
- * Configuration ROM.
- */
+ /*
+ * If the old config rom needs to be overwritten,
+ * bump the businfo.generation indicator to
+ * indicate that we need to be reprobed
+ * See 1394a-2000 8.3.2.5.4 for more details.
+ * generation starts at 2 and rolls over at 0xF
+ * back to 2.
+ *
+ * A generation of 0 indicates a device
+ * that is not 1394a-2000 compliant.
+ * A generation of 1 indicates a device that
+ * does not change it's Bus Info Block or
+ * Configuration ROM.
+ */
#define FW_MAX_GENERATION 0xF
newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
src = &fc->crom_src_buf->src;
crom_load(src, newrom, CROMSIZE);
if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
- if ( src->businfo.generation++ > FW_MAX_GENERATION )
+ if (src->businfo.generation++ > FW_MAX_GENERATION)
src->businfo.generation = FW_GENERATION_CHANGEABLE;
- bcopy(newrom, (void *)fc->config_rom, CROMSIZE);
+ bcopy(newrom, fc->config_rom, CROMSIZE);
}
free(newrom, M_FW);
-
}
/* Call once after reboot */
@@ -795,7 +795,7 @@ void fw_init(struct firewire_comm *fc)
STAILQ_INIT(&fc->atq->q);
STAILQ_INIT(&fc->ats->q);
- for( i = 0 ; i < fc->nisodma ; i ++ ){
+ for (i = 0; i < fc->nisodma; i++) {
fc->it[i]->queued = 0;
fc->ir[i]->queued = 0;
@@ -817,7 +817,7 @@ void fw_init(struct firewire_comm *fc)
fc->atq->maxq = FWMAXQUEUE;
fc->ats->maxq = FWMAXQUEUE;
- for( i = 0 ; i < fc->nisodma ; i++){
+ for (i = 0; i < fc->nisodma; i++) {
fc->ir[i]->maxq = FWMAXQUEUE;
fc->it[i]->maxq = FWMAXQUEUE;
}
@@ -829,9 +829,9 @@ void fw_init(struct firewire_comm *fc)
STAILQ_INIT(&fc->devices);
-/* Initialize Async handlers */
+ /* Initialize Async handlers */
STAILQ_INIT(&fc->binds);
- for( i = 0 ; i < 0x40 ; i++){
+ for (i = 0; i < 0x40; i++) {
STAILQ_INIT(&fc->tlabels[i]);
}
@@ -839,14 +839,14 @@ void fw_init(struct firewire_comm *fc)
#if 0
CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */
CSRARC(fc, oPCR) = 0x8000007a;
- for(i = 4 ; i < 0x7c/4 ; i+=4){
- CSRARC(fc, i + oPCR) = 0x8000007a;
+ for (i = 4; i < 0x7c/4; i += 4) {
+ CSRARC(fc, i + oPCR) = 0x8000007a;
}
-
+
CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */
CSRARC(fc, iPCR) = 0x803f0000;
- for(i = 4 ; i < 0x7c/4 ; i+=4){
- CSRARC(fc, i + iPCR) = 0x0;
+ for (i = 4; i < 0x7c/4; i += 4) {
+ CSRARC(fc, i + iPCR) = 0x0;
}
#endif
@@ -854,10 +854,11 @@ void fw_init(struct firewire_comm *fc)
#ifdef FW_VMACCESS
xfer = fw_xfer_alloc();
- if(xfer == NULL) return;
+ if (xfer == NULL)
+ return;
- fwb = (struct fw_bind *)malloc(sizeof (struct fw_bind), M_FW, M_NOWAIT);
- if(fwb == NULL){
+ fwb = malloc(sizeof(struct fw_bind), M_FW, M_NOWAIT);
+ if (fwb == NULL) {
fw_xfer_free(xfer);
return;
}
@@ -873,8 +874,8 @@ void fw_init(struct firewire_comm *fc)
#endif
}
-#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)?-1:\
- ((fwb)->end < (addr))?1:0)
+#define BIND_CMP(addr, fwb) (((addr) < (fwb)->start)? -1 : \
+ ((fwb)->end < (addr)) ? 1 : 0)
/*
* To lookup bound process from IEEE1394 address.
@@ -893,7 +894,7 @@ fw_bindlookup(struct firewire_comm *fc, uint16_t dest_hi, uint32_t dest_lo)
break;
}
FW_GUNLOCK(fc);
- return(r);
+ return (r);
}
/*
@@ -978,7 +979,7 @@ fw_xferlist_add(struct fw_xferlist *q, struct malloc_type *type,
for (i = 0; i < n; i++) {
xfer = fw_xfer_alloc_buf(type, slen, rlen);
if (xfer == NULL)
- return (n);
+ return (i);
xfer->fc = fc;
xfer->sc = sc;
xfer->hand = hand;
@@ -995,10 +996,10 @@ fw_xferlist_remove(struct fw_xferlist *q)
struct fw_xfer *xfer, *next;
for (xfer = STAILQ_FIRST(q); xfer != NULL; xfer = next) {
- next = STAILQ_NEXT(xfer, link);
- fw_xfer_free_buf(xfer);
- }
- STAILQ_INIT(q);
+ next = STAILQ_NEXT(xfer, link);
+ fw_xfer_free_buf(xfer);
+ }
+ STAILQ_INIT(q);
}
/*
* dump packet header
@@ -1031,7 +1032,7 @@ fw_tl_free(struct firewire_comm *fc, struct fw_xfer *xfer)
}
/* make sure the label is allocated */
STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel)
- if(txfer == xfer)
+ if (txfer == xfer)
break;
if (txfer == NULL) {
printf("%s: the xfer is not in the queue "
@@ -1064,7 +1065,7 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode)
mtx_lock(&fc->tlabel_lock);
STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel)
- if(xfer->send.hdr.mode.hdr.dst == node) {
+ if (xfer->send.hdr.mode.hdr.dst == node) {
mtx_unlock(&fc->tlabel_lock);
splx(s);
KASSERT(xfer->tl == tlabel,
@@ -1075,18 +1076,18 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode)
printf("%s: invalid response tcode "
"(0x%x for 0x%x)\n", __FUNCTION__,
tcode, req);
- return(NULL);
+ return (NULL);
}
-
+
if (firewire_debug > 2)
printf("fw_tl2xfer: found tl=%d\n", tlabel);
- return(xfer);
+ return (xfer);
}
mtx_unlock(&fc->tlabel_lock);
if (firewire_debug > 1)
printf("fw_tl2xfer: not found tl=%d\n", tlabel);
splx(s);
- return(NULL);
+ return (NULL);
}
/*
@@ -1113,14 +1114,14 @@ fw_xfer_alloc_buf(struct malloc_type *type, int send_len, int recv_len)
xfer = fw_xfer_alloc(type);
if (xfer == NULL)
- return(NULL);
+ return (NULL);
xfer->send.pay_len = send_len;
xfer->recv.pay_len = recv_len;
if (send_len > 0) {
xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO);
if (xfer->send.payload == NULL) {
fw_xfer_free(xfer);
- return(NULL);
+ return (NULL);
}
}
if (recv_len > 0) {
@@ -1129,10 +1130,10 @@ fw_xfer_alloc_buf(struct malloc_type *type, int send_len, int recv_len)
if (xfer->send.payload != NULL)
free(xfer->send.payload, type);
fw_xfer_free(xfer);
- return(NULL);
+ return (NULL);
}
}
- return(xfer);
+ return (xfer);
}
/*
@@ -1154,18 +1155,19 @@ fw_xfer_done(struct fw_xfer *xfer)
}
void
-fw_xfer_unload(struct fw_xfer* xfer)
+fw_xfer_unload(struct fw_xfer *xfer)
{
int s;
- if(xfer == NULL ) return;
- if(xfer->flag & FWXF_INQ){
+ if (xfer == NULL)
+ return;
+ if (xfer->flag & FWXF_INQ) {
printf("fw_xfer_free FWXF_INQ\n");
s = splfw();
FW_GLOCK(xfer->fc);
STAILQ_REMOVE(&xfer->q->q, xfer, fw_xfer, link);
#if 0
- xfer->q->queued --;
+ xfer->q->queued--;
#endif
FW_GUNLOCK(xfer->fc);
splx(s);
@@ -1177,7 +1179,7 @@ fw_xfer_unload(struct fw_xfer* xfer)
*/
fw_tl_free(xfer->fc, xfer);
#if 1
- if(xfer->flag & FWXF_START)
+ if (xfer->flag & FWXF_START)
/*
* This could happen if:
* 1. We call fwohci_arcv() before fwohci_txd().
@@ -1189,28 +1191,27 @@ fw_xfer_unload(struct fw_xfer* xfer)
xfer->flag = FWXF_INIT;
xfer->resp = 0;
}
+
/*
- * To free IEEE1394 XFER structure.
+ * To free IEEE1394 XFER structure.
*/
void
-fw_xfer_free_buf( struct fw_xfer* xfer)
+fw_xfer_free_buf(struct fw_xfer *xfer)
{
if (xfer == NULL) {
printf("%s: xfer == NULL\n", __func__);
return;
}
fw_xfer_unload(xfer);
- if(xfer->send.payload != NULL){
+ if (xfer->send.payload != NULL)
free(xfer->send.payload, xfer->malloc);
- }
- if(xfer->recv.payload != NULL){
+ if (xfer->recv.payload != NULL)
free(xfer->recv.payload, xfer->malloc);
- }
free(xfer, xfer->malloc);
}
void
-fw_xfer_free( struct fw_xfer* xfer)
+fw_xfer_free(struct fw_xfer *xfer)
{
if (xfer == NULL) {
printf("%s: xfer == NULL\n", __func__);
@@ -1231,7 +1232,7 @@ fw_asy_callback_free(struct fw_xfer *xfer)
}
/*
- * To configure PHY.
+ * To configure PHY.
*/
static void
fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count)
@@ -1250,9 +1251,9 @@ fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count)
fp = &xfer->send.hdr;
fp->mode.ld[1] = 0;
if (root_node >= 0)
- fp->mode.ld[1] |= (root_node & 0x3f) << 24 | 1 << 23;
+ fp->mode.ld[1] |= (1 << 23) | (root_node & 0x3f) << 24;
if (gap_count >= 0)
- fp->mode.ld[1] |= 1 << 22 | (gap_count & 0x3f) << 16;
+ fp->mode.ld[1] |= (1 << 22) | (gap_count & 0x3f) << 16;
fp->mode.ld[2] = ~fp->mode.ld[1];
/* XXX Dangerous, how to pass PHY packet to device driver */
fp->mode.common.tcode |= FWTCODE_PHY;
@@ -1264,113 +1265,107 @@ fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count)
}
/*
- * Dump self ID.
+ * Dump self ID.
*/
static void
fw_print_sid(uint32_t sid)
{
union fw_self_id *s;
s = (union fw_self_id *) &sid;
- if ( s->p0.sequel ) {
- if ( s->p1.sequence_num == FW_SELF_ID_PAGE0 ) {
+ if (s->p0.sequel) {
+ if (s->p1.sequence_num == FW_SELF_ID_PAGE0) {
printf("node:%d p3:%d p4:%d p5:%d p6:%d p7:%d"
- "p8:%d p9:%d p10:%d\n",
- s->p1.phy_id, s->p1.port3, s->p1.port4,
- s->p1.port5, s->p1.port6, s->p1.port7,
- s->p1.port8, s->p1.port9, s->p1.port10);
- } else if (s->p2.sequence_num == FW_SELF_ID_PAGE1 ){
+ "p8:%d p9:%d p10:%d\n",
+ s->p1.phy_id, s->p1.port3, s->p1.port4,
+ s->p1.port5, s->p1.port6, s->p1.port7,
+ s->p1.port8, s->p1.port9, s->p1.port10);
+ } else if (s->p2.sequence_num == FW_SELF_ID_PAGE1) {
printf("node:%d p11:%d p12:%d p13:%d p14:%d p15:%d\n",
- s->p2.phy_id, s->p2.port11, s->p2.port12,
- s->p2.port13, s->p2.port14, s->p2.port15);
+ s->p2.phy_id, s->p2.port11, s->p2.port12,
+ s->p2.port13, s->p2.port14, s->p2.port15);
} else {
printf("node:%d Unknown Self ID Page number %d\n",
- s->p1.phy_id, s->p1.sequence_num);
+ s->p1.phy_id, s->p1.sequence_num);
}
} else {
printf("node:%d link:%d gap:%d spd:%d con:%d pwr:%d"
- " p0:%d p1:%d p2:%d i:%d m:%d\n",
- s->p0.phy_id, s->p0.link_active, s->p0.gap_count,
- s->p0.phy_speed, s->p0.contender,
- s->p0.power_class, s->p0.port0, s->p0.port1,
- s->p0.port2, s->p0.initiated_reset, s->p0.more_packets);
+ " p0:%d p1:%d p2:%d i:%d m:%d\n",
+ s->p0.phy_id, s->p0.link_active, s->p0.gap_count,
+ s->p0.phy_speed, s->p0.contender,
+ s->p0.power_class, s->p0.port0, s->p0.port1,
+ s->p0.port2, s->p0.initiated_reset, s->p0.more_packets);
}
}
/*
- * To receive self ID.
+ * To receive self ID.
*/
-void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len)
+void fw_sidrcv(struct firewire_comm *fc, uint32_t *sid, u_int len)
{
uint32_t *p;
union fw_self_id *self_id;
u_int i, j, node, c_port = 0, i_branch = 0;
- fc->sid_cnt = len /(sizeof(uint32_t) * 2);
+ fc->sid_cnt = len / (sizeof(uint32_t) * 2);
fc->max_node = fc->nodeid & 0x3f;
CSRARC(fc, NODE_IDS) = ((uint32_t)fc->nodeid) << 16;
fc->status = FWBUSCYMELECT;
fc->topology_map->crc_len = 2;
- fc->topology_map->generation ++;
+ fc->topology_map->generation++;
fc->topology_map->self_id_count = 0;
- fc->topology_map->node_count = 0;
- fc->speed_map->generation ++;
- fc->speed_map->crc_len = 1 + (64*64 + 3) / 4;
+ fc->topology_map->node_count= 0;
+ fc->speed_map->generation++;
+ fc->speed_map->crc_len = 1 + (64 * 64 + 3) / 4;
self_id = &fc->topology_map->self_id[0];
- for(i = 0; i < fc->sid_cnt; i ++){
+ for (i = 0; i < fc->sid_cnt; i++) {
if (sid[1] != ~sid[0]) {
- device_printf(fc->bdev, "%s: ERROR invalid self-id packet\n",
- __func__);
+ device_printf(fc->bdev,
+ "%s: ERROR invalid self-id packet\n", __func__);
sid += 2;
continue;
}
*self_id = *((union fw_self_id *)sid);
fc->topology_map->crc_len++;
- if(self_id->p0.sequel == 0){
- fc->topology_map->node_count ++;
+ if (self_id->p0.sequel == 0) {
+ fc->topology_map->node_count++;
c_port = 0;
if (firewire_debug)
fw_print_sid(sid[0]);
node = self_id->p0.phy_id;
- if(fc->max_node < node){
+ if (fc->max_node < node)
fc->max_node = self_id->p0.phy_id;
- }
/* XXX I'm not sure this is the right speed_map */
- fc->speed_map->speed[node][node]
- = self_id->p0.phy_speed;
- for (j = 0; j < node; j ++) {
- fc->speed_map->speed[j][node]
- = fc->speed_map->speed[node][j]
- = min(fc->speed_map->speed[j][j],
- self_id->p0.phy_speed);
+ fc->speed_map->speed[node][node] =
+ self_id->p0.phy_speed;
+ for (j = 0; j < node; j++) {
+ fc->speed_map->speed[j][node] =
+ fc->speed_map->speed[node][j] =
+ min(fc->speed_map->speed[j][j],
+ self_id->p0.phy_speed);
}
if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) &&
- (self_id->p0.link_active && self_id->p0.contender)) {
+ (self_id->p0.link_active && self_id->p0.contender))
fc->irm = self_id->p0.phy_id;
- }
- if(self_id->p0.port0 >= 0x2){
+ if (self_id->p0.port0 >= 0x2)
c_port++;
- }
- if(self_id->p0.port1 >= 0x2){
+ if (self_id->p0.port1 >= 0x2)
c_port++;
- }
- if(self_id->p0.port2 >= 0x2){
+ if (self_id->p0.port2 >= 0x2)
c_port++;
- }
}
- if(c_port > 2){
+ if (c_port > 2)
i_branch += (c_port - 2);
- }
sid += 2;
self_id++;
- fc->topology_map->self_id_count ++;
+ fc->topology_map->self_id_count++;
}
/* CRC */
fc->topology_map->crc = fw_crc16(
- (uint32_t *)&fc->topology_map->generation,
- fc->topology_map->crc_len * 4);
+ (uint32_t *)&fc->topology_map->generation,
+ fc->topology_map->crc_len * 4);
fc->speed_map->crc = fw_crc16(
- (uint32_t *)&fc->speed_map->generation,
- fc->speed_map->crc_len * 4);
+ (uint32_t *)&fc->speed_map->generation,
+ fc->speed_map->crc_len * 4);
/* byteswap and copy to CSR */
p = (uint32_t *)fc->topology_map;
for (i = 0; i <= fc->topology_map->crc_len; i++)
@@ -1379,14 +1374,13 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len)
CSRARC(fc, SPED_MAP) = htonl(*p++);
CSRARC(fc, SPED_MAP + 4) = htonl(*p++);
/* don't byte-swap uint8_t array */
- bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1)*4);
+ bcopy(p, &CSRARC(fc, SPED_MAP + 8), (fc->speed_map->crc_len - 1) * 4);
fc->max_hop = fc->max_node - i_branch;
device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n",
- fc->max_node + 1, fc->max_hop,
- (fc->irm == -1) ? "Not IRM capable" : "cable IRM",
- fc->irm,
- (fc->irm == fc->nodeid) ? " (me) " : "");
+ fc->max_node + 1, fc->max_hop,
+ (fc->irm == -1) ? "Not IRM capable" : "cable IRM",
+ fc->irm, (fc->irm == fc->nodeid) ? " (me) " : "");
if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) {
if (fc->irm == fc->nodeid) {
@@ -1395,26 +1389,27 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len)
fw_bmr(fc);
} else {
fc->status = FWBUSMGRELECT;
- callout_reset(&fc->bmr_callout, hz/8,
- (void *)fw_try_bmr, (void *)fc);
+ callout_reset(&fc->bmr_callout, hz / 8,
+ fw_try_bmr, fc);
}
} else
fc->status = FWBUSMGRDONE;
- callout_reset(&fc->busprobe_callout, hz/4,
- (void *)fw_bus_probe, (void *)fc);
+ callout_reset(&fc->busprobe_callout, hz / 4, fw_bus_probe, fc);
}
/*
- * To probe devices on the IEEE1394 bus.
+ * To probe devices on the IEEE1394 bus.
*/
static void
-fw_bus_probe(struct firewire_comm *fc)
+fw_bus_probe(void *arg)
{
- int s;
+ struct firewire_comm *fc;
struct fw_device *fwdev;
+ int s;
s = splfw();
+ fc = arg;
fc->status = FWBUSEXPLORE;
/* Invalidate all devices, just after bus reset. */
@@ -1438,7 +1433,7 @@ fw_bus_probe(struct firewire_comm *fc)
}
splx(s);
- wakeup((void *)fc);
+ wakeup(fc);
}
static int
@@ -1449,10 +1444,9 @@ fw_explore_read_quads(struct fw_device *fwdev, int offset,
uint32_t tmp;
int i, error;
- for (i = 0; i < length; i ++, offset += sizeof(uint32_t)) {
- xfer = fwmem_read_quad(fwdev, NULL, -1,
- 0xffff, 0xf0000000 | offset, (void *)&tmp,
- fw_xferwake);
+ for (i = 0; i < length; i++, offset += sizeof(uint32_t)) {
+ xfer = fwmem_read_quad(fwdev, NULL, -1, 0xffff,
+ 0xf0000000 | offset, &tmp, fw_xferwake);
if (xfer == NULL)
return (-1);
fw_xferwait(xfer);
@@ -1476,14 +1470,14 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur)
struct csrdirectory *dir;
struct csrreg *reg;
- dir = (struct csrdirectory *)&fwdev->csrrom[offset/sizeof(uint32_t)];
+ dir = (struct csrdirectory *)&fwdev->csrrom[offset / sizeof(uint32_t)];
err = fw_explore_read_quads(fwdev, CSRROMOFF + offset,
(uint32_t *)dir, 1);
if (err)
return (-1);
offset += sizeof(uint32_t);
- reg = (struct csrreg *)&fwdev->csrrom[offset/sizeof(uint32_t)];
+ reg = (struct csrreg *)&fwdev->csrrom[offset / sizeof(uint32_t)];
err = fw_explore_read_quads(fwdev, CSRROMOFF + offset,
(uint32_t *)reg, dir->crc_len);
if (err)
@@ -1498,7 +1492,7 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur)
if (recur == 0)
return (0);
- for (i = 0; i < dir->crc_len; i ++, offset += sizeof(uint32_t)) {
+ for (i = 0; i < dir->crc_len; i++, offset += sizeof(uint32_t)) {
if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_D)
recur = 1;
else if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_L)
@@ -1509,7 +1503,7 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur)
off = offset + reg[i].val * sizeof(uint32_t);
if (off > CROMSIZE) {
printf("%s: invalid offset %d\n", __FUNCTION__, off);
- return(-1);
+ return (-1);
}
err = fw_explore_csrblock(fwdev, off, recur);
if (err)
@@ -1542,7 +1536,8 @@ fw_explore_node(struct fw_device *dfwdev)
hdr = (struct csrhdr *)&csr[0];
if (hdr->info_len != 4) {
if (firewire_debug)
- device_printf(fc->bdev, "%s: node%d: wrong bus info len(%d)\n",
+ device_printf(fc->bdev,
+ "%s: node%d: wrong bus info len(%d)\n",
__func__, node, hdr->info_len);
dfwdev->status = FWDEVINVAL;
return (-1);
@@ -1562,14 +1557,14 @@ fw_explore_node(struct fw_device *dfwdev)
if (firewire_debug)
device_printf(fc->bdev, "%s: node(%d) BUS INFO BLOCK:\n"
- "irmc(%d) cmc(%d) isc(%d) bmc(%d) pmc(%d) "
- "cyc_clk_acc(%d) max_rec(%d) max_rom(%d) "
- "generation(%d) link_spd(%d)\n",
- __func__, node,
- binfo->irmc, binfo->cmc, binfo->isc,
- binfo->bmc, binfo->pmc, binfo->cyc_clk_acc,
- binfo->max_rec, binfo->max_rom,
- binfo->generation, binfo->link_spd);
+ "irmc(%d) cmc(%d) isc(%d) bmc(%d) pmc(%d) "
+ "cyc_clk_acc(%d) max_rec(%d) max_rom(%d) "
+ "generation(%d) link_spd(%d)\n",
+ __func__, node,
+ binfo->irmc, binfo->cmc, binfo->isc,
+ binfo->bmc, binfo->pmc, binfo->cyc_clk_acc,
+ binfo->max_rec, binfo->max_rom,
+ binfo->generation, binfo->link_spd);
STAILQ_FOREACH(fwdev, &fc->devices, link)
if (FW_EUI64_EQUAL(fwdev->eui, binfo->eui64))
@@ -1577,7 +1572,7 @@ fw_explore_node(struct fw_device *dfwdev)
if (fwdev == NULL) {
/* new device */
fwdev = malloc(sizeof(struct fw_device), M_FW,
- M_NOWAIT | M_ZERO);
+ M_NOWAIT | M_ZERO);
if (fwdev == NULL) {
device_printf(fc->bdev, "%s: node%d: no memory\n",
__func__, node);
@@ -1591,16 +1586,15 @@ fw_explore_node(struct fw_device *dfwdev)
/*
* Pre-1394a-2000 didn't have link_spd in
- * the Bus Info block, so try and use the
+ * the Bus Info block, so try and use the
* speed map value.
* 1394a-2000 compliant devices only use
* the Bus Info Block link spd value, so
* ignore the speed map alltogether. SWB
*/
- if ( binfo->link_spd == FWSPD_S100 /* 0 */) {
+ if (binfo->link_spd == FWSPD_S100 /* 0 */) {
device_printf(fc->bdev, "%s: "
- "Pre 1394a-2000 detected\n",
- __func__);
+ "Pre 1394a-2000 detected\n", __func__);
fwdev->speed = fc->speed_map->speed[fc->nodeid][node];
} else
fwdev->speed = binfo->link_spd;
@@ -1610,20 +1604,19 @@ fw_explore_node(struct fw_device *dfwdev)
*/
while (fwdev->speed > FWSPD_S100 /* 0 */) {
err = fw_explore_read_quads(fwdev, CSRROMOFF,
- &speed_test, 1);
+ &speed_test, 1);
if (err) {
- device_printf(fc->bdev, "%s: fwdev->speed(%s)"
- " decremented due to negotiation\n",
- __func__,
- linkspeed[fwdev->speed]);
+ device_printf(fc->bdev,
+ "%s: fwdev->speed(%s) decremented due to negotiation\n",
+ __func__, linkspeed[fwdev->speed]);
fwdev->speed--;
} else
break;
-
+
}
/*
- * If the fwdev is not found in the
+ * If the fwdev is not found in the
* fc->devices TAILQ, then we will add it.
*/
pfwdev = NULL;
@@ -1644,7 +1637,8 @@ fw_explore_node(struct fw_device *dfwdev)
/* unchanged ? */
if (bcmp(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5) == 0) {
if (firewire_debug)
- device_printf(fc->dev, "node%d: crom unchanged\n", node);
+ device_printf(fc->dev,
+ "node%d: crom unchanged\n", node);
return (0);
}
}
@@ -1702,53 +1696,54 @@ fw_explore(struct firewire_comm *fc)
dfwdev.maxrec = 8; /* 512 */
dfwdev.status = FWDEVINIT;
- for (node = 0; node <= fc->max_node; node ++) {
+ for (node = 0; node <= fc->max_node; node++) {
/* We don't probe myself and linkdown nodes */
if (node == fc->nodeid) {
if (firewire_debug)
device_printf(fc->bdev, "%s:"
- "found myself node(%d) fc->nodeid(%d) fc->max_node(%d)\n",
- __func__, node, fc->nodeid, fc->max_node);
+ "found myself node(%d) fc->nodeid(%d) fc->max_node(%d)\n",
+ __func__, node, fc->nodeid, fc->max_node);
continue;
} else if (firewire_debug) {
device_printf(fc->bdev, "%s:"
- "node(%d) fc->max_node(%d) found\n",
- __func__, node, fc->max_node);
+ "node(%d) fc->max_node(%d) found\n",
+ __func__, node, fc->max_node);
}
fwsid = fw_find_self_id(fc, node);
if (!fwsid || !fwsid->p0.link_active) {
if (firewire_debug)
- device_printf(fc->bdev, "%s: node%d: link down\n",
- __func__, node);
+ device_printf(fc->bdev,
+ "%s: node%d: link down\n",
+ __func__, node);
continue;
}
nodes[todo++] = node;
}
s = splfw();
- for (trys = 0; todo > 0 && trys < 3; trys ++) {
+ for (trys = 0; todo > 0 && trys < 3; trys++) {
todo2 = 0;
- for (i = 0; i < todo; i ++) {
+ for (i = 0; i < todo; i++) {
dfwdev.dst = nodes[i];
err = fw_explore_node(&dfwdev);
if (err)
nodes[todo2++] = nodes[i];
if (firewire_debug)
- device_printf(fc->bdev, "%s: node %d, err = %d\n",
- __func__, node, err);
+ device_printf(fc->bdev,
+ "%s: node %d, err = %d\n",
+ __func__, node, err);
}
todo = todo2;
}
splx(s);
}
-
static void
fw_bus_probe_thread(void *arg)
{
struct firewire_comm *fc;
- fc = (struct firewire_comm *)arg;
+ fc = arg;
mtx_lock(&fc->wait_lock);
while (fc->status != FWBUSDETACH) {
@@ -1784,11 +1779,11 @@ fw_attach_dev(struct firewire_comm *fc)
if (fwdev->status == FWDEVINIT) {
fwdev->status = FWDEVATTACHED;
} else if (fwdev->status == FWDEVINVAL) {
- fwdev->rcnt ++;
+ fwdev->rcnt++;
if (firewire_debug)
device_printf(fc->bdev, "%s:"
- "fwdev->rcnt(%d), hold_count(%d)\n",
- __func__, fwdev->rcnt, hold_count);
+ "fwdev->rcnt(%d), hold_count(%d)\n",
+ __func__, fwdev->rcnt, hold_count);
if (fwdev->rcnt > hold_count) {
/*
* Remove devices which have not been seen
@@ -1802,9 +1797,9 @@ fw_attach_dev(struct firewire_comm *fc)
}
err = device_get_children(fc->bdev, &devlistp, &devcnt);
- if( err == 0 ) {
- for( i = 0 ; i < devcnt ; i++){
- if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
+ if (err == 0) {
+ for (i = 0; i < devcnt; i++) {
+ if (device_get_state(devlistp[i]) >= DS_ATTACHED) {
fdc = device_get_softc(devlistp[i]);
if (fdc->post_explore != NULL)
fdc->post_explore(fdc);
@@ -1832,8 +1827,8 @@ fw_get_tlabel(struct firewire_comm *fc, struct fw_xfer *xfer)
new_tlabel = (fc->last_tlabel[dst] + 1) & 0x3f;
STAILQ_FOREACH(txfer, &fc->tlabels[new_tlabel], tlabel)
if ((txfer->send.hdr.mode.hdr.dst & 0x3f) == dst)
- break;
- if(txfer == NULL) {
+ break;
+ if (txfer == NULL) {
fc->last_tlabel[dst] = new_tlabel;
STAILQ_INSERT_TAIL(&fc->tlabels[new_tlabel], xfer, tlabel);
mtx_unlock(&fc->tlabel_lock);
@@ -1865,7 +1860,7 @@ fw_rcv_copy(struct fw_rcv_buf *rb)
pkt = (struct fw_pkt *)rb->vec->iov_base;
tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode];
- /* Copy header */
+ /* Copy header */
p = (u_char *)&rb->xfer->recv.hdr;
bcopy(rb->vec->iov_base, p, tinfo->hdr_len);
rb->vec->iov_base = (u_char *)rb->vec->iov_base + tinfo->hdr_len;
@@ -1904,7 +1899,6 @@ fw_rcv_copy(struct fw_rcv_buf *rb)
break;
}
rb->xfer->recv.pay_len -= res;
-
}
/*
@@ -1923,11 +1917,11 @@ fw_rcv(struct fw_rcv_buf *rb)
int i;
qld = (uint32_t *)buf;
printf("spd %d len:%d\n", spd, len);
- for( i = 0 ; i <= len && i < 32; i+= 4){
+ for (i = 0; i <= len && i < 32; i+= 4) {
printf("0x%08x ", ntohl(qld[i/4]));
- if((i % 16) == 15) printf("\n");
+ if ((i % 16) == 15) printf("\n");
}
- if((i % 16) != 15) printf("\n");
+ if ((i % 16) != 15) printf("\n");
}
#endif
fp = (struct fw_pkt *)rb->vec[0].iov_base;
@@ -1939,20 +1933,19 @@ fw_rcv(struct fw_rcv_buf *rb)
case FWTCODE_LRES:
rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src,
fp->mode.hdr.tlrt >> 2, fp->mode.hdr.tcode);
- if(rb->xfer == NULL) {
- device_printf(rb->fc->bdev, "%s: "
- "unknown response "
- "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n",
- __func__,
- tcode_str[tcode], tcode,
- fp->mode.hdr.src,
- fp->mode.hdr.tlrt >> 2,
- fp->mode.hdr.tlrt & 3,
- fp->mode.rresq.data);
+ if (rb->xfer == NULL) {
+ device_printf(rb->fc->bdev, "%s: unknown response "
+ "%s(%x) src=0x%x tl=0x%x rt=%d data=0x%x\n",
+ __func__,
+ tcode_str[tcode], tcode,
+ fp->mode.hdr.src,
+ fp->mode.hdr.tlrt >> 2,
+ fp->mode.hdr.tlrt & 3,
+ fp->mode.rresq.data);
#if 0
printf("try ad-hoc work around!!\n");
rb->xfer = fw_tl2xfer(rb->fc, fp->mode.hdr.src,
- (fp->mode.hdr.tlrt >> 2)^3);
+ (fp->mode.hdr.tlrt >> 2)^3);
if (rb->xfer == NULL) {
printf("no use...\n");
return;
@@ -1981,7 +1974,8 @@ fw_rcv(struct fw_rcv_buf *rb)
break;
default:
device_printf(rb->fc->bdev, "%s: "
- "unexpected flag 0x%02x\n", __func__, rb->xfer->flag);
+ "unexpected flag 0x%02x\n", __func__,
+ rb->xfer->flag);
}
return;
case FWTCODE_WREQQ:
@@ -1990,29 +1984,26 @@ fw_rcv(struct fw_rcv_buf *rb)
case FWTCODE_RREQB:
case FWTCODE_LREQ:
bind = fw_bindlookup(rb->fc, fp->mode.rreqq.dest_hi,
- fp->mode.rreqq.dest_lo);
- if(bind == NULL){
+ fp->mode.rreqq.dest_lo);
+ if (bind == NULL) {
device_printf(rb->fc->bdev, "%s: "
- "Unknown service addr 0x%04x:0x%08x %s(%x)"
-#if defined(__DragonFly__) || __FreeBSD_version < 500000
- " src=0x%x data=%lx\n",
-#else
- " src=0x%x data=%x\n",
-#endif
- __func__,
- fp->mode.wreqq.dest_hi,
- fp->mode.wreqq.dest_lo,
- tcode_str[tcode], tcode,
- fp->mode.hdr.src,
- ntohl(fp->mode.wreqq.data));
+ "Unknown service addr 0x%04x:0x%08x %s(%x)"
+ " src=0x%x data=%x\n",
+ __func__,
+ fp->mode.wreqq.dest_hi,
+ fp->mode.wreqq.dest_lo,
+ tcode_str[tcode], tcode,
+ fp->mode.hdr.src,
+ ntohl(fp->mode.wreqq.data));
if (rb->fc->status == FWBUSINIT) {
- device_printf(rb->fc->bdev, "%s: cannot respond(bus reset)!\n",
- __func__);
+ device_printf(rb->fc->bdev,
+ "%s: cannot respond(bus reset)!\n",
+ __func__);
return;
}
rb->xfer = fw_xfer_alloc(M_FWXFER);
- if(rb->xfer == NULL){
+ if (rb->xfer == NULL) {
return;
}
rb->xfer->send.spd = rb->spd;
@@ -2043,20 +2034,16 @@ fw_rcv(struct fw_rcv_buf *rb)
rb->xfer->hand = fw_xferwake;
*/
rb->xfer->hand = fw_xfer_free;
- if(fw_asyreq(rb->fc, -1, rb->xfer)){
+ if (fw_asyreq(rb->fc, -1, rb->xfer))
fw_xfer_free(rb->xfer);
- return;
- }
- return;
}
len = 0;
- for (i = 0; i < rb->nvec; i ++)
+ for (i = 0; i < rb->nvec; i++)
len += rb->vec[i].iov_len;
rb->xfer = STAILQ_FIRST(&bind->xferlist);
if (rb->xfer == NULL) {
device_printf(rb->fc->bdev, "%s: "
- "Discard a packet for this bind.\n",
- __func__);
+ "Discard a packet for this bind.\n", __func__);
return;
}
STAILQ_REMOVE_HEAD(&bind->xferlist, link);
@@ -2073,11 +2060,11 @@ fw_rcv(struct fw_rcv_buf *rb)
printf("stream rcv dma %d len %d off %d spd %d\n",
sub, len, off, spd);
#endif
- if(xferq->queued >= xferq->maxq) {
+ if (xferq->queued >= xferq->maxq) {
printf("receive queue is full\n");
return;
}
- /* XXX get xfer from xfer queue, we don't need copy for
+ /* XXX get xfer from xfer queue, we don't need copy for
per packet mode */
rb->xfer = fw_xfer_alloc_buf(M_FWXFER, 0, /* XXX */
vec[0].iov_len);
@@ -2089,11 +2076,7 @@ fw_rcv(struct fw_rcv_buf *rb)
STAILQ_INSERT_TAIL(&xferq->q, rb->xfer, link);
splx(s);
sc = device_get_softc(rb->fc->bdev);
-#if defined(__DragonFly__) || __FreeBSD_version < 500000
- if (&xferq->rsel.si_pid != 0)
-#else
if (SEL_WAITING(&xferq->rsel))
-#endif
selwakeuppri(&xferq->rsel, FWPRI);
if (xferq->flag & FWXFERQ_WAKEUP) {
xferq->flag &= ~FWXFERQ_WAKEUP;
@@ -2108,7 +2091,7 @@ fw_rcv(struct fw_rcv_buf *rb)
#endif
default:
device_printf(rb->fc->bdev,"%s: unknown tcode %d\n",
- __func__, tcode);
+ __func__, tcode);
break;
}
}
@@ -2154,14 +2137,13 @@ static void
fw_try_bmr(void *arg)
{
struct fw_xfer *xfer;
- struct firewire_comm *fc = (struct firewire_comm *)arg;
+ struct firewire_comm *fc = arg;
struct fw_pkt *fp;
int err = 0;
xfer = fw_xfer_alloc_buf(M_FWXFER, 8, 4);
- if(xfer == NULL){
+ if (xfer == NULL)
return;
- }
xfer->send.spd = 0;
fc->status = FWBUSMGRELECT;
@@ -2180,7 +2162,7 @@ fw_try_bmr(void *arg)
xfer->hand = fw_try_bmr_callback;
err = fw_asyreq(fc, -1, xfer);
- if(err){
+ if (err) {
fw_xfer_free_buf(xfer);
return;
}
@@ -2190,33 +2172,37 @@ fw_try_bmr(void *arg)
#ifdef FW_VMACCESS
/*
* Software implementation for physical memory block access.
- * XXX:Too slow, usef for debug purpose only.
+ * XXX:Too slow, useful for debug purpose only.
*/
static void
-fw_vmaccess(struct fw_xfer *xfer){
+fw_vmaccess(struct fw_xfer *xfer)
+{
struct fw_pkt *rfp, *sfp = NULL;
uint32_t *ld = (uint32_t *)xfer->recv.buf;
printf("vmaccess spd:%2x len:%03x data:%08x %08x %08x %08x\n",
- xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]), ntohl(ld[3]));
- printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]), ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7]));
- if(xfer->resp != 0){
- fw_xfer_free( xfer);
+ xfer->spd, xfer->recv.len, ntohl(ld[0]), ntohl(ld[1]), ntohl(ld[2]),
+ ntohl(ld[3]));
+ printf("vmaccess data:%08x %08x %08x %08x\n", ntohl(ld[4]),
+ ntohl(ld[5]), ntohl(ld[6]), ntohl(ld[7]));
+ if (xfer->resp != 0) {
+ fw_xfer_free(xfer);
return;
}
- if(xfer->recv.buf == NULL){
- fw_xfer_free( xfer);
+ if (xfer->recv.buf == NULL) {
+ fw_xfer_free(xfer);
return;
}
rfp = (struct fw_pkt *)xfer->recv.buf;
- switch(rfp->mode.hdr.tcode){
+ switch (rfp->mode.hdr.tcode) {
/* XXX need fix for 64bit arch */
case FWTCODE_WREQB:
xfer->send.buf = malloc(12, M_FW, M_NOWAIT);
xfer->send.len = 12;
sfp = (struct fw_pkt *)xfer->send.buf;
bcopy(rfp->mode.wreqb.payload,
- (caddr_t)ntohl(rfp->mode.wreqb.dest_lo), ntohs(rfp->mode.wreqb.len));
+ (caddr_t)ntohl(rfp->mode.wreqb.dest_lo),s
+ ntohs(rfp->mode.wreqb.len));
sfp->mode.wres.tcode = FWTCODE_WRES;
sfp->mode.wres.rtcode = 0;
break;
@@ -2224,15 +2210,18 @@ fw_vmaccess(struct fw_xfer *xfer){
xfer->send.buf = malloc(12, M_FW, M_NOWAIT);
xfer->send.len = 12;
sfp->mode.wres.tcode = FWTCODE_WRES;
- *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) = rfp->mode.wreqq.data;
+ *((uint32_t *)(ntohl(rfp->mode.wreqb.dest_lo))) =
+ rfp->mode.wreqq.data;
sfp->mode.wres.rtcode = 0;
break;
case FWTCODE_RREQB:
- xfer->send.buf = malloc(16 + rfp->mode.rreqb.len, M_FW, M_NOWAIT);
+ xfer->send.buf = malloc(16 + rfp->mode.rreqb.len,
+ M_FW, M_NOWAIT);
xfer->send.len = 16 + ntohs(rfp->mode.rreqb.len);
sfp = (struct fw_pkt *)xfer->send.buf;
bcopy((caddr_t)ntohl(rfp->mode.rreqb.dest_lo),
- sfp->mode.rresb.payload, (uint16_t)ntohs(rfp->mode.rreqb.len));
+ sfp->mode.rresb.payload,
+ ntohs(rfp->mode.rreqb.len));
sfp->mode.rresb.tcode = FWTCODE_RRESB;
sfp->mode.rresb.len = rfp->mode.rreqb.len;
sfp->mode.rresb.rtcode = 0;
@@ -2242,12 +2231,13 @@ fw_vmaccess(struct fw_xfer *xfer){
xfer->send.buf = malloc(16, M_FW, M_NOWAIT);
xfer->send.len = 16;
sfp = (struct fw_pkt *)xfer->send.buf;
- sfp->mode.rresq.data = *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo));
+ sfp->mode.rresq.data =
+ *(uint32_t *)(ntohl(rfp->mode.rreqq.dest_lo));
sfp->mode.wres.tcode = FWTCODE_RRESQ;
sfp->mode.rresb.rtcode = 0;
break;
default:
- fw_xfer_free( xfer);
+ fw_xfer_free(xfer);
return;
}
sfp->mode.hdr.dst = rfp->mode.hdr.src;
@@ -2261,24 +2251,25 @@ fw_vmaccess(struct fw_xfer *xfer){
/**/
return;
}
-#endif
+#endif
/*
* CRC16 check-sum for IEEE1394 register blocks.
*/
uint16_t
-fw_crc16(uint32_t *ptr, uint32_t len){
+fw_crc16(uint32_t *ptr, uint32_t len)
+{
uint32_t i, sum, crc = 0;
int shift;
len = (len + 3) & ~3;
- for(i = 0 ; i < len ; i+= 4){
- for( shift = 28 ; shift >= 0 ; shift -= 4){
+ for (i = 0; i < len; i += 4) {
+ for (shift = 28; shift >= 0; shift -= 4) {
sum = ((crc >> 12) ^ (ptr[i/4] >> shift)) & 0xf;
- crc = (crc << 4) ^ ( sum << 12 ) ^ ( sum << 5) ^ sum;
+ crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum;
}
crc &= 0xffff;
}
- return((uint16_t) crc);
+ return ((uint16_t) crc);
}
/*
@@ -2303,7 +2294,7 @@ fw_bmr(struct firewire_comm *fc)
cmstr = fc->max_node;
else {
device_printf(fc->bdev,
- "root node is not cycle master capable\n");
+ "root node is not cycle master capable\n");
/* XXX shall we be the cycle master? */
cmstr = fc->nodeid;
/* XXX need bus reset */
@@ -2314,13 +2305,13 @@ fw_bmr(struct firewire_comm *fc)
device_printf(fc->bdev, "bus manager %d %s\n",
CSRARC(fc, BUS_MGR_ID),
(CSRARC(fc, BUS_MGR_ID) != fc->nodeid) ? "(me)" : "");
- if(CSRARC(fc, BUS_MGR_ID) != fc->nodeid) {
+ if (CSRARC(fc, BUS_MGR_ID) != fc->nodeid) {
/* We are not the bus manager */
- return(0);
+ return (0);
}
/* Optimize gapcount */
- if(fc->max_hop <= MAX_GAPHOP )
+ if (fc->max_hop <= MAX_GAPHOP)
fw_phy_config(fc, cmstr, gap_cnt[fc->max_hop]);
/* If we are the cycle master, nothing to do */
if (cmstr == fc->nodeid || cmstr == -1)
@@ -2335,7 +2326,7 @@ fw_bmr(struct firewire_comm *fc)
/* Set cmstr bit on the cycle master */
quad = htonl(1 << 8);
fwmem_write_quad(&fwdev, NULL, 0/*spd*/,
- 0xffff, 0xf0000000 | STATE_SET, &quad, fw_asy_callback_free);
+ 0xffff, 0xf0000000 | STATE_SET, &quad, fw_asy_callback_free);
return 0;
}
@@ -2353,7 +2344,7 @@ fw_open_isodma(struct firewire_comm *fc, int tx)
xferqa = &fc->ir[0];
FW_GLOCK(fc);
- for (i = 0; i < fc->nisodma; i ++) {
+ for (i = 0; i < fc->nisodma; i++) {
xferq = xferqa[i];
if ((xferq->flag & FWXFERQ_OPEN) == 0) {
xferq->flag |= FWXFERQ_OPEN;
@@ -2372,22 +2363,16 @@ static int
fw_modevent(module_t mode, int type, void *data)
{
int err = 0;
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
static eventhandler_tag fwdev_ehtag = NULL;
-#endif
switch (type) {
case MOD_LOAD:
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
fwdev_ehtag = EVENTHANDLER_REGISTER(dev_clone,
- fwdev_clone, 0, 1000);
-#endif
+ fwdev_clone, 0, 1000);
break;
case MOD_UNLOAD:
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
if (fwdev_ehtag != NULL)
EVENTHANDLER_DEREGISTER(dev_clone, fwdev_ehtag);
-#endif
break;
case MOD_SHUTDOWN:
break;
@@ -2398,8 +2383,6 @@ fw_modevent(module_t mode, int type, void *data)
}
-#ifdef __DragonFly__
-DECLARE_DUMMY_MODULE(firewire);
-#endif
-DRIVER_MODULE(firewire,fwohci,firewire_driver,firewire_devclass,fw_modevent,0);
+DRIVER_MODULE(firewire, fwohci, firewire_driver, firewire_devclass,
+ fw_modevent,0);
MODULE_VERSION(firewire, 1);
diff --git a/sys/dev/firewire/firewire.h b/sys/dev/firewire/firewire.h
index 0a512e1..442fd6f 100644
--- a/sys/dev/firewire/firewire.h
+++ b/sys/dev/firewire/firewire.h
@@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
@@ -42,8 +42,8 @@
#define DEV_DV 2
struct fw_isochreq {
- unsigned char ch:6,
- tag:2;
+ unsigned char ch:6;
+ unsigned char tag:2;
};
struct fw_isobufreq {
@@ -247,15 +247,15 @@ struct fw_eui64 {
uint32_t hi, lo;
};
#define FW_EUI64_BYTE(eui, x) \
- ((((x)<4)? \
- ((eui)->hi >> (8*(3-(x)))): \
- ((eui)->lo >> (8*(7-(x)))) \
+ ((((x) < 4)? \
+ ((eui)->hi >> (8 * (3 - (x)))): \
+ ((eui)->lo >> (8 * (7 - (x)))) \
) & 0xff)
#define FW_EUI64_EQUAL(x, y) \
((x).hi == (y).hi && (x).lo == (y).lo)
struct fw_asyreq {
- struct fw_asyreq_t{
+ struct fw_asyreq_t {
unsigned char sped;
unsigned int type;
#define FWASREQNODE 0
@@ -265,8 +265,8 @@ struct fw_asyreq {
unsigned short len;
union {
struct fw_eui64 eui;
- }dst;
- }req;
+ } dst;
+ } req;
struct fw_pkt pkt;
uint32_t data[512];
};
@@ -406,7 +406,7 @@ struct fw_topology_map {
uint32_t generation;
uint32_t self_id_count:16,
node_count:16;
- union fw_self_id self_id[4*64];
+ union fw_self_id self_id[4 * 64];
};
struct fw_speed_map {
diff --git a/sys/dev/firewire/firewire_phy.h b/sys/dev/firewire/firewire_phy.h
index 42feff2..a420a4a 100644
--- a/sys/dev/firewire/firewire_phy.h
+++ b/sys/dev/firewire/firewire_phy.h
@@ -29,7 +29,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
diff --git a/sys/dev/firewire/firewirereg.h b/sys/dev/firewire/firewirereg.h
index ba58f28..e9a8606 100644
--- a/sys/dev/firewire/firewirereg.h
+++ b/sys/dev/firewire/firewirereg.h
@@ -30,21 +30,13 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
-#ifdef __DragonFly__
-typedef d_thread_t fw_proc;
-#include <sys/select.h>
-#elif __FreeBSD_version >= 500000
typedef struct thread fw_proc;
#include <sys/selinfo.h>
-#else
-typedef struct proc fw_proc;
-#include <sys/select.h>
-#endif
#include <sys/uio.h>
#include <sys/mutex.h>
@@ -54,7 +46,7 @@ typedef struct proc fw_proc;
STAILQ_HEAD(fw_xferlist, fw_xfer);
-struct fw_device{
+struct fw_device {
uint16_t dst;
struct fw_eui64 eui;
uint8_t speed;
@@ -64,7 +56,7 @@ struct fw_device{
#define CSRROMOFF 0x400
#define CSRROMSIZE 0x400
int rommax; /* offset from 0xffff f000 0000 */
- uint32_t csrrom[CSRROMSIZE/4];
+ uint32_t csrrom[CSRROMSIZE / 4];
int rcnt;
struct firewire_comm *fc;
uint32_t status;
@@ -101,11 +93,11 @@ struct tcode_info {
u_char valid_res;
};
-struct firewire_comm{
+struct firewire_comm {
device_t dev;
device_t bdev;
uint16_t busid:10,
- nodeid:6;
+ nodeid:6;
u_int mode;
u_int nport;
u_int speed;
@@ -137,7 +129,7 @@ struct firewire_comm{
STAILQ_HEAD(, fw_device) devices;
u_int sid_cnt;
#define CSRSIZE 0x4000
- uint32_t csr_arc[CSRSIZE/4];
+ uint32_t csr_arc[CSRSIZE / 4];
#define CROMSIZE 0x400
uint32_t *config_rom;
struct crom_src_buf *crom_src_buf;
@@ -149,7 +141,7 @@ struct firewire_comm{
struct callout bmr_callout;
struct callout timeout_callout;
struct task task_timeout;
- uint32_t (*cyctimer) (struct firewire_comm *);
+ uint32_t (*cyctimer) (struct firewire_comm *);
void (*ibr) (struct firewire_comm *);
uint32_t (*set_bmr) (struct firewire_comm *, uint32_t);
int (*ioctl) (struct cdev *, u_long, caddr_t, int, fw_proc *);
@@ -169,7 +161,7 @@ struct firewire_comm{
struct taskqueue *taskqueue;
struct proc *probe_thread;
};
-#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
+#define CSRARC(sc, offset) ((sc)->csr_arc[(offset) / 4])
#define FW_GMTX(fc) (&(fc)->mtx)
#define FW_GLOCK(fc) mtx_lock(FW_GMTX(fc))
@@ -190,7 +182,7 @@ struct fw_xferq {
#define FWXFERQ_HANDLER (1 << 16)
#define FWXFERQ_WAKEUP (1 << 17)
- void (*start) (struct firewire_comm*);
+ void (*start) (struct firewire_comm *);
int dmach;
struct fw_xferlist q;
u_int queued;
@@ -209,7 +201,7 @@ struct fw_xferq {
void (*hand) (struct fw_xferq *);
};
-struct fw_bulkxfer{
+struct fw_bulkxfer {
int poffset;
struct mbuf *mbuf;
STAILQ_ENTRY(fw_bulkxfer) link;
@@ -218,7 +210,7 @@ struct fw_bulkxfer{
int resp;
};
-struct fw_bind{
+struct fw_bind {
u_int64_t start;
u_int64_t end;
struct fw_xferlist xferlist;
@@ -227,7 +219,7 @@ struct fw_bind{
void *sc;
};
-struct fw_xfer{
+struct fw_xfer {
caddr_t sc;
struct firewire_comm *fc;
struct fw_xferq *q;
@@ -267,9 +259,9 @@ struct fw_rcv_buf {
void fw_sidrcv (struct firewire_comm *, uint32_t *, u_int);
void fw_rcv (struct fw_rcv_buf *);
-void fw_xfer_unload ( struct fw_xfer*);
-void fw_xfer_free_buf ( struct fw_xfer*);
-void fw_xfer_free ( struct fw_xfer*);
+void fw_xfer_unload (struct fw_xfer *);
+void fw_xfer_free_buf (struct fw_xfer *);
+void fw_xfer_free (struct fw_xfer*);
struct fw_xfer *fw_xfer_alloc (struct malloc_type *);
struct fw_xfer *fw_xfer_alloc_buf (struct malloc_type *, int, int);
void fw_init (struct firewire_comm *);
@@ -280,7 +272,7 @@ int fw_bindremove (struct firewire_comm *, struct fw_bind *);
int fw_xferlist_add (struct fw_xferlist *, struct malloc_type *, int, int, int,
struct firewire_comm *, void *, void (*)(struct fw_xfer *));
void fw_xferlist_remove (struct fw_xferlist *);
-int fw_asyreq (struct firewire_comm *, int, struct fw_xfer*);
+int fw_asyreq (struct firewire_comm *, int, struct fw_xfer *);
void fw_busreset (struct firewire_comm *, uint32_t);
uint16_t fw_crc16 (uint32_t *, uint32_t);
void fw_xfer_timeout (void *);
@@ -301,7 +293,7 @@ extern int firewire_debug;
extern devclass_t firewire_devclass;
extern int firewire_phydma_enable;
-#define FWPRI ((PZERO+8)|PCATCH)
+#define FWPRI ((PZERO + 8) | PCATCH)
#define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */)
diff --git a/sys/dev/firewire/fwcrom.c b/sys/dev/firewire/fwcrom.c
index 4ee0f11..e53d3b6 100644
--- a/sys/dev/firewire/fwcrom.c
+++ b/sys/dev/firewire/fwcrom.c
@@ -59,13 +59,8 @@ __FBSDID("$FreeBSD$");
#endif
#endif
-#ifdef __DragonFly__
-#include "firewire.h"
-#include "iec13213.h"
-#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/iec13213.h>
-#endif
#define MAX_ROM (1024 - sizeof(uint32_t) * 5)
#define CROM_END(cc) ((vm_offset_t)(cc)->stack[0].dir + MAX_ROM - 1)
@@ -116,7 +111,7 @@ crom_next(struct crom_context *cc)
printf("crom_next: too deep\n");
goto again;
}
- cc->depth ++;
+ cc->depth++;
ptr = &cc->stack[cc->depth];
ptr->dir = (struct csrdirectory *) (reg + reg->val);
@@ -125,10 +120,10 @@ crom_next(struct crom_context *cc)
}
again:
ptr = &cc->stack[cc->depth];
- ptr->index ++;
+ ptr->index++;
check:
if (ptr->index < ptr->dir->crc_len &&
- (vm_offset_t)crom_get(cc) <= CROM_END(cc))
+ (vm_offset_t)crom_get(cc) <= CROM_END(cc))
return;
if (ptr->index < ptr->dir->crc_len)
@@ -148,7 +143,7 @@ crom_search_key(struct crom_context *cc, uint8_t key)
{
struct csrreg *reg;
- while(cc->depth >= 0) {
+ while (cc->depth >= 0) {
reg = crom_get(cc);
if (reg->key == key)
return reg;
@@ -166,7 +161,7 @@ crom_has_specver(uint32_t *p, uint32_t spec, uint32_t ver)
cc = &c;
crom_init_context(cc, p);
- while(cc->depth >= 0) {
+ while (cc->depth >= 0) {
reg = crom_get(cc);
if (state == 0) {
if (reg->key == CSRKEY_SPEC && reg->val == spec)
@@ -198,7 +193,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len)
reg = crom_get(cc);
if (reg->key != CROM_TEXTLEAF ||
- (vm_offset_t)(reg + reg->val) > CROM_END(cc)) {
+ (vm_offset_t)(reg + reg->val) > CROM_END(cc)) {
strncpy(buf, nullstr, len);
return;
}
@@ -215,7 +210,7 @@ crom_parse_text(struct crom_context *cc, char *buf, int len)
qlen = textleaf->crc_len - 2;
if (len < qlen * 4)
qlen = len/4;
- for (i = 0; i < qlen; i ++)
+ for (i = 0; i < qlen; i++)
*bp++ = ntohl(textleaf->text[i]);
/* make sure to terminate the string */
if (len <= qlen * 4)
@@ -238,7 +233,7 @@ crom_crc(uint32_t *ptr, int len)
}
crc &= 0xffff;
}
- return((uint16_t) crc);
+ return ((uint16_t) crc);
}
#if !defined(_KERNEL) && !defined(_BOOT)
@@ -315,17 +310,17 @@ crom_desc(struct crom_context *cc, char *buf, int len)
break;
case CSRTYPE_C:
len -= snprintf(buf, len, "offset=0x%04x(%d)",
- reg->val, reg->val);
+ reg->val, reg->val);
buf += strlen(buf);
break;
case CSRTYPE_L:
/* XXX fall through */
case CSRTYPE_D:
- dir = (struct csrdirectory *) (reg + reg->val);
+ dir = (struct csrdirectory *)(reg + reg->val);
crc = crom_crc((uint32_t *)&dir->entry[0], dir->crc_len);
len -= snprintf(buf, len, "len=%d crc=0x%04x(%s) ",
- dir->crc_len, dir->crc,
- (crc == dir->crc) ? "OK" : "NG");
+ dir->crc_len, dir->crc,
+ (crc == dir->crc) ? "OK" : "NG");
buf += strlen(buf);
}
switch (reg->key) {
@@ -399,11 +394,11 @@ crom_add_quad(struct crom_chunk *chunk, uint32_t entry)
index = chunk->data.crc_len;
if (index >= CROM_MAX_CHUNK_LEN - 1) {
printf("too large chunk %d\n", index);
- return(-1);
+ return (-1);
}
chunk->data.buf[index] = entry;
chunk->data.crc_len++;
- return(index);
+ return (index);
}
int
@@ -414,7 +409,7 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val)
struct csrreg reg;
uint32_t i;
} foo;
-
+
foo.reg.key = key;
foo.reg.val = val;
return (crom_add_quad(chunk, foo.i));
@@ -422,29 +417,29 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val)
int
crom_add_chunk(struct crom_src *src, struct crom_chunk *parent,
- struct crom_chunk *child, int key)
+ struct crom_chunk *child, int key)
{
int index;
if (parent == NULL) {
STAILQ_INSERT_TAIL(&src->chunk_list, child, link);
- return(0);
+ return (0);
}
index = crom_add_entry(parent, key, 0);
if (index < 0) {
- return(-1);
+ return (-1);
}
child->ref_chunk = parent;
child->ref_index = index;
STAILQ_INSERT_TAIL(&src->chunk_list, child, link);
- return(index);
+ return (index);
}
#define MAX_TEXT ((CROM_MAX_CHUNK_LEN + 1) * 4 - sizeof(struct csrtext))
int
crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
- struct crom_chunk *chunk, char *buf)
+ struct crom_chunk *chunk, char *buf)
{
struct csrtext *tl;
uint32_t *p;
@@ -453,7 +448,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
len = strlen(buf);
if (len > MAX_TEXT) {
- printf("text(%d) trancated to %td.\n", len, MAX_TEXT);
+ printf("text(%d) truncated to %td.\n", len, MAX_TEXT);
len = MAX_TEXT;
}
@@ -465,7 +460,7 @@ crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent,
bzero(&t[0], roundup2(len, sizeof(uint32_t)));
bcopy(buf, &t[0], len);
p = (uint32_t *)&t[0];
- for (i = 0; i < howmany(len, sizeof(uint32_t)); i ++)
+ for (i = 0; i < howmany(len, sizeof(uint32_t)); i++)
tl->text[i] = ntohl(*p++);
return (crom_add_chunk(src, parent, chunk, CROM_TEXTLEAF));
}
@@ -475,11 +470,11 @@ crom_copy(uint32_t *src, uint32_t *dst, int *offset, int len, int maxlen)
{
if (*offset + len > maxlen) {
printf("Config. ROM is too large for the buffer\n");
- return(-1);
+ return (-1);
}
bcopy(src, (char *)(dst + *offset), len * sizeof(uint32_t));
*offset += len;
- return(0);
+ return (0);
}
int
@@ -503,9 +498,9 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
if (parent != NULL) {
struct csrreg *reg;
reg = (struct csrreg *)
- &parent->data.buf[chunk->ref_index];
+ &parent->data.buf[chunk->ref_index];
reg->val = offset -
- (parent->offset + 1 + chunk->ref_index);
+ (parent->offset + 1 + chunk->ref_index);
}
offset += 1 + chunk->data.crc_len;
}
@@ -514,15 +509,15 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
len = 1 + src->hdr.info_len;
count = 0;
if (crom_copy((uint32_t *)&src->hdr, buf, &count, len, maxlen) < 0)
- return(-1);
+ return (-1);
STAILQ_FOREACH(chunk, &src->chunk_list, link) {
chunk->data.crc =
- crom_crc(&chunk->data.buf[0], chunk->data.crc_len);
+ crom_crc(&chunk->data.buf[0], chunk->data.crc_len);
len = 1 + chunk->data.crc_len;
if (crom_copy((uint32_t *)&chunk->data, buf,
- &count, len, maxlen) < 0)
- return(-1);
+ &count, len, maxlen) < 0)
+ return (-1);
}
hdr = (struct csrhdr *)buf;
hdr->crc_len = count - 1;
@@ -531,19 +526,20 @@ crom_load(struct crom_src *src, uint32_t *buf, int maxlen)
#if defined(_KERNEL) || defined(_BOOT)
/* byte swap */
ptr = buf;
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i++) {
*ptr = htonl(*ptr);
ptr++;
}
#endif
- return(count);
+ return (count);
}
#endif
#ifdef TEST
int
-main () {
+main()
+{
struct crom_src src;
struct crom_chunk root,unit1,unit2,unit3;
struct crom_chunk text1,text2,text3,text4,text5,text6,text7;
@@ -587,15 +583,9 @@ main () {
/* private company_id */
crom_add_entry(&root, CSRKEY_VENDOR, 0xacde48);
-#ifdef __DragonFly__
- crom_add_simple_text(&src, &root, &text1, "DragonFly");
- crom_add_entry(&root, CSRKEY_HW, __DragonFly_cc_version);
- crom_add_simple_text(&src, &root, &text2, "DragonFly-1");
-#else
crom_add_simple_text(&src, &root, &text1, "FreeBSD");
crom_add_entry(&root, CSRKEY_HW, __FreeBSD_version);
crom_add_simple_text(&src, &root, &text2, "FreeBSD-5");
-#endif
/* SBP unit directory */
crom_add_chunk(&src, &root, &unit1, CROM_UDIR);
@@ -628,11 +618,11 @@ main () {
crom_load(&src, buf, 256);
p = buf;
#define DUMP_FORMAT "%08x %08x %08x %08x %08x %08x %08x %08x\n"
- for (i = 0; i < 256/8; i ++) {
+ for (i = 0; i < 256/8; i++) {
printf(DUMP_FORMAT,
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
p += 8;
}
- return(0);
+ return (0);
}
#endif
diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c
index 20d89a4..e09ce2c 100644
--- a/sys/dev/firewire/fwdev.c
+++ b/sys/dev/firewire/fwdev.c
@@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
@@ -52,19 +52,11 @@
#include <sys/ioccom.h>
-#ifdef __DragonFly__
-#include "firewire.h"
-#include "firewirereg.h"
-#include "fwdma.h"
-#include "fwmem.h"
-#include "iec68113.h"
-#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwdma.h>
#include <dev/firewire/fwmem.h>
#include <dev/firewire/iec68113.h>
-#endif
#define FWNODE_INVAL 0xffff
@@ -78,12 +70,6 @@ static d_mmap_t fw_mmap;
static d_strategy_t fw_strategy;
struct cdevsw firewire_cdevsw = {
-#ifdef __DragonFly__
-#define CDEV_MAJOR 127
- "fw", CDEV_MAJOR, D_MEM, NULL, 0,
- fw_open, fw_close, fw_read, fw_write, fw_ioctl,
- fw_poll, fw_mmap, fw_strategy, nodump, nopsize,
-#elif __FreeBSD_version >= 500104
.d_version = D_VERSION,
.d_open = fw_open,
.d_close = fw_close,
@@ -95,12 +81,6 @@ struct cdevsw firewire_cdevsw = {
.d_strategy = fw_strategy,
.d_name = "fw",
.d_flags = D_MEM
-#else
-#define CDEV_MAJOR 127
- fw_open, fw_close, fw_read, fw_write, fw_ioctl,
- fw_poll, fw_mmap, fw_strategy, "fw", CDEV_MAJOR,
- nodump, nopsize, D_MEM, -1
-#endif
};
struct fw_drv1 {
@@ -119,22 +99,21 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q,
int i;
if (q->flag & (FWXFERQ_RUNNING | FWXFERQ_EXTBUF))
- return(EBUSY);
+ return (EBUSY);
- q->bulkxfer = (struct fw_bulkxfer *) malloc(
- sizeof(struct fw_bulkxfer) * b->nchunk,
- M_FW, M_WAITOK);
+ q->bulkxfer = malloc(sizeof(struct fw_bulkxfer) * b->nchunk,
+ M_FW, M_WAITOK);
if (q->bulkxfer == NULL)
- return(ENOMEM);
+ return (ENOMEM);
b->psize = roundup2(b->psize, sizeof(uint32_t));
q->buf = fwdma_malloc_multiseg(fc, sizeof(uint32_t),
- b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK);
+ b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK);
if (q->buf == NULL) {
free(q->bulkxfer, M_FW);
q->bulkxfer = NULL;
- return(ENOMEM);
+ return (ENOMEM);
}
q->bnchunk = b->nchunk;
q->bnpacket = b->npacket;
@@ -146,7 +125,7 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q,
STAILQ_INIT(&q->stdma);
q->stproc = NULL;
- for(i = 0 ; i < q->bnchunk; i++){
+ for (i = 0; i < q->bnchunk; i++) {
q->bulkxfer[i].poffset = i * q->bnpacket;
q->bulkxfer[i].mbuf = NULL;
STAILQ_INSERT_TAIL(&q->stfree, &q->bulkxfer[i], link);
@@ -177,7 +156,7 @@ fwdev_freebuf(struct fw_xferq *q)
static int
-fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
+fw_open(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
int err = 0;
int unit = DEV2UNIT(dev);
@@ -209,10 +188,10 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
int sub = DEV2SUB(dev);
make_dev(&firewire_cdevsw, dev2unit(dev),
- UID_ROOT, GID_OPERATOR, 0660,
- "fw%d.%d", unit, sub);
+ UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, sub);
}
- d = (struct fw_drv1 *)dev->si_drv1;
+
+ d = dev->si_drv1;
d->fc = sc->fc;
STAILQ_INIT(&d->binds);
STAILQ_INIT(&d->rq);
@@ -221,7 +200,7 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
}
static int
-fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
+fw_close(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct firewire_comm *fc;
struct fw_drv1 *d;
@@ -232,12 +211,12 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
if (DEV_FWMEM(dev))
return fwmem_close(dev, flags, fmt, td);
- d = (struct fw_drv1 *)dev->si_drv1;
+ d = dev->si_drv1;
fc = d->fc;
/* remove binding */
for (fwb = STAILQ_FIRST(&d->binds); fwb != NULL;
- fwb = STAILQ_FIRST(&d->binds)) {
+ fwb = STAILQ_FIRST(&d->binds)) {
fw_bindremove(fc, fwb);
STAILQ_REMOVE_HEAD(&d->binds, chlist);
fw_xferlist_remove(&fwb->xferlist);
@@ -256,15 +235,15 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
fwdev_freebuf(ir);
/* drain receiving buffer */
for (xfer = STAILQ_FIRST(&ir->q);
- xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) {
- ir->queued --;
+ xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) {
+ ir->queued--;
STAILQ_REMOVE_HEAD(&ir->q, link);
xfer->resp = 0;
fw_xfer_done(xfer);
}
- ir->flag &= ~(FWXFERQ_OPEN |
- FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
+ ir->flag &= ~(FWXFERQ_OPEN | FWXFERQ_MODEMASK |
+ FWXFERQ_CHTAGMASK);
d->ir = NULL;
}
@@ -280,7 +259,7 @@ fw_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
/* free extbuf */
fwdev_freebuf(it);
it->flag &= ~(FWXFERQ_OPEN |
- FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
+ FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
d->it = NULL;
}
free(dev->si_drv1, M_FW);
@@ -317,10 +296,10 @@ fw_read_async(struct fw_drv1 *d, struct uio *uio, int ioflag)
fc->irx_post(fc, fp->mode.ld);
#endif
tinfo = &xfer->fc->tcode[fp->mode.hdr.tcode];
- err = uiomove((void *)fp, tinfo->hdr_len, uio);
+ err = uiomove(fp, tinfo->hdr_len, uio);
if (err)
goto out;
- err = uiomove((void *)xfer->recv.payload, xfer->recv.pay_len, uio);
+ err = uiomove(xfer->recv.payload, xfer->recv.pay_len, uio);
out:
/* recycle this xfer */
@@ -337,7 +316,7 @@ out:
* read request.
*/
static int
-fw_read (struct cdev *dev, struct uio *uio, int ioflag)
+fw_read(struct cdev *dev, struct uio *uio, int ioflag)
{
struct fw_drv1 *d;
struct fw_xferq *ir;
@@ -348,7 +327,7 @@ fw_read (struct cdev *dev, struct uio *uio, int ioflag)
if (DEV_FWMEM(dev))
return (physio(dev, uio, ioflag));
- d = (struct fw_drv1 *)dev->si_drv1;
+ d = dev->si_drv1;
fc = d->fc;
ir = d->ir;
@@ -383,21 +362,21 @@ readloop:
err = EIO;
FW_GUNLOCK(fc);
return err;
- } else if(ir->stproc != NULL) {
+ } else if (ir->stproc != NULL) {
/* iso bulkxfer */
FW_GUNLOCK(fc);
- fp = (struct fw_pkt *)fwdma_v_addr(ir->buf,
- ir->stproc->poffset + ir->queued);
- if(fc->irx_post != NULL)
+ fp = (struct fw_pkt *)fwdma_v_addr(ir->buf,
+ ir->stproc->poffset + ir->queued);
+ if (fc->irx_post != NULL)
fc->irx_post(fc, fp->mode.ld);
- if(fp->mode.stream.len == 0){
+ if (fp->mode.stream.len == 0) {
err = EIO;
return err;
}
err = uiomove((caddr_t)fp,
fp->mode.stream.len + sizeof(uint32_t), uio);
- ir->queued ++;
- if(ir->queued >= ir->bnpacket){
+ ir->queued++;
+ if (ir->queued >= ir->bnpacket) {
s = splfw();
STAILQ_INSERT_TAIL(&ir->stfree, ir->stproc, link);
splx(s);
@@ -470,7 +449,7 @@ out:
}
static int
-fw_write (struct cdev *dev, struct uio *uio, int ioflag)
+fw_write(struct cdev *dev, struct uio *uio, int ioflag)
{
int err = 0;
int s, slept = 0;
@@ -482,7 +461,7 @@ fw_write (struct cdev *dev, struct uio *uio, int ioflag)
if (DEV_FWMEM(dev))
return (physio(dev, uio, ioflag));
- d = (struct fw_drv1 *)dev->si_drv1;
+ d = dev->si_drv1;
fc = d->fc;
it = d->it;
@@ -523,7 +502,7 @@ isoloop:
err = uiomove((caddr_t)fp, sizeof(struct fw_isohdr), uio);
err = uiomove((caddr_t)fp->mode.stream.payload,
fp->mode.stream.len, uio);
- it->queued ++;
+ it->queued++;
if (it->queued >= it->bnpacket) {
s = splfw();
STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link);
@@ -550,7 +529,7 @@ fw_hand(struct fw_xfer *xfer)
struct fw_drv1 *d;
fwb = (struct fw_bind *)xfer->sc;
- d = (struct fw_drv1 *)fwb->sc;
+ d = fwb->sc;
FW_GLOCK(xfer->fc);
STAILQ_INSERT_TAIL(&d->rq, xfer, link);
FW_GUNLOCK(xfer->fc);
@@ -561,7 +540,7 @@ fw_hand(struct fw_xfer *xfer)
* ioctl support.
*/
int
-fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
+fw_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
{
struct firewire_comm *fc;
struct fw_drv1 *d;
@@ -585,9 +564,9 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
return fwmem_ioctl(dev, cmd, data, flag, td);
if (!data)
- return(EINVAL);
+ return (EINVAL);
- d = (struct fw_drv1 *)dev->si_drv1;
+ d = dev->si_drv1;
fc = d->fc;
ir = d->ir;
it = d->it;
@@ -703,7 +682,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
bcopy(fp, (void *)&xfer->send.hdr, tinfo->hdr_len);
if (pay_len > 0)
bcopy((char *)fp + tinfo->hdr_len,
- (void *)xfer->send.payload, pay_len);
+ xfer->send.payload, pay_len);
xfer->send.spd = asyreq->req.sped;
xfer->hand = fw_xferwake;
@@ -725,7 +704,7 @@ fw_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
pay_len = xfer->recv.pay_len;
if (asyreq->req.len >= xfer->recv.pay_len + tinfo->hdr_len) {
asyreq->req.len = xfer->recv.pay_len +
- tinfo->hdr_len;
+ tinfo->hdr_len;
} else {
err = EINVAL;
pay_len = 0;
@@ -745,7 +724,7 @@ out:
case FW_CBINDADDR:
fwb = fw_bindlookup(fc,
bindreq->start.hi, bindreq->start.lo);
- if(fwb == NULL){
+ if (fwb == NULL) {
err = EINVAL;
break;
}
@@ -755,30 +734,30 @@ out:
free(fwb, M_FW);
break;
case FW_SBINDADDR:
- if(bindreq->len <= 0 ){
+ if (bindreq->len <= 0) {
err = EINVAL;
break;
}
- if(bindreq->start.hi > 0xffff ){
+ if (bindreq->start.hi > 0xffff) {
err = EINVAL;
break;
}
- fwb = (struct fw_bind *)malloc(sizeof (struct fw_bind), M_FW, M_WAITOK);
- if(fwb == NULL){
+ fwb = malloc(sizeof(struct fw_bind), M_FW, M_WAITOK);
+ if (fwb == NULL) {
err = ENOMEM;
break;
}
fwb->start = ((u_int64_t)bindreq->start.hi << 32) |
bindreq->start.lo;
fwb->end = fwb->start + bindreq->len;
- fwb->sc = (void *)d;
+ fwb->sc = d;
STAILQ_INIT(&fwb->xferlist);
err = fw_bindadd(fc, fwb);
if (err == 0) {
fw_xferlist_add(&fwb->xferlist, M_FWXFER,
/* XXX */
PAGE_SIZE, PAGE_SIZE, 5,
- fc, (void *)fwb, fw_hand);
+ fc, fwb, fw_hand);
STAILQ_INSERT_TAIL(&d->binds, fwb, chlist);
}
break;
@@ -791,11 +770,11 @@ out:
devinfo->eui.hi = fc->eui.hi;
devinfo->eui.lo = fc->eui.lo;
STAILQ_FOREACH(fwdev, &fc->devices, link) {
- if(len < FW_MAX_DEVLST){
+ if (len < FW_MAX_DEVLST) {
devinfo = &fwdevlst->dev[len++];
devinfo->dst = fwdev->dst;
- devinfo->status =
- (fwdev->status == FWDEVINVAL)?0:1;
+ devinfo->status =
+ (fwdev->status == FWDEVINVAL) ? 0 : 1;
devinfo->eui.hi = fwdev->eui.hi;
devinfo->eui.lo = fwdev->eui.lo;
}
@@ -806,7 +785,7 @@ out:
break;
case FW_GTPMAP:
bcopy(fc->topology_map, data,
- (fc->topology_map->crc_len + 1) * 4);
+ (fc->topology_map->crc_len + 1) * 4);
break;
case FW_GCROM:
STAILQ_FOREACH(fwdev, &fc->devices, link)
@@ -841,7 +820,7 @@ out:
free(ptr, M_FW);
break;
default:
- fc->ioctl (dev, cmd, data, flag, td);
+ fc->ioctl(dev, cmd, data, flag, td);
break;
}
return err;
@@ -867,7 +846,7 @@ fw_poll(struct cdev *dev, int events, fw_proc *td)
}
tmp = POLLOUT | POLLWRNORM;
if (events & tmp) {
- /* XXX should be fixed */
+ /* XXX should be fixed */
revents |= tmp;
}
@@ -877,7 +856,7 @@ fw_poll(struct cdev *dev, int events, fw_proc *td)
static int
fw_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int nproto, vm_memattr_t *memattr)
-{
+{
if (DEV_FWMEM(dev))
return fwmem_mmap(dev, offset, paddr, nproto, memattr);
@@ -912,12 +891,9 @@ fwdev_makedev(struct firewire_softc *sc)
unit = device_get_unit(sc->fc->bdev);
sc->dev = make_dev(&firewire_cdevsw, MAKEMINOR(0, unit, 0),
- UID_ROOT, GID_OPERATOR, 0660,
- "fw%d.%d", unit, 0);
- d = make_dev(&firewire_cdevsw,
- MAKEMINOR(FWMEM_FLAG, unit, 0),
- UID_ROOT, GID_OPERATOR, 0660,
- "fwmem%d.%d", unit, 0);
+ UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, 0);
+ d = make_dev(&firewire_cdevsw, MAKEMINOR(FWMEM_FLAG, unit, 0),
+ UID_ROOT, GID_OPERATOR, 0660, "fwmem%d.%d", unit, 0);
dev_depends(sc->dev, d);
make_dev_alias(sc->dev, "fw%d", unit);
make_dev_alias(d, "fwmem%d", unit);
diff --git a/sys/dev/firewire/fwdma.c b/sys/dev/firewire/fwdma.c
index d63966d..c8378f0 100644
--- a/sys/dev/firewire/fwdma.c
+++ b/sys/dev/firewire/fwdma.c
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2003
* Hidetoshi Shimokawa. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
*/
#ifdef __FreeBSD__
@@ -87,7 +87,7 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size,
&dma->dma_tag);
if (err) {
printf("fwdma_malloc: failed(1)\n");
- return(NULL);
+ return (NULL);
}
err = bus_dmamem_alloc(dma->dma_tag, &dma->v_addr,
@@ -95,13 +95,13 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size,
if (err) {
printf("fwdma_malloc: failed(2)\n");
/* XXX destroy tag */
- return(NULL);
+ return (NULL);
}
bus_dmamap_load(dma->dma_tag, dma->dma_map, dma->v_addr,
size, fwdma_map_cb, &dma->bus_addr, /*flags*/0);
- return(dma->v_addr);
+ return (dma->v_addr);
}
void
@@ -121,11 +121,11 @@ fwdma_malloc_size(bus_dma_tag_t dmat, bus_dmamap_t *dmamap,
if (bus_dmamem_alloc(dmat, &v_addr, flag, dmamap)) {
printf("fwdma_malloc_size: failed(1)\n");
- return(NULL);
+ return (NULL);
}
bus_dmamap_load(dmat, *dmamap, v_addr, size,
fwdma_map_cb, bus_addr, /*flags*/0);
- return(v_addr);
+ return (v_addr);
}
void
@@ -134,7 +134,7 @@ fwdma_free_size(bus_dma_tag_t dmat, bus_dmamap_t dmamap,
{
bus_dmamap_unload(dmat, dmamap);
bus_dmamem_free(dmat, vaddr, dmamap);
-}
+}
/*
* Allocate multisegment dma buffers
@@ -162,7 +162,7 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
+ sizeof(struct fwdma_seg)*nseg, M_FW, M_WAITOK);
if (am == NULL) {
printf("fwdma_malloc_multiseg: malloc failed\n");
- return(NULL);
+ return (NULL);
}
am->ssize = ssize;
am->esize = esize;
@@ -183,21 +183,21 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment,
&am->dma_tag)) {
printf("fwdma_malloc_multiseg: tag_create failed\n");
free(am, M_FW);
- return(NULL);
+ return (NULL);
}
- for (seg = &am->seg[0]; nseg --; seg ++) {
+ for (seg = &am->seg[0]; nseg--; seg++) {
seg->v_addr = fwdma_malloc_size(am->dma_tag, &seg->dma_map,
ssize, &seg->bus_addr, flag);
if (seg->v_addr == NULL) {
printf("fwdma_malloc_multi: malloc_size failed %d\n",
am->nseg);
fwdma_free_multiseg(am);
- return(NULL);
+ return (NULL);
}
am->nseg++;
}
- return(am);
+ return (am);
}
void
@@ -205,7 +205,7 @@ fwdma_free_multiseg(struct fwdma_alloc_multi *am)
{
struct fwdma_seg *seg;
- for (seg = &am->seg[0]; am->nseg --; seg ++) {
+ for (seg = &am->seg[0]; am->nseg--; seg++) {
fwdma_free_size(am->dma_tag, seg->dma_map,
seg->v_addr, am->ssize);
}
diff --git a/sys/dev/firewire/fwdma.h b/sys/dev/firewire/fwdma.h
index 3a8278c..ec67971 100644
--- a/sys/dev/firewire/fwdma.h
+++ b/sys/dev/firewire/fwdma.h
@@ -1,7 +1,7 @@
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,20 +30,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*/
struct fwdma_alloc {
bus_dma_tag_t dma_tag;
bus_dmamap_t dma_map;
- void * v_addr;
+ void *v_addr;
bus_addr_t bus_addr;
};
struct fwdma_seg {
bus_dmamap_t dma_map;
- void * v_addr;
+ void *v_addr;
bus_addr_t bus_addr;
};
@@ -74,20 +74,20 @@ fwdma_bus_addr(struct fwdma_alloc_multi *am, int index)
}
static __inline void
-fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op)
+fwdma_sync(struct fwdma_alloc *dma, bus_dmasync_op_t op)
{
bus_dmamap_sync(dma->dma_tag, dma->dma_map, op);
}
static __inline void
fwdma_sync_multiseg(struct fwdma_alloc_multi *am,
- int start, int end, bus_dmasync_op_t op)
+ int start, int end, bus_dmasync_op_t op)
{
struct fwdma_seg *seg, *eseg;
seg = &am->seg[am->esize * start / am->ssize];
eseg = &am->seg[am->esize * end / am->ssize];
- for (; seg <= eseg; seg ++)
+ for (; seg <= eseg; seg++)
bus_dmamap_sync(am->dma_tag, seg->dma_map, op);
}
diff --git a/sys/dev/firewire/fwmem.c b/sys/dev/firewire/fwmem.c
index 4cd24d0..182fc8a 100644
--- a/sys/dev/firewire/fwmem.c
+++ b/sys/dev/firewire/fwmem.c
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
*/
#ifdef __FreeBSD__
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/fwmem.h>
-static int fwmem_speed=2, fwmem_debug=0;
+static int fwmem_speed = 2, fwmem_debug = 0;
static struct fw_eui64 fwmem_eui64;
SYSCTL_DECL(_hw_firewire);
static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwmem, CTLFLAG_RD, 0,
@@ -126,7 +126,7 @@ fwmem_read_quad(
struct fw_xfer *xfer;
struct fw_pkt *fp;
- xfer = fwmem_xfer_req(fwdev, (void *)sc, spd, 0, 4, hand);
+ xfer = fwmem_xfer_req(fwdev, sc, spd, 0, 4, hand);
if (xfer == NULL) {
return NULL;
}
@@ -141,7 +141,7 @@ fwmem_read_quad(
if (fwmem_debug)
printf("fwmem_read_quad: %d %04x:%08x\n", fwdev->dst,
- dst_hi, dst_lo);
+ dst_hi, dst_lo);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@@ -177,7 +177,7 @@ fwmem_write_quad(
if (fwmem_debug)
printf("fwmem_write_quad: %d %04x:%08x %08x\n", fwdev->dst,
- dst_hi, dst_lo, *(uint32_t *)data);
+ dst_hi, dst_lo, *(uint32_t *)data);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@@ -199,7 +199,7 @@ fwmem_read_block(
{
struct fw_xfer *xfer;
struct fw_pkt *fp;
-
+
xfer = fwmem_xfer_req(fwdev, sc, spd, 0, roundup2(len, 4), hand);
if (xfer == NULL)
return NULL;
@@ -216,7 +216,7 @@ fwmem_read_block(
if (fwmem_debug)
printf("fwmem_read_block: %d %04x:%08x %d\n", fwdev->dst,
- dst_hi, dst_lo, len);
+ dst_hi, dst_lo, len);
if (fw_asyreq(xfer->fc, -1, xfer) == 0)
return xfer;
@@ -262,9 +262,8 @@ fwmem_write_block(
return NULL;
}
-
int
-fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
+fwmem_open(struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct fwmem_softc *fms;
struct firewire_softc *sc;
@@ -278,20 +277,20 @@ fwmem_open (struct cdev *dev, int flags, int fmt, fw_proc *td)
if (dev->si_drv1 != NULL) {
if ((flags & FWRITE) != 0) {
FW_GUNLOCK(sc->fc);
- return(EBUSY);
+ return (EBUSY);
}
FW_GUNLOCK(sc->fc);
- fms = (struct fwmem_softc *)dev->si_drv1;
- fms->refcount ++;
+ fms = dev->si_drv1;
+ fms->refcount++;
} else {
dev->si_drv1 = (void *)-1;
FW_GUNLOCK(sc->fc);
dev->si_drv1 = malloc(sizeof(struct fwmem_softc),
- M_FWMEM, M_WAITOK);
+ M_FWMEM, M_WAITOK);
if (dev->si_drv1 == NULL)
- return(ENOMEM);
+ return (ENOMEM);
dev->si_iosize_max = DFLTPHYS;
- fms = (struct fwmem_softc *)dev->si_drv1;
+ fms = dev->si_drv1;
bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64));
fms->sc = sc;
fms->refcount = 1;
@@ -307,10 +306,10 @@ fwmem_close (struct cdev *dev, int flags, int fmt, fw_proc *td)
{
struct fwmem_softc *fms;
- fms = (struct fwmem_softc *)dev->si_drv1;
+ fms = dev->si_drv1;
FW_GLOCK(fms->sc->fc);
- fms->refcount --;
+ fms->refcount--;
FW_GUNLOCK(fms->sc->fc);
if (fwmem_debug)
printf("%s: refcount=%d\n", __func__, fms->refcount);
@@ -349,18 +348,18 @@ fwmem_strategy(struct bio *bp)
struct fw_device *fwdev;
struct fw_xfer *xfer;
struct cdev *dev;
- int err=0, s, iolen;
+ int err = 0, s, iolen;
dev = bp->bio_dev;
/* XXX check request length */
s = splfw();
- fms = (struct fwmem_softc *)dev->si_drv1;
+ fms = dev->si_drv1;
fwdev = fw_noderesolve_eui64(fms->sc->fc, &fms->eui);
if (fwdev == NULL) {
if (fwmem_debug)
printf("fwmem: no such device ID:%08x%08x\n",
- fms->eui.hi, fms->eui.lo);
+ fms->eui.hi, fms->eui.lo);
err = EINVAL;
goto error;
}
@@ -369,12 +368,12 @@ fwmem_strategy(struct bio *bp)
if ((bp->bio_cmd & BIO_READ) == BIO_READ) {
if (iolen == 4 && (bp->bio_offset & 3) == 0)
xfer = fwmem_read_quad(fwdev,
- (void *) bp, fwmem_speed,
+ (void *)bp, fwmem_speed,
bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
bp->bio_data, fwmem_biodone);
else
xfer = fwmem_read_block(fwdev,
- (void *) bp, fwmem_speed,
+ (void *)bp, fwmem_speed,
bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
iolen, bp->bio_data, fwmem_biodone);
} else {
@@ -408,12 +407,12 @@ error:
}
int
-fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
+fwmem_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
{
struct fwmem_softc *fms;
int err = 0;
- fms = (struct fwmem_softc *)dev->si_drv1;
+ fms = dev->si_drv1;
switch (cmd) {
case FW_SDEUI64:
bcopy(data, &fms->eui, sizeof(struct fw_eui64));
@@ -424,16 +423,18 @@ fwmem_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
default:
err = EINVAL;
}
- return(err);
+ return (err);
}
+
int
-fwmem_poll (struct cdev *dev, int events, fw_proc *td)
-{
+fwmem_poll(struct cdev *dev, int events, fw_proc *td)
+{
return EINVAL;
}
+
int
-fwmem_mmap (struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
+fwmem_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int nproto, vm_memattr_t *memattr)
-{
+{
return EINVAL;
}
diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c
index 06321f0..e0d638d 100644
--- a/sys/dev/firewire/fwohci.c
+++ b/sys/dev/firewire/fwohci.c
@@ -30,18 +30,11 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
-#define ATRQ_CH 0
-#define ATRS_CH 1
-#define ARRQ_CH 2
-#define ARRS_CH 3
-#define ITX_CH 4
-#define IRX_CH 0x24
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -73,25 +66,25 @@ SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RWTUN,
SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RWTUN,
&firewire_phydma_enable, 0, "Allow physical request DMA from firewire");
-static char dbcode[16][0x10]={"OUTM", "OUTL","INPM","INPL",
- "STOR","LOAD","NOP ","STOP",};
-
-static char dbkey[8][0x10]={"ST0", "ST1","ST2","ST3",
- "UNDEF","REG","SYS","DEV"};
-static char dbcond[4][0x10]={"NEV","C=1", "C=0", "ALL"};
-char fwohcicode[32][0x20]={
- "No stat","Undef","long","miss Ack err",
- "FIFO underrun","FIFO overrun","desc err", "data read err",
- "data write err","bus reset","timeout","tcode err",
- "Undef","Undef","unknown event","flushed",
- "Undef","ack complete","ack pend","Undef",
- "ack busy_X","ack busy_A","ack busy_B","Undef",
- "Undef","Undef","Undef","ack tardy",
- "Undef","ack data_err","ack type_err",""};
+static char dbcode[16][0x10] = {"OUTM", "OUTL", "INPM", "INPL",
+ "STOR", "LOAD", "NOP ", "STOP",};
+
+static char dbkey[8][0x10] = {"ST0", "ST1", "ST2", "ST3",
+ "UNDEF", "REG", "SYS", "DEV"};
+static char dbcond[4][0x10] = {"NEV", "C=1", "C=0", "ALL"};
+char fwohcicode[32][0x20]= {
+ "No stat", "Undef", "long", "miss Ack err",
+ "FIFO underrun", "FIFO overrun", "desc err", "data read err",
+ "data write err", "bus reset", "timeout", "tcode err",
+ "Undef", "Undef", "unknown event", "flushed",
+ "Undef" ,"ack complete", "ack pend", "Undef",
+ "ack busy_X", "ack busy_A", "ack busy_B", "Undef",
+ "Undef", "Undef", "Undef", "ack tardy",
+ "Undef", "ack data_err", "ack type_err", ""};
#define MAX_SPEED 3
extern char *linkspeed[];
-uint32_t tagbit[4] = { 1 << 28, 1 << 29, 1 << 30, 1 << 31};
+uint32_t tagbit[4] = {1 << 28, 1 << 29, 1 << 30, 1 << 31};
static struct tcode_info tinfo[] = {
/* hdr_len block flag valid_response */
@@ -113,6 +106,13 @@ static struct tcode_info tinfo[] = {
/* f XXX */ { 0, 0, 0xff}
};
+#define ATRQ_CH 0
+#define ATRS_CH 1
+#define ARRQ_CH 2
+#define ARRS_CH 3
+#define ITX_CH 4
+#define IRX_CH 0x24
+
#define OHCI_WRITE_SIGMASK 0xffff0000
#define OHCI_READ_SIGMASK 0xffff0000
@@ -127,8 +127,8 @@ static void fwohci_txd (struct fwohci_softc *, struct fwohci_dbch *);
static void fwohci_start_atq (struct firewire_comm *);
static void fwohci_start_ats (struct firewire_comm *);
static void fwohci_start (struct fwohci_softc *, struct fwohci_dbch *);
-static uint32_t fwphy_wrdata ( struct fwohci_softc *, uint32_t, uint32_t);
-static uint32_t fwphy_rddata ( struct fwohci_softc *, uint32_t);
+static uint32_t fwphy_wrdata (struct fwohci_softc *, uint32_t, uint32_t);
+static uint32_t fwphy_rddata (struct fwohci_softc *, uint32_t);
static int fwohci_rx_enable (struct fwohci_softc *, struct fwohci_dbch *);
static int fwohci_tx_enable (struct fwohci_softc *, struct fwohci_dbch *);
static int fwohci_irx_enable (struct firewire_comm *, int);
@@ -143,9 +143,9 @@ static void fwohci_set_intr (struct firewire_comm *, int);
static int fwohci_add_rx_buf (struct fwohci_dbch *, struct fwohcidb_tr *, int, struct fwdma_alloc *);
static int fwohci_add_tx_buf (struct fwohci_dbch *, struct fwohcidb_tr *, int);
-static void dump_db (struct fwohci_softc *, uint32_t);
-static void print_db (struct fwohcidb_tr *, struct fwohcidb *, uint32_t , uint32_t);
-static void dump_dma (struct fwohci_softc *, uint32_t);
+static void dump_db (struct fwohci_softc *, uint32_t);
+static void print_db (struct fwohcidb_tr *, struct fwohcidb *, uint32_t , uint32_t);
+static void dump_dma (struct fwohci_softc *, uint32_t);
static uint32_t fwohci_cyctimer (struct firewire_comm *);
static void fwohci_rbuf_update (struct fwohci_softc *, int);
static void fwohci_tbuf_update (struct fwohci_softc *, int);
@@ -257,18 +257,19 @@ d_ioctl_t fwohci_ioctl;
*/
/* XXX need lock for phy access */
static uint32_t
-fwphy_wrdata( struct fwohci_softc *sc, uint32_t addr, uint32_t data)
+fwphy_wrdata(struct fwohci_softc *sc, uint32_t addr, uint32_t data)
{
uint32_t fun;
addr &= 0xf;
data &= 0xff;
- fun = (PHYDEV_WRCMD | (addr << PHYDEV_REGADDR) | (data << PHYDEV_WRDATA));
+ fun = (PHYDEV_WRCMD | (addr << PHYDEV_REGADDR) |
+ (data << PHYDEV_WRDATA));
OWRITE(sc, OHCI_PHYACCESS, fun);
DELAY(100);
- return(fwphy_rddata( sc, addr));
+ return (fwphy_rddata(sc, addr));
}
static uint32_t
@@ -289,17 +290,16 @@ fwohci_set_bus_manager(struct firewire_comm *fc, u_int node)
for (i = 0; !(OREAD(sc, OHCI_CSR_CONT) & (1<<31)) && (i < 1000); i++)
DELAY(10);
bm = OREAD(sc, OHCI_CSR_DATA);
- if((bm & 0x3f) == 0x3f)
+ if ((bm & 0x3f) == 0x3f)
bm = node;
if (firewire_debug)
device_printf(sc->fc.dev, "%s: %d->%d (loop=%d)\n",
__func__, bm, node, i);
-
- return(bm);
+ return (bm);
}
static uint32_t
-fwphy_rddata(struct fwohci_softc *sc, u_int addr)
+fwphy_rddata(struct fwohci_softc *sc, u_int addr)
{
uint32_t fun, stat;
u_int i, retry = 0;
@@ -310,13 +310,13 @@ again:
OWRITE(sc, FWOHCI_INTSTATCLR, OHCI_INT_REG_FAIL);
fun = PHYDEV_RDCMD | (addr << PHYDEV_REGADDR);
OWRITE(sc, OHCI_PHYACCESS, fun);
- for ( i = 0 ; i < MAX_RETRY ; i ++ ){
+ for (i = 0; i < MAX_RETRY; i++) {
fun = OREAD(sc, OHCI_PHYACCESS);
if ((fun & PHYDEV_RDCMD) == 0 && (fun & PHYDEV_RDDONE) != 0)
break;
DELAY(100);
}
- if(i >= MAX_RETRY) {
+ if (i >= MAX_RETRY) {
if (firewire_debug)
device_printf(sc->fc.dev, "%s: failed(1).\n", __func__);
if (++retry < MAX_RETRY) {
@@ -336,12 +336,13 @@ again:
}
}
if (firewire_debug > 1 || retry >= MAX_RETRY)
- device_printf(sc->fc.dev,
+ device_printf(sc->fc.dev,
"%s:: 0x%x loop=%d, retry=%d\n",
__func__, addr, i, retry);
#undef MAX_RETRY
- return((fun >> PHYDEV_RDDATA )& 0xff);
+ return ((fun >> PHYDEV_RDDATA) & 0xff);
}
+
/* Device specific ioctl. */
int
fwohci_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
@@ -350,41 +351,41 @@ fwohci_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
struct fwohci_softc *fc;
int unit = DEV2UNIT(dev);
int err = 0;
- struct fw_reg_req_t *reg = (struct fw_reg_req_t *) data;
+ struct fw_reg_req_t *reg = (struct fw_reg_req_t *) data;
uint32_t *dmach = (uint32_t *) data;
sc = devclass_get_softc(firewire_devclass, unit);
- if(sc == NULL){
- return(EINVAL);
- }
+ if (sc == NULL)
+ return (EINVAL);
+
fc = (struct fwohci_softc *)sc->fc;
if (!data)
- return(EINVAL);
+ return (EINVAL);
switch (cmd) {
case FWOHCI_WRREG:
#define OHCI_MAX_REG 0x800
- if(reg->addr <= OHCI_MAX_REG){
+ if (reg->addr <= OHCI_MAX_REG) {
OWRITE(fc, reg->addr, reg->data);
reg->data = OREAD(fc, reg->addr);
- }else{
+ } else {
err = EINVAL;
}
break;
case FWOHCI_RDREG:
- if(reg->addr <= OHCI_MAX_REG){
+ if (reg->addr <= OHCI_MAX_REG) {
reg->data = OREAD(fc, reg->addr);
- }else{
+ } else {
err = EINVAL;
}
break;
/* Read DMA descriptors for debug */
case DUMPDMA:
- if(*dmach <= OHCI_MAX_DMA_CH ){
+ if (*dmach <= OHCI_MAX_DMA_CH) {
dump_dma(fc, *dmach);
dump_db(fc, *dmach);
- }else{
+ } else {
err = EINVAL;
}
break;
@@ -414,19 +415,20 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev)
{
uint32_t reg, reg2;
int e1394a = 1;
-/*
- * probe PHY parameters
- * 0. to prove PHY version, whether compliance of 1394a.
- * 1. to probe maximum speed supported by the PHY and
- * number of port supported by core-logic.
- * It is not actually available port on your PC .
- */
+
+ /*
+ * probe PHY parameters
+ * 0. to prove PHY version, whether compliance of 1394a.
+ * 1. to probe maximum speed supported by the PHY and
+ * number of port supported by core-logic.
+ * It is not actually available port on your PC .
+ */
OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_LPS);
DELAY(500);
reg = fwphy_rddata(sc, FW_PHY_SPD_REG);
- if((reg >> 5) != 7 ){
+ if ((reg >> 5) != 7) {
sc->fc.mode &= ~FWPHYASYST;
sc->fc.nport = reg & FW_PHY_NP;
sc->fc.speed = reg & FW_PHY_SPD >> 6;
@@ -438,7 +440,7 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev)
device_printf(dev,
"Phy 1394 only %s, %d ports.\n",
linkspeed[sc->fc.speed], sc->fc.nport);
- }else{
+ } else {
reg2 = fwphy_rddata(sc, FW_PHY_ESPD_REG);
sc->fc.mode |= FWPHYASYST;
sc->fc.nport = reg & FW_PHY_NP;
@@ -475,7 +477,7 @@ fwohci_probe_phy(struct fwohci_softc *sc, device_t dev)
}
reg = fwphy_rddata(sc, FW_PHY_SPD_REG);
- if((reg >> 5) == 7 ){
+ if ((reg >> 5) == 7) {
reg = fwphy_rddata(sc, 4);
reg |= 1 << 6;
fwphy_wrdata(sc, 4, reg);
@@ -492,19 +494,19 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev)
uint32_t reg, reg2;
struct fwohcidb_tr *db_tr;
- /* Disable interrupts */
+ /* Disable interrupts */
OWRITE(sc, FWOHCI_INTMASKCLR, ~0);
/* Now stopping all DMA channels */
- OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_IR_MASKCLR, ~0);
- for( i = 0 ; i < sc->fc.nisodma ; i ++ ){
- OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_IR_MASKCLR, ~0);
+ for (i = 0; i < sc->fc.nisodma; i++) {
+ OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN);
}
/* FLUSH FIFO and reset Transmitter/Reciever */
@@ -512,7 +514,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev)
if (firewire_debug)
device_printf(dev, "resetting OHCI...");
i = 0;
- while(OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) {
+ while (OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) {
if (i++ > 100) break;
DELAY(1000);
}
@@ -523,7 +525,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev)
fwohci_probe_phy(sc, dev);
/* Probe link */
- reg = OREAD(sc, OHCI_BUS_OPT);
+ reg = OREAD(sc, OHCI_BUS_OPT);
reg2 = reg | OHCI_BUSFNC;
max_rec = (reg & 0x0000f000) >> 12;
speed = (reg & 0x00000007);
@@ -538,7 +540,7 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev)
}
if (firewire_debug)
device_printf(dev, "BUS_OPT 0x%x -> 0x%x\n", reg, reg2);
- OWRITE(sc, OHCI_BUS_OPT, reg2);
+ OWRITE(sc, OHCI_BUS_OPT, reg2);
/* Initialize registers */
OWRITE(sc, OHCI_CROMHDR, sc->fc.config_rom[0]);
@@ -564,33 +566,31 @@ fwohci_reset(struct fwohci_softc *sc, device_t dev)
/* AT Retries */
OWRITE(sc, FWOHCI_RETRY,
/* CycleLimit PhyRespRetries ATRespRetries ATReqRetries */
- (0xffff << 16 ) | (0x0f << 8) | (0x0f << 4) | 0x0f) ;
+ (0xffff << 16) | (0x0f << 8) | (0x0f << 4) | 0x0f);
sc->atrq.top = STAILQ_FIRST(&sc->atrq.db_trq);
sc->atrs.top = STAILQ_FIRST(&sc->atrs.db_trq);
sc->atrq.bottom = sc->atrq.top;
sc->atrs.bottom = sc->atrs.top;
- for( i = 0, db_tr = sc->atrq.top; i < sc->atrq.ndb ;
- i ++, db_tr = STAILQ_NEXT(db_tr, link)){
+ for (i = 0, db_tr = sc->atrq.top; i < sc->atrq.ndb;
+ i++, db_tr = STAILQ_NEXT(db_tr, link)) {
db_tr->xfer = NULL;
}
- for( i = 0, db_tr = sc->atrs.top; i < sc->atrs.ndb ;
- i ++, db_tr = STAILQ_NEXT(db_tr, link)){
+ for (i = 0, db_tr = sc->atrs.top; i < sc->atrs.ndb;
+ i++, db_tr = STAILQ_NEXT(db_tr, link)) {
db_tr->xfer = NULL;
}
-
/* Enable interrupts */
sc->intmask = (OHCI_INT_ERR | OHCI_INT_PHY_SID
- | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS
+ | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS
| OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS
| OHCI_INT_PHY_BUS_R | OHCI_INT_PW_ERR);
sc->intmask |= OHCI_INT_DMA_IR | OHCI_INT_DMA_IT;
sc->intmask |= OHCI_INT_CYC_LOST | OHCI_INT_PHY_INT;
OWRITE(sc, FWOHCI_INTMASK, sc->intmask);
fwohci_set_intr(&sc->fc, 1);
-
}
int
@@ -604,7 +604,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
reg = OREAD(sc, OHCI_VERSION);
mver = (reg >> 16) & 0xff;
device_printf(dev, "OHCI version %x.%x (ROM=%d)\n",
- mver, reg & 0xff, (reg>>24) & 1);
+ mver, reg & 0xff, (reg >> 24) & 1);
if (mver < 1 || mver > 9) {
device_printf(dev, "invalid OHCI version\n");
return (ENXIO);
@@ -659,7 +659,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
sc->atrq.ndb = NDB;
sc->atrs.ndb = NDB / 2;
- for( i = 0 ; i < sc->fc.nisodma ; i ++ ){
+ for (i = 0; i < sc->fc.nisodma; i++) {
sc->fc.it[i] = &sc->it[i].xferq;
sc->fc.ir[i] = &sc->ir[i].xferq;
sc->it[i].xferq.dmach = i;
@@ -673,7 +673,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
sc->fc.config_rom = fwdma_malloc(&sc->fc, CROMSIZE, CROMSIZE,
&sc->crom_dma, BUS_DMA_WAITOK | BUS_DMA_COHERENT);
- if(sc->fc.config_rom == NULL){
+ if (sc->fc.config_rom == NULL) {
device_printf(dev, "config_rom alloc failed.");
return ENOMEM;
}
@@ -690,7 +690,6 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
sc->fc.config_rom[0] |= fw_crc16(&sc->fc.config_rom[1], 5*4);
#endif
-
/* SID recieve buffer must align 2^11 */
#define OHCI_SIDSIZE (1 << 11)
sc->sid_buf = fwdma_malloc(&sc->fc, OHCI_SIDSIZE, OHCI_SIDSIZE,
@@ -701,7 +700,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
}
fwdma_malloc(&sc->fc, sizeof(uint32_t), sizeof(uint32_t),
- &sc->dummy_dma, BUS_DMA_WAITOK);
+ &sc->dummy_dma, BUS_DMA_WAITOK);
if (sc->dummy_dma.v_addr == NULL) {
device_printf(dev, "dummy_dma alloc failed.");
@@ -726,7 +725,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
sc->fc.eui.hi = OREAD(sc, FWOHCIGUID_H);
sc->fc.eui.lo = OREAD(sc, FWOHCIGUID_L);
- for( i = 0 ; i < 8 ; i ++)
+ for (i = 0; i < 8; i++)
ui[i] = FW_EUI64_BYTE(&sc->fc.eui,i);
device_printf(dev, "EUI64 %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
ui[0], ui[1], ui[2], ui[3], ui[4], ui[5], ui[6], ui[7]);
@@ -756,7 +755,7 @@ fwohci_init(struct fwohci_softc *sc, device_t dev)
sc->fc.taskqueue = taskqueue_create_fast("fw_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->fc.taskqueue);
taskqueue_start_threads(&sc->fc.taskqueue, 1, PI_NET, "fw%d_taskq",
- device_get_unit(dev));
+ device_get_unit(dev));
TASK_INIT(&sc->fwohci_task_busreset, 2, fwohci_task_busreset, sc);
TASK_INIT(&sc->fwohci_task_sid, 1, fwohci_task_sid, sc);
TASK_INIT(&sc->fwohci_task_dma, 0, fwohci_task_dma, sc);
@@ -779,7 +778,7 @@ uint32_t
fwohci_cyctimer(struct firewire_comm *fc)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
- return(OREAD(sc, OHCI_CYCLETIMER));
+ return (OREAD(sc, OHCI_CYCLETIMER));
}
int
@@ -798,7 +797,7 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev)
fwohci_db_free(&sc->atrq);
fwohci_db_free(&sc->atrs);
- for( i = 0 ; i < sc->fc.nisodma ; i ++ ){
+ for (i = 0; i < sc->fc.nisodma; i++) {
fwohci_db_free(&sc->it[i]);
fwohci_db_free(&sc->ir[i]);
}
@@ -819,7 +818,7 @@ fwohci_detach(struct fwohci_softc *sc, device_t dev)
int _cnt = _dbtr->dbcnt; \
db = &_dbtr->db[ (_cnt > 2) ? (_cnt -1) : 0]; \
} while (0)
-
+
static void
fwohci_execute_db(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
@@ -847,7 +846,7 @@ fwohci_execute_db(void *arg, bus_dma_segment_t *segs, int nseg, int error)
static void
fwohci_execute_db2(void *arg, bus_dma_segment_t *segs, int nseg,
- bus_size_t size, int error)
+ bus_size_t size, int error)
{
fwohci_execute_db(arg, segs, nseg, error);
}
@@ -870,11 +869,11 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
FW_GLOCK_ASSERT(&sc->fc);
- if(&sc->atrq == dbch){
+ if (&sc->atrq == dbch) {
off = OHCI_ATQOFF;
- }else if(&sc->atrs == dbch){
+ } else if (&sc->atrs == dbch) {
off = OHCI_ATSOFF;
- }else{
+ } else {
return;
}
@@ -885,11 +884,11 @@ fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
db_tr = dbch->top;
txloop:
xfer = STAILQ_FIRST(&dbch->xferq.q);
- if(xfer == NULL){
+ if (xfer == NULL) {
goto kick;
}
#if 0
- if(dbch->xferq.queued == 0 ){
+ if (dbch->xferq.queued == 0) {
device_printf(sc->fc.dev, "TX queue empty\n");
}
#endif
@@ -906,11 +905,11 @@ txloop:
ld = &ohcifp->mode.ld[0];
ld[0] = ld[1] = ld[2] = ld[3] = 0;
- for( i = 0 ; i < pl_off ; i+= 4)
+ for (i = 0; i < pl_off; i+= 4)
ld[i/4] = fp->mode.ld[i/4];
ohcifp->mode.common.spd = xfer->send.spd & 0x7;
- if (tcode == FWTCODE_STREAM ){
+ if (tcode == FWTCODE_STREAM) {
hdr_len = 8;
ohcifp->mode.stream.len = fp->mode.stream.len;
} else if (tcode == FWTCODE_PHY) {
@@ -930,14 +929,14 @@ txloop:
FWOHCI_DMA_WRITE(db->db.desc.addr, 0);
FWOHCI_DMA_WRITE(db->db.desc.res, 0);
/* Specify bound timer of asy. responce */
- if(&sc->atrs == dbch){
+ if (&sc->atrs == dbch) {
FWOHCI_DMA_WRITE(db->db.desc.res,
(OREAD(sc, OHCI_CYCLETIMER) >> 12) + (1 << 13));
}
#if BYTE_ORDER == BIG_ENDIAN
if (tcode == FWTCODE_WREQQ || tcode == FWTCODE_RRESQ)
hdr_len = 12;
- for (i = 0; i < hdr_len/4; i ++)
+ for (i = 0; i < hdr_len/4; i++)
FWOHCI_DMA_WRITE(ld[i], ld[i]);
#endif
@@ -968,7 +967,7 @@ again:
m_copydata(xfer->mbuf, 0,
xfer->mbuf->m_pkthdr.len,
mtod(m0, caddr_t));
- m0->m_len = m0->m_pkthdr.len =
+ m0->m_len = m0->m_pkthdr.len =
xfer->mbuf->m_pkthdr.len;
m_freem(xfer->mbuf);
xfer->mbuf = m0;
@@ -999,16 +998,16 @@ again:
FWOHCI_DMA_WRITE(db->db.desc.depend,
STAILQ_NEXT(db_tr, link)->bus_addr);
- if(fsegment == -1 )
+ if (fsegment == -1)
fsegment = db_tr->dbcnt;
if (dbch->pdb_tr != NULL) {
LAST_DB(dbch->pdb_tr, db);
FWOHCI_DMA_SET(db->db.desc.depend, db_tr->dbcnt);
}
- dbch->xferq.queued ++;
+ dbch->xferq.queued++;
dbch->pdb_tr = db_tr;
db_tr = STAILQ_NEXT(db_tr, link);
- if(db_tr != dbch->bottom){
+ if (db_tr != dbch->bottom) {
goto txloop;
} else {
device_printf(sc->fc.dev, "fwohci_start: lack of db_trq\n");
@@ -1019,7 +1018,7 @@ kick:
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREREAD);
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREWRITE);
- if(dbch->xferq.flag & FWXFERQ_RUNNING) {
+ if (dbch->xferq.flag & FWXFERQ_RUNNING) {
OWRITE(sc, OHCI_DMACTL(off), OHCI_CNTL_DMA_WAKE);
} else {
if (firewire_debug)
@@ -1040,7 +1039,7 @@ fwohci_start_atq(struct firewire_comm *fc)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
FW_GLOCK(&sc->fc);
- fwohci_start( sc, &(sc->atrq));
+ fwohci_start(sc, &(sc->atrq));
FW_GUNLOCK(&sc->fc);
return;
}
@@ -1050,7 +1049,7 @@ fwohci_start_ats(struct firewire_comm *fc)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
FW_GLOCK(&sc->fc);
- fwohci_start( sc, &(sc->atrs));
+ fwohci_start(sc, &(sc->atrs));
FW_GUNLOCK(&sc->fc);
return;
}
@@ -1067,13 +1066,13 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
int packets;
struct firewire_comm *fc = (struct firewire_comm *)sc;
- if(&sc->atrq == dbch){
+ if (&sc->atrq == dbch) {
off = OHCI_ATQOFF;
ch = ATRQ_CH;
- }else if(&sc->atrs == dbch){
+ } else if (&sc->atrs == dbch) {
off = OHCI_ATSOFF;
ch = ATRS_CH;
- }else{
+ } else {
return;
}
s = splfw();
@@ -1081,11 +1080,11 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
packets = 0;
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTREAD);
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_POSTWRITE);
- while(dbch->xferq.queued > 0){
+ while (dbch->xferq.queued > 0) {
LAST_DB(tr, db);
status = FWOHCI_DMA_READ(db->db.desc.res) >> OHCI_STATUS_SHIFT;
- if(!(status & OHCI_CNTL_DMA_ACTIVE)){
- if (fc->status != FWBUSINIT)
+ if (!(status & OHCI_CNTL_DMA_ACTIVE)) {
+ if (fc->status != FWBUSINIT)
/* maybe out of order?? */
goto out;
}
@@ -1096,7 +1095,7 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
if (firewire_debug > 1)
dump_db(sc, ch);
#endif
- if(status & OHCI_CNTL_DMA_DEAD) {
+ if (status & OHCI_CNTL_DMA_DEAD) {
/* Stop DMA */
OWRITE(sc, OHCI_DMACTLCLR(off), OHCI_CNTL_DMA_RUN);
device_printf(sc->fc.dev, "force reset AT FIFO\n");
@@ -1105,7 +1104,7 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
OWRITE(sc, OHCI_DMACTLCLR(off), OHCI_CNTL_DMA_RUN);
}
stat = status & FWOHCIEV_MASK;
- switch(stat){
+ switch (stat) {
case FWOHCIEV_ACKPEND:
case FWOHCIEV_ACKCOMPL:
err = 0;
@@ -1159,17 +1158,17 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
}
/*
* The watchdog timer takes care of split
- * transcation timeout for ACKPEND case.
+ * transaction timeout for ACKPEND case.
*/
} else {
printf("this shouldn't happen\n");
}
FW_GLOCK(fc);
- dbch->xferq.queued --;
+ dbch->xferq.queued--;
FW_GUNLOCK(fc);
tr->xfer = NULL;
- packets ++;
+ packets++;
tr = STAILQ_NEXT(tr, link);
dbch->bottom = tr;
if (dbch->bottom == dbch->top) {
@@ -1199,10 +1198,10 @@ fwohci_db_free(struct fwohci_dbch *dbch)
if ((dbch->flags & FWOHCI_DBCH_INIT) == 0)
return;
- for(db_tr = STAILQ_FIRST(&dbch->db_trq), idb = 0; idb < dbch->ndb;
- db_tr = STAILQ_NEXT(db_tr, link), idb++){
+ for (db_tr = STAILQ_FIRST(&dbch->db_trq), idb = 0; idb < dbch->ndb;
+ db_tr = STAILQ_NEXT(db_tr, link), idb++) {
if ((dbch->xferq.flag & FWXFERQ_EXTBUF) == 0 &&
- db_tr->buf != NULL) {
+ db_tr->buf != NULL) {
fwdma_free_size(dbch->dmat, db_tr->dma_map,
db_tr->buf, dbch->xferq.psize);
db_tr->buf = NULL;
@@ -1237,10 +1236,8 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
/*nsegments*/ dbch->ndesc > 3 ? dbch->ndesc - 2 : 1,
/*maxsegsz*/ MAX_REQCOUNT,
/*flags*/ 0,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 501102
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/FW_GMTX(&sc->fc),
-#endif
&dbch->dmat))
return;
@@ -1250,7 +1247,7 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
db_tr = (struct fwohcidb_tr *)
malloc(sizeof(struct fwohcidb_tr) * dbch->ndb,
M_FW, M_WAITOK | M_ZERO);
- if(db_tr == NULL){
+ if (db_tr == NULL) {
printf("fwohci_db_init: malloc(1) failed\n");
return;
}
@@ -1264,7 +1261,7 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
return;
}
/* Attach DB to DMA ch. */
- for(idb = 0 ; idb < dbch->ndb ; idb++){
+ for (idb = 0; idb < dbch->ndb; idb++) {
db_tr->dbcnt = 0;
db_tr->db = (struct fwohcidb *)fwdma_v_addr(dbch->am, idb);
db_tr->bus_addr = fwdma_bus_addr(dbch->am, idb);
@@ -1303,7 +1300,7 @@ fwohci_itx_disable(struct firewire_comm *fc, int dmach)
{
struct fwohci_softc *sc = (struct fwohci_softc *)fc;
- OWRITE(sc, OHCI_ITCTLCLR(dmach),
+ OWRITE(sc, OHCI_ITCTLCLR(dmach),
OHCI_CNTL_DMA_RUN | OHCI_CNTL_CYCMATCH_S);
OWRITE(sc, OHCI_IT_MASKCLR, 1 << dmach);
OWRITE(sc, OHCI_IT_STATCLR, 1 << dmach);
@@ -1347,31 +1344,31 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
struct fwohcidb_tr *db_tr;
struct fwohcidb *db;
- if(!(dbch->xferq.flag & FWXFERQ_EXTBUF)){
+ if (!(dbch->xferq.flag & FWXFERQ_EXTBUF)) {
err = EINVAL;
return err;
}
z = dbch->ndesc;
- for(dmach = 0 ; dmach < sc->fc.nisodma ; dmach++){
- if( &sc->it[dmach] == dbch){
+ for (dmach = 0; dmach < sc->fc.nisodma; dmach++) {
+ if (&sc->it[dmach] == dbch) {
off = OHCI_ITOFF(dmach);
break;
}
}
- if(off == 0){
+ if (off == 0) {
err = EINVAL;
return err;
}
- if(dbch->xferq.flag & FWXFERQ_RUNNING)
+ if (dbch->xferq.flag & FWXFERQ_RUNNING)
return err;
dbch->xferq.flag |= FWXFERQ_RUNNING;
- for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){
+ for (i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++) {
dbch->bottom = STAILQ_NEXT(dbch->bottom, link);
}
db_tr = dbch->top;
- for (idb = 0; idb < dbch->ndb; idb ++) {
+ for (idb = 0; idb < dbch->ndb; idb++) {
fwohci_add_tx_buf(dbch, db_tr, idb);
- if(STAILQ_NEXT(db_tr, link) == NULL){
+ if (STAILQ_NEXT(db_tr, link) == NULL) {
break;
}
db = db_tr->db;
@@ -1379,8 +1376,8 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
FWOHCI_DMA_WRITE(db[0].db.desc.depend,
STAILQ_NEXT(db_tr, link)->bus_addr | z);
db[ldesc].db.desc.depend = db[0].db.desc.depend;
- if(dbch->xferq.flag & FWXFERQ_EXTBUF){
- if(((idb + 1 ) % dbch->xferq.bnpacket) == 0){
+ if (dbch->xferq.flag & FWXFERQ_EXTBUF) {
+ if (((idb + 1) % dbch->xferq.bnpacket) == 0) {
FWOHCI_DMA_SET(
db[ldesc].db.desc.cmd,
OHCI_INTERRUPT_ALWAYS);
@@ -1407,38 +1404,38 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
struct fwohcidb *db;
z = dbch->ndesc;
- if(&sc->arrq == dbch){
+ if (&sc->arrq == dbch) {
off = OHCI_ARQOFF;
- }else if(&sc->arrs == dbch){
+ } else if (&sc->arrs == dbch) {
off = OHCI_ARSOFF;
- }else{
- for(dmach = 0 ; dmach < sc->fc.nisodma ; dmach++){
- if( &sc->ir[dmach] == dbch){
+ } else {
+ for (dmach = 0; dmach < sc->fc.nisodma; dmach++) {
+ if (&sc->ir[dmach] == dbch) {
off = OHCI_IROFF(dmach);
break;
}
}
}
- if(off == 0){
+ if (off == 0) {
err = EINVAL;
return err;
}
- if(dbch->xferq.flag & FWXFERQ_STREAM){
- if(dbch->xferq.flag & FWXFERQ_RUNNING)
+ if (dbch->xferq.flag & FWXFERQ_STREAM) {
+ if (dbch->xferq.flag & FWXFERQ_RUNNING)
return err;
- }else{
- if(dbch->xferq.flag & FWXFERQ_RUNNING){
+ } else {
+ if (dbch->xferq.flag & FWXFERQ_RUNNING) {
err = EBUSY;
return err;
}
}
dbch->xferq.flag |= FWXFERQ_RUNNING;
dbch->top = STAILQ_FIRST(&dbch->db_trq);
- for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){
+ for (i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++) {
dbch->bottom = STAILQ_NEXT(dbch->bottom, link);
}
db_tr = dbch->top;
- for (idb = 0; idb < dbch->ndb; idb ++) {
+ for (idb = 0; idb < dbch->ndb; idb++) {
fwohci_add_rx_buf(dbch, db_tr, idb, &sc->dummy_dma);
if (STAILQ_NEXT(db_tr, link) == NULL)
break;
@@ -1446,8 +1443,8 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
ldesc = db_tr->dbcnt - 1;
FWOHCI_DMA_WRITE(db[ldesc].db.desc.depend,
STAILQ_NEXT(db_tr, link)->bus_addr | z);
- if(dbch->xferq.flag & FWXFERQ_EXTBUF){
- if(((idb + 1 ) % dbch->xferq.bnpacket) == 0){
+ if (dbch->xferq.flag & FWXFERQ_EXTBUF) {
+ if (((idb + 1) % dbch->xferq.bnpacket) == 0) {
FWOHCI_DMA_SET(
db[ldesc].db.desc.cmd,
OHCI_INTERRUPT_ALWAYS);
@@ -1463,9 +1460,9 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
dbch->buf_offset = 0;
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREREAD);
fwdma_sync_multiseg_all(dbch->am, BUS_DMASYNC_PREWRITE);
- if(dbch->xferq.flag & FWXFERQ_STREAM){
+ if (dbch->xferq.flag & FWXFERQ_STREAM) {
return err;
- }else{
+ } else {
OWRITE(sc, OHCI_DMACMD(off), dbch->top->bus_addr | z);
}
OWRITE(sc, OHCI_DMACTL(off), OHCI_CNTL_DMA_RUN);
@@ -1487,12 +1484,12 @@ fwohci_next_cycle(struct firewire_comm *fc, int cycle_now)
#endif
cycle = cycle + CYCLE_DELAY;
if (cycle >= 8000) {
- sec ++;
+ sec++;
cycle -= 8000;
}
cycle = roundup2(cycle, CYCLE_MOD);
if (cycle >= 8000) {
- sec ++;
+ sec++;
if (cycle == 8000)
cycle = 0;
else
@@ -1500,7 +1497,7 @@ fwohci_next_cycle(struct firewire_comm *fc, int cycle_now)
}
cycle_match = ((sec << 13) | cycle) & 0x7ffff;
- return(cycle_match);
+ return (cycle_match);
}
static int
@@ -1529,7 +1526,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach)
err = fwohci_tx_enable(sc, dbch);
}
- if(err)
+ if (err)
return err;
ldesc = dbch->ndesc - 1;
@@ -1549,7 +1546,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach)
OHCI_BRANCH_ALWAYS);
#endif
#if 0 /* if bulkxfer->npacket changes */
- db[ldesc].db.desc.depend = db[0].db.desc.depend =
+ db[ldesc].db.desc.depend = db[0].db.desc.depend =
((struct fwohcidb_tr *)
(chunk->start))->bus_addr | dbch->ndesc;
#else
@@ -1652,7 +1649,7 @@ fwohci_irx_enable(struct firewire_comm *fc, int dmach)
return ENOMEM;
err = fwohci_rx_enable(sc, dbch);
}
- if(err)
+ if (err)
return err;
first = STAILQ_FIRST(&ir->stfree);
@@ -1731,28 +1728,28 @@ fwohci_stop(struct fwohci_softc *sc, device_t dev)
fwohci_set_intr(&sc->fc, 0);
/* Now stopping all DMA channel */
- OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ARQCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ARSCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
- for( i = 0 ; i < sc->fc.nisodma ; i ++ ){
- OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN);
- OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN);
+ for (i = 0; i < sc->fc.nisodma; i++) {
+ OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN);
}
-#if 0 /* Let dcons(4) be accessed */
+#if 0 /* Let dcons(4) be accessed */
/* Stop interrupt */
OWRITE(sc, FWOHCI_INTMASKCLR,
OHCI_INT_EN | OHCI_INT_ERR | OHCI_INT_PHY_SID
| OHCI_INT_PHY_INT
- | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS
+ | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS
| OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS
- | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS
+ | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS
| OHCI_INT_PHY_BUS_R);
/* FLUSH FIFO and reset Transmitter/Reciever */
- OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET);
+ OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET);
#endif
/* XXX Link down? Bus reset? */
@@ -1768,14 +1765,14 @@ fwohci_resume(struct fwohci_softc *sc, device_t dev)
fwohci_reset(sc, dev);
/* XXX resume isochronous receive automatically. (how about TX?) */
- for(i = 0; i < sc->fc.nisodma; i ++) {
+ for (i = 0; i < sc->fc.nisodma; i++) {
ir = &sc->ir[i].xferq;
- if((ir->flag & FWXFERQ_RUNNING) != 0) {
+ if ((ir->flag & FWXFERQ_RUNNING) != 0) {
device_printf(sc->fc.dev,
"resume iso receive ch: %d\n", i);
ir->flag &= ~FWXFERQ_RUNNING;
/* requeue stdma to stfree */
- while((chunk = STAILQ_FIRST(&ir->stdma)) != NULL) {
+ while ((chunk = STAILQ_FIRST(&ir->stdma)) != NULL) {
STAILQ_REMOVE_HEAD(&ir->stdma, link);
STAILQ_INSERT_TAIL(&ir->stfree, chunk, link);
}
@@ -1792,7 +1789,7 @@ fwohci_resume(struct fwohci_softc *sc, device_t dev)
static void
fwohci_dump_intr(struct fwohci_softc *sc, uint32_t stat)
{
- if(stat & OREAD(sc, FWOHCI_INTMASK))
+ if (stat & OREAD(sc, FWOHCI_INTMASK))
device_printf(fc->dev, "INTERRUPT < %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s> 0x%08x, 0x%08x\n",
stat & OHCI_INT_EN ? "DMA_EN ":"",
stat & OHCI_INT_PHY_REG ? "PHY_REG ":"",
@@ -1815,10 +1812,11 @@ fwohci_dump_intr(struct fwohci_softc *sc, uint32_t stat)
stat & OHCI_INT_DMA_ARRQ ? "DMA_ARRQ " :"",
stat & OHCI_INT_DMA_ATRS ? "DMA_ATRS " :"",
stat & OHCI_INT_DMA_ATRQ ? "DMA_ATRQ " :"",
- stat, OREAD(sc, FWOHCI_INTMASK)
+ stat, OREAD(sc, FWOHCI_INTMASK)
);
}
#endif
+
static void
fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count)
{
@@ -1829,15 +1827,15 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count)
if ((stat & OHCI_INT_PHY_BUS_R) && (fc->status != FWBUSRESET)) {
fc->status = FWBUSRESET;
/* Disable bus reset interrupt until sid recv. */
- OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R);
-
+ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R);
+
device_printf(fc->dev, "%s: BUS reset\n", __func__);
- OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST);
+ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST);
OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC);
- OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN);
sc->atrq.xferq.flag &= ~FWXFERQ_RUNNING;
- OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
+ OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN);
sc->atrs.xferq.flag &= ~FWXFERQ_RUNNING;
if (!kdb_active)
@@ -1858,10 +1856,10 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count)
OWRITE(sc, OHCI_PREQUPPER, 0x10000);
}
/* Set ATRetries register */
- OWRITE(sc, OHCI_ATRETRY, 1<<(13+16) | 0xfff);
+ OWRITE(sc, OHCI_ATRETRY, 1<<(13 + 16) | 0xfff);
/*
- * Checking whether the node is root or not. If root, turn on
+ * Checking whether the node is root or not. If root, turn on
* cycle master.
*/
node_id = OREAD(sc, FWOHCI_NODEID);
@@ -1878,7 +1876,7 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count)
/* cycle timer */
sc->cycle_lost = 0;
- OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_CYC_LOST);
+ OWRITE(sc, FWOHCI_INTMASK, OHCI_INT_CYC_LOST);
if ((node_id & OHCI_NODE_ROOT) && !nocyclemaster) {
printf("CYCLEMASTER mode\n");
OWRITE(sc, OHCI_LNKCTL,
@@ -1908,10 +1906,10 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count)
if (stat & OHCI_INT_DMA_IR) {
irstat = atomic_readandclear_int(&sc->irstat);
- for(i = 0; i < fc->nisodma ; i++){
+ for (i = 0; i < fc->nisodma; i++) {
struct fwohci_dbch *dbch;
- if((irstat & (1 << i)) != 0){
+ if ((irstat & (1 << i)) != 0) {
dbch = &sc->ir[i];
if ((dbch->xferq.flag & FWXFERQ_OPEN) == 0) {
device_printf(sc->fc.dev,
@@ -1924,8 +1922,8 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count)
}
if (stat & OHCI_INT_DMA_IT) {
itstat = atomic_readandclear_int(&sc->itstat);
- for(i = 0; i < fc->nisodma ; i++){
- if((itstat & (1 << i)) != 0){
+ for (i = 0; i < fc->nisodma; i++) {
+ if ((itstat & (1 << i)) != 0) {
fwohci_tbuf_update(sc, i);
}
}
@@ -1946,13 +1944,13 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count)
}
if (stat & OHCI_INT_CYC_LOST) {
if (sc->cycle_lost >= 0)
- sc->cycle_lost ++;
+ sc->cycle_lost++;
if (sc->cycle_lost > 10) {
sc->cycle_lost = -1;
#if 0
OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCTIMER);
#endif
- OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST);
+ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST);
device_printf(fc->dev, "too many cycles lost, "
"no cycle master present?\n");
}
@@ -1972,8 +1970,6 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count)
if (stat & OHCI_INT_PHY_INT) {
device_printf(fc->dev, "phy int\n");
}
-
- return;
}
static void
@@ -2018,8 +2014,8 @@ fwohci_task_sid(void *arg, int pending)
device_printf(fc->dev, "malloc failed\n");
return;
}
- for (i = 0; i < plen / 4; i ++)
- buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i+1]);
+ for (i = 0; i < plen / 4; i++)
+ buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i + 1]);
/* pending all pre-bus_reset packets */
fwohci_txd(sc, &sc->atrq);
@@ -2138,7 +2134,7 @@ fwohci_tbuf_update(struct fwohci_softc *sc, int dmach)
dump_db(sc, ITX_CH + dmach);
while ((chunk = STAILQ_FIRST(&it->stdma)) != NULL) {
db = ((struct fwohcidb_tr *)(chunk->end))->db;
- stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res)
+ stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res)
>> OHCI_STATUS_SHIFT;
db = ((struct fwohcidb_tr *)(chunk->start))->db;
/* timestamp */
@@ -2147,7 +2143,7 @@ fwohci_tbuf_update(struct fwohci_softc *sc, int dmach)
if (stat == 0)
break;
STAILQ_REMOVE_HEAD(&it->stdma, link);
- switch (stat & FWOHCIEV_MASK){
+ switch (stat & FWOHCIEV_MASK) {
case FWOHCIEV_ACKCOMPL:
#if 0
device_printf(fc->dev, "0x%08x\n", count);
@@ -2226,7 +2222,7 @@ fwohci_rbuf_update(struct fwohci_softc *sc, int dmach)
if (w == 0)
return;
- if (ir->flag & FWXFERQ_HANDLER)
+ if (ir->flag & FWXFERQ_HANDLER)
ir->hand(ir);
else
wakeup(ir);
@@ -2237,17 +2233,17 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch)
{
uint32_t off, cntl, stat, cmd, match;
- if(ch == 0){
+ if (ch == 0) {
off = OHCI_ATQOFF;
- }else if(ch == 1){
+ } else if (ch == 1) {
off = OHCI_ATSOFF;
- }else if(ch == 2){
+ } else if (ch == 2) {
off = OHCI_ARQOFF;
- }else if(ch == 3){
+ } else if (ch == 3) {
off = OHCI_ARSOFF;
- }else if(ch < IRX_CH){
+ } else if (ch < IRX_CH) {
off = OHCI_ITCTL(ch - ITX_CH);
- }else{
+ } else {
off = OHCI_IRCTL(ch - IRX_CH);
}
cntl = stat = OREAD(sc, off);
@@ -2256,10 +2252,10 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch)
device_printf(sc->fc.dev, "ch %1x cntl:0x%08x cmd:0x%08x match:0x%08x\n",
ch,
- cntl,
- cmd,
+ cntl,
+ cmd,
match);
- stat &= 0xffff ;
+ stat &= 0xffff;
if (stat) {
device_printf(sc->fc.dev, "dma %d ch:%s%s%s%s%s%s %s(%x)\n",
ch,
@@ -2272,7 +2268,7 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch)
fwohcicode[stat & 0x1f],
stat & 0x1f
);
- }else{
+ } else {
device_printf(sc->fc.dev, "dma %d ch: Nostat\n", ch);
}
}
@@ -2285,60 +2281,61 @@ dump_db(struct fwohci_softc *sc, uint32_t ch)
struct fwohcidb *curr = NULL, *prev, *next = NULL;
int idb, jdb;
uint32_t cmd, off;
- if(ch == 0){
+
+ if (ch == 0) {
off = OHCI_ATQOFF;
dbch = &sc->atrq;
- }else if(ch == 1){
+ } else if (ch == 1) {
off = OHCI_ATSOFF;
dbch = &sc->atrs;
- }else if(ch == 2){
+ } else if (ch == 2) {
off = OHCI_ARQOFF;
dbch = &sc->arrq;
- }else if(ch == 3){
+ } else if (ch == 3) {
off = OHCI_ARSOFF;
dbch = &sc->arrs;
- }else if(ch < IRX_CH){
+ } else if (ch < IRX_CH) {
off = OHCI_ITCTL(ch - ITX_CH);
dbch = &sc->it[ch - ITX_CH];
- }else {
+ } else {
off = OHCI_IRCTL(ch - IRX_CH);
dbch = &sc->ir[ch - IRX_CH];
}
cmd = OREAD(sc, off + 0xc);
- if( dbch->ndb == 0 ){
+ if (dbch->ndb == 0) {
device_printf(sc->fc.dev, "No DB is attached ch=%d\n", ch);
return;
}
pp = dbch->top;
prev = pp->db;
- for(idb = 0 ; idb < dbch->ndb ; idb ++ ){
+ for (idb = 0; idb < dbch->ndb; idb++) {
cp = STAILQ_NEXT(pp, link);
- if(cp == NULL){
+ if (cp == NULL) {
curr = NULL;
goto outdb;
}
np = STAILQ_NEXT(cp, link);
- for(jdb = 0 ; jdb < dbch->ndesc ; jdb ++ ){
+ for (jdb = 0; jdb < dbch->ndesc; jdb++) {
if ((cmd & 0xfffffff0) == cp->bus_addr) {
curr = cp->db;
- if(np != NULL){
+ if (np != NULL) {
next = np->db;
- }else{
+ } else {
next = NULL;
}
goto outdb;
}
}
pp = STAILQ_NEXT(pp, link);
- if(pp == NULL){
+ if (pp == NULL) {
curr = NULL;
goto outdb;
}
prev = pp->db;
}
outdb:
- if( curr != NULL){
+ if (curr != NULL) {
#if 0
printf("Prev DB %d\n", ch);
print_db(pp, prev, ch, dbch->ndesc);
@@ -2349,7 +2346,7 @@ outdb:
printf("Next DB %d\n", ch);
print_db(np, next, ch, dbch->ndesc);
#endif
- }else{
+ } else {
printf("dbdump err ch = %d cmd = 0x%08x\n", ch, cmd);
}
return;
@@ -2363,7 +2360,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db,
int i, key;
uint32_t cmd, res;
- if(db == NULL){
+ if (db == NULL) {
printf("No Descriptor is found\n");
return;
}
@@ -2380,18 +2377,13 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db,
"Depend",
"Stat",
"Cnt");
- for( i = 0 ; i <= max ; i ++){
+ for (i = 0; i <= max; i++) {
cmd = FWOHCI_DMA_READ(db[i].db.desc.cmd);
res = FWOHCI_DMA_READ(db[i].db.desc.res);
key = cmd & OHCI_KEY_MASK;
stat = res >> OHCI_STATUS_SHIFT;
-#if defined(__DragonFly__) || __FreeBSD_version < 500000
- printf("%08x %s %s %s %s %5d %08x %08x %04x:%04x",
- db_tr->bus_addr,
-#else
printf("%08jx %s %s %s %s %5d %08x %08x %04x:%04x",
(uintmax_t)db_tr->bus_addr,
-#endif
dbcode[(cmd >> 28) & 0xf],
dbkey[(cmd >> 24) & 0x7],
dbcond[(cmd >> 20) & 0x3],
@@ -2401,7 +2393,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db,
FWOHCI_DMA_READ(db[i].db.desc.depend),
stat,
res & OHCI_COUNT_MASK);
- if(stat & 0xff00){
+ if (stat & 0xff00) {
printf(" %s%s%s%s%s%s %s(%x)\n",
stat & OHCI_CNTL_DMA_RUN ? "RUN," : "",
stat & OHCI_CNTL_DMA_WAKE ? "WAKE," : "",
@@ -2412,32 +2404,32 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db,
fwohcicode[stat & 0x1f],
stat & 0x1f
);
- }else{
+ } else {
printf(" Nostat\n");
}
- if(key == OHCI_KEY_ST2 ){
- printf("0x%08x 0x%08x 0x%08x 0x%08x\n",
- FWOHCI_DMA_READ(db[i+1].db.immed[0]),
- FWOHCI_DMA_READ(db[i+1].db.immed[1]),
- FWOHCI_DMA_READ(db[i+1].db.immed[2]),
- FWOHCI_DMA_READ(db[i+1].db.immed[3]));
+ if (key == OHCI_KEY_ST2) {
+ printf("0x%08x 0x%08x 0x%08x 0x%08x\n",
+ FWOHCI_DMA_READ(db[i + 1].db.immed[0]),
+ FWOHCI_DMA_READ(db[i + 1].db.immed[1]),
+ FWOHCI_DMA_READ(db[i + 1].db.immed[2]),
+ FWOHCI_DMA_READ(db[i + 1].db.immed[3]));
}
- if(key == OHCI_KEY_DEVICE){
+ if (key == OHCI_KEY_DEVICE) {
return;
}
- if((cmd & OHCI_BRANCH_MASK)
- == OHCI_BRANCH_ALWAYS){
+ if ((cmd & OHCI_BRANCH_MASK)
+ == OHCI_BRANCH_ALWAYS) {
return;
}
- if((cmd & OHCI_CMD_MASK)
- == OHCI_OUTPUT_LAST){
+ if ((cmd & OHCI_CMD_MASK)
+ == OHCI_OUTPUT_LAST) {
return;
}
- if((cmd & OHCI_CMD_MASK)
- == OHCI_INPUT_LAST){
+ if ((cmd & OHCI_CMD_MASK)
+ == OHCI_INPUT_LAST) {
return;
}
- if(key == OHCI_KEY_ST2 ){
+ if (key == OHCI_KEY_ST2) {
i++;
}
}
@@ -2498,7 +2490,7 @@ fwohci_txbufdb(struct fwohci_softc *sc, int dmach, struct fw_bulkxfer *bulkxfer)
/*
device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_tr->bus_addr);
*/
- for (idb = 0; idb < dbch->xferq.bnpacket; idb ++) {
+ for (idb = 0; idb < dbch->xferq.bnpacket; idb++) {
db = db_tr->db;
fp = (struct fw_pkt *)db_tr->buf;
ohcifp = (struct fwohci_txpkthdr *) db[1].db.immed;
@@ -2508,8 +2500,8 @@ device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_
ohcifp->mode.stream.chtag = chtag;
ohcifp->mode.stream.tcode = 0xa;
#if BYTE_ORDER == BIG_ENDIAN
- FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]);
- FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]);
+ FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]);
+ FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]);
#endif
FWOHCI_DMA_CLEAR(db[2].db.desc.cmd, OHCI_COUNT_MASK);
@@ -2554,7 +2546,7 @@ fwohci_add_tx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr,
int err = 0;
it = &dbch->xferq;
- if(it->buf == 0){
+ if (it->buf == 0) {
err = EINVAL;
return err;
}
@@ -2594,7 +2586,7 @@ fwohci_add_rx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr,
&db_tr->dma_map, ir->psize, &dbuf[0],
BUS_DMA_NOWAIT);
if (db_tr->buf == NULL)
- return(ENOMEM);
+ return (ENOMEM);
}
db_tr->dbcnt = 1;
dsiz[0] = ir->psize;
@@ -2609,11 +2601,11 @@ fwohci_add_rx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr,
dsiz[db_tr->dbcnt] = ir->psize;
if (ir->buf != NULL) {
db_tr->buf = fwdma_v_addr(ir->buf, poffset);
- dbuf[db_tr->dbcnt] = fwdma_bus_addr( ir->buf, poffset);
+ dbuf[db_tr->dbcnt] = fwdma_bus_addr(ir->buf, poffset);
}
db_tr->dbcnt++;
}
- for(i = 0 ; i < db_tr->dbcnt ; i++){
+ for (i = 0; i < db_tr->dbcnt; i++) {
FWOHCI_DMA_WRITE(db[i].db.desc.addr, dbuf[i]);
FWOHCI_DMA_WRITE(db[i].db.desc.cmd, OHCI_INPUT_MORE | dsiz[i]);
if (ir->flag & FWXFERQ_STREAM) {
@@ -2663,19 +2655,19 @@ fwohci_arcv_swap(struct fw_pkt *fp, int len)
break;
default:
printf("Unknown tcode %d\n", fp0->mode.common.tcode);
- return(0);
+ return (0);
}
hlen = tinfo[fp0->mode.common.tcode].hdr_len;
if (hlen > len) {
if (firewire_debug)
printf("splitted header\n");
- return(-hlen);
+ return (-hlen);
}
#if BYTE_ORDER == BIG_ENDIAN
- for(i = 0; i < slen/4; i ++)
+ for (i = 0; i < slen/4; i++)
fp->mode.ld[i] = FWOHCI_DMA_READ(fp->mode.ld[i]);
#endif
- return(hlen);
+ return (hlen);
}
static int
@@ -2737,11 +2729,11 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
caddr_t buf;
int resCount;
- if(&sc->arrq == dbch){
+ if (&sc->arrq == dbch) {
off = OHCI_ARQOFF;
- }else if(&sc->arrs == dbch){
+ } else if (&sc->arrs == dbch) {
off = OHCI_ARSOFF;
- }else{
+ } else {
return;
}
@@ -2769,10 +2761,10 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
if (len > 0)
bus_dmamap_sync(dbch->dmat, db_tr->dma_map,
BUS_DMASYNC_POSTREAD);
- while (len > 0 ) {
+ while (len > 0) {
if (count >= 0 && count-- == 0)
goto out;
- if(dbch->pdb_tr != NULL){
+ if (dbch->pdb_tr != NULL) {
/* we have a fragment in previous buffer */
int rlen;
@@ -2824,7 +2816,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
dbch->pdb_tr = db_tr;
dbch->buf_offset = - dbch->buf_offset;
/* sanity check */
- if (resCount != 0) {
+ if (resCount != 0) {
printf("resCount=%d hlen=%d\n",
resCount, hlen);
goto err;
@@ -2849,7 +2841,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
if (firewire_debug)
printf("splitted payload\n");
/* sanity check */
- if (resCount != 0) {
+ if (resCount != 0) {
printf("resCount=%d plen=%d"
" len=%d\n",
resCount, plen, len);
@@ -2859,7 +2851,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
}
vec[nvec].iov_base = ld;
vec[nvec].iov_len = plen;
- nvec ++;
+ nvec++;
ld += plen;
}
dbch->buf_offset = ld - (uint8_t *)db_tr->buf;
@@ -2886,7 +2878,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
if ((vec[nvec-1].iov_len -=
sizeof(struct fwohci_trailer)) == 0)
- nvec--;
+ nvec--;
rb.fc = &sc->fc;
rb.vec = vec;
rb.nvec = nvec;
@@ -2913,7 +2905,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count)
#endif
break;
}
- pcnt ++;
+ pcnt++;
if (dbch->pdb_tr != NULL) {
fwohci_arcv_free_buf(sc, dbch, dbch->pdb_tr,
off, 1);
diff --git a/sys/dev/firewire/fwohci_pci.c b/sys/dev/firewire/fwohci_pci.c
index 77cb586..7523f2c 100644
--- a/sys/dev/firewire/fwohci_pci.c
+++ b/sys/dev/firewire/fwohci_pci.c
@@ -67,7 +67,7 @@ static int fwohci_pci_detach(device_t self);
* The probe routine.
*/
static int
-fwohci_pci_probe( device_t dev )
+fwohci_pci_probe(device_t dev)
{
uint32_t id;
@@ -211,7 +211,7 @@ fwohci_pci_init(device_t self)
cmd = pci_read_config(self, PCIR_COMMAND, 2);
cmd |= PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
#if 1 /* for broken hardware */
- cmd &= ~PCIM_CMD_MWRICEN;
+ cmd &= ~PCIM_CMD_MWRICEN;
#endif
pci_write_config(self, PCIR_COMMAND, cmd, 2);
@@ -311,14 +311,15 @@ fwohci_pci_attach(device_t self)
/*lockarg*/FW_GMTX(&sc->fc),
&sc->fc.dmat);
if (err != 0) {
- printf("fwohci_pci_attach: Could not allocate DMA tag "
- "- error %d\n", err);
- return (ENOMEM);
+ device_printf(self, "fwohci_pci_attach: Could not allocate DMA "
+ "tag - error %d\n", err);
+ fwohci_pci_detach(self);
+ return (ENOMEM);
}
err = fwohci_init(sc, self);
- if (err) {
+ if (err != 0) {
device_printf(self, "fwohci_init failed with err=%d\n", err);
fwohci_pci_detach(self);
return EIO;
@@ -337,13 +338,13 @@ fwohci_pci_detach(device_t self)
fwohci_softc_t *sc = device_get_softc(self);
int s;
-
s = splfw();
if (sc->bsr)
fwohci_stop(sc, self);
bus_generic_detach(self);
+
if (sc->fc.bdev) {
device_delete_child(self, sc->fc.bdev);
sc->fc.bdev = NULL;
@@ -368,7 +369,7 @@ fwohci_pci_detach(device_t self)
}
if (sc->bsr) {
- bus_release_resource(self, SYS_RES_MEMORY,PCI_CBMEM,sc->bsr);
+ bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, sc->bsr);
sc->bsr = NULL;
sc->bst = 0;
sc->bsh = 0;
@@ -428,7 +429,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit)
return (child);
sc->fc.bdev = child;
- device_set_ivars(child, (void *)&sc->fc);
+ device_set_ivars(child, &sc->fc);
err = device_probe_and_attach(child);
if (err) {
@@ -447,7 +448,7 @@ fwohci_pci_add_child(device_t dev, u_int order, const char *name, int unit)
int s;
DELAY(250); /* 2 cycles */
s = splfw();
- fwohci_poll((void *)sc, 0, -1);
+ fwohci_poll(&sc->fc, 0, -1);
splx(s);
}
diff --git a/sys/dev/firewire/fwohcireg.h b/sys/dev/firewire/fwohcireg.h
index d8deca8..95fe26e 100644
--- a/sys/dev/firewire/fwohcireg.h
+++ b/sys/dev/firewire/fwohcireg.h
@@ -184,7 +184,7 @@ struct fwohcidb {
#define FWOHCIEV_MASK 0x1f
-struct ohci_dma{
+struct ohci_dma {
fwohcireg_t cntl;
#define OHCI_CNTL_CYCMATCH_S (0x1 << 31)
@@ -211,7 +211,7 @@ struct ohci_dma{
fwohcireg_t dummy3;
};
-struct ohci_itdma{
+struct ohci_itdma {
fwohcireg_t cntl;
fwohcireg_t cntl_clr;
fwohcireg_t dummy0;
@@ -237,7 +237,7 @@ struct ohci_registers {
fwohcireg_t config_rom; /* config ROM map 0x34 */
fwohcireg_t post_wr_lo; /* post write addr lo 0x38 */
fwohcireg_t post_wr_hi; /* post write addr hi 0x3c */
- fwohcireg_t vender; /* vender ID 0x40 */
+ fwohcireg_t vendor; /* vendor ID 0x40 */
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */
@@ -308,7 +308,7 @@ struct ohci_registers {
fwohcireg_t pys_upper; /* Physical Upper bound 0x120 */
fwohcireg_t dummy7[23]; /* dummy 0x124-0x17c */
-
+
/* 0x180, 0x184, 0x188, 0x18c */
/* 0x190, 0x194, 0x198, 0x19c */
/* 0x1a0, 0x1a4, 0x1a8, 0x1ac */
@@ -328,7 +328,7 @@ struct ohci_registers {
struct ohci_dma dma_irch[0x20];
};
-struct fwohcidb_tr{
+struct fwohcidb_tr {
STAILQ_ENTRY(fwohcidb_tr) link;
struct fw_xfer *xfer;
struct fwohcidb *db;
@@ -341,8 +341,8 @@ struct fwohcidb_tr{
/*
* OHCI info structure.
*/
-struct fwohci_txpkthdr{
- union{
+struct fwohci_txpkthdr {
+ union {
uint32_t ld[4];
struct {
#if BYTE_ORDER == BIG_ENDIAN
@@ -376,7 +376,7 @@ struct fwohci_txpkthdr{
:8;
#endif
BIT16x2(dst, );
- }asycomm;
+ } asycomm;
struct {
#if BYTE_ORDER == BIG_ENDIAN
uint32_t :13,
@@ -392,16 +392,17 @@ struct fwohci_txpkthdr{
:13;
#endif
BIT16x2(len, );
- }stream;
- }mode;
+ } stream;
+ } mode;
};
-struct fwohci_trailer{
+
+struct fwohci_trailer {
#if BYTE_ORDER == BIG_ENDIAN
uint32_t stat:16,
- time:16;
+ time:16;
#else
uint32_t time:16,
- stat:16;
+ stat:16;
#endif
};
@@ -412,7 +413,7 @@ struct fwohci_trailer{
#define OHCI_CNTL_SID (0x1 << 9)
/*
- * defined in OHCI 1.1
+ * defined in OHCI 1.1
* chapter 6.1
*/
#define OHCI_INT_DMA_ATRQ (0x1 << 0)
diff --git a/sys/dev/firewire/fwohcivar.h b/sys/dev/firewire/fwohcivar.h
index 3c9b242..985bc6a 100644
--- a/sys/dev/firewire/fwohcivar.h
+++ b/sys/dev/firewire/fwohcivar.h
@@ -44,7 +44,7 @@ typedef struct fwohci_softc {
void *ih;
struct resource *bsr;
struct resource *irq_res;
- struct fwohci_dbch{
+ struct fwohci_dbch {
u_int ndb;
u_int ndesc;
STAILQ_HEAD(, fwohcidb_tr) db_trq;
diff --git a/sys/dev/firewire/iec68113.h b/sys/dev/firewire/iec68113.h
index 11f3042..393d931 100644
--- a/sys/dev/firewire/iec68113.h
+++ b/sys/dev/firewire/iec68113.h
@@ -97,7 +97,7 @@ struct ciphdr {
} fdf;
};
-struct dvdbc{
+struct dvdbc {
#if BYTE_ORDER == BIG_ENDIAN
uint8_t sct:3, /* Section type */
:1, /* Reserved */
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index f43fccb..5d15ead 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*/
@@ -123,8 +123,8 @@ fwe_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
- if(device_get_unit(dev) != device_get_unit(pa)){
- return(ENXIO);
+ if (device_get_unit(dev) != device_get_unit(pa)) {
+ return (ENXIO);
}
device_set_desc(dev, "Ethernet over FireWire");
@@ -176,7 +176,7 @@ fwe_attach(device_t dev)
"%02x:%02x:%02x:%02x:%02x:%02x\n", unit,
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
- /* fill the rest and attach interface */
+ /* fill the rest and attach interface */
ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
@@ -220,12 +220,12 @@ fwe_stop(struct fwe_softc *fwe)
if (xferq->flag & FWXFERQ_RUNNING)
fc->irx_disable(fc, fwe->dma_ch);
- xferq->flag &=
+ xferq->flag &=
~(FWXFERQ_MODEMASK | FWXFERQ_OPEN | FWXFERQ_STREAM |
FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);
xferq->hand = NULL;
- for (i = 0; i < xferq->bnchunk; i ++)
+ for (i = 0; i < xferq->bnchunk; i++)
m_freem(xferq->bulkxfer[i].mbuf);
free(xferq->bulkxfer, M_FWE);
@@ -315,7 +315,7 @@ fwe_init(void *arg)
STAILQ_INIT(&xferq->stfree);
STAILQ_INIT(&xferq->stdma);
xferq->stproc = NULL;
- for (i = 0; i < xferq->bnchunk; i ++) {
+ for (i = 0; i < xferq->bnchunk; i++) {
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
xferq->bulkxfer[i].mbuf = m;
m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
@@ -393,7 +393,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
!(ifp->if_capenable & IFCAP_POLLING)) {
error = ether_poll_register(fwe_poll, ifp);
if (error)
- return(error);
+ return (error);
/* Disable interrupts */
fc->set_intr(fc, 0);
ifp->if_capenable |= IFCAP_POLLING;
@@ -435,7 +435,6 @@ fwe_output_callback(struct fw_xfer *xfer)
FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
-
m_freem(xfer->mbuf);
fw_xfer_unload(xfer);
@@ -604,7 +603,7 @@ fwe_as_input(struct fw_xferq *xferq)
c[16], c[17], c[18], c[19],
c[20], c[21], c[22], c[23],
c[20], c[21], c[22], c[23]
- );
+ );
#endif
(*ifp->if_input)(ifp, m);
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index b88bf77..0617a9c 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -60,16 +60,10 @@
#include <net/firewire.h>
#include <net/if_arp.h>
#include <net/if_types.h>
-#ifdef __DragonFly__
-#include <bus/firewire/firewire.h>
-#include <bus/firewire/firewirereg.h>
-#include "if_fwipvar.h"
-#else
#include <dev/firewire/firewire.h>
#include <dev/firewire/firewirereg.h>
#include <dev/firewire/iec13213.h>
#include <dev/firewire/if_fwipvar.h>
-#endif
/*
* We really need a mechanism for allocating regions in the FIFO
@@ -139,8 +133,8 @@ fwip_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
- if(device_get_unit(dev) != device_get_unit(pa)){
- return(ENXIO);
+ if (device_get_unit(dev) != device_get_unit(pa)) {
+ return (ENXIO);
}
device_set_desc(dev, "IP over FireWire");
@@ -228,7 +222,7 @@ fwip_stop(struct fwip_softc *fwip)
FWXFERQ_EXTBUF | FWXFERQ_HANDLER | FWXFERQ_CHTAGMASK);
xferq->hand = NULL;
- for (i = 0; i < xferq->bnchunk; i ++)
+ for (i = 0; i < xferq->bnchunk; i++)
m_freem(xferq->bulkxfer[i].mbuf);
free(xferq->bulkxfer, M_FWIP);
@@ -322,7 +316,7 @@ fwip_init(void *arg)
STAILQ_INIT(&xferq->stfree);
STAILQ_INIT(&xferq->stdma);
xferq->stproc = NULL;
- for (i = 0; i < xferq->bnchunk; i ++) {
+ for (i = 0; i < xferq->bnchunk; i++) {
m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
xferq->bulkxfer[i].mbuf = m;
m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
@@ -335,7 +329,7 @@ fwip_init(void *arg)
/* pre-allocate xfer */
STAILQ_INIT(&fwip->fwb.xferlist);
- for (i = 0; i < rx_queue_len; i ++) {
+ for (i = 0; i < rx_queue_len; i++) {
xfer = fw_xfer_alloc(M_FWIP);
if (xfer == NULL)
break;
@@ -411,13 +405,12 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
!(ifp->if_capenable & IFCAP_POLLING)) {
error = ether_poll_register(fwip_poll, ifp);
if (error)
- return(error);
+ return (error);
/* Disable interrupts */
fc->set_intr(fc, 0);
ifp->if_capenable |= IFCAP_POLLING |
IFCAP_POLLING_NOCOUNT;
return (error);
-
}
if (!(ifr->ifr_reqcap & IFCAP_POLLING) &&
ifp->if_capenable & IFCAP_POLLING) {
@@ -485,7 +478,6 @@ fwip_output_callback(struct fw_xfer *xfer)
FWIPDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
-
m_freem(xfer->mbuf);
fw_xfer_unload(xfer);
@@ -937,9 +929,6 @@ static driver_t fwip_driver = {
};
-#ifdef __DragonFly__
-DECLARE_DUMMY_MODULE(fwip);
-#endif
DRIVER_MODULE(fwip, firewire, fwip_driver, fwip_devclass, 0, 0);
MODULE_VERSION(fwip, 1);
MODULE_DEPEND(fwip, firewire, 1, 1, 1);
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index d66933a..69e83c4 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -30,7 +30,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*
*/
@@ -75,16 +75,16 @@
#define SBP_QUEUE_LEN ((SBP_DMA_SIZE - SBP_LOGIN_SIZE) / sizeof(struct sbp_ocb))
#define SBP_NUM_OCB (SBP_QUEUE_LEN * SBP_NUM_TARGETS)
-/*
+/*
* STATUS FIFO addressing
* bit
- * -----------------------
+ *-----------------------
* 0- 1( 2): 0 (alignment)
* 2- 7( 6): target
* 8-15( 8): lun
* 16-31( 8): reserved
- * 32-47(16): SBP_BIND_HI
- * 48-64(16): bus_id, node_id
+ * 32-47(16): SBP_BIND_HI
+ * 48-64(16): bus_id, node_id
*/
#define SBP_BIND_HI 0x1
#define SBP_DEV2ADDR(t, l) \
@@ -154,7 +154,7 @@ struct sbp_ocb {
#define OCB_ACT_CMD 1
#define OCB_MATCH(o,s) ((o)->bus_addr == ntohl((s)->orb_lo))
-struct sbp_dev{
+struct sbp_dev {
#define SBP_DEV_RESET 0 /* accept login */
#define SBP_DEV_LOGIN 1 /* to login */
#if 0
@@ -232,7 +232,7 @@ static void sbp_cmd_callback (struct fw_xfer *);
#endif
static void sbp_orb_pointer (struct sbp_dev *, struct sbp_ocb *);
static void sbp_doorbell(struct sbp_dev *);
-static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int);
+static void sbp_execute_ocb (void *, bus_dma_segment_t *, int, int);
static void sbp_free_ocb (struct sbp_dev *, struct sbp_ocb *);
static void sbp_abort_ocb (struct sbp_ocb *, int);
static void sbp_abort_all_ocbs (struct sbp_dev *, int);
@@ -388,7 +388,7 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev)
/* XXX wired-down configuration should be gotten from
tunable or device hint */
- for (i = 0; wired[i].bus >= 0; i ++) {
+ for (i = 0; wired[i].bus >= 0; i++) {
if (wired[i].bus == bus) {
w[wired[i].target] = 1;
if (wired[i].eui.hi == fwdev->eui.hi &&
@@ -397,16 +397,16 @@ sbp_new_target(struct sbp_softc *sbp, struct fw_device *fwdev)
}
}
if (target >= 0) {
- if(target < SBP_NUM_TARGETS &&
+ if (target < SBP_NUM_TARGETS &&
sbp->targets[target].fwdev == NULL)
- return(target);
+ return (target);
device_printf(sbp->fd.dev,
- "target %d is not free for %08x:%08x\n",
+ "target %d is not free for %08x:%08x\n",
target, fwdev->eui.hi, fwdev->eui.lo);
target = -1;
}
/* non-wired target */
- for (i = 0; i < SBP_NUM_TARGETS; i ++)
+ for (i = 0; i < SBP_NUM_TARGETS; i++)
if (sbp->targets[i].fwdev == NULL && w[i] == 0) {
target = i;
break;
@@ -445,12 +445,12 @@ END_DEBUG
device_printf(target->sbp->fd.dev, "%d no LUN found\n",
target->target_id);
- maxlun ++;
+ maxlun++;
if (maxlun >= SBP_NUM_LUNS)
maxlun = SBP_NUM_LUNS;
/* Invalidiate stale devices */
- for (lun = 0; lun < target->num_lun; lun ++) {
+ for (lun = 0; lun < target->num_lun; lun++) {
sdev = target->luns[lun];
if (sdev == NULL)
continue;
@@ -468,7 +468,7 @@ END_DEBUG
newluns = (struct sbp_dev **) realloc(target->luns,
sizeof(struct sbp_dev *) * maxlun,
M_SBP, M_NOWAIT | M_ZERO);
-
+
if (newluns == NULL) {
printf("%s: realloc failed\n", __func__);
newluns = target->luns;
@@ -527,7 +527,7 @@ END_DEBUG
if (new == 0)
goto next;
- fwdma_malloc(sbp->fd.fc,
+ fwdma_malloc(sbp->fd.fc,
/* alignment */ sizeof(uint32_t),
SBP_DMA_SIZE, &sdev->dma, BUS_DMA_NOWAIT |
BUS_DMA_COHERENT);
@@ -542,7 +542,7 @@ END_DEBUG
sdev->ocb = (struct sbp_ocb *)
((char *)sdev->dma.v_addr + SBP_LOGIN_SIZE);
bzero((char *)sdev->ocb,
- sizeof (struct sbp_ocb) * SBP_QUEUE_LEN);
+ sizeof(struct sbp_ocb) * SBP_QUEUE_LEN);
STAILQ_INIT(&sdev->free_ocbs);
for (i = 0; i < SBP_QUEUE_LEN; i++) {
@@ -564,7 +564,7 @@ next:
crom_next(&cc);
}
- for (lun = 0; lun < target->num_lun; lun ++) {
+ for (lun = 0; lun < target->num_lun; lun++) {
sdev = target->luns[lun];
if (sdev != NULL && (sdev->flags & VALID_LUN) == 0) {
sbp_cam_detach_sdev(sdev);
@@ -713,7 +713,7 @@ END_DEBUG
if (alive && (sdev->status != SBP_DEV_DEAD)) {
if (sdev->path != NULL) {
xpt_freeze_devq(sdev->path, 1);
- sdev->freeze ++;
+ sdev->freeze++;
}
sbp_probe_lun(sdev);
sbp_show_sdev_info(sdev);
@@ -743,7 +743,7 @@ SBP_DEBUG(0)
END_DEBUG
if (sdev->path) {
xpt_freeze_devq(sdev->path, 1);
- sdev->freeze ++;
+ sdev->freeze++;
}
sdev->status = SBP_DEV_RETRY;
sbp_cam_detach_sdev(sdev);
@@ -797,7 +797,7 @@ END_DEBUG
return;
if (sbp_cold > 0)
- sbp_cold --;
+ sbp_cold--;
SBP_LOCK(sbp);
#if 0
@@ -809,7 +809,7 @@ END_DEBUG
#endif
/* Garbage Collection */
- for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
+ for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link)
if (target->fwdev == NULL || target->fwdev == fwdev)
@@ -829,14 +829,14 @@ SBP_DEBUG(0)
fwdev->status);
END_DEBUG
alive = SBP_FWDEV_ALIVE(fwdev);
- for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
+ for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
- if(target->fwdev == fwdev ) {
+ if (target->fwdev == fwdev) {
/* known target */
break;
}
}
- if(i == SBP_NUM_TARGETS){
+ if (i == SBP_NUM_TARGETS) {
if (alive) {
/* new target */
target = sbp_alloc_target(sbp, fwdev);
@@ -857,7 +857,8 @@ END_DEBUG
#if NEED_RESPONSE
static void
-sbp_loginres_callback(struct fw_xfer *xfer){
+sbp_loginres_callback(struct fw_xfer *xfer)
+{
struct sbp_dev *sdev;
sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1)
@@ -950,8 +951,8 @@ sbp_next_dev(struct sbp_target *target, int lun)
for (i = lun, sdevp = &target->luns[lun]; i < target->num_lun;
i++, sdevp++)
if (*sdevp != NULL && (*sdevp)->status == SBP_DEV_PROBE)
- return(*sdevp);
- return(NULL);
+ return (*sdevp);
+ return (NULL);
}
#define SCAN_PRI 1
@@ -1147,7 +1148,7 @@ END_DEBUG
fp = &xfer->send.hdr;
fp->mode.wreqq.dest_hi = 0xffff;
fp->mode.wreqq.dest_lo = 0xf0000000 | BUSY_TIMEOUT;
- fp->mode.wreqq.data = htonl((1 << (13+12)) | 0xf);
+ fp->mode.wreqq.data = htonl((1 << (13 + 12)) | 0xf);
fw_asyreq(xfer->fc, -1, xfer);
}
@@ -1213,8 +1214,8 @@ END_DEBUG
fp = &xfer->send.hdr;
fp->mode.wreqb.len = 8;
fp->mode.wreqb.extcode = 0;
- xfer->send.payload[0] =
- htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16));
+ xfer->send.payload[0] =
+ htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS) << 16));
xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr);
if (fw_asyreq(xfer->fc, -1, xfer) != 0) {
@@ -1288,14 +1289,14 @@ sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
if (xfer == NULL) {
if (target->n_xfer > 5 /* XXX */) {
printf("sbp: no more xfer for this target\n");
- return(NULL);
+ return (NULL);
}
xfer = fw_xfer_alloc_buf(M_SBP, 8, 0);
- if(xfer == NULL){
+ if (xfer == NULL) {
printf("sbp: fw_xfer_alloc_buf failed\n");
return NULL;
}
- target->n_xfer ++;
+ target->n_xfer++;
if (debug)
printf("sbp: alloc %d xfer\n", target->n_xfer);
new = 1;
@@ -1362,7 +1363,7 @@ SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
"%s:%s %s\n",
__func__,sdev->bustgtlun,
- orb_fun_name[(func>>16)&0xf]);
+ orb_fun_name[(func >> 16) & 0xf]);
END_DEBUG
switch (func) {
case ORB_FUN_LGI:
@@ -1399,7 +1400,7 @@ start:
callout_reset(&target->mgm_ocb_timeout, 5*hz,
sbp_mgm_timeout, (caddr_t)ocb);
xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0);
- if(xfer == NULL){
+ if (xfer == NULL) {
return;
}
xfer->hand = sbp_mgm_callback;
@@ -1470,25 +1471,25 @@ END_DEBUG
case SCSI_STATUS_CHECK_COND:
case SCSI_STATUS_BUSY:
case SCSI_STATUS_CMD_TERMINATED:
- if(sbp_cmd_status->sfmt == SBP_SFMT_CURR){
+ if (sbp_cmd_status->sfmt == SBP_SFMT_CURR) {
sense->error_code = SSD_CURRENT_ERROR;
- }else{
+ } else {
sense->error_code = SSD_DEFERRED_ERROR;
}
- if(sbp_cmd_status->valid)
+ if (sbp_cmd_status->valid)
sense->error_code |= SSD_ERRCODE_VALID;
sense->flags = sbp_cmd_status->s_key;
- if(sbp_cmd_status->mark)
+ if (sbp_cmd_status->mark)
sense->flags |= SSD_FILEMARK;
- if(sbp_cmd_status->eom)
+ if (sbp_cmd_status->eom)
sense->flags |= SSD_EOM;
- if(sbp_cmd_status->ill_len)
+ if (sbp_cmd_status->ill_len)
sense->flags |= SSD_ILI;
bcopy(&sbp_cmd_status->info, &sense->info[0], 4);
if (sbp_status->len <= 1)
- /* XXX not scsi status. shouldn't be happened */
+ /* XXX not scsi status. shouldn't be happened */
sense->extra_len = 0;
else if (sbp_status->len <= 4)
/* add_sense_code(_qual), info, cmd_spec_info */
@@ -1513,10 +1514,10 @@ END_DEBUG
{
uint8_t j, *tmp;
tmp = sense;
- for( j = 0 ; j < 32 ; j+=8){
- printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n",
- tmp[j], tmp[j+1], tmp[j+2], tmp[j+3],
- tmp[j+4], tmp[j+5], tmp[j+6], tmp[j+7]);
+ for (j = 0; j < 32; j += 8) {
+ printf("sense %02x%02x %02x%02x %02x%02x %02x%02x\n",
+ tmp[j], tmp[j + 1], tmp[j + 2], tmp[j + 3],
+ tmp[j + 4], tmp[j + 5], tmp[j + 6], tmp[j + 7]);
}
}
@@ -1550,7 +1551,7 @@ END_DEBUG
switch (SID_TYPE(inq)) {
case T_DIRECT:
#if 0
- /*
+ /*
* XXX Convert Direct Access device to RBC.
* I've never seen FireWire DA devices which support READ_6.
*/
@@ -1566,7 +1567,7 @@ END_DEBUG
#if 1
bcopy(sdev->vendor, inq->vendor, sizeof(inq->vendor));
bcopy(sdev->product, inq->product, sizeof(inq->product));
- bcopy(sdev->revision+2, inq->revision, sizeof(inq->revision));
+ bcopy(sdev->revision + 2, inq->revision, sizeof(inq->revision));
#endif
break;
}
@@ -1606,16 +1607,16 @@ printf("sbp %08x %08x %08x %08x\n", ntohl(ld[8]), ntohl(ld[9]), ntohl(ld[10]), n
*/
sbp = (struct sbp_softc *)xfer->sc;
SBP_LOCK_ASSERT(sbp);
- if (xfer->resp != 0){
+ if (xfer->resp != 0) {
printf("sbp_recv: xfer->resp = %d\n", xfer->resp);
goto done0;
}
- if (xfer->recv.payload == NULL){
+ if (xfer->recv.payload == NULL) {
printf("sbp_recv: xfer->recv.payload == NULL\n");
goto done0;
}
rfp = &xfer->recv.hdr;
- if(rfp->mode.wreqb.tcode != FWTCODE_WREQB){
+ if (rfp->mode.wreqb.tcode != FWTCODE_WREQB) {
printf("sbp_recv: tcode = %d\n", rfp->mode.wreqb.tcode);
goto done0;
}
@@ -1677,7 +1678,7 @@ END_DEBUG
&& sbp_status->dead == 0);
status_valid = (status_valid0 && sbp_status->status == 0);
- if (!status_valid0 || debug > 2){
+ if (!status_valid0 || debug > 2) {
int status;
SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
@@ -1691,7 +1692,7 @@ END_DEBUG
device_printf(sdev->target->sbp->fd.dev,
"%s\n", sdev->bustgtlun);
status = sbp_status->status;
- switch(sbp_status->resp) {
+ switch (sbp_status->resp) {
case 0:
if (status > MAX_ORB_STATUS0)
printf("%s\n", orb_status0[MAX_ORB_STATUS0]);
@@ -1700,7 +1701,7 @@ END_DEBUG
break;
case 1:
printf("Obj: %s, Error: %s\n",
- orb_status1_object[(status>>6) & 3],
+ orb_status1_object[(status >> 6) & 3],
orb_status1_serial_bus_error[status & 0xf]);
break;
case 2:
@@ -1718,7 +1719,7 @@ END_DEBUG
if (sbp_status->dead) {
if (sdev->path) {
xpt_freeze_devq(sdev->path, 1);
- sdev->freeze ++;
+ sdev->freeze++;
}
reset_agent = 1;
}
@@ -1726,17 +1727,17 @@ END_DEBUG
if (ocb == NULL)
goto done;
- switch(ntohl(ocb->orb[4]) & ORB_FMT_MSK){
+ switch (ntohl(ocb->orb[4]) & ORB_FMT_MSK) {
case ORB_FMT_NOP:
break;
case ORB_FMT_VED:
break;
case ORB_FMT_STD:
- switch(ocb->flags) {
+ switch (ocb->flags) {
case OCB_ACT_MGM:
orb_fun = ntohl(ocb->orb[4]) & ORB_FUN_MSK;
reset_agent = 0;
- switch(orb_fun) {
+ switch (orb_fun) {
case ORB_FUN_LGI:
fwdma_sync(&sdev->dma, BUS_DMASYNC_POSTREAD);
login_res = sdev->login;
@@ -1807,16 +1808,16 @@ END_DEBUG
break;
case OCB_ACT_CMD:
sdev->timeout = 0;
- if(ocb->ccb != NULL){
+ if (ocb->ccb != NULL) {
union ccb *ccb;
ccb = ocb->ccb;
- if(sbp_status->len > 1){
+ if (sbp_status->len > 1) {
sbp_scsi_status(sbp_status, ocb);
- }else{
- if(sbp_status->resp != ORB_RES_CMPL){
+ } else {
+ if (sbp_status->resp != ORB_RES_CMPL) {
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- }else{
+ } else {
ccb->ccb_h.status = CAM_REQ_CMP;
}
}
@@ -1843,7 +1844,7 @@ done0:
* the buffer. In that case, the controller return ack_complete and
* no respose is necessary.
*
- * XXX fwohci.c and firewire.c should inform event_code such as
+ * XXX fwohci.c and firewire.c should inform event_code such as
* ack_complete or ack_pending to upper driver.
*/
#if NEED_RESPONSE
@@ -1900,7 +1901,7 @@ SBP_DEBUG(0)
END_DEBUG
if (cold)
- sbp_cold ++;
+ sbp_cold++;
sbp = device_get_softc(dev);
sbp->fd.dev = dev;
sbp->fd.fc = fc = device_get_ivars(dev);
@@ -1932,7 +1933,7 @@ END_DEBUG
if (devq == NULL)
return (ENXIO);
- for( i = 0 ; i < SBP_NUM_TARGETS ; i++){
+ for (i = 0; i < SBP_NUM_TARGETS; i++) {
sbp->targets[i].fwdev = NULL;
sbp->targets[i].luns = NULL;
sbp->targets[i].sbp = sbp;
@@ -2001,7 +2002,7 @@ SBP_DEBUG(0)
printf("sbp_logout_all\n");
END_DEBUG
SBP_LOCK_ASSERT(sbp);
- for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
+ for (i = 0; i < SBP_NUM_TARGETS; i++) {
target = &sbp->targets[i];
if (target->luns == NULL)
continue;
@@ -2090,7 +2091,7 @@ SBP_DEBUG(0)
END_DEBUG
SBP_LOCK(sbp);
- for (i = 0; i < SBP_NUM_TARGETS; i ++)
+ for (i = 0; i < SBP_NUM_TARGETS; i++)
sbp_cam_detach_target(&sbp->targets[i]);
xpt_async(AC_LOST_DEVICE, sbp->path, NULL);
@@ -2105,7 +2106,7 @@ END_DEBUG
pause("sbpdtc", hz/2);
SBP_LOCK(sbp);
- for (i = 0 ; i < SBP_NUM_TARGETS ; i ++)
+ for (i = 0; i < SBP_NUM_TARGETS; i++)
sbp_free_target(&sbp->targets[i]);
SBP_UNLOCK(sbp);
@@ -2172,12 +2173,12 @@ sbp_target_reset(struct sbp_dev *sdev, int method)
if (tsdev->status == SBP_DEV_RESET)
continue;
xpt_freeze_devq(tsdev->path, 1);
- tsdev->freeze ++;
+ tsdev->freeze++;
sbp_abort_all_ocbs(tsdev, CAM_CMD_TIMEOUT);
if (method == 2)
tsdev->status = SBP_DEV_LOGIN;
}
- switch(method) {
+ switch (method) {
case 1:
printf("target reset\n");
sbp_mgm_orb(sdev, ORB_FUN_RST, NULL);
@@ -2187,7 +2188,7 @@ sbp_target_reset(struct sbp_dev *sdev, int method)
sbp_reset_start(sdev);
break;
}
-
+
}
static void
@@ -2225,12 +2226,12 @@ sbp_timeout(void *arg)
__func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
SBP_LOCK_ASSERT(sdev->target->sbp);
- sdev->timeout ++;
- switch(sdev->timeout) {
+ sdev->timeout++;
+ switch (sdev->timeout) {
case 1:
printf("agent reset\n");
xpt_freeze_devq(sdev->path, 1);
- sdev->freeze ++;
+ sdev->freeze++;
sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT);
sbp_agent_reset(sdev);
break;
@@ -2309,7 +2310,7 @@ END_DEBUG
* sometimes aimed at the SIM (sc is invalid and target is
* CAM_TARGET_WILDCARD)
*/
- if (sbp == NULL &&
+ if (sbp == NULL &&
ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
SBP_DEBUG(0)
printf("%s:%d:%jx func_code 0x%04x: "
@@ -2361,7 +2362,7 @@ SBP_DEBUG(2)
csio->cdb_len, csio->dxfer_len,
csio->sense_len);
END_DEBUG
- if(sdev == NULL){
+ if (sdev == NULL) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
xpt_done(ccb);
return;
@@ -2383,7 +2384,7 @@ END_DEBUG
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
if (sdev->freeze == 0) {
xpt_freeze_devq(sdev->path, 1);
- sdev->freeze ++;
+ sdev->freeze++;
}
xpt_done(ccb);
return;
@@ -2395,12 +2396,12 @@ END_DEBUG
ccb->ccb_h.ccb_sdev_ptr = sdev;
ocb->orb[0] = htonl(1U << 31);
ocb->orb[1] = 0;
- ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS )<< 16) );
+ ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS) << 16));
ocb->orb[3] = htonl(ocb->bus_addr + IND_PTR_OFFSET);
speed = min(target->fwdev->speed, max_speed);
ocb->orb[4] = htonl(ORB_NOTIFY | ORB_CMD_SPD(speed)
| ORB_CMD_MAXP(speed + 7));
- if((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN){
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
ocb->orb[4] |= htonl(ORB_CMD_IN);
}
@@ -2467,7 +2468,7 @@ END_DEBUG
case XPT_PATH_INQ: /* Path routing inquiry */
{
struct ccb_pathinq *cpi = &ccb->cpi;
-
+
SBP_DEBUG(1)
printf("%s:%d:%jx XPT_PATH_INQ:.\n",
device_get_nameunit(sbp->fd.dev),
@@ -2536,7 +2537,7 @@ END_DEBUG
}
static void
-sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
+sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
{
int i;
struct sbp_ocb *ocb;
@@ -2563,7 +2564,7 @@ END_DEBUG
panic("ds_len > SBP_SEG_MAX, fix busdma code");
ocb->orb[3] = htonl(s->ds_addr);
ocb->orb[4] |= htonl(s->ds_len);
- } else if(seg > 1) {
+ } else if (seg > 1) {
/* page table */
for (i = 0; i < seg; i++) {
s = &segments[i];
@@ -2572,7 +2573,7 @@ SBP_DEBUG(0)
if (s->ds_len < 16)
printf("sbp_execute_ocb: warning, "
"segment length(%zd) is less than 16."
- "(seg=%d/%d)\n", (size_t)s->ds_len, i+1, seg);
+ "(seg=%d/%d)\n", (size_t)s->ds_len, i + 1, seg);
END_DEBUG
if (s->ds_len > SBP_SEG_MAX)
panic("ds_len > SBP_SEG_MAX, fix busdma code");
@@ -2581,7 +2582,7 @@ END_DEBUG
}
ocb->orb[4] |= htonl(ORB_CMD_PTBL | seg);
}
-
+
if (seg > 0)
bus_dmamap_sync(ocb->sdev->target->sbp->dmat, ocb->dmamap,
(ntohl(ocb->orb[4]) & ORB_CMD_IN) ?
@@ -2593,19 +2594,19 @@ END_DEBUG
if (ocb->sdev->last_ocb != NULL)
sbp_doorbell(ocb->sdev);
else
- sbp_orb_pointer(ocb->sdev, ocb);
+ sbp_orb_pointer(ocb->sdev, ocb);
}
} else {
if (prev == NULL || (ocb->sdev->flags & ORB_LINK_DEAD) != 0) {
ocb->sdev->flags &= ~ORB_LINK_DEAD;
- sbp_orb_pointer(ocb->sdev, ocb);
+ sbp_orb_pointer(ocb->sdev, ocb);
}
}
}
static void
sbp_poll(struct cam_sim *sim)
-{
+{
struct sbp_softc *sbp;
struct firewire_comm *fc;
@@ -2648,7 +2649,7 @@ END_DEBUG
if (!use_doorbell) {
if (sbp_status->src == SRC_NO_NEXT) {
if (next != NULL)
- sbp_orb_pointer(sdev, next);
+ sbp_orb_pointer(sdev, next);
else if (order > 0) {
/*
* Unordered execution
@@ -2661,7 +2662,7 @@ END_DEBUG
} else {
/*
* XXX this is not correct for unordered
- * execution.
+ * execution.
*/
if (sdev->last_ocb != NULL) {
sbp_free_ocb(sdev, sdev->last_ocb);
@@ -2673,7 +2674,7 @@ END_DEBUG
}
break;
} else
- order ++;
+ order++;
}
SBP_DEBUG(0)
if (ocb && order > 0) {
diff --git a/sys/dev/firewire/sbp.h b/sys/dev/firewire/sbp.h
index 84d522a..79f2e28 100644
--- a/sys/dev/firewire/sbp.h
+++ b/sys/dev/firewire/sbp.h
@@ -76,7 +76,7 @@ struct ind_ptr {
#define SBP_RECV_LEN 32
-struct sbp_login_res{
+struct sbp_login_res {
uint16_t len;
uint16_t id;
uint16_t res0;
@@ -86,7 +86,7 @@ struct sbp_login_res{
uint16_t recon_hold;
};
-struct sbp_status{
+struct sbp_status {
#if BYTE_ORDER == BIG_ENDIAN
uint8_t src:2,
resp:2,
@@ -155,7 +155,7 @@ struct sbp_status{
/* F: Address error */
-struct sbp_cmd_status{
+struct sbp_cmd_status {
#define SBP_SFMT_CURR 0
#define SBP_SFMT_DEFER 1
#if BYTE_ORDER == BIG_ENDIAN
diff --git a/sys/dev/firewire/sbp_targ.c b/sys/dev/firewire/sbp_targ.c
index f8f3063..0d78e9f 100644
--- a/sys/dev/firewire/sbp_targ.c
+++ b/sys/dev/firewire/sbp_targ.c
@@ -1,7 +1,7 @@
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -18,7 +18,7 @@
* 4. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -30,7 +30,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* $FreeBSD$
*/
@@ -104,16 +104,16 @@ struct sbp_targ_login {
struct sbp_targ_lstate *lstate;
struct fw_device *fwdev;
struct sbp_login_res loginres;
- uint16_t fifo_hi;
+ uint16_t fifo_hi;
uint16_t last_hi;
- uint32_t fifo_lo;
+ uint32_t fifo_lo;
uint32_t last_lo;
STAILQ_HEAD(, orb_info) orbs;
STAILQ_ENTRY(sbp_targ_login) link;
uint16_t hold_sec;
uint16_t id;
- uint8_t flags;
- uint8_t spd;
+ uint8_t flags;
+ uint8_t spd;
struct callout hold_callout;
};
@@ -124,7 +124,7 @@ struct sbp_targ_lstate {
struct ccb_hdr_slist accept_tios;
struct ccb_hdr_slist immed_notifies;
struct crom_chunk model;
- uint32_t flags;
+ uint32_t flags;
STAILQ_HEAD(, sbp_targ_login) logins;
};
@@ -205,7 +205,7 @@ struct orb_info {
struct sbp_targ_login *login;
union ccb *ccb;
struct ccb_accept_tio *atio;
- uint8_t state;
+ uint8_t state;
#define ORBI_STATUS_NONE 0
#define ORBI_STATUS_FETCH 1
#define ORBI_STATUS_ATIO 2
@@ -213,7 +213,7 @@ struct orb_info {
#define ORBI_STATUS_STATUS 4
#define ORBI_STATUS_POINTER 5
#define ORBI_STATUS_ABORTED 7
- uint8_t refcount;
+ uint8_t refcount;
uint16_t orb_hi;
uint32_t orb_lo;
uint32_t data_hi;
@@ -250,8 +250,8 @@ sbp_targ_probe(device_t dev)
device_t pa;
pa = device_get_parent(dev);
- if(device_get_unit(dev) != device_get_unit(pa)){
- return(ENXIO);
+ if (device_get_unit(dev) != device_get_unit(pa)) {
+ return (ENXIO);
}
device_set_desc(dev, "SBP-2/SCSI over FireWire target mode");
@@ -336,7 +336,7 @@ sbp_targ_post_busreset(void *arg)
crom_add_entry(unit, CROM_MGM, SBP_TARG_MGM >> 2);
crom_add_entry(unit, CSRKEY_UNIT_CH, (10<<8) | 8);
- for (i = 0; i < MAX_LUN; i ++) {
+ for (i = 0; i < MAX_LUN; i++) {
lstate = sc->lstate[i];
if (lstate == NULL)
continue;
@@ -347,7 +347,7 @@ sbp_targ_post_busreset(void *arg)
}
/* Process for reconnection hold time */
- for (i = 0; i < MAX_LOGINS; i ++) {
+ for (i = 0; i < MAX_LOGINS; i++) {
login = sc->logins[i];
if (login == NULL)
continue;
@@ -355,7 +355,7 @@ sbp_targ_post_busreset(void *arg)
if (login->flags & F_LOGIN) {
login->flags |= F_HOLD;
callout_reset(&login->hold_callout,
- hz * login->hold_sec,
+ hz * login->hold_sec,
sbp_targ_hold_expire, (void *)login);
}
}
@@ -392,7 +392,7 @@ sbp_targ_find_devs(struct sbp_targ_softc *sc, union ccb *ccb,
lun = ccb->ccb_h.target_lun;
if (lun >= MAX_LUN)
return (CAM_LUN_INVALID);
-
+
*lstate = sc->lstate[lun];
if (notfound_failure != 0 && *lstate == NULL) {
@@ -840,7 +840,7 @@ sbp_targ_cam_done(struct fw_xfer *xfer)
sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link));
}
- orbi->refcount --;
+ orbi->refcount--;
ccb = orbi->ccb;
if (orbi->refcount == 0) {
@@ -916,7 +916,7 @@ sbp_targ_abort_ccb(struct sbp_targ_softc *sc, union ccb *ccb)
found = 1;
SLIST_REMOVE_HEAD(list, sim_links.sle);
} else {
- while(curelm != NULL) {
+ while (curelm != NULL) {
struct ccb_hdr *nextelm;
nextelm = SLIST_NEXT(curelm, sim_links.sle);
@@ -982,7 +982,7 @@ sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
if (xfer == NULL) {
printf("%s: xfer == NULL", __func__);
/* XXX what should we do?? */
- orbi->refcount --;
+ orbi->refcount--;
}
off += len;
}
@@ -1354,7 +1354,7 @@ sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.status = CAM_UA_ABORT;
break;
default:
- printf("%s: aborting unknown function %d\n",
+ printf("%s: aborting unknown function %d\n",
__func__, accb->ccb_h.func_code);
ccb->ccb_h.status = CAM_REQ_INVALID;
break;
@@ -1464,7 +1464,7 @@ sbp_targ_cmd_handler(struct fw_xfer *xfer)
orb = orbi->orb;
/* swap payload except SCSI command */
- for (i = 0; i < 5; i ++)
+ for (i = 0; i < 5; i++)
orb[i] = ntohl(orb[i]);
orb4 = (struct corb4 *)&orb[4];
@@ -1545,12 +1545,12 @@ sbp_targ_get_login(struct sbp_targ_softc *sc, struct fw_device *fwdev, int lun)
int i;
lstate = sc->lstate[lun];
-
+
STAILQ_FOREACH(login, &lstate->logins, link)
if (login->fwdev == fwdev)
return (login);
- for (i = 0; i < MAX_LOGINS; i ++)
+ for (i = 0; i < MAX_LOGINS; i++)
if (sc->logins[i] == NULL)
goto found;
@@ -1607,7 +1607,7 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
orb = orbi->orb;
/* swap payload */
- for (i = 0; i < 8; i ++) {
+ for (i = 0; i < 8; i++) {
orb[i] = ntohl(orb[i]);
}
orb4 = (struct morb4 *)&orb[4];
@@ -1628,10 +1628,10 @@ sbp_targ_mgm_handler(struct fw_xfer *xfer)
lstate = orbi->sc->lstate[lun];
if (lun >= MAX_LUN || lstate == NULL ||
- (exclusive &&
+ (exclusive &&
STAILQ_FIRST(&lstate->logins) != NULL &&
STAILQ_FIRST(&lstate->logins)->fwdev != orbi->fwdev)
- ) {
+ ) {
/* error */
orbi->status.dead = 1;
orbi->status.status = STATUS_ACCESS_DENY;
@@ -1819,16 +1819,16 @@ sbp_targ_cmd(struct fw_xfer *xfer, struct fw_device *fwdev, int login_id,
int rtcode = 0;
if (login_id < 0 || login_id >= MAX_LOGINS)
- return(RESP_ADDRESS_ERROR);
+ return (RESP_ADDRESS_ERROR);
sc = (struct sbp_targ_softc *)xfer->sc;
login = sc->logins[login_id];
if (login == NULL)
- return(RESP_ADDRESS_ERROR);
+ return (RESP_ADDRESS_ERROR);
if (login->fwdev != fwdev) {
/* XXX */
- return(RESP_ADDRESS_ERROR);
+ return (RESP_ADDRESS_ERROR);
}
switch (reg) {
@@ -1895,17 +1895,17 @@ sbp_targ_mgm(struct fw_xfer *xfer, struct fw_device *fwdev)
sc = (struct sbp_targ_softc *)xfer->sc;
fp = &xfer->recv.hdr;
- if (fp->mode.wreqb.tcode != FWTCODE_WREQB){
+ if (fp->mode.wreqb.tcode != FWTCODE_WREQB) {
printf("%s: tcode = %d\n", __func__, fp->mode.wreqb.tcode);
- return(RESP_TYPE_ERROR);
+ return (RESP_TYPE_ERROR);
}
sbp_targ_fetch_orb(sc, fwdev,
ntohl(xfer->recv.payload[0]),
ntohl(xfer->recv.payload[1]),
NULL, FETCH_MGM);
-
- return(0);
+
+ return (0);
}
static void
@@ -2023,9 +2023,9 @@ sbp_targ_detach(device_t dev)
xpt_free_path(sc->path);
xpt_bus_deregister(cam_sim_path(sc->sim));
SBP_UNLOCK(sc);
- cam_sim_free(sc->sim, /*free_devq*/TRUE);
+ cam_sim_free(sc->sim, /*free_devq*/TRUE);
- for (i = 0; i < MAX_LUN; i ++) {
+ for (i = 0; i < MAX_LUN; i++) {
lstate = sc->lstate[i];
if (lstate != NULL) {
xpt_free_path(lstate->path);
@@ -2036,7 +2036,7 @@ sbp_targ_detach(device_t dev)
xpt_free_path(sc->black_hole->path);
free(sc->black_hole, M_SBP_TARG);
}
-
+
fw_bindremove(sc->fd.fc, &sc->fwb);
fw_xferlist_remove(&sc->fwb.xferlist);
OpenPOWER on IntegriCloud