[dahdi-commits] tzafrir: linux/trunk r10328 - in /linux/trunk: drivers/dahdi/ include/dahdi/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Nov 7 11:49:01 CST 2011
Author: tzafrir
Date: Mon Nov 7 11:48:00 2011
New Revision: 10328
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10328
Log:
Extra debugging aids and messages
* Added dahdi_dev_dbg() macro to print when we don't (yet)
have a span number.
* Added a new debug category: DAHDI_DBG_ASSIGN
* Made sure error return code paths prints helpfull messages
* Promote error messages from INFO to NOTICE
* Change some errno values from EINVAL to EFAULT (internal
errors not caused by user input)
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Acked-by: Shaun Ruffell <sruffell at digium.com>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
linux/trunk/drivers/dahdi/dahdi-sysfs.c
linux/trunk/include/dahdi/kernel.h
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=10328&r1=10327&r2=10328
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Nov 7 11:48:00 2011
@@ -6647,6 +6647,9 @@
set_spanno_and_basechan(struct dahdi_span *span, u32 spanno, u32 basechan)
{
int i;
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "set: spanno=%d, basechan=%d (span->channels=%d)\n",
+ spanno, basechan, span->channels);
span->spanno = spanno;
for (i = 0; i < span->channels; ++i)
span->chans[i]->channo = basechan + i;
@@ -6668,6 +6671,8 @@
unsigned int spanno = 1;
unsigned int basechan = 1;
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "assign: channels=%d\n", span->channels);
list_for_each_entry(pos, &span_list, spans_node) {
if (pos->spanno <= spanno) {
@@ -6686,6 +6691,9 @@
basechan = pos->chans[0]->channo + pos->channels;
}
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "good: spanno=%d, basechan=%d (span->channels=%d)\n",
+ spanno, basechan, span->channels);
set_spanno_and_basechan(span, spanno, basechan);
return 0;
}
@@ -6733,14 +6741,20 @@
struct dahdi_span *pos;
unsigned int next_channo;
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "check: spanno=%d, basechan=%d (span->channels=%d)\n",
+ spanno, basechan, span->channels);
list_for_each_entry(pos, &span_list, spans_node) {
next_channo = _get_next_channo(pos);
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "pos: spanno=%d channels=%d (next_channo=%d)\n",
+ pos->spanno, pos->channels, next_channo);
if (pos->spanno <= spanno) {
if (basechan < next_channo + pos->channels) {
/* Requested basechan breaks channel sorting */
- dev_info(span->parent->dev.parent,
+ dev_notice(span->parent->dev.parent,
"[%d] basechan (%d) is too low for wanted span %d\n",
local_spanno(span), basechan, spanno);
return -EINVAL;
@@ -6755,9 +6769,15 @@
break;
/* Cannot fit the span into the requested location. Abort. */
+ dev_notice(span->parent->dev.parent,
+ "cannot fit span %d (basechan=%d) into requested location\n",
+ spanno, basechan);
return -EINVAL;
}
+ dahdi_dev_dbg(ASSIGN, span->parent->dev.parent,
+ "good: spanno=%d, basechan=%d (span->channels=%d)\n",
+ spanno, basechan, span->channels);
set_spanno_and_basechan(span, spanno, basechan);
return 0;
}
@@ -6851,10 +6871,10 @@
unsigned int x;
if (!span || !span->ops || !span->ops->owner)
- return -EINVAL;
+ return -EFAULT;
if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
- dev_info(span->parent->dev.parent,
+ dev_notice(span->parent->dev.parent,
"local span %d is already assigned span %d "
"with base channel %d\n", local_spanno(span), span->spanno,
span->chans[0]->channo);
@@ -6865,7 +6885,9 @@
span->ops->disable_hw_preechocan) {
if ((NULL == span->ops->enable_hw_preechocan) ||
(NULL == span->ops->disable_hw_preechocan))
- return -EINVAL;
+ dev_notice(span->parent->dev.parent,
+ "span with inconsistent enable/disable hw_preechocan");
+ return -EFAULT;
}
if (!span->deflaw) {
Modified: linux/trunk/drivers/dahdi/dahdi-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=10328&r1=10327&r2=10328
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-sysfs.c Mon Nov 7 11:48:00 2011
@@ -590,8 +590,10 @@
ret = sscanf(buf, "%u:%u:%u", &local_span_number, &desired_spanno,
&desired_basechanno);
- if (ret != 3)
+ if (ret != 3) {
+ dev_notice(dev, "badly formatted input (should be <num>:<num>:<num>)\n");
return -EINVAL;
+ }
if (desired_spanno && !desired_basechanno) {
dev_notice(dev, "Must set span number AND base chan number\n");
Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=10328&r1=10327&r2=10328
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Mon Nov 7 11:48:00 2011
@@ -1567,6 +1567,7 @@
* be of the form DAHDI_DBG_*
*/
#define DAHDI_DBG_GENERAL BIT(0)
+#define DAHDI_DBG_ASSIGN BIT(1)
#define DAHDI_DBG_DEVICES BIT(7) /* instantiation/destruction etc. */
#define dahdi_dbg(bits, fmt, ...) \
((void)((debug & (DAHDI_DBG_ ## bits)) && DAHDI_PRINTK(DEBUG, \
@@ -1579,6 +1580,10 @@
((void)((debug & (DAHDI_DBG_ ## bits)) && \
chan_printk(DEBUG, "-" #bits, chan, \
"%s: " fmt, __func__, ## __VA_ARGS__)))
+#define dahdi_dev_dbg(bits, dev, fmt, ...) \
+ ((void)((debug & (DAHDI_DBG_ ## bits)) && \
+ dev_printk(KERN_DEBUG, dev, \
+ "DBG-%s(%s): " fmt, #bits, __func__, ## __VA_ARGS__)))
#endif /* DAHDI_PRINK_MACROS_USE_debug */
#endif /* _DAHDI_KERNEL_H */
More information about the dahdi-commits
mailing list