Compare commits

...

20 Commits

Author SHA1 Message Date
Shaun Ruffell
ae8a02168b build_tools/make_version: Strip off the leading 'v' in the version string.
Quote: "It's a change. People hate change"

Make the version string say something like 2.6.2 instead of v2.6.2.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit 9b0d19c054)
2013-03-08 11:39:53 -06:00
Shaun Ruffell
2a5638deef build_tools/make_version: If making from a tag show only the tag in the version.
Also, if there is no other version information use the directory name. Downloads
from gitweb will include the sha information in the build and otherwise a user
could locate the source directory via the embedded version information. I
believe this is better than an empty string.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit 37371f19e9)
2013-03-07 16:20:00 -06:00
Tzafrir Cohen
fcaec330e5 Redefine the removed __dev* for now
The __dev* directives and functions were removed in 3.8, as they
are no-ops. We still have use of them for older versions, thus
we should define them (as noops) if they don't exist.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-03-04 11:07:35 -06:00
Shaun Ruffell
41639330a5 wctdm24xxp: Eliminate chance for channel to be stuck in RED alarm.
There was a code patch where it was possible to get stuck in RED ALARM on a
channel when debouncing the battery states. The state transitions would look
like this:

BATTERY_PRESENT -> BATTERY_DEBOUNCING_LOST -> BATTERY_DEBOUNCING_LOST_ALARM --
(send alarm up to asterisk) --> BATTERY_LOST -> BATTERY_DEBOUNCING_PRESENT ->
BATTERY_DEBOUNCING_PRESENT_ALARM -> BATTERY_DEBOUNCING_LOST -> BATTERY_PRESENT

In the above sequence there was never any transition from
BATTERY_DEBOUNCING_PRESENT_ALARM to BATTERY_PRESENT so the alarm to Asterisk was
never cleared and the channel stayed stuck.

Now when you loose battery when in the BATTERY_DEBOUNCING_PRESENT_ALARM go all
the way back to the BATTERY_LOST state instead of the BATTERY_DEBOUNCING_LOST
state so that all the events are properly sent up.

This fixes a regression introduced in 2.6.0 with commit (r10169 "wctdm24xxp: Use
interval for debouncing FXO battery." 874b76bd22).

Internal-Issue-ID: DAHDI-1019
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit 8bf0434896)
2013-01-25 13:12:59 -06:00
Shaun Ruffell
e3931e5d5f wctdm24xxp: Use framecount and not jiffies when looking for battery present.
The logic to check for battery lost and battery present were using different
time bases. One was using jiffies and the other was using framecount. Since
framecount is always in milliseconds, let's use that to stay consistent.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit a6be603590)
2013-01-25 13:12:50 -06:00
Shaun Ruffell
33b4edf463 wcb4xxp: Allocate memory in hfc_decode_st_state() with GFP_ATOMIC.
hfc_decode_st_state() will be called from interrupt context when the debug flag
is set to 32. Therefore, must use GFP_ATOMIC when allocating memory.

Only affects the wcb4xxp driver when called with particular debug flags set.

Internal-Issue-ID: DAHLIN-314
Reported-by: Gerald Schnabel
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit 85e6cdde83)
2013-01-25 13:10:52 -06:00
Shaun Ruffell
46cfdca5d5 wct4xxp: t4_serial_setup() was called more often than necessary.
The driver iterates through all the spans on a given device during assignment,
checking for unassigned spans, but it was erroneously testing the span on which
assigned was called.

This just removes some unexpected behavior and provides a slight performance
increase on load and does not impact the functionality of the driver as far as
I'm aware.

Reported-by: Doug Bailey <dbailey@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
(cherry picked from commit 9de213b104)
2013-01-25 13:10:10 -06:00
Shaun Ruffell
42be50ca28 wct4xxp: EC channel calculation in TONEDETECT assumes TE820.
Since r10290 "wct4xxp: Add support for TE820 and VPMOCT256." [1],
the TONEDETECT ioctl was not calculating the VPM channel correctly
on non TE820 cards. This fixes a regression first introduced in
2.6.0.

[1] http://svnview.digium.com/svn/dahdi?view=revision&revision=10290

Internal-Issue-ID: DAHLIN-302
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10733 a0bf4364-ded3-4de4-8d8a-66a801d63aff
(cherry picked from commit abad4b4479)
2013-01-25 13:09:49 -06:00
Shaun Ruffell
f6511b1040 wctdm24xxp: Only two polarity reversals are needed to validate RING on FXO ports.
This fixes a regression introduced in commit r10186 "wctdm24xxp: Use time
interval for debouncing FXO ring detect." [1] which was first released in
DAHDI-Linux 2.6.0. This only affects users with analog trunks whose providers do
not present 4 polarity reversals on the ring signals. The reporter of this issue
is based in South Africa.

[1] http://svnview.digium.com/svn/dahdi?view=revision&revision=10168

