From bbdf5918d6a6d2e0fe06af87e0570d970790f91a Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 23 May 2011 16:45:53 +0300 Subject: Revert "remove OLD_PROC code (leave only informative proc files)" This reverts commit bab264ce3cb81098ff5b450f7c94a44a10f95dec. --- drivers/dahdi/xpp/card_global.c | 125 +++++++++++++++++++++++ drivers/dahdi/xpp/card_global.h | 4 + drivers/dahdi/xpp/card_pri.c | 215 ++++++++++++++++++++++++++++++++++++++++ drivers/dahdi/xpp/xbus-core.c | 61 ++++++++++++ drivers/dahdi/xpp/xbus-core.h | 5 + drivers/dahdi/xpp/xbus-pcm.c | 90 +++++++++++++++++ drivers/dahdi/xpp/xpd.h | 5 + drivers/dahdi/xpp/xpp_dahdi.c | 153 ++++++++++++++++++++++++++++ 8 files changed, 658 insertions(+) diff --git a/drivers/dahdi/xpp/card_global.c b/drivers/dahdi/xpp/card_global.c index 551192c..ba66b9e 100644 --- a/drivers/dahdi/xpp/card_global.c +++ b/drivers/dahdi/xpp/card_global.c @@ -40,6 +40,59 @@ extern int debug; /*---------------- GLOBAL PROC handling -----------------------------------*/ +#ifdef OLD_PROC +static int proc_xpd_register_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + reg_cmd_t *info; + bool do_datah; + char datah_str[50]; + + if(!xpd) + return -ENODEV; + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + spin_lock_irqsave(&xpd->lock, flags); + info = &xpd->last_reply; + len += sprintf(page + len, "# Writing bad data into this file may damage your hardware!\n"); + len += sprintf(page + len, "# Consult firmware docs first\n"); + len += sprintf(page + len, "#\n"); + do_datah = REG_FIELD(info, do_datah) ? 1 : 0; + if(do_datah) { + snprintf(datah_str, ARRAY_SIZE(datah_str), "\t%02X", + REG_FIELD(info, data_high)); + } else + datah_str[0] = '\0'; + if(REG_FIELD(info, do_subreg)) { + len += sprintf(page + len, "#CH\tOP\tReg.\tSub\tDL%s\n", + (do_datah) ? "\tDH" : ""); + len += sprintf(page + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n", + info->portnum, + REG_FIELD(info, regnum), REG_FIELD(info, subreg), + REG_FIELD(info, data_low), datah_str); + } else { + len += sprintf(page + len, "#CH\tOP\tReg.\tDL%s\n", + (do_datah) ? "\tDH" : ""); + len += sprintf(page + len, "%2d\tRD\t%02X\t%02X%s\n", + info->portnum, + REG_FIELD(info, regnum), + REG_FIELD(info, data_low), datah_str); + } + spin_unlock_irqrestore(&xpd->lock, flags); + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} +#endif + static int parse_hexbyte(const char *buf) { char *endp; @@ -289,6 +342,78 @@ out: return ret; } +#ifdef OLD_PROC +static int proc_xpd_register_write(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + xpd_t *xpd = data; + char buf[MAX_PROC_WRITE]; + char *p; + int i; + int ret; + + if(!xpd) + return -ENODEV; + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + for(i = 0; i < count; /* noop */) { + for(p = buf; p < buf + MAX_PROC_WRITE; p++) { /* read a line */ + if(i >= count) + break; + if(get_user(*p, buffer + i)) + return -EFAULT; + i++; + if(*p == '\n' || *p == '\r') /* whatever */ + break; + } + if(p >= buf + MAX_PROC_WRITE) + return -E2BIG; + *p = '\0'; + ret = parse_chip_command(xpd, buf); + if(ret < 0) { + XPD_NOTICE(xpd, "Failed writing command: '%s'\n", buf); + return ret; + } + /* Don't flood command_queue */ + if(xframe_queue_count(&xpd->xbus->command_queue) > 5) + msleep(6); + } + return count; +} + +void chip_proc_remove(xbus_t *xbus, xpd_t *xpd) +{ + BUG_ON(!xpd); +#ifdef CONFIG_PROC_FS + if(xpd->proc_xpd_chipregs) { + XBUS_DBG(PROC, xbus, "UNIT %d: Removing %s\n", xpd->addr.unit, CHIP_REGISTERS); + xpd->proc_xpd_chipregs->data = NULL; + remove_proc_entry(CHIP_REGISTERS, xpd->proc_xpd_dir); + } +#endif +} + +int chip_proc_create(xbus_t *xbus, xpd_t *xpd) +{ + BUG_ON(!xpd); +#ifdef CONFIG_PROC_FS + XBUS_DBG(PROC, xbus, "UNIT %d: Creating %s\n", xpd->addr.unit, CHIP_REGISTERS); + xpd->proc_xpd_chipregs = create_proc_entry(CHIP_REGISTERS, 0644, xpd->proc_xpd_dir); + if(!xpd->proc_xpd_chipregs) { + XPD_ERR(xpd, "Failed to create proc file '%s'\n", CHIP_REGISTERS); + goto err; + } + SET_PROC_DIRENTRY_OWNER(xpd->proc_xpd_chipregs); + xpd->proc_xpd_chipregs->write_proc = proc_xpd_register_write; + xpd->proc_xpd_chipregs->read_proc = proc_xpd_register_read; + xpd->proc_xpd_chipregs->data = xpd; +#endif + return 0; +err: + chip_proc_remove(xbus, xpd); + return -EINVAL; +} +#endif + /*---------------- GLOBAL Protocol Commands -------------------------------*/ static bool global_packet_is_valid(xpacket_t *pack); diff --git a/drivers/dahdi/xpp/card_global.h b/drivers/dahdi/xpp/card_global.h index 6264e84..7c2c9e7 100644 --- a/drivers/dahdi/xpp/card_global.h +++ b/drivers/dahdi/xpp/card_global.h @@ -100,6 +100,10 @@ DEF_RPACKET_DATA(GLOBAL, ERROR_CODE, /* 0x19 */ DECLARE_CMD(GLOBAL, SYNC_SOURCE, enum sync_mode mode, int drift); /* 0x23 */ DECLARE_CMD(GLOBAL, RESET_SYNC_COUNTERS); +#ifdef OLD_PROC +void chip_proc_remove(xbus_t *xbus, xpd_t *xpd); +int chip_proc_create(xbus_t *xbus, xpd_t *xpd); +#endif int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, bool writing, byte regnum, bool do_subreg, byte subreg, byte data_low, bool do_datah, byte data_high, bool should_reply); diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index abb3d8a..6780621 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -75,6 +75,10 @@ static bool is_sigtype_dchan(int sigtype) static bool pri_packet_is_valid(xpacket_t *pack); static void pri_packet_dump(const char *msg, xpacket_t *pack); +#ifdef OLD_PROC +static int proc_pri_info_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_pri_info_write(struct file *file, const char __user *buffer, unsigned long count, void *data); +#endif static int pri_startup(struct dahdi_span *span); static int pri_shutdown(struct dahdi_span *span); static int pri_rbsbits(struct dahdi_chan *chan, int bits); @@ -82,6 +86,9 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig); static void send_idlebits(xpd_t *xpd, bool saveold); #define PROC_REGISTER_FNAME "slics" +#ifdef OLD_PROC +#define PROC_PRI_INFO_FNAME "pri_info" +#endif enum pri_protocol { PRI_PROTO_0 = 0, @@ -307,6 +314,9 @@ struct pri_leds { struct PRI_priv_data { bool clock_source; +#ifdef OLD_PROC + struct proc_dir_entry *pri_info; +#endif enum pri_protocol pri_protocol; xpp_line_t rbslines; int deflaw; @@ -484,6 +494,50 @@ static int write_cas_reg(xpd_t *xpd, int rsnum, byte val) return 0; } +#ifdef OLD_PROC +static void pri_proc_remove(xbus_t *xbus, xpd_t *xpd) +{ + struct PRI_priv_data *priv; + + BUG_ON(!xpd); + priv = xpd->priv; + XPD_DBG(PROC, xpd, "\n"); +#ifdef CONFIG_PROC_FS + if(priv->pri_info) { + XPD_DBG(PROC, xpd, "Removing xpd PRI_INFO file\n"); + remove_proc_entry(PROC_PRI_INFO_FNAME, xpd->proc_xpd_dir); + } +#endif +} +#endif + +#ifdef OLD_PROC +static int pri_proc_create(xbus_t *xbus, xpd_t *xpd) +{ + struct PRI_priv_data *priv; + + BUG_ON(!xpd); + priv = xpd->priv; + XPD_DBG(PROC, xpd, "\n"); +#ifdef CONFIG_PROC_FS + XPD_DBG(PROC, xpd, "Creating PRI_INFO file\n"); + priv->pri_info = create_proc_entry(PROC_PRI_INFO_FNAME, 0644, xpd->proc_xpd_dir); + if(!priv->pri_info) { + XPD_ERR(xpd, "Failed to create proc '%s'\n", PROC_PRI_INFO_FNAME); + goto err; + } + SET_PROC_DIRENTRY_OWNER(priv->pri_info); + priv->pri_info->write_proc = proc_pri_info_write; + priv->pri_info->read_proc = proc_pri_info_read; + priv->pri_info->data = xpd; +#endif + return 0; +err: + pri_proc_remove(xbus, xpd); + return -EINVAL; +} +#endif + static bool valid_pri_modes(const xpd_t *xpd) { struct PRI_priv_data *priv; @@ -1135,6 +1189,12 @@ static xpd_t *PRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab priv->pri_protocol = PRI_PROTO_0; /* Default, changes in set_pri_proto() */ priv->deflaw = DAHDI_LAW_DEFAULT; /* Default, changes in set_pri_proto() */ xpd->type_name = type_name(priv->pri_protocol); +#ifdef OLD_PROC + if(pri_proc_create(xbus, xpd) < 0) { + xpd_free(xpd); + return NULL; + } +#endif xbus->sync_mode_default = SYNC_MODE_AB; return xpd; } @@ -1181,6 +1241,9 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd) priv->initialized = 1; return 0; err: +#ifdef OLD_PROC + pri_proc_remove(xbus, xpd); +#endif XPD_ERR(xpd, "Failed initializing registers (%d)\n", ret); return ret; } @@ -1192,6 +1255,9 @@ static int PRI_card_remove(xbus_t *xbus, xpd_t *xpd) BUG_ON(!xpd); priv = xpd->priv; XPD_DBG(GENERAL, xpd, "\n"); +#ifdef OLD_PROC + pri_proc_remove(xbus, xpd); +#endif return 0; } @@ -2151,6 +2217,155 @@ static void pri_packet_dump(const char *msg, xpacket_t *pack) { DBG(GENERAL, "%s\n", msg); } +/*------------------------- REGISTER Handling --------------------------*/ +#ifdef OLD_PROC +static int proc_pri_info_write(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + xpd_t *xpd = data; + struct PRI_priv_data *priv; + char buf[MAX_PROC_WRITE]; + char *p; + char *tok; + int ret = 0; + bool got_localloop = 0; + bool got_nolocalloop = 0; + bool got_e1 = 0; + bool got_t1 = 0; + bool got_j1 = 0; + + if(!xpd) + return -ENODEV; + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] write to /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + priv = xpd->priv; + if(count >= MAX_PROC_WRITE) { /* leave room for null */ + XPD_ERR(xpd, "write too long (%ld)\n", count); + return -E2BIG; + } + if(copy_from_user(buf, buffer, count)) { + XPD_ERR(xpd, "Failed reading user data\n"); + return -EFAULT; + } + buf[count] = '\0'; + XPD_DBG(PROC, xpd, "PRI-SETUP: got %s\n", buf); + /* + * First parse. Act only of *everything* is good. + */ + p = buf; + while((tok = strsep(&p, " \t\v\n")) != NULL) { + if(*tok == '\0') + continue; + XPD_DBG(PROC, xpd, "Got token='%s'\n", tok); + if(strnicmp(tok, "LOCALLOOP", 8) == 0) + got_localloop = 1; + else if(strnicmp(tok, "NOLOCALLOOP", 8) == 0) + got_nolocalloop = 1; + else if(strnicmp(tok, "E1", 2) == 0) + got_e1 = 1; + else if(strnicmp(tok, "T1", 2) == 0) + got_t1 = 1; + else if(strnicmp(tok, "J1", 2) == 0) { + got_j1 = 1; + } else { + XPD_NOTICE(xpd, "PRI-SETUP: unknown keyword: '%s'\n", tok); + return -EINVAL; + } + } + if(got_e1) + ret = set_pri_proto(xpd, PRI_PROTO_E1); + else if(got_t1) + ret = set_pri_proto(xpd, PRI_PROTO_T1); + else if(got_j1) + ret = set_pri_proto(xpd, PRI_PROTO_J1); + if(priv->pri_protocol == PRI_PROTO_0) { + XPD_ERR(xpd, + "Must set PRI protocol (E1/T1/J1) before setting other parameters\n"); + return -EINVAL; + } + if(got_localloop) + ret = set_localloop(xpd, 1); + if(got_nolocalloop) + ret = set_localloop(xpd, 0); + return (ret) ? ret : count; +} + + +static int proc_pri_info_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + struct PRI_priv_data *priv; + int i; + + DBG(PROC, "\n"); + if(!xpd) + return -ENODEV; + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + spin_lock_irqsave(&xpd->lock, flags); + priv = xpd->priv; + BUG_ON(!priv); + len += sprintf(page + len, "PRI: %s %s%s (deflaw=%d, dchan=%d)\n", + (priv->clock_source) ? "MASTER" : "SLAVE", + pri_protocol_name(priv->pri_protocol), + (priv->local_loopback) ? " LOCALLOOP" : "", + priv->deflaw, priv->dchan_num); + len += sprintf(page + len, "%05d Layer1: ", priv->layer1_replies); + if(priv->poll_noreplies > 1) + len += sprintf(page + len, "No Replies [%d]\n", + priv->poll_noreplies); + else { + len += sprintf(page + len, "%s\n", + ((priv->layer1_up) ? "UP" : "DOWN")); + len += sprintf(page + len, + "Framer Status: FRS0=0x%02X, FRS1=0x%02X ALARMS:", + priv->reg_frs0, priv->reg_frs1); + if(priv->reg_frs0 & REG_FRS0_LOS) + len += sprintf(page + len, " RED"); + if(priv->reg_frs0 & REG_FRS0_AIS) + len += sprintf(page + len, " BLUE"); + if(priv->reg_frs0 & REG_FRS0_RRA) + len += sprintf(page + len, " YELLOW"); + len += sprintf(page + len, "\n"); + } + if(priv->is_cas) { + len += sprintf(page + len, + "CAS: replies=%d\n", priv->cas_replies); + len += sprintf(page + len, " CAS-TS: "); + for(i = 0; i < NUM_CAS_RS_E; i++) { + len += sprintf(page + len, " %02X", priv->cas_ts_e[i]); + } + len += sprintf(page + len, "\n"); + len += sprintf(page + len, " CAS-RS: "); + for(i = 0; i < NUM_CAS_RS_E; i++) { + len += sprintf(page + len, " %02X", priv->cas_rs_e[i]); + } + len += sprintf(page + len, "\n"); + } + len += sprintf(page + len, "D-Channel: TX=[%5d] (0x%02X) RX=[%5d] (0x%02X) ", + priv->dchan_tx_counter, priv->dchan_tx_sample, + priv->dchan_rx_counter, priv->dchan_rx_sample); + if(priv->dchan_alive) { + len += sprintf(page + len, "(alive %d K-ticks)\n", + priv->dchan_alive_ticks/1000); + } else { + len += sprintf(page + len, "(dead)\n"); + } + for(i = 0; i < NUM_LEDS; i++) + len += sprintf(page + len, "LED #%d: %d\n", i, priv->ledstate[i]); + spin_unlock_irqrestore(&xpd->lock, flags); + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} +#endif /*------------------------- sysfs stuff --------------------------------*/ static DEVICE_ATTR_READER(pri_protocol_show, dev, buf) diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index d23b7f2..9feaeaa 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -51,6 +51,9 @@ static const char rcsid[] = "$Id$"; #define INITIALIZATION_TIMEOUT (90*HZ) /* in jiffies */ #define PROC_XBUSES "xbuses" #define PROC_XBUS_SUMMARY "summary" +#ifdef OLD_PROC +#define PROC_XBUS_WAITFOR_XPDS "waitfor_xpds" +#endif #ifdef PROTOCOL_DEBUG #ifdef CONFIG_PROC_FS @@ -67,6 +70,9 @@ static DEF_PARM_BOOL(rx_tasklet, 0, 0644, "Use receive tasklets"); #ifdef CONFIG_PROC_FS static int xbus_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); +#ifdef OLD_PROC +static int xbus_read_waitfor_xpds(char *page, char **start, off_t off, int count, int *eof, void *data); +#endif #endif static void transport_init(xbus_t *xbus, struct xbus_ops *ops, ushort max_send_size, struct device *transport_device, void *priv); static void transport_destroy(xbus_t *xbus); @@ -1125,6 +1131,16 @@ static void worker_destroy(xbus_t *xbus) worker->wq = NULL; XBUS_DBG(DEVICES, xbus, "destroying workqueue -- done\n"); } +#ifdef CONFIG_PROC_FS +#ifdef OLD_PROC + if (xbus->proc_xbus_dir && worker->proc_xbus_waitfor_xpds) { + XBUS_DBG(PROC, xbus, "Removing proc '%s'\n", + PROC_XBUS_WAITFOR_XPDS); + remove_proc_entry(PROC_XBUS_WAITFOR_XPDS, xbus->proc_xbus_dir); + worker->proc_xbus_waitfor_xpds = NULL; + } +#endif +#endif XBUS_DBG(DEVICES, xbus, "detach worker\n"); put_xbus(__func__, xbus); /* got from worker_run() */ } @@ -1160,6 +1176,22 @@ static int worker_run(xbus_t *xbus) BUG_ON(worker->wq); /* Hmmm... nested workers? */ XBUS_DBG(DEVICES, xbus, "\n"); /* poll related variables */ +#ifdef CONFIG_PROC_FS +#ifdef OLD_PROC + if(xbus->proc_xbus_dir) { + worker->proc_xbus_waitfor_xpds = create_proc_read_entry( + PROC_XBUS_WAITFOR_XPDS, 0444, + xbus->proc_xbus_dir, + xbus_read_waitfor_xpds, + xbus); + if (!worker->proc_xbus_waitfor_xpds) { + XBUS_ERR(xbus, "Failed to create proc file '%s'\n", PROC_XBUS_WAITFOR_XPDS); + goto err; + } + SET_PROC_DIRENTRY_OWNER(worker->proc_xbus_waitfor_xpds); + } +#endif +#endif worker->wq = create_singlethread_workqueue(xbus->busname); if(!worker->wq) { XBUS_ERR(xbus, "Failed to create worker workqueue.\n"); @@ -1698,6 +1730,35 @@ out: } +#ifdef OLD_PROC +static int xbus_read_waitfor_xpds(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + int i = (int)((unsigned long)data); + xbus_t *xbus; + + xbus = get_xbus(__func__, i); + if (xbus != NULL) { + XBUS_NOTICE(xbus, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __func__, current->comm, current->tgid); + /* first handle special cases */ + if (count && !off) + len = waitfor_xpds(xbus, page); + put_xbus(__func__, xbus); + } + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; + +} +#endif + #ifdef PROTOCOL_DEBUG static int proc_xbus_command_write(struct file *file, const char __user *buffer, unsigned long count, void *data) { diff --git a/drivers/dahdi/xpp/xbus-core.h b/drivers/dahdi/xpp/xbus-core.h index ebc3483..536acaf 100644 --- a/drivers/dahdi/xpp/xbus-core.h +++ b/drivers/dahdi/xpp/xbus-core.h @@ -135,6 +135,11 @@ struct xbus_workqueue { int num_units; int num_units_initialized; wait_queue_head_t wait_for_xpd_initialization; +#ifdef CONFIG_PROC_FS +#ifdef OLD_PROC + struct proc_dir_entry *proc_xbus_waitfor_xpds; +#endif +#endif spinlock_t worker_lock; struct semaphore running_initialization; }; diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c index 448cf5a..65cf9c0 100644 --- a/drivers/dahdi/xpp/xbus-pcm.c +++ b/drivers/dahdi/xpp/xbus-pcm.c @@ -1219,6 +1219,73 @@ int fill_sync_string(char *buf, size_t count) return len; } +#ifdef OLD_PROC +#ifdef CONFIG_PROC_FS +static int proc_sync_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + struct timeval now; + unsigned int counter = atomic_read(&xpp_tick_counter); + unsigned long usec; + + do_gettimeofday(&now); + NOTICE("%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + len += sprintf(page + len, "# To modify sync source write into this file:\n"); + len += sprintf(page + len, "# DAHDI - Another dahdi device provide sync\n"); + len += sprintf(page + len, "# SYNC=nn - XBUS-nn provide sync\n"); + len += sprintf(page + len, "# QUERY=nn - Query XBUS-nn for sync information (DEBUG)\n"); + len += fill_sync_string(page + len, PAGE_SIZE - len); +#ifdef DAHDI_SYNC_TICK + if(force_dahdi_sync) { + len += sprintf(page + len, + "Dahdi Reference Sync (%d registered spans):\n", + total_registered_spans()); + len += sprintf(page + len, "\tdahdi_tick: #%d\n", dahdi_tick_count); + len += sprintf(page + len, "\ttick - dahdi_tick = %d\n", + counter - dahdi_tick_count); + } else { + len += sprintf(page + len, + "Dahdi Reference Sync Not activated\n"); + } +#endif + usec = usec_diff(&now, &global_ticks_series.last_sample.tv); + len += sprintf(page + len, "\ntick: #%d\n", counter); + len += sprintf(page + len, + "tick duration: %d usec (measured %ld.%ld msec ago)\n", + global_ticks_series.tick_period, + usec / 1000, usec % 1000); + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} + +static int proc_sync_write(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + char buf[MAX_PROC_WRITE]; + + // DBG(SYNC, "%s: count=%ld\n", __FUNCTION__, count); + NOTICE("%s: DEPRECATED: %s[%d] write to /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + if(count >= MAX_PROC_WRITE) + return -EINVAL; + if(copy_from_user(buf, buffer, count)) + return -EFAULT; + buf[count] = '\0'; + return exec_sync_command(buf, count); +} + +static struct proc_dir_entry *top; + +#endif +#endif /* OLD_PROC */ + int xbus_pcm_init(void *toplevel) { int ret = 0; @@ -1234,11 +1301,34 @@ int xbus_pcm_init(void *toplevel) #endif xpp_ticker_init(&global_ticks_series); xpp_ticker_init(&dahdi_ticker); +#ifdef OLD_PROC +#ifdef CONFIG_PROC_FS + { + struct proc_dir_entry *ent; + + top = toplevel; + ent = create_proc_entry(PROC_SYNC, 0644, top); + if(ent) { + ent->read_proc = proc_sync_read; + ent->write_proc = proc_sync_write; + ent->data = NULL; + } else { + ret = -EFAULT; + } + } +#endif +#endif /* OLD_PROC */ return ret; } void xbus_pcm_shutdown(void) { +#ifdef OLD_PROC +#ifdef CONFIG_PROC_FS + DBG(GENERAL, "Removing '%s' from proc\n", PROC_SYNC); + remove_proc_entry(PROC_SYNC, top); +#endif +#endif /* OLD_PROC */ } diff --git a/drivers/dahdi/xpp/xpd.h b/drivers/dahdi/xpp/xpd.h index 4644fcf..66ba88c 100644 --- a/drivers/dahdi/xpp/xpd.h +++ b/drivers/dahdi/xpp/xpd.h @@ -217,6 +217,11 @@ struct xpd { #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_xpd_dir; struct proc_dir_entry *proc_xpd_summary; +#ifdef OLD_PROC + struct proc_dir_entry *proc_xpd_ztregister; + struct proc_dir_entry *proc_xpd_blink; + struct proc_dir_entry *proc_xpd_chipregs; +#endif #endif int counters[XPD_COUNTER_MAX]; diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index 992064a..4bd9287 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -50,6 +50,10 @@ static const char rcsid[] = "$Id$"; #ifdef CONFIG_PROC_FS struct proc_dir_entry *xpp_proc_toplevel = NULL; #define PROC_DIR "xpp" +#ifdef OLD_PROC +#define PROC_XPD_ZTREGISTER "dahdi_registration" +#define PROC_XPD_BLINK "blink" +#endif #define PROC_XPD_SUMMARY "summary" #endif @@ -110,6 +114,12 @@ int total_registered_spans(void) #ifdef CONFIG_PROC_FS static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); +#ifdef OLD_PROC +static int proc_xpd_ztregister_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_xpd_ztregister_write(struct file *file, const char __user *buffer, unsigned long count, void *data); +static int proc_xpd_blink_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_xpd_blink_write(struct file *file, const char __user *buffer, unsigned long count, void *data); +#endif #endif /*------------------------- XPD Management -------------------------*/ @@ -152,11 +162,26 @@ static void xpd_proc_remove(xbus_t *xbus, xpd_t *xpd) { #ifdef CONFIG_PROC_FS if(xpd->proc_xpd_dir) { +#ifdef OLD_PROC + chip_proc_remove(xbus, xpd); +#endif if(xpd->proc_xpd_summary) { XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_SUMMARY); remove_proc_entry(PROC_XPD_SUMMARY, xpd->proc_xpd_dir); xpd->proc_xpd_summary = NULL; } +#ifdef OLD_PROC + if(xpd->proc_xpd_ztregister) { + XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_ZTREGISTER); + remove_proc_entry(PROC_XPD_ZTREGISTER, xpd->proc_xpd_dir); + xpd->proc_xpd_ztregister = NULL; + } + if(xpd->proc_xpd_blink) { + XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_BLINK); + remove_proc_entry(PROC_XPD_BLINK, xpd->proc_xpd_dir); + xpd->proc_xpd_blink = NULL; + } +#endif XPD_DBG(PROC, xpd, "Removing %s/%s proc directory\n", xbus->busname, xpd->xpdname); remove_proc_entry(xpd->xpdname, xbus->proc_xbus_dir); @@ -181,6 +206,28 @@ static int xpd_proc_create(xbus_t *xbus, xpd_t *xpd) goto err; } SET_PROC_DIRENTRY_OWNER(xpd->proc_xpd_summary); +#ifdef OLD_PROC + xpd->proc_xpd_ztregister = create_proc_entry(PROC_XPD_ZTREGISTER, 0644, xpd->proc_xpd_dir); + if (!xpd->proc_xpd_ztregister) { + XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_XPD_ZTREGISTER); + goto err; + } + SET_PROC_DIRENTRY_OWNER(xpd->proc_xpd_ztregister); + xpd->proc_xpd_ztregister->data = xpd; + xpd->proc_xpd_ztregister->read_proc = proc_xpd_ztregister_read; + xpd->proc_xpd_ztregister->write_proc = proc_xpd_ztregister_write; + xpd->proc_xpd_blink = create_proc_entry(PROC_XPD_BLINK, 0644, xpd->proc_xpd_dir); + if (!xpd->proc_xpd_blink) { + XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_XPD_BLINK); + goto err; + } + SET_PROC_DIRENTRY_OWNER(xpd->proc_xpd_blink); + xpd->proc_xpd_blink->data = xpd; + xpd->proc_xpd_blink->read_proc = proc_xpd_blink_read; + xpd->proc_xpd_blink->write_proc = proc_xpd_blink_write; + if(chip_proc_create(xbus, xpd) < 0) + goto err; +#endif #endif return 0; #ifdef CONFIG_PROC_FS @@ -710,6 +757,112 @@ void hookstate_changed(xpd_t *xpd, int pos, bool to_offhook) notify_rxsig(xpd, pos, (to_offhook) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK); } +#ifdef CONFIG_PROC_FS +#ifdef OLD_PROC +static int proc_xpd_ztregister_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + + BUG_ON(!xpd); + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + spin_lock_irqsave(&xpd->lock, flags); + len += sprintf(page + len, "%d\n", SPAN_REGISTERED(xpd) ? xpd->span.spanno : 0); + spin_unlock_irqrestore(&xpd->lock, flags); + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} + +static int proc_xpd_ztregister_write(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + xpd_t *xpd = data; + char buf[MAX_PROC_WRITE]; + int dahdi_reg; + int ret; + + BUG_ON(!xpd); + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + if(count >= MAX_PROC_WRITE) + return -EINVAL; + if(copy_from_user(buf, buffer, count)) + return -EFAULT; + buf[count] = '\0'; + ret = sscanf(buf, "%d", &dahdi_reg); + if(ret != 1) + return -EINVAL; + if(!XBUS_IS(xpd->xbus, READY)) + return -ENODEV; + XPD_DBG(GENERAL, xpd, "%s\n", (dahdi_reg) ? "register" : "unregister"); + if(dahdi_reg) + ret = dahdi_register_xpd(xpd); + else + ret = dahdi_unregister_xpd(xpd); + return (ret < 0) ? ret : count; +} + +static int proc_xpd_blink_read(char *page, char **start, off_t off, int count, int *eof, void *data) +{ + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + + BUG_ON(!xpd); + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + spin_lock_irqsave(&xpd->lock, flags); + len += sprintf(page + len, "0x%lX\n", xpd->blink_mode); + spin_unlock_irqrestore(&xpd->lock, flags); + if (len <= off+count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} + +static int proc_xpd_blink_write(struct file *file, const char __user *buffer, unsigned long count, void *data) +{ + xpd_t *xpd = data; + char buf[MAX_PROC_WRITE]; + char *endp; + unsigned long blink; + + + BUG_ON(!xpd); + XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", + __FUNCTION__, current->comm, current->tgid); + if(count >= MAX_PROC_WRITE) + return -EINVAL; + if(copy_from_user(buf, buffer, count)) + return -EFAULT; + buf[count] = '\0'; + if(count > 0 && buf[count-1] == '\n') /* chomp */ + buf[count-1] = '\0'; + blink = simple_strtoul(buf, &endp, 0); + if(*endp != '\0' || blink > 0xFFFF) + return -EINVAL; + XPD_DBG(GENERAL, xpd, "BLINK channels: 0x%lX\n", blink); + xpd->blink_mode = blink; + return count; +} +#endif + +#endif + + #define XPP_MAX_LEN 512 /*------------------------- Dahdi Interfaces -----------------------*/ -- cgit v1.2.3