2010-08-28 05:59:27 +08:00
|
|
|
/*
|
|
|
|
* Written by Oron Peled <oron@actcom.co.il>
|
|
|
|
* Copyright (C) 2004-2006, Xorcom
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/version.h>
|
|
|
|
|
2012-01-11 23:21:13 +08:00
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
|
2012-01-11 23:22:46 +08:00
|
|
|
#warning "This module is tested only with 2.6 kernels"
|
2010-08-28 05:59:27 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <dahdi/kernel.h>
|
|
|
|
#include "dahdi_debug.h"
|
|
|
|
#include "xdefs.h"
|
|
|
|
|
|
|
|
static const char rcsid[] = "$Id$";
|
|
|
|
|
|
|
|
#define P_(x) [ x ] = { .value = x, .name = #x, }
|
2012-01-11 23:22:46 +08:00
|
|
|
static struct {
|
2010-08-28 05:59:27 +08:00
|
|
|
int value;
|
|
|
|
char *name;
|
|
|
|
} poll_names[] = {
|
2012-01-11 23:22:46 +08:00
|
|
|
P_(POLLIN), P_(POLLPRI), P_(POLLOUT), P_(POLLERR), P_(POLLHUP),
|
|
|
|
P_(POLLNVAL), P_(POLLRDNORM), P_(POLLRDBAND), P_(POLLWRNORM),
|
|
|
|
P_(POLLWRBAND), P_(POLLMSG), P_(POLLREMOVE)
|
2010-08-28 05:59:27 +08:00
|
|
|
};
|
2012-01-11 23:22:46 +08:00
|
|
|
|
2010-08-28 05:59:27 +08:00
|
|
|
#undef P_
|
|
|
|
|
|
|
|
void dump_poll(int debug, const char *msg, int poll)
|
|
|
|
{
|
2012-01-11 23:22:46 +08:00
|
|
|
int i;
|
2010-08-28 05:59:27 +08:00
|
|
|
|
2012-01-11 23:20:05 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(poll_names); i++) {
|
|
|
|
if (poll & poll_names[i].value)
|
2010-08-28 05:59:27 +08:00
|
|
|
DBG(GENERAL, "%s: %s\n", msg, poll_names[i].name);
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 04:01:32 +08:00
|
|
|
EXPORT_SYMBOL(dump_poll);
|
2010-08-28 05:59:27 +08:00
|
|
|
|
|
|
|
void alarm2str(int alarm, char *buf, int buflen)
|
|
|
|
{
|
2012-01-11 23:22:46 +08:00
|
|
|
char *p = buf;
|
|
|
|
int left = buflen;
|
|
|
|
int i;
|
|
|
|
int n;
|
2010-08-28 05:59:27 +08:00
|
|
|
|
2012-01-11 23:20:05 +08:00
|
|
|
if (!alarm) {
|
2010-08-28 05:59:27 +08:00
|
|
|
snprintf(buf, buflen, "NONE");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memset(buf, 0, buflen);
|
2012-01-11 23:20:05 +08:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (left && (alarm & BIT(i))) {
|
2010-08-28 05:59:27 +08:00
|
|
|
n = snprintf(p, left, "%s,", alarmbit2str(i));
|
|
|
|
p += n;
|
|
|
|
left -= n;
|
|
|
|
}
|
|
|
|
}
|
2012-01-11 23:22:46 +08:00
|
|
|
if (p > buf) /* kill last comma */
|
2010-08-28 05:59:27 +08:00
|
|
|
*(p - 1) = '\0';
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(alarm2str);
|