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@xorcom.com> Acked-by Tzafrir Cohen <tzafrir.cohen@xorcom.com> Acked-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10328 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
875c1ec3b6
commit
09e46f2213
@ -6647,6 +6647,9 @@ static void
|
|||||||
set_spanno_and_basechan(struct dahdi_span *span, u32 spanno, u32 basechan)
|
set_spanno_and_basechan(struct dahdi_span *span, u32 spanno, u32 basechan)
|
||||||
{
|
{
|
||||||
int i;
|
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;
|
span->spanno = spanno;
|
||||||
for (i = 0; i < span->channels; ++i)
|
for (i = 0; i < span->channels; ++i)
|
||||||
span->chans[i]->channo = basechan + i;
|
span->chans[i]->channo = basechan + i;
|
||||||
@ -6668,6 +6671,8 @@ static int _assign_spanno_and_basechan(struct dahdi_span *span)
|
|||||||
unsigned int spanno = 1;
|
unsigned int spanno = 1;
|
||||||
unsigned int basechan = 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) {
|
list_for_each_entry(pos, &span_list, spans_node) {
|
||||||
|
|
||||||
if (pos->spanno <= spanno) {
|
if (pos->spanno <= spanno) {
|
||||||
@ -6686,6 +6691,9 @@ static int _assign_spanno_and_basechan(struct dahdi_span *span)
|
|||||||
basechan = pos->chans[0]->channo + pos->channels;
|
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);
|
set_spanno_and_basechan(span, spanno, basechan);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -6733,14 +6741,20 @@ _check_spanno_and_basechan(struct dahdi_span *span, u32 spanno, u32 basechan)
|
|||||||
struct dahdi_span *pos;
|
struct dahdi_span *pos;
|
||||||
unsigned int next_channo;
|
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) {
|
list_for_each_entry(pos, &span_list, spans_node) {
|
||||||
|
|
||||||
next_channo = _get_next_channo(pos);
|
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 (pos->spanno <= spanno) {
|
||||||
if (basechan < next_channo + pos->channels) {
|
if (basechan < next_channo + pos->channels) {
|
||||||
/* Requested basechan breaks channel sorting */
|
/* 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",
|
"[%d] basechan (%d) is too low for wanted span %d\n",
|
||||||
local_spanno(span), basechan, spanno);
|
local_spanno(span), basechan, spanno);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -6755,9 +6769,15 @@ _check_spanno_and_basechan(struct dahdi_span *span, u32 spanno, u32 basechan)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Cannot fit the span into the requested location. Abort. */
|
/* 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;
|
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);
|
set_spanno_and_basechan(span, spanno, basechan);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -6851,10 +6871,10 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno,
|
|||||||
unsigned int x;
|
unsigned int x;
|
||||||
|
|
||||||
if (!span || !span->ops || !span->ops->owner)
|
if (!span || !span->ops || !span->ops->owner)
|
||||||
return -EINVAL;
|
return -EFAULT;
|
||||||
|
|
||||||
if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
|
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 "
|
"local span %d is already assigned span %d "
|
||||||
"with base channel %d\n", local_spanno(span), span->spanno,
|
"with base channel %d\n", local_spanno(span), span->spanno,
|
||||||
span->chans[0]->channo);
|
span->chans[0]->channo);
|
||||||
@ -6865,7 +6885,9 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno,
|
|||||||
span->ops->disable_hw_preechocan) {
|
span->ops->disable_hw_preechocan) {
|
||||||
if ((NULL == span->ops->enable_hw_preechocan) ||
|
if ((NULL == span->ops->enable_hw_preechocan) ||
|
||||||
(NULL == span->ops->disable_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) {
|
if (!span->deflaw) {
|
||||||
|
@ -590,8 +590,10 @@ dahdi_device_assign_span(struct device *dev, struct device_attribute *attr,
|
|||||||
|
|
||||||
ret = sscanf(buf, "%u:%u:%u", &local_span_number, &desired_spanno,
|
ret = sscanf(buf, "%u:%u:%u", &local_span_number, &desired_spanno,
|
||||||
&desired_basechanno);
|
&desired_basechanno);
|
||||||
if (ret != 3)
|
if (ret != 3) {
|
||||||
|
dev_notice(dev, "badly formatted input (should be <num>:<num>:<num>)\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (desired_spanno && !desired_basechanno) {
|
if (desired_spanno && !desired_basechanno) {
|
||||||
dev_notice(dev, "Must set span number AND base chan number\n");
|
dev_notice(dev, "Must set span number AND base chan number\n");
|
||||||
|
@ -1567,6 +1567,7 @@ struct mutex {
|
|||||||
* be of the form DAHDI_DBG_*
|
* be of the form DAHDI_DBG_*
|
||||||
*/
|
*/
|
||||||
#define DAHDI_DBG_GENERAL BIT(0)
|
#define DAHDI_DBG_GENERAL BIT(0)
|
||||||
|
#define DAHDI_DBG_ASSIGN BIT(1)
|
||||||
#define DAHDI_DBG_DEVICES BIT(7) /* instantiation/destruction etc. */
|
#define DAHDI_DBG_DEVICES BIT(7) /* instantiation/destruction etc. */
|
||||||
#define dahdi_dbg(bits, fmt, ...) \
|
#define dahdi_dbg(bits, fmt, ...) \
|
||||||
((void)((debug & (DAHDI_DBG_ ## bits)) && DAHDI_PRINTK(DEBUG, \
|
((void)((debug & (DAHDI_DBG_ ## bits)) && DAHDI_PRINTK(DEBUG, \
|
||||||
@ -1579,6 +1580,10 @@ struct mutex {
|
|||||||
((void)((debug & (DAHDI_DBG_ ## bits)) && \
|
((void)((debug & (DAHDI_DBG_ ## bits)) && \
|
||||||
chan_printk(DEBUG, "-" #bits, chan, \
|
chan_printk(DEBUG, "-" #bits, chan, \
|
||||||
"%s: " fmt, __func__, ## __VA_ARGS__)))
|
"%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_PRINK_MACROS_USE_debug */
|
||||||
|
|
||||||
#endif /* _DAHDI_KERNEL_H */
|
#endif /* _DAHDI_KERNEL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user