| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <linux/version.h> |
| 23 |
#include <linux/kernel.h> |
| 24 |
#include <linux/errno.h> |
| 25 |
#include <linux/module.h> |
| 26 |
#include <dahdi/kernel.h> |
| 27 |
#include "dahdi_debug.h" |
| 28 |
#include "xdefs.h" |
| 29 |
|
| 30 |
static const char rcsid[] = "$Id$"; |
| 31 |
|
| 32 |
#define P_(x) [ x ] = { .value = x, .name = #x, } |
| 33 |
static struct { |
| 34 |
int value; |
| 35 |
char *name; |
| 36 |
} poll_names[] = { |
| 37 |
P_(POLLIN), P_(POLLPRI), P_(POLLOUT), P_(POLLERR), P_(POLLHUP), |
| 38 |
P_(POLLNVAL), P_(POLLRDNORM), P_(POLLRDBAND), P_(POLLWRNORM), |
| 39 |
P_(POLLWRBAND), P_(POLLMSG), P_(POLLREMOVE) |
| 40 |
}; |
| 41 |
|
| 42 |
#undef P_ |
| 43 |
|
| 44 |
void dump_poll(int debug, const char *msg, int poll) |
| 45 |
{ |
| 46 |
int i; |
| 47 |
|
| 48 |
for (i = 0; i < ARRAY_SIZE(poll_names); i++) { |
| 49 |
if (poll & poll_names[i].value) |
| 50 |
DBG(GENERAL, "%s: %s\n", msg, poll_names[i].name); |
| 51 |
} |
| 52 |
} |
| 53 |
EXPORT_SYMBOL(dump_poll); |
| 54 |
|
| 55 |
void alarm2str(int alarm, char *buf, int buflen) |
| 56 |
{ |
| 57 |
char *p = buf; |
| 58 |
int left = buflen; |
| 59 |
int i; |
| 60 |
int n; |
| 61 |
|
| 62 |
if (!alarm) { |
| 63 |
snprintf(buf, buflen, "NONE"); |
| 64 |
return; |
| 65 |
} |
| 66 |
memset(buf, 0, buflen); |
| 67 |
for (i = 0; i < 8; i++) { |
| 68 |
if (left && (alarm & BIT(i))) { |
| 69 |
n = snprintf(p, left, "%s,", alarmbit2str(i)); |
| 70 |
p += n; |
| 71 |
left -= n; |
| 72 |
} |
| 73 |
} |
| 74 |
if (p > buf) |
| 75 |
*(p - 1) = '\0'; |
| 76 |
} |
| 77 |
EXPORT_SYMBOL(alarm2str); |