In prior versions, the ring detector did not check for polarity reversals, only
the presence of ringing voltage unless fwringdetect or neonmwi_monitor mode was
set, and even when one of those modes were set, the driver only needed two
reversals to validate a ring. This commit allows the driver to always stay in
fwringdetect mode but restores the requirement for only two reversals.

Also included in this commit is a change to ensure that ringing is not reported
when debouncing lost battery which can happen when voltage is swinging through
0.

Reported-and-Tested-by: Jaco Kroon <jaco@uls.co.za>
Internal-Issue-ID: DAHLIN-298
Signed-off-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10719 a0bf4364-ded3-4de4-8d8a-66a801d63aff
(cherry picked from commit 84e70cdac5)
2013-01-25 13:09:32 -06:00
Shaun Ruffell
179a48862d xpp: Do not typedef bool on RHEL 5.2 or later.
Without digging into the specifics, it looks like Red Hat Linux 5.9
removed the hex_asc definition that was previously used to determine
if the bool definition was backported.

We can simply use the RHEL_RELEASE_CODE now since we do not support any
releases before the 5 series now.

Reported-By: Vladimir Mikhelson
Internal-Issue-ID: DAHLIN-312
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-By: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
(cherry picked from commit da0aa6f231)

Conflicts:
	drivers/dahdi/xpp/xdefs.h
2013-01-25 13:08:52 -06:00
Tzafrir Cohen
f9632cdeb3 gitignore: Add README.html to git ignore list
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
(cherry picked from commit a8dfd61e53)
2013-01-25 13:07:15 -06:00
Tzafrir Cohen
161698087d Add .gitignore file
Allows 'git status' command to better show untracked files which one may be
interested in.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
(cherry picked from commit d889fb39d3)
2013-01-25 13:06:39 -06:00
Tzafrir Cohen
6262abb53c xpp: pre/post_unregister: not for the EC
Don't run the pre- and post-unregister hooks on a non-phone XPD
(practically: the echo canceller). This fixes a panic with manual
'dahdi_registertion off' as it is now called for the whole device
(regression of 2.6.x).

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10735

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10736 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-11-15 15:15:48 +00:00
Shaun Ruffell
7ad722e684 dahdi: pci-aspm.h was included in 2.6.26 not 2.6.25.
When compiling against kernels 2.6.25, you could get the following error.

  error: linux/pci-aspm.h: No such file or directory

This fixes a build regression introduced in r10556 "dahdi: Add
dahdi_pci_disable_link_state for kernel < 2.6.25." [1]

[1] http://svnview.digium.com/svn/dahdi?view=revision&revision=10556

Reported-by: Jean-Philippe Lord
Internal-Issue-ID: DAHLIN-299
Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10705

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10708 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-08-16 21:39:01 +00:00
Shaun Ruffell
3a3684a38e wcte12xp: Fix stack corruption when checking T1 RBS states.
This fixes an (embarrassing) error in t1_check_sigbits in the previous commit
where I was writing pass the end of an array on the stack.

Now instead of using an array on the stack, of which all elements were not used,
the pending commands are now stored on a list. I also removed the automatic free
of commands from __t1_getresults and now the function that allocated the command
now frees them.

I believe this will be less error-prone going forward.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10700

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10707 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-08-16 21:38:57 +00:00
Shaun Ruffell
8db0c61fd8 wcte12xp: Fix pulse digit detection when set for FXO signalling modes.
The frequency that the RBS registers were polled was too slow to catch the pulse
dialing digits. The result was that often times dahdi would generate WINK events
instead of PULSEDIGIT events.

This speeds up the rate at which the registers are checked from 100ms to 33ms
and also makes the process of checking the registers quicker by queing up all
the reads at once.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10699

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10706 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-08-16 21:38:52 +00:00
Shaun Ruffell
319d51ae5d wcte12xp: Allow default_linemode to be set to j1.
To enable J1 mode previously one would configure the card in T1 mode and then
set the j1mode module parameter. Now "modprobe wcte12xp default_linemode=j1"
will work like the other linemodes globally for all cards manged by this driver.
J1 can also be set on a card-by-card basis in sysfs.

Also move pr_fmt to top of file so pr_xxx macros print the module name as
intended.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10696

Conflicts:
	drivers/dahdi/wcte12xp/base.c

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10698 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-06-23 04:36:12 +00:00
Shaun Ruffell
83090b71cf wcte12xp: Destroy the cache if the linemode is not recognized.
Fixes the following errors when running:
  # modprobe wcte12xp default_linemode=blah; modprobe wcte12xp default_linemode=blah

'blah' is an unknown span type.kmem_cache_create: duplicate cache wcte12xp

Call Trace:
 [<ffffffff800394cf>] kmem_cache_create+0x572/0x5ac
 [<ffffffff800a926e>] __link_module+0x0/0x18
 [<ffffffff80064624>] __down_read+0x12/0x92
 [<ffffffff8002224d>] __up_read+0x19/0x7f
 [<ffffffff8818b01f>] :wcte12xp:te12xp_init+0x1f/0xde
 [<ffffffff800a9e37>] sys_init_module+0xbd/0x206
 [<ffffffff8005d28d>] tracesys+0xd5/0xe0

