From 77ec2dce9f7267c2c33e5d56632ebe4322c40d7a Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Thu, 25 Aug 2011 18:28:53 +0000 Subject: [PATCH] wcte12xp: Abort driver bind if read/write test fails. When the driver begins to initialize a device it conducts a read/write test on one of the framer registers. The driver ignores the result of that test and results in much output spammed to the kernel logs for a failed card since the driver doesn't then try to unbind from the device. What was getting spammed: wcte12xp 0000:03:01.0: Timeout in t1_getreg wcte12xp 0000:03:01.0: Wrote '0' but read 'fffffffb' Now abort the bind if the read / write test fails. Signed-off-by: Shaun Ruffell Acked-by: Russ Meyerriecks git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10155 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wcte12xp/base.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 0d31350..aa9d019 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -1856,7 +1856,7 @@ static inline unsigned char t1_vpm_out(struct t1 *wc, int unit, const unsigned i static int t1_hardware_post_init(struct t1 *wc) { int res; - unsigned int reg; + int reg; int x; /* T1 or E1 */ @@ -1878,14 +1878,25 @@ static int t1_hardware_post_init(struct t1 *wc) /* what version of the FALC are we using? */ reg = t1_setreg(wc, 0x4a, 0xaa); reg = t1_getreg(wc, 0x4a); + if (reg < 0) { + t1_info(wc, "Failed to read FALC version (%d)\n", reg); + return -EIO; + } debug_printk(wc, 1, "FALC version: %08x\n", reg); /* make sure reads and writes work */ for (x = 0; x < 256; x++) { t1_setreg(wc, 0x14, x); reg = t1_getreg(wc, 0x14); - if (reg != x) - t1_info(wc, "Wrote '%x' but read '%x'\n", x, reg); + if (reg < 0) { + t1_info(wc, "Failed register read (%d)\n", reg); + return -EIO; + } + if (reg != x) { + t1_info(wc, "Register test failed. " + "Wrote '%x' but read '%x'\n", x, reg); + return -EIO; + } } t1_setleds(wc, wc->ledstate);