[svn-commits] fjoe: freebsd/trunk r8320 - in /freebsd/trunk: drivers/dahdi/ drivers/dahdi/w...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Mar 10 09:47:18 CST 2010
Author: fjoe
Date: Wed Mar 10 09:47:14 2010
New Revision: 8320
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8320
Log:
- Waitqueue API:
- wake_up_interruptible should wake up only one waiter
- add wake_up(), wake_up_interruptible_all() and wait_event_timeout()
- Semaphore API:
- add down() and down_trylock()
- add init_MUTEX() and destroy_MUTEX()
- Workqueue API: add flush_scheduled_work() and flush_workqueue()
- Module API: add module_param()
- Add firmware API
- Add fcstab
- Add dahdi_schluffen
Modified:
freebsd/trunk/drivers/dahdi/dahdi-base.c
freebsd/trunk/drivers/dahdi/wct4xxp/base.c
freebsd/trunk/freebsd/dahdi/bsd-compat.c
freebsd/trunk/include/dahdi/compat/bsd.h
freebsd/trunk/include/dahdi/kernel.h
Modified: freebsd/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=8320&r1=8319&r2=8320
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi-base.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi-base.c Wed Mar 10 09:47:14 2010
@@ -148,7 +148,7 @@
/*
* FCS lookup table as calculated by genfcstab.
*/
-static u_short fcstab[256] = {
+u_short fcstab[256] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
@@ -322,8 +322,8 @@
}
/* sleep in user space until woken up. Equivilant of tsleep() in BSD */
-static int
-schluffen(wait_queue_head_t *q)
+int
+dahdi_schluffen(wait_queue_head_t *q)
{
int rc = tsleep(q, PZERO | PCATCH, "schluffen", 10);
switch (rc) {
@@ -407,7 +407,7 @@
/* sleep in user space until woken up. Equivilant of tsleep() in BSD */
static int
-schluffen(wait_queue_head_t *q)
+dahdi_schluffen(wait_queue_head_t *q)
{
DECLARE_WAITQUEUE(wait, current);
@@ -2370,7 +2370,7 @@
break;
if (file->f_flags & O_NONBLOCK)
return -EAGAIN;
- rv = schluffen(&chan->readbufq);
+ rv = dahdi_schluffen(&chan->readbufq);
if (rv)
return rv;
}
@@ -2505,7 +2505,7 @@
return -EAGAIN;
}
/* Wait for something to be available */
- rv = schluffen(&chan->writebufq);
+ rv = dahdi_schluffen(&chan->writebufq);
if (rv) {
return rv;
}
@@ -4876,7 +4876,7 @@
spin_unlock_irqrestore(&spans[maint.spanno]->lock, flags);
if (rv)
return rv;
- rv = schluffen(&spans[maint.spanno]->maintq);
+ rv = dahdi_schluffen(&spans[maint.spanno]->maintq);
if (rv)
return rv;
spin_lock_irqsave(&spans[maint.spanno]->lock, flags);
@@ -5111,7 +5111,7 @@
i = (chan->outwritebuf > -1);
spin_unlock_irqrestore(&chan->lock, flags);
if (!i) break; /* skip if none */
- rv = schluffen(&chan->writebufq);
+ rv = dahdi_schluffen(&chan->writebufq);
if (rv) return(rv);
}
break;
@@ -5159,7 +5159,7 @@
put_user(ret, (int __user *)data);
break; /* get out of loop */
}
- rv = schluffen(&chan->eventbufq);
+ rv = dahdi_schluffen(&chan->eventbufq);
if (rv) return(rv);
}
/* clear IO MUX mask */
@@ -6038,7 +6038,7 @@
if (file->f_flags & O_NONBLOCK)
return -EINPROGRESS;
#if 0
- rv = schluffen(&chan->txstateq);
+ rv = dahdi_schluffen(&chan->txstateq);
if (rv) return rv;
#endif
break;
@@ -6052,7 +6052,7 @@
spin_unlock_irqrestore(&chan->lock, flags);
if (file->f_flags & O_NONBLOCK)
return -EINPROGRESS;
- rv = schluffen(&chan->txstateq);
+ rv = dahdi_schluffen(&chan->txstateq);
if (rv) return rv;
break;
case DAHDI_FLASH:
@@ -6065,7 +6065,7 @@
spin_unlock_irqrestore(&chan->lock, flags);
if (file->f_flags & O_NONBLOCK)
return -EINPROGRESS;
- rv = schluffen(&chan->txstateq);
+ rv = dahdi_schluffen(&chan->txstateq);
if (rv) return rv;
break;
case DAHDI_RINGOFF:
Modified: freebsd/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=8320&r1=8319&r2=8320
==============================================================================
--- freebsd/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wct4xxp/base.c Wed Mar 10 09:47:14 2010
@@ -3923,20 +3923,11 @@
switch ((vpm_capacity = get_vpm450m_capacity(wc))) {
case 64:
#if defined(HOTPLUG_FIRMWARE)
-#if defined(__FreeBSD__)
- firmware = firmware_get(oct064_firmware);
- if (firmware == NULL) {
- device_printf(wc->dev->dev, "VPM450: can not load firmware %s\n",
- oct064_firmware);
- return;
- }
-#else
if ((request_firmware(&firmware, oct064_firmware, &wc->dev->dev) != 0) ||
!firmware) {
printk(KERN_NOTICE "VPM450: firmware %s not available from userspace\n", oct064_firmware);
return;
}
-#endif
#else
embedded_firmware.data = _binary_dahdi_fw_oct6114_064_bin_start;
/* Yes... this is weird. objcopy gives us a symbol containing
@@ -3950,20 +3941,11 @@
break;
case 128:
#if defined(HOTPLUG_FIRMWARE)
-#if defined(__FreeBSD__)
- firmware = firmware_get(oct128_firmware);
- if (firmware == NULL) {
- device_printf(wc->dev->dev, "VPM450: can not load firmware %s\n",
- oct128_firmware);
- return;
- }
-#else
if ((request_firmware(&firmware, oct128_firmware, &wc->dev->dev) != 0) ||
!firmware) {
printk(KERN_NOTICE "VPM450: firmware %s not available from userspace\n", oct128_firmware);
return;
}
-#endif
#else
embedded_firmware.data = _binary_dahdi_fw_oct6114_128_bin_start;
/* Yes... this is weird. objcopy gives us a symbol containing
@@ -3983,20 +3965,12 @@
if (!(wc->vpm450m = init_vpm450m(wc, laws, wc->numspans, firmware))) {
printk(KERN_NOTICE "VPM450: Failed to initialize\n");
if (firmware != &embedded_firmware)
-#if defined(__FreeBSD__)
- firmware_put(firmware, FIRMWARE_UNLOAD);
-#else
release_firmware(firmware);
-#endif
return;
}
if (firmware != &embedded_firmware)
-#if defined(__FreeBSD__)
- firmware_put(firmware, FIRMWARE_UNLOAD);
-#else
release_firmware(firmware);
-#endif
if (vpmdtmfsupport == -1) {
printk(KERN_NOTICE "VPM450: hardware DTMF disabled.\n");
Modified: freebsd/trunk/freebsd/dahdi/bsd-compat.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi/bsd-compat.c?view=diff&rev=8320&r1=8319&r2=8320
==============================================================================
--- freebsd/trunk/freebsd/dahdi/bsd-compat.c (original)
+++ freebsd/trunk/freebsd/dahdi/bsd-compat.c Wed Mar 10 09:47:14 2010
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/callout.h>
+#include <sys/firmware.h>
#include <sys/syscallsubr.h>
#include <sys/systm.h>
#include <sys/taskqueue.h>
@@ -175,11 +176,7 @@
mtx_lock(&c->lock);
res = cv_timedwait(&c->cv, &c->lock, timeout);
mtx_unlock(&c->lock);
- if (res == 0)
- return 1;
-
- /* Signal timeout */
- return 0;
+ return res == 0;
}
void
@@ -201,6 +198,12 @@
_sema_destroy(struct semaphore *s)
{
sema_destroy(&s->sema);
+}
+
+void
+down(struct semaphore *s)
+{
+ sema_wait(&s->sema);
}
int
@@ -210,6 +213,12 @@
return 0;
}
+int
+down_trylock(struct semaphore *s)
+{
+ return sema_trywait(&s->sema) == 0;
+}
+
void
up(struct semaphore *s)
{
@@ -236,6 +245,12 @@
cancel_work_sync(struct work_struct *work)
{
taskqueue_drain(taskqueue_fast, &work->task);
+}
+
+void
+flush_scheduled_work(void)
+{
+ taskqueue_run_fast(taskqueue_fast);
}
struct workqueue_struct *
@@ -273,7 +288,13 @@
void
queue_work(struct workqueue_struct *wq, struct work_struct *work)
{
- taskqueue_enqueue(wq->tq, &work->task);
+ taskqueue_enqueue_fast(wq->tq, &work->task);
+}
+
+void
+flush_workqueue(struct workqueue_struct *wq)
+{
+ taskqueue_run_fast(wq->tq);
}
/*
@@ -332,6 +353,22 @@
va_end(ap);
return kern_kldload(curthread, modname, &fileid);
+}
+
+/*
+ * Firmware API
+ */
+int
+request_firmware(const struct firmware **firmware_p, const char *name, device_t *device)
+{
+ *firmware_p = firmware_get(name);
+ return *firmware_p == NULL;
+}
+
+void
+release_firmware(const struct firmware *firmware)
+{
+ firmware_put(firmware, FIRMWARE_UNLOAD);
}
/*
Modified: freebsd/trunk/include/dahdi/compat/bsd.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/bsd.h?view=diff&rev=8320&r1=8319&r2=8320
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Wed Mar 10 09:47:14 2010
@@ -42,7 +42,24 @@
*/
typedef void *wait_queue_head_t;
#define init_waitqueue_head(q)
-#define wake_up_interruptible(q) wakeup(q)
+#define wake_up(q) wakeup_one(q)
+#define wake_up_interruptible(q) wakeup_one(q)
+#define wake_up_interruptible_all(q) wakeup(q)
+#define wait_event_timeout(q, condition, timeout) \
+({ \
+ int __ret = timeout; \
+ if (!(condition)) { \
+ for (;;) { \
+ if (tsleep(&q, 0, "wait_event", (timeout))) { \
+ __ret = 0; \
+ break; \
+ } \
+ if (condition) \
+ break; \
+ } \
+ } \
+ __ret; \
+})
/*
* Bit API
@@ -197,8 +214,13 @@
void _sema_init(struct semaphore *s, int value);
void _sema_destroy(struct semaphore *s);
+void down(struct semaphore *s);
int down_interruptible(struct semaphore *s);
+int down_trylock(struct semaphore *s);
void up(struct semaphore *s);
+
+#define init_MUTEX(s) _sema_init((s), 1)
+#define destroy_MUTEX(s) _sema_destroy(s)
/*
* Workqueue API
@@ -220,6 +242,7 @@
void work_run(void *context, int pending);
void schedule_work(struct work_struct *work);
void cancel_work_sync(struct work_struct *work);
+void flush_scheduled_work(void);
struct workqueue_struct {
struct taskqueue *tq;
@@ -228,6 +251,7 @@
struct workqueue_struct *create_singlethread_workqueue(const char *name);
void destroy_workqueue(struct workqueue_struct *wq);
void queue_work(struct workqueue_struct *wq, struct work_struct *work);
+void flush_workqueue(struct workqueue_struct *wq);
/*
* Logging and assertions API
@@ -304,6 +328,20 @@
#define EXPORT_SYMBOL(s)
+#define module_param(name, type, mode) module_param_##type(MODULE_PARAM_PREFIX "." #name, name)
+#define module_param_int(name, var) TUNABLE_INT((name), &(var))
+#define module_param_uint(name, var) TUNABLE_INT((name), &(var))
+#define module_param_charp(name, var) TUNABLE_STR((name), (var), sizeof(var))
+#define MODULE_PARM_DESC(name, desc)
+
+/*
+ * Firmware API
+ */
+struct firmware;
+
+int request_firmware(const struct firmware **firmware_p, const char *name, device_t *device);
+void release_firmware(const struct firmware *firmware);
+
/*
* PCI device API
*/
@@ -374,4 +412,6 @@
#define DAHDI_IRQ_HANDLER(a) static int a(void *dev_id)
+extern u_short fcstab[256];
+
#endif /* _DAHDI_COMPAT_BSD_H_ */
Modified: freebsd/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/kernel.h?view=diff&rev=8320&r1=8319&r2=8320
==============================================================================
--- freebsd/trunk/include/dahdi/kernel.h (original)
+++ freebsd/trunk/include/dahdi/kernel.h Wed Mar 10 09:47:14 2010
@@ -1067,6 +1067,9 @@
/*! \brief Unregister a span */
int dahdi_unregister(struct dahdi_span *span);
+
+/*! \brief Sleep in user space until woken up. Equivilant of tsleep() in BSD */
+int dahdi_schluffen(wait_queue_head_t *q);
/*! \brief Gives a name to an LBO */
char *dahdi_lboname(int lbo);
@@ -1233,10 +1236,12 @@
#define clamp(x, low, high) min (max (low, x), high)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
+#if !defined(__FreeBSD__)
/* Some distributions backported fatal_signal_pending so we'll use a macro to
* override the inline functino definition. */
#define fatal_signal_pending(p) \
(signal_pending((p)) && sigismember(&(p)->pending.signal, SIGKILL))
+#endif
#if !defined(__FreeBSD__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
static inline void list_replace(struct list_head *old, struct list_head *new)
More information about the svn-commits
mailing list