Reported-by: James Brown <jbrown@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10695

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10697 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-06-23 04:36:08 +00:00
Oron Peled
c0eebd73bb xpp: usermode_helper() bugfix for kernels >= 3.3.0
* UMH_WAIT_PROC semantics (and value) was changed from enum to
  a bitmask (via #define)
* This constant was missing from kernels older than 2.6.23

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10694 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-06-21 17:53:33 +00:00
Doug Bailey
9aa57f62f1 Assign NULL values to pointers to insure that future kfree calls do not cause errors.
From: Doug Bailey <dbailey@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10678

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10679 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-04-27 20:12:09 +00:00
12 changed files with 305 additions and 85 deletions

41
.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# Files that are generated as part of the build process which we do not want git
# to track.
*.[oa]
*.mod
*.mod.[oc]
*.ko
*.cmd
*.order
*.tar.gz
tags
cscope.*
*.symvers
*.markers
.*.o.d
README.html
modules.order
Module.markers
build_tools/checkpatch.pl
drivers/dahdi/xpp/*.verified
drivers/dahdi/.tmp_versions/
drivers/dahdi/Module.symvers
drivers/dahdi/makefw
drivers/dahdi/radfw.h
drivers/dahdi/tor2fw.h
drivers/dahdi/xpp/init_fxo_modes
drivers/dahdi/xpp/print_fxo_modes
drivers/dahdi/xpp/xpp_version.h
include/dahdi/version.h
drivers/dahdi/vpmadt032_loader/vpmadt032_loader.h
drivers/dahdi/vpmadt032_loader/vpmadt032_x86_32.o_shipped
drivers/dahdi/vpmadt032_loader/vpmadt032_x86_64.o_shipped
drivers/dahdi/firmware/dahdi-fw-hx8.bin
drivers/dahdi/firmware/dahdi-fw-oct6114-064.bin
drivers/dahdi/firmware/dahdi-fw-oct6114-128.bin
drivers/dahdi/firmware/dahdi-fw-oct6114-256.bin
drivers/dahdi/firmware/dahdi-fw-tc400m.bin
drivers/dahdi/firmware/dahdi-fw-te820.bin
drivers/dahdi/firmware/dahdi-fw-vpmoct032.bin
drivers/dahdi/firmware/make_firmware_object

View File

@@ -67,13 +67,7 @@ GENERATED_DOCS:=README.html
ifneq ($(wildcard .version),)
DAHDIVERSION:=$(shell cat .version)
else
ifneq ($(wildcard .svn),)
DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
else
ifneq ($(wildcard .git),)
DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
endif
endif
endif
all: modules

View File

@@ -59,7 +59,7 @@ elif [ -d ${1}/.git ]; then
MODIFIED=""
SVN_REV=`git log --pretty=full -1 | grep -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
if [ -z "$SVN_REV" ]; then
VERSION=`git describe --long --always --tags --dirty=M 2> /dev/null`
VERSION=`git describe --tags --dirty=M 2> /dev/null | sed -e "s/^v//"`
if [ $? -ne 0 ]; then
if [ "`git ls-files -m | wc -l`" != "0" ]; then
MODIFIED="M"
@@ -115,4 +115,8 @@ elif [ -d ${1}/.git ]; then
echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED}
fi
else
# Use the directory information in the absence of any other version
# information
pwd -P
fi

View File

@@ -1249,7 +1249,8 @@ static char *hfc_decode_st_state(struct b4xxp *b4, int port, unsigned char state
"?", "?", "?", "?", "?", "?", "?", "?" }
};
if (!(str = kmalloc(256, GFP_KERNEL))) {
str = kmalloc(256, GFP_ATOMIC);
if (!str) {
dev_warn(&b4->pdev->dev, "could not allocate mem for ST state decode string!\n");
return NULL;
}

View File

@@ -1239,9 +1239,11 @@ static int t4_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long dat
else
clear_bit(chan->chanpos - 1, &ts->dtmfmutemask);
channel = (chan->chanpos) << 3;
if (!has_e1_span(wc))
channel += (4 << 3);
channel = has_e1_span(wc) ? chan->chanpos : chan->chanpos + 4;
if (is_octal(wc))
channel = channel << 3;
else
channel = channel << 2;
channel |= chan->span->offset;
vpm450m_setdtmf(wc->vpm, channel, j & DAHDI_TONEDETECT_ON,
j & DAHDI_TONEDETECT_MUTE);
@@ -2037,7 +2039,7 @@ static void t4_span_assigned(struct dahdi_span *span)
/* We use this to make sure all the spans are assigned before
* running the serial setup. */
list_for_each_entry(pos, &wc->ddev->spans, device_node) {
if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags))
if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &pos->flags))
++unassigned_spans;
}
@@ -2093,6 +2095,8 @@ static int t4_alloc_channels(struct t4 *wc, struct t4_span *ts,
for (i = 0; i < ARRAY_SIZE(ts->chans); ++i) {
kfree(ts->chans[i]);
kfree(ts->ec[i]);
ts->chans[i] = NULL;
ts->ec[i] = NULL;
}
ts->linemode = linemode;

View File

@@ -1833,19 +1833,22 @@ static void wctdm_qrvdri_check_hook(struct wctdm *wc, int card)
static inline bool is_fxo_ringing(const struct fxo *const fxo)
{
return ((fxo->hook_ring_shadow & 0x60) &&
(fxo->battery_state == BATTERY_PRESENT));
((fxo->battery_state == BATTERY_PRESENT) ||
(fxo->battery_state == BATTERY_DEBOUNCING_LOST)));
}
static inline bool is_fxo_ringing_positive(const struct fxo *const fxo)
{
return (((fxo->hook_ring_shadow & 0x60) == 0x20) &&
(fxo->battery_state == BATTERY_PRESENT));
((fxo->battery_state == BATTERY_PRESENT) ||
(fxo->battery_state == BATTERY_DEBOUNCING_LOST)));
}
static inline bool is_fxo_ringing_negative(const struct fxo *const fxo)
{
return (((fxo->hook_ring_shadow & 0x60) == 0x40) &&
(fxo->battery_state == BATTERY_PRESENT));
((fxo->battery_state == BATTERY_PRESENT) ||
(fxo->battery_state == BATTERY_DEBOUNCING_LOST)));
}
static inline void set_ring(struct fxo *fxo, enum ring_detector_state new)
@@ -1856,19 +1859,21 @@ static inline void set_ring(struct fxo *fxo, enum ring_detector_state new)
static void wctdm_fxo_ring_detect(struct wctdm *wc, struct wctdm_module *mod)
{
struct fxo *const fxo = &mod->mod.fxo;
static const unsigned int POLARITY_CHANGES_NEEDED = 2;
/* Look for ring status bits (Ring Detect Signal Negative and Ring
* Detect Signal Positive) to transition back and forth some number of
* times to indicate that a ring is occurring. Provide some number of
* samples to allow for the transitions to occur before giving up.
* NOTE: neon mwi voltages will trigger one of these bits to go active
* but not to have transitions between the two bits (i.e. no negative
* to positive or positive to negative traversals) */
* Detect Signal Positive) to transition back and forth
* POLARITY_CHANGES_NEEDED times to indicate that a ring is occurring.
* Provide some number of samples to allow for the transitions to occur
* before giving up. NOTE: neon mwi voltages will trigger one of these
* bits to go active but not to have transitions between the two bits
* (i.e. no negative to positive or positive to negative traversals) */
switch (fxo->ring_state) {
case DEBOUNCING_RINGING_POSITIVE:
if (is_fxo_ringing_negative(fxo)) {
if (++fxo->ring_polarity_change_count > 4) {
if (++fxo->ring_polarity_change_count >
POLARITY_CHANGES_NEEDED) {
mod_hooksig(wc, mod, DAHDI_RXSIG_RING);
set_ring(fxo, RINGING);
if (debug) {
@@ -1886,7 +1891,8 @@ static void wctdm_fxo_ring_detect(struct wctdm *wc, struct wctdm_module *mod)
break;
case DEBOUNCING_RINGING_NEGATIVE:
if (is_fxo_ringing_positive(fxo)) {
if (++fxo->ring_polarity_change_count > 4) {
if (++fxo->ring_polarity_change_count >
POLARITY_CHANGES_NEEDED) {
mod_hooksig(wc, mod, DAHDI_RXSIG_RING);
set_ring(fxo, RINGING);
if (debug) {
@@ -1956,13 +1962,13 @@ wctdm_check_battery_lost(struct wctdm *wc, struct wctdm_module *const mod)
*/
switch (fxo->battery_state) {
case BATTERY_DEBOUNCING_PRESENT:
case BATTERY_DEBOUNCING_PRESENT_ALARM: /* intentional drop through */
/* we were going to BATTERY_PRESENT, but
* battery was lost again. */
fxo->battery_state = BATTERY_LOST;
break;
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_ONHOOK);
case BATTERY_DEBOUNCING_PRESENT_ALARM: /* intentional drop through */
case BATTERY_PRESENT:
fxo->battery_state = BATTERY_DEBOUNCING_LOST;
fxo->battdebounce_timer = wc->framecount + battdebounce;
@@ -2017,7 +2023,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod)
switch (fxo->battery_state) {
case BATTERY_DEBOUNCING_PRESENT:
if (time_after(jiffies, fxo->battdebounce_timer)) {
if (time_after(wc->framecount, fxo->battdebounce_timer)) {
if (debug) {
dev_info(&wc->vb.pdev->dev,
"BATTERY on %d/%d (%s)!\n",
@@ -2042,12 +2048,12 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod)
* of its time period has already passed while
* debouncing occurred */
fxo->battery_state = BATTERY_DEBOUNCING_PRESENT_ALARM;
fxo->battdebounce_timer = jiffies +
msecs_to_jiffies(battalarm - battdebounce);
fxo->battdebounce_timer = wc->framecount +
battalarm - battdebounce;
}
break;
case BATTERY_DEBOUNCING_PRESENT_ALARM:
if (time_after(jiffies, fxo->battdebounce_timer)) {
if (time_after(wc->framecount, fxo->battdebounce_timer)) {
fxo->battery_state = BATTERY_PRESENT;
dahdi_alarm_channel(get_dahdi_chan(wc, mod),
DAHDI_ALARM_NONE);
@@ -2056,6 +2062,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod)
case BATTERY_PRESENT:
break;
case BATTERY_DEBOUNCING_LOST:
case BATTERY_DEBOUNCING_LOST_ALARM:
/* we were going to BATTERY_LOST, but battery appeared again,
* so clear the debounce timer */
fxo->battery_state = BATTERY_PRESENT;
@@ -2063,10 +2070,8 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod)
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_OFFHOOK);
case BATTERY_LOST: /* intentional drop through */
case BATTERY_DEBOUNCING_LOST_ALARM:
fxo->battery_state = BATTERY_DEBOUNCING_PRESENT;
fxo->battdebounce_timer = jiffies +
msecs_to_jiffies(battdebounce);
fxo->battdebounce_timer = wc->framecount + battdebounce;
break;
}
}

View File

@@ -27,6 +27,8 @@
* this program for more details.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
@@ -55,18 +57,14 @@
#error VOICEBUS_SFRAME_SIZE != SFRAME_SIZE
#endif
#ifndef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif
static int debug;
static int j1mode = 0;
static int j1mode = -1;
static int alarmdebounce = 2500; /* LOF/LFA def to 2.5s AT&T TR54016*/
static int losalarmdebounce = 2500; /* LOS def to 2.5s AT&T TR54016*/
static int aisalarmdebounce = 2500; /* AIS(blue) def to 2.5s AT&T TR54016*/
static int yelalarmdebounce = 500; /* RAI(yellow) def to 0.5s AT&T devguide */
static int t1e1override = -1; /* deprecated */
static char *default_linemode = "auto"; /* 'auto', 'e1', or 't1' */
static char *default_linemode = "auto"; /* 'auto', 'e1', 't1', or 'j1' */
static int latency = VOICEBUS_DEFAULT_LATENCY;
static unsigned int max_latency = VOICEBUS_DEFAULT_MAXLATENCY;
static int vpmsupport = 1;
@@ -645,21 +643,21 @@ static inline int t1_setreg(struct t1 *wc, int addr, int val)
return 0;
}
static int t1_getreg(struct t1 *wc, int addr)
static void __t1_getreg(struct t1 *wc, int addr, struct command *cmd)
{
struct command *cmd = NULL;
unsigned long ret;
unsigned long flags;
might_sleep();
cmd = get_free_cmd(wc);
if (!cmd)
return -ENOMEM;
cmd->address = addr;
cmd->data = 0x00;
cmd->flags = __CMD_RD;
submit_cmd(wc, cmd);
}
static int __t1_getresult(struct t1 *wc, struct command *cmd)
{
int ret;
unsigned long flags;
might_sleep();
ret = wait_for_completion_interruptible_timeout(&cmd->complete, HZ*10);
if (unlikely(!ret)) {
spin_lock_irqsave(&wc->reglock, flags);
@@ -690,10 +688,22 @@ static int t1_getreg(struct t1 *wc, int addr)
}
}
ret = cmd->data;
free_cmd(wc, cmd);
return ret;
}
static int t1_getreg(struct t1 *wc, int addr)
{
int res;
struct command *cmd = NULL;
cmd = get_free_cmd(wc);
if (!cmd)
return -ENOMEM;
__t1_getreg(wc, addr, cmd);
res = __t1_getresult(wc, cmd);
free_cmd(wc, cmd);
return res;
}
static void t1_setleds(struct t1 *wc, int leds)
{
struct command *cmd;
@@ -883,7 +893,8 @@ static void t1_configure_t1(struct t1 *wc, int lineconfig, int txlevel)
fmr1 = 0x9e; /* FMR1: Mode 0, T1 mode, CRC on for ESF, 2.048 Mhz system data rate, no XAIS */
fmr2 = 0x20; /* FMR2: no payload loopback, don't auto yellow alarm */
if (j1mode)
if (!strcasecmp("j1", wc->span.spantype))
fmr4 = 0x1c;
else
fmr4 = 0x0c; /* FMR4: Lose sync on 2 out of 5 framing bits, auto resync */
@@ -923,7 +934,7 @@ static void t1_configure_t1(struct t1 *wc, int lineconfig, int txlevel)
t1_setreg(wc, 0x38, 0x0a); /* PCD: LOS after 176 consecutive "zeros" */
t1_setreg(wc, 0x39, 0x15); /* PCR: 22 "ones" clear LOS */
if (j1mode)
if (!strcasecmp("j1", wc->span.spantype))
t1_setreg(wc, 0x24, 0x80); /* J1 overide */
/* Generate pulse mask for T1 */
@@ -1184,15 +1195,47 @@ static int t1xxp_rbsbits(struct dahdi_chan *chan, int bits)
return 0;
}
static inline void t1_check_sigbits(struct t1 *wc)
static void t1_check_sigbits(struct t1 *wc)
{
struct command_container {
struct command *cmd;
struct list_head node;
unsigned int index;
};
struct command_container *cont;
LIST_HEAD(commands);
int a,i,rxs;
if (!(test_bit(DAHDI_FLAGBIT_RUNNING, &wc->span.flags)))
return;
if (dahdi_is_e1_span(&wc->span)) {
/* Send out all the commands first. */
for (i = 0; i < 15; i++) {
a = t1_getreg(wc, 0x71 + i);
if (!(wc->span.chans[i+16]->sig & DAHDI_SIG_CLEAR) ||
!(wc->span.chans[i]->sig & DAHDI_SIG_CLEAR)) {
cont = kzalloc(sizeof(*cont), GFP_KERNEL);
if (!cont) {
WARN_ON_ONCE(1);
goto done;
}
cont->cmd = get_free_cmd(wc);
if (!cont->cmd) {
WARN_ON_ONCE(1);
goto done;
}
cont->index = i;
list_add_tail(&cont->node, &commands);
__t1_getreg(wc, 0x71 + i, cont->cmd);
}
}
/* Now check the results */
list_for_each_entry_reverse(cont, &commands, node) {
i = cont->index;
a = __t1_getresult(wc, cont->cmd);
free_cmd(wc, cont->cmd);
cont->cmd = NULL;
if (a > -1) {
/* Get high channel in low bits */
rxs = (a & 0xf);
@@ -1210,8 +1253,29 @@ static inline void t1_check_sigbits(struct t1 *wc)
}
}
} else if (wc->span.lineconfig & DAHDI_CONFIG_D4) {
for (i = 0; i < 24; i+=4) {
a = t1_getreg(wc, 0x70 + (i>>2));
/* First we'll send out the commands */
for (i = 0; i < 24; i += 4) {
cont = kzalloc(sizeof(*cont), GFP_KERNEL);
if (!cont) {
WARN_ON_ONCE(1);
goto done;
}
cont->cmd = get_free_cmd(wc);
if (!cont->cmd) {
WARN_ON_ONCE(1);
goto done;
}
cont->index = i;
list_add_tail(&cont->node, &commands);
__t1_getreg(wc, 0x70 + (i>>2), cont->cmd);
}
/* Now we'll check the results */
list_for_each_entry_reverse(cont, &commands, node) {
i = cont->index;
a = __t1_getresult(wc, cont->cmd);
free_cmd(wc, cont->cmd);
cont->cmd = NULL;
if (a > -1) {
/* Get high channel in low bits */
rxs = (a & 0x3) << 2;
@@ -1241,8 +1305,28 @@ static inline void t1_check_sigbits(struct t1 *wc)
}
}
} else {
for (i = 0; i < 24; i+=2) {
a = t1_getreg(wc, 0x70 + (i>>1));
/* First send out the commands. */
for (i = 0; i < 24; i += 2) {
cont = kzalloc(sizeof(*cont), GFP_KERNEL);
if (!cont) {
WARN_ON_ONCE(1);
goto done;
}
cont->cmd = get_free_cmd(wc);
if (!cont->cmd) {
WARN_ON_ONCE(1);
goto done;
}
cont->index = i;
list_add_tail(&cont->node, &commands);
__t1_getreg(wc, 0x70 + (i>>1), cont->cmd);
}
list_for_each_entry_reverse(cont, &commands, node) {
i = cont->index;
a = __t1_getresult(wc, cont->cmd);
free_cmd(wc, cont->cmd);
cont->cmd = NULL;
if (a > -1) {
/* Get high channel in low bits */
rxs = (a & 0xf);
@@ -1260,6 +1344,21 @@ static inline void t1_check_sigbits(struct t1 *wc)
}
}
}
done:
while (!list_empty(&commands)) {
cont = container_of(commands.next,
struct command_container, node);
if (unlikely(cont->cmd)) {
/* We do not care about the result, let's just wait for
* the rest of the system to finish with it. */
__t1_getresult(wc, cont->cmd);
free_cmd(wc, cont->cmd);
cont->cmd = NULL;
}
list_del(&cont->node);
kfree(cont);
}
return;
}
struct maint_work_struct {
@@ -1846,18 +1945,32 @@ static int t1_software_init(struct t1 *wc, enum linemode type)
memset(chans, 0, sizeof(chans));
memset(ec, 0, sizeof(ec));
if (type == E1) {
switch (type) {
case E1:
wc->span.channels = 31;
wc->span.spantype = "E1";
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_HDB3 |
DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
wc->span.deflaw = DAHDI_LAW_ALAW;
} else {
break;
case T1:
wc->span.channels = 24;
wc->span.spantype = "T1";
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS |
DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
wc->span.deflaw = DAHDI_LAW_MULAW;
break;
case J1:
wc->span.channels = 24;
wc->span.spantype = "J1";
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS |
DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
wc->span.deflaw = DAHDI_LAW_MULAW;
break;
default:
spin_unlock_irqrestore(&wc->reglock, flags);
res = -EINVAL;
goto error_exit;
}
spin_unlock_irqrestore(&wc->reglock, flags);
@@ -1866,7 +1979,7 @@ static int t1_software_init(struct t1 *wc, enum linemode type)
return -ENOMEM;
t1_info(wc, "Setting up global serial parameters for %s\n",
(dahdi_is_e1_span(&wc->span) ? "E1" : "T1"));
wc->span.spantype);
t4_serial_setup(wc);
set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags);
@@ -1922,12 +2035,19 @@ static int t1xxp_set_linemode(struct dahdi_span *span, const char *linemode)
if (!strcasecmp(linemode, "t1")) {
dev_info(&wc->vb.pdev->dev,
"Changing from E1 to T1 line mode.\n");
"Changing from %s to T1 line mode.\n",
wc->span.spantype);
res = t1_software_init(wc, T1);
} else if (!strcasecmp(linemode, "e1")) {
dev_info(&wc->vb.pdev->dev,
"Changing from T1 to E1 line mode.\n");
"Changing from %s to E1 line mode.\n",
wc->span.spantype);
res = t1_software_init(wc, E1);
} else if (!strcasecmp(linemode, "j1")) {
dev_info(&wc->vb.pdev->dev,
"Changing from %s to E1 line mode.\n",
wc->span.spantype);
res = t1_software_init(wc, J1);
} else {
dev_err(&wc->vb.pdev->dev,
"'%s' is an unknown linemode.\n", linemode);
@@ -1967,14 +2087,15 @@ static int t1_hardware_post_init(struct t1 *wc, enum linemode *type)
int x;
/* T1 or E1 */
if (-1 != t1e1override) {
pr_info("t1e1override is deprecated. Please use 'default_linemode'.\n");
*type = (t1e1override) ? E1 : T1;
if ((-1 != t1e1override) || (-1 != j1mode)) {
*type = (t1e1override) ? E1 : (j1mode) ? J1 : T1;
} else {
if (!strcasecmp(default_linemode, "e1")) {
*type = E1;
} else if (!strcasecmp(default_linemode, "t1")) {
*type = T1;
} else if (!strcasecmp(default_linemode, "j1")) {
*type = J1;
} else {
u8 pins;
res = t1_getpins(wc, &pins);
@@ -1983,7 +2104,8 @@ static int t1_hardware_post_init(struct t1 *wc, enum linemode *type)
*type = (pins & 0x01) ? T1 : E1;
}
}
debug_printk(wc, 1, "linemode: %s\n", (*type == T1) ? "T1" : "E1");
debug_printk(wc, 1, "linemode: %s\n", (*type == T1) ? "T1" :
(J1 == *type) ? "J1" : "E1");
/* what version of the FALC are we using? */
reg = t1_setreg(wc, 0x4a, 0xaa);
@@ -2014,19 +2136,41 @@ static int t1_hardware_post_init(struct t1 *wc, enum linemode *type)
return 0;
}
static inline void t1_check_alarms(struct t1 *wc)
static void t1_check_alarms(struct t1 *wc)
{
unsigned char c,d;
int alarms;
int x,j;
unsigned char fmr4; /* must read this always */
struct command *cmds[3];
if (!(test_bit(DAHDI_FLAGBIT_RUNNING, &wc->span.flags)))
return;
c = t1_getreg(wc, 0x4c);
fmr4 = t1_getreg(wc, 0x20); /* must read this even if we don't use it */
d = t1_getreg(wc, 0x4d);
for (x = 0; x < ARRAY_SIZE(cmds); ++x) {
cmds[x] = get_free_cmd(wc);
if (!cmds[x]) {
WARN_ON(1);
for (x = 0; x < ARRAY_SIZE(cmds); ++x)
free_cmd(wc, cmds[x]);
return;
}
}
/* Since this is voicebus, if we issue all the reads initially and then
* check the results we can save ourselves some time. Otherwise, each
* read will take a minimum of 3ms to go through the complete pipeline.
*/
__t1_getreg(wc, 0x4c, cmds[0]);
__t1_getreg(wc, 0x20, cmds[1]); /* must read this even if not used */
__t1_getreg(wc, 0x4d, cmds[2]);
d = __t1_getresult(wc, cmds[2]);
fmr4 = __t1_getresult(wc, cmds[1]);
c = __t1_getresult(wc, cmds[0]);
for (x=0; x < ARRAY_SIZE(cmds); ++x)
free_cmd(wc, cmds[x]);
/* Assume no alarms */
alarms = 0;
@@ -2442,11 +2586,11 @@ static void timer_work_func(struct work_struct *work)
{
struct t1 *wc = container_of(work, struct t1, timer_work);
#endif
if (test_bit(INITIALIZED, &wc->bit_flags))
mod_timer(&wc->timer, jiffies + HZ/30);
t1_do_counters(wc);
t1_check_alarms(wc);
t1_check_sigbits(wc);
if (test_bit(INITIALIZED, &wc->bit_flags))
mod_timer(&wc->timer, jiffies + HZ/10);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
@@ -2932,14 +3076,20 @@ static int __init te12xp_init(void)
if (!cmd_cache)
return -ENOMEM;
if (-1 != t1e1override) {
pr_info("'t1e1override' is deprecated. "
"Please use 'default_linemode' instead\n");
if ((-1 != t1e1override) || (-1 != j1mode)) {
pr_info("'t1e1override' and 'j1mode' are deprecated. "
"Please use 'default_linemode' instead.\n");
/* If someone is setting j1mode, then, t1e1override most likely
* needs to be forced to t1 mode */
if (j1mode > 0)
t1e1override = 0;
} else if (strcasecmp(default_linemode, "auto") &&
strcasecmp(default_linemode, "t1") &&
strcasecmp(default_linemode, "j1") &&
strcasecmp(default_linemode, "e1")) {
pr_err("'%s' is an unknown span type.", default_linemode);
pr_err("'%s' is an unknown span type.\n", default_linemode);
default_linemode = "auto";
kmem_cache_destroy(cmd_cache);
return -EINVAL;
}
res = dahdi_pci_module(&te12xp_driver);

View File

@@ -77,6 +77,7 @@
enum linemode {
T1 = 1,
E1,
J1,
};
struct command {

View File

@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/kmod.h>
#include "xdefs.h"
#include "xpd.h"
#include "xpp_dahdi.h"
@@ -655,6 +656,15 @@ static void global_packet_dump(const char *msg, xpacket_t *pack)
#define MAX_PATH_STR 128
#ifndef UMH_WAIT_PROC
/*
* - UMH_WAIT_PROC was introduced as enum in 2.6.23
* with a value of 1
* - It was changed to a macro (and it's value was modified) in 3.3.0
*/
#define UMH_WAIT_PROC 1
#endif
int run_initialize_registers(xpd_t *xpd)
{
int ret;
@@ -737,7 +747,7 @@ int run_initialize_registers(xpd_t *xpd)
}
XPD_DBG(DEVICES, xpd, "running '%s' for type=%d revision=%d\n",
init_card, xpd->type, xbus->revision);
ret = call_usermodehelper(init_card, argv, envp, 1);
ret = call_usermodehelper(init_card, argv, envp, UMH_WAIT_PROC);
/*
* Carefully report results
*/

View File

@@ -144,12 +144,14 @@ typedef unsigned char byte;
#define SET_PROC_DIRENTRY_OWNER(p) do { } while(0);
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
/* Also don't define this for later RHEL >= 5.2 . hex_asc is from the
* same linux-2.6-net-infrastructure-updates-to-mac80211-iwl4965.patch
* as is the bool typedef. */
#if LINUX_VERSION_CODE != KERNEL_VERSION(2,6,18) || ! defined(hex_asc)
typedef int bool;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
/* Also don't define this for later RHEL >= 5.2. */
#if defined(RHEL_RELEASE_CODE) && defined(RHEL_RELEASE_VERSION)
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5, 3)
typedef int bool;
#endif
#else
typedef int bool;
#endif
#endif
#else

View File

@@ -1083,7 +1083,7 @@ int xpd_dahdi_postregister(xpd_t *xpd)
*/
void xpd_dahdi_preunregister(xpd_t *xpd)
{
if (!xpd)
if (!xpd || !IS_PHONEDEV(xpd))
return;
XPD_DBG(DEVICES, xpd, "\n");
update_xpd_status(xpd, DAHDI_ALARM_NOTOPEN);
@@ -1103,7 +1103,7 @@ void xpd_dahdi_preunregister(xpd_t *xpd)
void xpd_dahdi_postunregister(xpd_t *xpd)
{
if (!xpd)
if (!xpd || !IS_PHONEDEV(xpd))
return;
atomic_dec(&PHONEDEV(xpd).dahdi_registered);
atomic_dec(&num_registered_spans);

View File

@@ -72,7 +72,7 @@
#define DAHDI_IRQ_HANDLER(a) static irqreturn_t a(int irq, void *dev_id, struct pt_regs *regs)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
#ifdef CONFIG_PCI
#include <linux/pci-aspm.h>
#endif
@@ -120,6 +120,14 @@
# endif
#endif
/* __dev* were removed in 3.8. They still have effect in 2.6.18. */
#ifndef __devinit
# define __devinit
# define __devinitdata
# define __devexit
# define __devexit_p(x) x
#endif
/*! Default chunk size for conferences and such -- static right now, might make
variable sometime. 8 samples = 1 ms = most frequent service interval possible
for a USB device */