From e27f89b0b603029df0f9fe14d1ad86f5c344f0a3 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 15 Mar 2011 19:06:05 +0000 Subject: [PATCH] wctdm24xxp: Fix regression with LEDS on TDM410. r9720 disabled the LEDs on the front panel of the TDM410. This commit restores the behavior and clarify which part of the TDM410 eframes control the LED operation. (closes issue #18939) Signed-off-by: Shaun Ruffell git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9827 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wctdm24xxp/base.c | 25 +++++++++++++++++++------ drivers/dahdi/wctdm24xxp/wctdm24xxp.h | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index b1685a0..d0bb28a 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -898,12 +898,8 @@ static inline void wctdm_transmitprep(struct wctdm *wc, unsigned char *sframe) if (x < DAHDI_CHUNKSIZE - 1) { eframe[EFRAME_SIZE] = wc->ctlreg; eframe[EFRAME_SIZE + 1] = wc->txident++; - - if ((wc->desc->ports == 4) && ((wc->ctlreg & 0x10))) { - eframe[EFRAME_SIZE + 2] = 0; - for (y = 0; y < 4; y++) - eframe[EFRAME_SIZE + 2] |= (1 << y); - } + if (4 == wc->desc->ports) + eframe[EFRAME_SIZE + 2] = wc->tdm410leds; } eframe += (EFRAME_SIZE + EFRAME_GAP); } @@ -4510,6 +4506,21 @@ static inline void remove_sysfs_files(struct wctdm *wc) { return; } #endif /* CONFIG_VOICEBUS_SYSFS */ +static void wctdm_set_tdm410_leds(struct wctdm *wc) +{ + int i; + + if (4 != wc->desc->ports) + return; + + wc->tdm410leds = 0; /* all on by default */ + for (i = 0; i < wc->desc->ports; ++i) { + /* Turn off the LED for any module that isn't installed. */ + if (MOD_TYPE_NONE == wc->modtype[i]) + wc->tdm410leds |= (1 << i); + } +} + #ifdef USE_ASYNC_INIT struct async_data { struct pci_dev *pdev; @@ -4652,6 +4663,8 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* Now track down what modules are installed */ wctdm_identify_modules(wc); + wctdm_set_tdm410_leds(wc); + if (fatal_signal_pending(current)) { wctdm_back_out_gracefully(wc); return -EINTR; diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h index 90c4aaa..99d8159 100644 --- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h +++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h @@ -164,7 +164,8 @@ struct wctdm { unsigned char rxident; int flags[NUM_MODULES]; /* bitmap of board-specific + module-specific flags */ - unsigned char ctlreg; /* FIXME: something to do with VPM? */ + u8 ctlreg; + u8 tdm410leds; int mods_per_board; /* maximum number of modules for this board */ int digi_mods; /* number of digital modules present */