summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2007-05-31 23:28:31 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2007-05-31 23:28:31 +0000
commit7d0025b0c06952a8102c0d10a4cfa3ddddcaaac6 (patch)
tree4b4a787b4b4f49c663ee0c529fbee0f939a17bd8 /sys/dev
parent04885bf9ba912ab184c4a415f731af6f4d66a522 (diff)
Clean up and fix sbt_write_packet()
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sdmmc/sbt.c81
1 files changed, 11 insertions, 70 deletions
diff --git a/sys/dev/sdmmc/sbt.c b/sys/dev/sdmmc/sbt.c
index 9eaa3067d12..9810ca6e038 100644
--- a/sys/dev/sdmmc/sbt.c
+++ b/sys/dev/sdmmc/sbt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbt.c,v 1.1 2007/05/31 18:45:09 uwe Exp $ */
+/* $OpenBSD: sbt.c,v 1.2 2007/05/31 23:28:30 uwe Exp $ */
/*
* Copyright (c) 2007 Uwe Stuehler <uwe@openbsd.org>
@@ -20,8 +20,6 @@
#include <sys/param.h>
#include <sys/device.h>
-#include <sys/kernel.h>
-#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
@@ -64,10 +62,6 @@ struct sbt_softc {
int sbt_match(struct device *, void *, void *);
void sbt_attach(struct device *, struct device *, void *);
int sbt_detach(struct device *, int);
-void sbt_create_thread(void *);
-
-void sbt_thread0(void *);
-void sbt_thread(void *);
int sbt_write_packet(struct sbt_softc *, u_char *, size_t);
int sbt_read_packet(struct sbt_softc *, u_char *, size_t *);
@@ -98,8 +92,6 @@ struct cfdriver sbt_cd = {
NULL, "sbt", DV_DULL
};
-extern struct cfdriver bthub_cd;
-
/*
* Autoconf glue
@@ -174,12 +166,6 @@ sbt_attach(struct device *parent, struct device *self, void *aux)
}
sdmmc_intr_enable(sc->sc_sf);
- /* Create a thread for the packet transport. */
-#ifdef DO_CONFIG_PENDING
- config_pending_incr();
-#endif
- kthread_create_deferred(sbt_create_thread, sc);
-
/*
* Attach Bluetooth unit (machine-independent HCI).
*/
@@ -194,23 +180,6 @@ sbt_attach(struct device *parent, struct device *self, void *aux)
hci_attach(&sc->sc_unit);
}
-void
-sbt_create_thread(void *arg)
-{
- struct sbt_softc *sc = arg;
- struct proc *thread0;
-
- if (kthread_create(sbt_thread, sc, &sc->sc_thread, "%s",
- DEVNAME(sc)) != 0)
- printf("%s: unable to create thread\n", DEVNAME(sc));
- if (kthread_create(sbt_thread0, sc, &thread0, "%s (hci)",
- DEVNAME(sc)) != 0)
- printf("%s: unable to create hci thread\n", DEVNAME(sc));
-#ifdef DO_CONFIG_PENDING
- config_pending_decr();
-#endif
-}
-
int
sbt_detach(struct device *self, int flags)
{
@@ -230,41 +199,6 @@ sbt_detach(struct device *self, int flags)
/*
- * Bluetooth HCI packet transport thread (*caugh*)
- */
-
-void
-sbt_thread0(void *arg)
-{
- struct sbt_softc *sc = arg;
-
- /* XXX wrong place */
- if (!(sc->sc_unit.hci_flags & BTF_UP) &&
- hci_enable(&sc->sc_unit) == 0)
- sc->sc_unit.hci_flags |= BTF_UP;
-
- kthread_exit(0);
-}
-
-void
-sbt_thread(void *arg)
-{
- struct sbt_softc *sc = arg;
-
- while (!sc->sc_dying) {
-#ifdef SBT_POLLING
- if (sbt_intr_pending(sc) && sbt_intr(sc))
- continue;
-#endif
- tsleep(sc, PPAUSE, "slack", hz / 4);
- }
-
- sc->sc_thread = NULL;
- wakeup(sc);
- kthread_exit(0);
-}
-
-/*
* Bluetooth HCI packet transport
*/
@@ -272,6 +206,7 @@ int
sbt_write_packet(struct sbt_softc *sc, u_char *buf, size_t len)
{
u_char hdr[3];
+ size_t pktlen;
int error = EIO;
int retry = 3;
@@ -285,9 +220,10 @@ again:
sdmmc_io_write_1(sc->sc_sf, SBT_REG_WPC, WPC_PCWRT);
/* Write the packet length. */
- hdr[0] = len & 0xff;
- hdr[1] = (len >> 8) & 0xff;
- hdr[2] = (len >> 16) & 0xff;
+ pktlen = len + 3;
+ hdr[0] = pktlen & 0xff;
+ hdr[1] = (pktlen >> 8) & 0xff;
+ hdr[2] = (pktlen >> 16) & 0xff;
error = sdmmc_io_write_multi_1(sc->sc_sf, SBT_REG_DAT, hdr, 3);
if (error) {
DPRINTF(("sbt_write_packet: failed to send length\n"));
@@ -357,6 +293,9 @@ sbt_intr(void *arg)
struct mbuf *m = NULL;
u_int8_t status;
size_t len;
+ int s;
+
+ s = splsdmmc();
status = CSR_READ_1(sc, SBT_REG_ISTAT);
CSR_WRITE_1(sc, SBT_REG_ICLR, status);
@@ -394,6 +333,8 @@ eoi:
else
sc->sc_unit.hci_stats.err_rx++;
+ splx(s);
+
/* Claim this interrupt. */
return 1;
}