[svn-commits] tzafrir: linux/trunk r5097 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Oct 16 12:40:22 CDT 2008
Author: tzafrir
Date: Thu Oct 16 12:40:22 2008
New Revision: 5097
URL: http://svn.digium.com/view/dahdi?view=rev&rev=5097
Log:
xpp: start migration from procfs to sysfs.
* Sysfs representation for XPDs:
/sys/bus/xpds/devices/<bus>:<unit>:<subunit>
* Astribanks sysfs directories now include the XPDs as subdirectories:
e.g. /sys/bus/astribanks/devices/xbus-00/00:3:0
* procfs control interface deprecated: conditioned by OLD_PROC
(defaults to off). Control functionality moved to sysfs:
* xbus attributes: cls connector label status timing waitfor_xpds xbus_state
* XPDs can have driver-specific attributes. Common attriubtes:
blink chipregs span
* PRI-specific attributes:
pri_clocking pri_dchan pri_cas pri_alarms pri_layer1 pri_localloop pri_protocol
* The Astribank attribute "xbus_state" is read/write. Reading it shows
the current state of the Astribank. Writing "start" or "stop" allows a
software equivalent of connect or disconnect respectively.
* When an Astribank is ready it sends an "online" event. Whenever its
not ready (e.g. at the time of disconnect) it sends an "offline" event.
Use astribank_hook.sample to handle those.
Added:
linux/trunk/drivers/dahdi/xpp/astribank_hook.sample (with props)
Modified:
linux/trunk/drivers/dahdi/xpp/Kbuild
linux/trunk/drivers/dahdi/xpp/card_bri.c
linux/trunk/drivers/dahdi/xpp/card_fxo.c
linux/trunk/drivers/dahdi/xpp/card_fxs.c
linux/trunk/drivers/dahdi/xpp/card_global.c
linux/trunk/drivers/dahdi/xpp/card_global.h
linux/trunk/drivers/dahdi/xpp/card_pri.c
linux/trunk/drivers/dahdi/xpp/init_card_1_30
linux/trunk/drivers/dahdi/xpp/init_card_2_30
linux/trunk/drivers/dahdi/xpp/init_card_3_30
linux/trunk/drivers/dahdi/xpp/init_card_4_30
linux/trunk/drivers/dahdi/xpp/mmapdrv.c
linux/trunk/drivers/dahdi/xpp/xbus-core.c
linux/trunk/drivers/dahdi/xpp/xbus-core.h
linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
linux/trunk/drivers/dahdi/xpp/xdefs.h
linux/trunk/drivers/dahdi/xpp/xframe_queue.c
linux/trunk/drivers/dahdi/xpp/xframe_queue.h
linux/trunk/drivers/dahdi/xpp/xpd.h
linux/trunk/drivers/dahdi/xpp/xpp.rules
linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
linux/trunk/drivers/dahdi/xpp/xpp_dahdi.h
linux/trunk/drivers/dahdi/xpp/xpp_usb.c
linux/trunk/drivers/dahdi/xpp/xproto.c
linux/trunk/drivers/dahdi/xpp/xproto.h
Modified: linux/trunk/drivers/dahdi/xpp/Kbuild
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/Kbuild?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/Kbuild (original)
+++ linux/trunk/drivers/dahdi/xpp/Kbuild Thu Oct 16 12:40:22 2008
@@ -3,7 +3,7 @@
-DPOLL_DIGITAL_INPUTS \
-DDEBUG_PCMTX \
-DPROTOCOL_DEBUG \
- -g
+ -g # -DOLD_PROC
#
WITH_BRISTUFF := $(shell grep -c '^[[:space:]]*\#[[:space:]]*define[[:space:]]\+CONFIG_DAHDI_BRI_DCHANS\>' $(src)/../dahdi_config.h)
@@ -80,7 +80,8 @@
$(obj)/init_fxo_modes.verified: $(obj)/init_card_2_$(XPP_PROTOCOL_VERSION) $(obj)/init_fxo_modes
@echo ' CHECK $(obj)/init_card_2_$(XPP_PROTOCOL_VERSION)'
- $(Q)$(FXO_VERIFY) && touch $@ || (rm -f $@; exit 1)
+ $(Q)$(FXO_VERIFY) || (rm -f $@; exit 1)
+ touch $@
$(obj)/init_card_%_$(XPP_PROTOCOL_VERSION).verified: $(src)/init_card_%_$(XPP_PROTOCOL_VERSION)
@echo ' VERIFY $<'
Added: linux/trunk/drivers/dahdi/xpp/astribank_hook.sample
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/astribank_hook.sample?view=auto&rev=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/astribank_hook.sample (added)
+++ linux/trunk/drivers/dahdi/xpp/astribank_hook.sample Thu Oct 16 12:40:22 2008
@@ -1,0 +1,26 @@
+#! /bin/sh
+
+me=`basename $0`
+LOGGER="logger -i -t '$me'"
+
+set -e
+
+echo "starting($ACTION): '$*'" | $LOGGER
+
+case "$ACTION" in
+add)
+ ;;
+remove)
+ ;;
+online)
+ ;;
+offline)
+ ;;
+*)
+ echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
+ echo "$0: ARGS='$*'" | $LOGGER
+ echo "$0: ENV:" | $LOGGER
+ env | $LOGGER
+ exit 1
+esac
+
Propchange: linux/trunk/drivers/dahdi/xpp/astribank_hook.sample
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: linux/trunk/drivers/dahdi/xpp/astribank_hook.sample
------------------------------------------------------------------------------
svn:executable = *
Propchange: linux/trunk/drivers/dahdi/xpp/astribank_hook.sample
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: linux/trunk/drivers/dahdi/xpp/astribank_hook.sample
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: linux/trunk/drivers/dahdi/xpp/card_bri.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_bri.c?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_bri.c Thu Oct 16 12:40:22 2008
@@ -616,13 +616,11 @@
int channels = min(3, CHANNELS_PERXPD);
XBUS_DBG(GENERAL, xbus, "\n");
- xpd = xpd_alloc(sizeof(struct BRI_priv_data), proto_table, channels);
+ xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct BRI_priv_data), proto_table, channels);
if(!xpd)
return NULL;
xpd->direction = (to_phone) ? TO_PHONE : TO_PSTN;
xpd->type_name = (to_phone) ? "BRI_NT" : "BRI_TE";
- if(xpd_common_init(xbus, xpd, unit, subunit, subtype, subunits) < 0)
- goto err;
if(bri_proc_create(xbus, xpd) < 0)
goto err;
return xpd;
@@ -924,7 +922,7 @@
static int BRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg)
{
BUG_ON(!xpd);
- if(!TRANSPORT_RUNNING(xpd->xbus))
+ if(!XBUS_IS(xpd->xbus, READY))
return -ENODEV;
switch (cmd) {
case DAHDI_TONEDETECT:
@@ -1021,7 +1019,7 @@
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(!TRANSPORT_RUNNING(xpd->xbus)) {
+ if(!XBUS_IS(xpd->xbus, READY)) {
XPD_DBG(GENERAL, xpd, "Startup called by dahdi. No Hardware. Ignored\n");
return -ENODEV;
}
@@ -1054,7 +1052,7 @@
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(!TRANSPORT_RUNNING(xpd->xbus)) {
+ if(!XBUS_IS(xpd->xbus, READY)) {
XPD_DBG(GENERAL, xpd, "Shutdown called by dahdi. No Hardware. Ignored\n");
return -ENODEV;
}
@@ -1479,10 +1477,46 @@
return len;
}
+static int bri_xpd_probe(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ /* Is it our device? */
+ if(xpd->type != XPD_TYPE_BRI) {
+ XPD_ERR(xpd, "drop suggestion for %s (%d)\n",
+ dev->bus_id, xpd->type);
+ return -EINVAL;
+ }
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static int bri_xpd_remove(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static struct xpd_driver bri_driver = {
+ .type = XPD_TYPE_BRI,
+ .driver = {
+ .name = "bri",
+ .owner = THIS_MODULE,
+ .probe = bri_xpd_probe,
+ .remove = bri_xpd_remove
+ }
+};
+
static int __init card_bri_startup(void)
{
- DBG(GENERAL, "\n");
-
+ int ret;
+
+ if((ret = xpd_driver_register(&bri_driver.driver)) < 0)
+ return ret;
INFO("revision %s\n", XPP_VERSION);
xproto_register(&PROTO_TABLE(BRI));
return 0;
@@ -1492,6 +1526,7 @@
{
DBG(GENERAL, "\n");
xproto_unregister(&PROTO_TABLE(BRI));
+ xpd_driver_unregister(&bri_driver.driver);
}
MODULE_DESCRIPTION("XPP BRI Card Driver");
Modified: linux/trunk/drivers/dahdi/xpp/card_fxo.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxo.c Thu Oct 16 12:40:22 2008
@@ -437,13 +437,11 @@
channels = min(2, CHANNELS_PERXPD);
else
channels = min(8, CHANNELS_PERXPD);
- xpd = xpd_alloc(sizeof(struct FXO_priv_data), proto_table, channels);
+ xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXO_priv_data), proto_table, channels);
if(!xpd)
return NULL;
xpd->direction = TO_PSTN;
xpd->type_name = "FXO";
- if(xpd_common_init(xbus, xpd, unit, subunit, subtype, subunits) < 0)
- goto err;
if(fxo_proc_create(xbus, xpd) < 0)
goto err;
return xpd;
@@ -790,7 +788,7 @@
unsigned char echotune_data[ARRAY_SIZE(echotune_regs)];
BUG_ON(!xpd);
- if(!TRANSPORT_RUNNING(xpd->xbus))
+ if(!XBUS_IS(xpd->xbus, READY))
return -ENODEV;
switch (cmd) {
case WCTDM_SET_ECHOTUNE:
@@ -1315,12 +1313,50 @@
}
#endif
+static int fxo_xpd_probe(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ /* Is it our device? */
+ if(xpd->type != XPD_TYPE_FXO) {
+ XPD_ERR(xpd, "drop suggestion for %s (%d)\n",
+ dev->bus_id, xpd->type);
+ return -EINVAL;
+ }
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static int fxo_xpd_remove(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static struct xpd_driver fxo_driver = {
+ .type = XPD_TYPE_FXO,
+ .driver = {
+ .name = "fxo",
+ .owner = THIS_MODULE,
+ .probe = fxo_xpd_probe,
+ .remove = fxo_xpd_remove
+ }
+};
+
static int __init card_fxo_startup(void)
{
+ int ret;
+
if(ring_debounce <= 0) {
ERR("ring_debounce=%d. Must be positive number of ticks\n", ring_debounce);
return -EINVAL;
}
+ if((ret = xpd_driver_register(&fxo_driver.driver)) < 0)
+ return ret;
INFO("revision %s\n", XPP_VERSION);
#ifdef WITH_METERING
INFO("FEATURE: WITH METERING Detection\n");
@@ -1334,6 +1370,7 @@
static void __exit card_fxo_cleanup(void)
{
xproto_unregister(&PROTO_TABLE(FXO));
+ xpd_driver_unregister(&fxo_driver.driver);
}
MODULE_DESCRIPTION("XPP FXO Card Driver");
Modified: linux/trunk/drivers/dahdi/xpp/card_fxs.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxs.c Thu Oct 16 12:40:22 2008
@@ -382,7 +382,7 @@
channels = regular_channels;
if(unit == 0)
channels += 6; /* 2 DIGITAL OUTPUTS, 4 DIGITAL INPUTS */
- xpd = xpd_alloc(sizeof(struct FXS_priv_data), proto_table, channels);
+ xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXS_priv_data), proto_table, channels);
if(!xpd)
return NULL;
if(unit == 0) {
@@ -392,8 +392,6 @@
}
xpd->direction = TO_PHONE;
xpd->type_name = "FXS";
- if(xpd_common_init(xbus, xpd, unit, subunit, subtype, subunits) < 0)
- goto err;
if(fxs_proc_create(xbus, xpd) < 0)
goto err;
priv = xpd->priv;
@@ -765,7 +763,7 @@
BUG_ON(!priv);
xbus = xpd->xbus;
BUG_ON(!xbus);
- if(!TRANSPORT_RUNNING(xbus))
+ if(!XBUS_IS(xbus, READY))
return -ENODEV;
if (pos < 0 || pos >= xpd->channels) {
XPD_NOTICE(xpd, "Bad channel number %d in %s(), cmd=%u\n",
@@ -1466,8 +1464,47 @@
}
#endif
+static int fxs_xpd_probe(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ /* Is it our device? */
+ if(xpd->type != XPD_TYPE_FXS) {
+ XPD_ERR(xpd, "drop suggestion for %s (%d)\n",
+ dev->bus_id, xpd->type);
+ return -EINVAL;
+ }
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static int fxs_xpd_remove(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ return 0;
+}
+
+static struct xpd_driver fxs_driver = {
+ .type = XPD_TYPE_FXS,
+ .driver = {
+ .name = "fxs",
+ .owner = THIS_MODULE,
+ .probe = fxs_xpd_probe,
+ .remove = fxs_xpd_remove
+ }
+};
+
static int __init card_fxs_startup(void)
{
+ int ret;
+
+ if((ret = xpd_driver_register(&fxs_driver.driver)) < 0)
+ return ret;
+
INFO("revision %s\n", XPP_VERSION);
#ifdef POLL_DIGITAL_INPUTS
INFO("FEATURE: with DIGITAL INPUTS support (polled every %d msec)\n",
@@ -1492,6 +1529,7 @@
static void __exit card_fxs_cleanup(void)
{
xproto_unregister(&PROTO_TABLE(FXS));
+ xpd_driver_unregister(&fxs_driver.driver);
}
MODULE_DESCRIPTION("XPP FXS Card Driver");
Modified: linux/trunk/drivers/dahdi/xpp/card_global.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_global.c?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_global.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_global.c Thu Oct 16 12:40:22 2008
@@ -40,6 +40,7 @@
/*---------------- 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;
@@ -51,6 +52,8 @@
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");
@@ -88,6 +91,7 @@
len = 0;
return len;
}
+#endif
static int parse_hexbyte(const char *buf)
{
@@ -289,7 +293,7 @@
return ret;
}
-static int parse_chip_command(xpd_t *xpd, char *cmdline)
+int parse_chip_command(xpd_t *xpd, char *cmdline)
{
xbus_t *xbus;
int ret = -EBADR;
@@ -303,8 +307,9 @@
BUG_ON(!xpd);
xbus = xpd->xbus;
- if(!XBUS_GET(xbus)) {
- XBUS_DBG(GENERAL, xbus, "Dropped packet. Is shutting down.\n");
+ if(XBUS_IS(xbus, DISCONNECTED)) {
+ XBUS_DBG(GENERAL, xbus, "Dropped packet. In state %s.\n",
+ xbus_statename(XBUS_STATE(xbus)));
return -EBUSY;
}
strlcpy(buf, cmdline, MAX_PROC_WRITE); /* Save a copy */
@@ -335,11 +340,10 @@
else
ret = 0; /* empty command - no op */
out:
- XBUS_PUT(xbus);
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;
@@ -350,6 +354,8 @@
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)
@@ -405,6 +411,7 @@
chip_proc_remove(xbus, xpd);
return -EINVAL;
}
+#endif
/*---------------- GLOBAL Protocol Commands -------------------------------*/
@@ -415,7 +422,7 @@
/* 0x07 */ HOSTCMD(GLOBAL, AB_REQUEST)
{
- int ret = 0;
+ int ret = -ENODEV;
xframe_t *xframe;
xpacket_t *pack;
@@ -427,7 +434,8 @@
RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, rev) = XPP_PROTOCOL_VERSION;
RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, reserved) = 0;
XBUS_DBG(DEVICES, xbus, "Protocol Version %d\n", XPP_PROTOCOL_VERSION);
- ret = send_cmd_frame(xbus, xframe);
+ if(xbus_setstate(xbus, XBUS_STATE_SENT_REQUEST))
+ ret = send_cmd_frame(xbus, xframe);
return ret;
}
@@ -587,6 +595,10 @@
if(count_units <= 0) {
XBUS_NOTICE(xbus, "Empty astribank? (%d units)\n",
count_units);
+ ret = -EPROTO;
+ goto proto_err;
+ }
+ if(!xbus_setstate(xbus, XBUS_STATE_RECVD_DESC)) {
ret = -EPROTO;
goto proto_err;
}
@@ -631,19 +643,8 @@
list_add_tail(&card_desc->card_list, &worker->card_list);
spin_unlock_irqrestore(&worker->worker_lock, flags);
}
- /* Initialize the work. (adapt to kernel API changes). */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
- INIT_WORK(&worker->xpds_init_work, xbus_populate);
-#else
- INIT_WORK(&worker->xpds_init_work, xbus_populate, worker);
-#endif
- xbus = get_xbus(xbus->num); /* released in xbus_populate() */
- BUG_ON(!xbus);
- /* Now send it */
- if(!queue_work(worker->wq, &worker->xpds_init_work)) {
- XBUS_ERR(xbus, "Failed to queue xpd initialization work\n");
+ if(!xbus_process_worker(xbus))
return -ENODEV;
- }
return 0;
proto_err:
dump_packet("AB_DESCRIPTION", pack, DBG_ANY);
@@ -762,12 +763,14 @@
int ret;
xbus_t *xbus;
char busstr[MAX_ENV_STR];
+ char busnumstr[MAX_ENV_STR];
char unitstr[MAX_ENV_STR];
char subunitsstr[MAX_ENV_STR];
char typestr[MAX_ENV_STR];
char directionstr[MAX_ENV_STR];
char revstr[MAX_ENV_STR];
char connectorstr[MAX_ENV_STR];
+ char xbuslabel[MAX_ENV_STR];
char init_card[MAX_PATH_STR];
byte direction_mask;
int i;
@@ -777,12 +780,14 @@
};
char *envp[] = {
busstr,
+ busnumstr,
unitstr,
subunitsstr,
typestr,
directionstr,
revstr,
connectorstr,
+ xbuslabel,
NULL
};
@@ -792,6 +797,10 @@
XPD_NOTICE(xpd, "Missing initdir parameter\n");
return -EINVAL;
}
+ if(!xpd_setstate(xpd, XPD_STATE_INIT_REGS)) {
+ ret = -EINVAL;
+ goto err;
+ }
direction_mask = 0;
for(i = 0; i < xpd->subunits; i++) {
xpd_t *su = xpd_byaddr(xbus, xpd->addr.unit, i);
@@ -805,21 +814,25 @@
direction_mask |= (su->direction == TO_PHONE) ? BIT(i) : 0;
}
snprintf(busstr, MAX_ENV_STR, "XBUS_NAME=%s", xbus->busname);
+ snprintf(busnumstr, MAX_ENV_STR, "XBUS_NUMBER=%d", xbus->num);
snprintf(unitstr, MAX_ENV_STR, "UNIT_NUMBER=%d", xpd->addr.unit);
snprintf(typestr, MAX_ENV_STR, "UNIT_TYPE=%d", xpd->type);
snprintf(subunitsstr, MAX_ENV_STR, "UNIT_SUBUNITS=%d", xpd->subunits);
snprintf(directionstr, MAX_ENV_STR, "UNIT_SUBUNITS_DIR=%d", direction_mask);
snprintf(revstr, MAX_ENV_STR, "XBUS_REVISION=%d", xbus->revision);
- snprintf(connectorstr, MAX_ENV_STR, "XBUS_CONNECTOR=%s", xbus->location);
- snprintf(connectorstr, MAX_ENV_STR, "XBUS_LABEL=%s", xbus->label);
+ snprintf(connectorstr, MAX_ENV_STR, "XBUS_CONNECTOR=%s", xbus->connector);
+ snprintf(xbuslabel, MAX_ENV_STR, "XBUS_LABEL=%s", xbus->label);
if(snprintf(init_card, MAX_PATH_STR, "%s/init_card_%d_%d",
initdir, xpd->type, xbus->revision) > MAX_PATH_STR) {
XPD_NOTICE(xpd, "Cannot initialize. pathname is longer than %d characters.\n", MAX_PATH_STR);
- return -E2BIG;
- }
- if(!XBUS_GET(xbus)) {
- XBUS_ERR(xbus, "Skipped register initialization. XBUS is going down\n");
- return -ENODEV;
+ ret = -E2BIG;
+ goto err;
+ }
+ if(!XBUS_IS(xbus, RECVD_DESC)) {
+ XBUS_ERR(xbus, "Skipped register initialization. In state %s.\n",
+ xbus_statename(XBUS_STATE(xbus)));
+ ret = -ENODEV;
+ goto err;
}
XPD_DBG(DEVICES, xpd, "running '%s' for type=%d revision=%d\n",
init_card, xpd->type, xbus->revision);
@@ -842,7 +855,7 @@
}
ret = -EINVAL;
}
- XBUS_PUT(xbus);
+err:
return ret;
}
Modified: linux/trunk/drivers/dahdi/xpp/card_global.h
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_global.h?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_global.h (original)
+++ linux/trunk/drivers/dahdi/xpp/card_global.h Thu Oct 16 12:40:22 2008
@@ -99,8 +99,10 @@
/* 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);
@@ -108,6 +110,7 @@
bool eoftx, byte *buf, unsigned len);
extern xproto_table_t PROTO_TABLE(GLOBAL);
int run_initialize_registers(xpd_t *xpd);
+int parse_chip_command(xpd_t *xpd, char *cmdline);
extern charp initdir;
#endif /* CARD_GLOBAL_H */
Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Thu Oct 16 12:40:22 2008
@@ -62,15 +62,19 @@
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);
static int pri_lineconfig(xpd_t *xpd, int lineconfig);
#define PROC_REGISTER_FNAME "slics"
+#ifdef OLD_PROC
#define PROC_PRI_INFO_FNAME "pri_info"
+#endif
enum pri_protocol {
PRI_PROTO_0 = 0,
@@ -104,7 +108,7 @@
static const char *type_name(enum pri_protocol pri_protocol)
{
static const char *names[4] = {
- [PRI_PROTO_0] = "Unknown",
+ [PRI_PROTO_0] = "PRI-Unknown",
[PRI_PROTO_E1] = "E1",
[PRI_PROTO_T1] = "T1",
[PRI_PROTO_J1] = "J1"
@@ -276,7 +280,9 @@
struct PRI_priv_data {
bool clock_source;
+#ifdef OLD_PROC
struct proc_dir_entry *pri_info;
+#endif
enum pri_protocol pri_protocol;
int deflaw;
unsigned int dchan_num;
@@ -373,6 +379,7 @@
);
}
+#ifdef OLD_PROC
static void pri_proc_remove(xbus_t *xbus, xpd_t *xpd)
{
struct PRI_priv_data *priv;
@@ -387,7 +394,9 @@
}
#endif
}
-
+#endif
+
+#ifdef OLD_PROC
static int pri_proc_create(xbus_t *xbus, xpd_t *xpd)
{
struct PRI_priv_data *priv;
@@ -412,6 +421,7 @@
pri_proc_remove(xbus, xpd);
return -EINVAL;
}
+#endif
static bool valid_pri_modes(const xpd_t *xpd)
{
@@ -570,7 +580,7 @@
int best_subunit_prio = 0;
int i;
- xbus = get_xbus(xpd->xbus->num);
+ xbus = xpd->xbus;
/* Find subunit with best timing priority */
for(i = 0; i < MAX_SLAVES; i++) {
struct PRI_priv_data *priv;
@@ -612,7 +622,6 @@
}
}
dahdi_update_syncsrc(xpd);
- put_xbus(xbus);
}
static void set_reg_lim0(const char *msg, xpd_t *xpd)
@@ -890,21 +899,20 @@
int channels = min(31, CHANNELS_PERXPD); /* worst case */
XBUS_DBG(GENERAL, xbus, "\n");
- xpd = xpd_alloc(sizeof(struct PRI_priv_data), proto_table, channels);
+ xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct PRI_priv_data), proto_table, channels);
if(!xpd)
return NULL;
priv = xpd->priv;
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);
- if(xpd_common_init(xbus, xpd, unit, subunit, subtype, subunits) < 0)
- goto err;
- if(pri_proc_create(xbus, xpd) < 0)
- goto err;
+#ifdef OLD_PROC
+ if(pri_proc_create(xbus, xpd) < 0) {
+ xpd_free(xpd);
+ return NULL;
+ }
+#endif
return xpd;
-err:
- xpd_free(xpd);
- return NULL;
}
static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
@@ -948,7 +956,9 @@
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;
}
@@ -960,7 +970,9 @@
BUG_ON(!xpd);
priv = xpd->priv;
XPD_DBG(GENERAL, xpd, "\n");
+#ifdef OLD_PROC
pri_proc_remove(xbus, xpd);
+#endif
return 0;
}
@@ -1164,7 +1176,7 @@
static int PRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg)
{
BUG_ON(!xpd);
- if(!TRANSPORT_RUNNING(xpd->xbus))
+ if(!XBUS_IS(xpd->xbus, READY))
return -ENODEV;
switch (cmd) {
case DAHDI_TONEDETECT:
@@ -1199,7 +1211,7 @@
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(!TRANSPORT_RUNNING(xpd->xbus)) {
+ if(!XBUS_IS(xpd->xbus, READY)) {
XPD_DBG(GENERAL, xpd, "Startup called by dahdi. No Hardware. Ignored\n");
return -ENODEV;
}
@@ -1220,7 +1232,7 @@
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(!TRANSPORT_RUNNING(xpd->xbus)) {
+ if(!XBUS_IS(xpd->xbus, READY)) {
XPD_DBG(GENERAL, xpd, "Shutdown called by dahdi. No Hardware. Ignored\n");
return -ENODEV;
}
@@ -1631,6 +1643,7 @@
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;
@@ -1647,6 +1660,8 @@
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);
@@ -1711,6 +1726,8 @@
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);
@@ -1773,11 +1790,366 @@
len = 0;
return len;
}
+#endif
+
+/*------------------------- sysfs stuff --------------------------------*/
+static DEVICE_ATTR_READER(pri_protocol_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ len += sprintf(buf, "%s\n", pri_protocol_name(priv->pri_protocol));
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR_WRITER(pri_protocol_store, dev, buf, count)
+{
+ xpd_t *xpd;
+ enum pri_protocol new_protocol = PRI_PROTO_0;
+ int i;
+ int ret;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(GENERAL, xpd, "%s\n", buf);
+ if(!xpd)
+ return -ENODEV;
+ if((i = strcspn(buf, " \r\n")) != 2) {
+ XPD_NOTICE(xpd,
+ "Protocol name '%s' has %d characters (should be 2). Ignored.\n",
+ buf, i);
+ return -EINVAL;
+ }
+ if(strnicmp(buf, "E1", 2) == 0)
+ new_protocol = PRI_PROTO_E1;
+ else if(strnicmp(buf, "T1", 2) == 0)
+ new_protocol = PRI_PROTO_T1;
+ else if(strnicmp(buf, "J1", 2) == 0)
+ new_protocol = PRI_PROTO_J1;
+ else {
+ XPD_NOTICE(xpd,
+ "Unknown PRI protocol '%s' (should be E1|T1|J1). Ignored.\n",
+ buf);
+ return -EINVAL;
+ }
+ ret = set_pri_proto(xpd, new_protocol);
+ return (ret < 0) ? ret : count;
+}
+
+static DEVICE_ATTR(pri_protocol, S_IRUGO | S_IWUSR, pri_protocol_show, pri_protocol_store);
+
+static DEVICE_ATTR_READER(pri_localloop_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ len += sprintf(buf, "%c\n",
+ (priv->local_loopback) ? 'Y' : 'N');
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR_WRITER(pri_localloop_store, dev, buf, count)
+{
+ xpd_t *xpd;
+ bool ll = 0;
+ int i;
+ int ret;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(GENERAL, xpd, "%s\n", buf);
+ if(!xpd)
+ return -ENODEV;
+ if((i = strcspn(buf, " \r\n")) != 1) {
+ XPD_NOTICE(xpd,
+ "Value '%s' has %d characters (should be 1). Ignored.\n",
+ buf, i);
+ return -EINVAL;
+ }
+ if(strchr("1Yy", buf[0]) != NULL)
+ ll = 1;
+ else if(strchr("0Nn", buf[0]) != NULL)
+ ll = 0;
+ else {
+ XPD_NOTICE(xpd,
+ "Unknown value '%s' (should be [1Yy]|[0Nn]). Ignored.\n",
+ buf);
+ return -EINVAL;
+ }
+ ret = set_localloop(xpd, ll);
+ return (ret < 0) ? ret : count;
+}
+
+static DEVICE_ATTR(pri_localloop, S_IRUGO | S_IWUSR, pri_localloop_show, pri_localloop_store);
+
+static DEVICE_ATTR_READER(pri_layer1_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ if(priv->poll_noreplies > 1)
+ len += sprintf(buf + len, "Unknown[%d]", priv->poll_noreplies);
+ else
+ len += sprintf(buf + len, "%-10s", ((priv->layer1_up) ? "UP" : "DOWN"));
+ len += sprintf(buf + len, "%d\n", priv->layer1_replies);
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(pri_layer1, S_IRUGO, pri_layer1_show, NULL);
+
+static DEVICE_ATTR_READER(pri_alarms_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+ const static struct {
+ byte bits;
+ const char *name;
+ } alarm_types[] = {
+ { REG_FRS0_LOS, "RED" },
+ { REG_FRS0_AIS, "BLUE" },
+ { REG_FRS0_RRA, "YELLOW" },
+ };
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ if(priv->poll_noreplies > 1)
+ len += sprintf(buf + len, "Unknown[%d]", priv->poll_noreplies);
+ else {
+ int i;
+
+ for(i = 0; i < ARRAY_SIZE(alarm_types); i++) {
+ if(priv->reg_frs0 & alarm_types[i].bits)
+ len += sprintf(buf + len, "%s ", alarm_types[i].name);
+ }
+ }
+ len += sprintf(buf + len, "\n");
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(pri_alarms, S_IRUGO, pri_alarms_show, NULL);
+
+static DEVICE_ATTR_READER(pri_cas_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ if(priv->is_cas) {
+ int i;
+
+ len += sprintf(buf + len,
+ "CAS: replies=%d\n", priv->cas_replies);
+ len += sprintf(buf + len, " CAS-TS: ");
+ for(i = 0; i < NUM_CAS_RS; i++) {
+ len += sprintf(buf + len, " %02X", priv->cas_ts_e[i]);
+ }
+ len += sprintf(buf + len, "\n");
+ len += sprintf(buf + len, " CAS-RS: ");
+ for(i = 0; i < NUM_CAS_RS; i++) {
+ len += sprintf(buf + len, " %02X", priv->cas_rs_e[i]);
+ }
+ len += sprintf(buf + len, "\n");
+ }
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(pri_cas, S_IRUGO, pri_cas_show, NULL);
+
+static DEVICE_ATTR_READER(pri_dchan_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ len += sprintf(buf + 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(buf + len, "(alive %d K-ticks)\n",
+ priv->dchan_alive_ticks/1000);
+ } else {
+ len += sprintf(buf + len, "(dead)\n");
+ }
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(pri_dchan, S_IRUGO, pri_dchan_show, NULL);
+
+static DEVICE_ATTR_READER(pri_clocking_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct PRI_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ len += sprintf(buf + len, "%s\n", (priv->clock_source) ? "MASTER" : "SLAVE");
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(pri_clocking, S_IRUGO, pri_clocking_show, NULL);
+
+
+static int pri_xpd_probe(struct device *dev)
+{
+ xpd_t *xpd;
+ int ret = 0;
+
+ xpd = dev_to_xpd(dev);
+ /* Is it our device? */
+ if(xpd->type != XPD_TYPE_PRI) {
+ XPD_ERR(xpd, "drop suggestion for %s (%d)\n",
+ dev->bus_id, xpd->type);
+ return -EINVAL;
+ }
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ ret = device_create_file(dev, &dev_attr_pri_protocol);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_protocol) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_protocol;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_localloop);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_localloop) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_localloop;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_layer1);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_layer1) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_layer1;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_alarms);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_alarms) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_alarms;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_cas);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_cas) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_cas;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_dchan);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_dchan) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_dchan;
+ }
+ ret = device_create_file(dev, &dev_attr_pri_clocking);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(pri_clocking) failed: %d\n", __FUNCTION__, ret);
+ goto fail_pri_clocking;
+ }
+ return 0;
+fail_pri_clocking:
+ device_remove_file(dev, &dev_attr_pri_dchan);
+fail_pri_dchan:
+ device_remove_file(dev, &dev_attr_pri_cas);
+fail_pri_cas:
+ device_remove_file(dev, &dev_attr_pri_alarms);
+fail_pri_alarms:
+ device_remove_file(dev, &dev_attr_pri_layer1);
+fail_pri_layer1:
+ device_remove_file(dev, &dev_attr_pri_localloop);
+fail_pri_localloop:
+ device_remove_file(dev, &dev_attr_pri_protocol);
+fail_pri_protocol:
+ return ret;
+}
+
+static int pri_xpd_remove(struct device *dev)
+{
+ xpd_t *xpd;
+
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ device_remove_file(dev, &dev_attr_pri_clocking);
+ device_remove_file(dev, &dev_attr_pri_dchan);
+ device_remove_file(dev, &dev_attr_pri_cas);
+ device_remove_file(dev, &dev_attr_pri_alarms);
+ device_remove_file(dev, &dev_attr_pri_layer1);
+ device_remove_file(dev, &dev_attr_pri_localloop);
+ device_remove_file(dev, &dev_attr_pri_protocol);
+ return 0;
+}
+
+static struct xpd_driver pri_driver = {
+ .type = XPD_TYPE_PRI,
+ .driver = {
+ .name = "pri",
+ .owner = THIS_MODULE,
+ .probe = pri_xpd_probe,
+ .remove = pri_xpd_remove
+ }
+};
static int __init card_pri_startup(void)
{
- DBG(GENERAL, "\n");
-
+ int ret;
+
+ if((ret = xpd_driver_register(&pri_driver.driver)) < 0)
+ return ret;
INFO("revision %s\n", XPP_VERSION);
xproto_register(&PROTO_TABLE(PRI));
return 0;
@@ -1787,6 +2159,7 @@
{
DBG(GENERAL, "\n");
xproto_unregister(&PROTO_TABLE(PRI));
+ xpd_driver_unregister(&pri_driver.driver);
}
MODULE_DESCRIPTION("XPP PRI Card Driver");
Modified: linux/trunk/drivers/dahdi/xpp/init_card_1_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_1_30?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_1_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_1_30 Thu Oct 16 12:40:22 2008
@@ -1,5 +1,8 @@
#! /usr/bin/perl -w
use strict;
+
+# Make warnings fatal
+local $SIG{__WARN__} = sub { die @_ };
#
# Written by Oron Peled <oron at actcom.co.il>
@@ -48,16 +51,13 @@
use XppConfig $init_dir;
my $unit_id;
my %opts;
-$ENV{XPP_BASE} = '/proc/xpp';
getopts('o:', \%opts);
my %settings;
$settings{debug} = 0;
$settings{fxs_skip_calib} = 0;
-
-my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER});
-my $chipregs = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/chipregs";
+my $chipregs;
sub logit {
print STDERR "$unit_id: @_\n";
@@ -70,11 +70,34 @@
# Arrange for error logging
if (-t STDERR) {
$unit_id = 'Interactive';
- logit "Interactive startup";
+ main::debug "Interactive startup";
} else {
$unit_id = "$ENV{XBUS_NAME}/UNIT-$ENV{UNIT_NUMBER}";
open (STDERR, "| logger -t $program -p kern.info") || die;
- logit "Non Interactive startup";
+ main::debug "Non Interactive startup";
+ foreach my $k (qw(
+ XBUS_NAME
+ XBUS_NUMBER
+ UNIT_NUMBER
+ UNIT_TYPE
+ UNIT_SUBUNITS
+ UNIT_SUBUNITS_DIR
+ XBUS_REVISION
+ XBUS_CONNECTOR
+ XBUS_LABEL)) {
+ unless(defined $ENV{$k}) {
+ logit "Missing ENV{$k}\n";
+ die;
+ }
+ }
+ $chipregs = sprintf "/sys/bus/xpds/devices/%02d:%1d:0/chipregs",
+ $ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER};
+ if(! -f $chipregs) {
+ my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER});
+ $chipregs = "/proc/xpp/$ENV{XBUS_NAME}/$xpd_name/chipregs";
+ logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc"
+ if -f $chipregs;
+ }
}
sub set_output() {
@@ -88,7 +111,7 @@
}
open(REG, ">$output") || die "Failed to open '$output': $!\n";
my $oldfh = select REG;
- print "# Setting output\n" if $opts{o};
+ main::logit "# Setting output" if $opts{o};
return $oldfh;
}
Modified: linux/trunk/drivers/dahdi/xpp/init_card_2_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_2_30?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_2_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_2_30 Thu Oct 16 12:40:22 2008
@@ -1,5 +1,8 @@
#! /usr/bin/perl -w
use strict;
+
+# Make warnings fatal
+local $SIG{__WARN__} = sub { die @_ };
#
# Written by Oron Peled <oron at actcom.co.il>
@@ -48,14 +51,11 @@
use XppConfig $init_dir;
my $unit_id;
my %opts;
-$ENV{XPP_BASE} = '/proc/xpp';
getopts('o:v:', \%opts);
my %settings;
$settings{debug} = 0;
-
-my $xpd_name;
my $chipregs;
sub logit {
@@ -72,10 +72,31 @@
main::debug "Interactive startup";
} else {
$unit_id = "$ENV{XBUS_NAME}/UNIT-$ENV{UNIT_NUMBER}";
- $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER});
- $chipregs = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/chipregs";
open (STDERR, "| logger -t $program -p kern.info") || die;
main::debug "Non Interactive startup";
+ foreach my $k (qw(
+ XBUS_NAME
+ XBUS_NUMBER
+ UNIT_NUMBER
+ UNIT_TYPE
+ UNIT_SUBUNITS
+ UNIT_SUBUNITS_DIR
+ XBUS_REVISION
+ XBUS_CONNECTOR
+ XBUS_LABEL)) {
+ unless(defined $ENV{$k}) {
+ logit "Missing ENV{$k}\n";
+ die;
+ }
+ }
+ $chipregs = sprintf "/sys/bus/xpds/devices/%02d:%1d:0/chipregs",
+ $ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER};
+ if(! -f $chipregs) {
+ my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER});
+ $chipregs = "/proc/xpp/$ENV{XBUS_NAME}/$xpd_name/chipregs";
+ logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc"
+ if -f $chipregs;
+ }
}
sub set_output() {
Modified: linux/trunk/drivers/dahdi/xpp/init_card_3_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_3_30?view=diff&rev=5097&r1=5096&r2=5097
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_3_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_3_30 Thu Oct 16 12:40:22 2008
@@ -1,5 +1,8 @@
#! /usr/bin/perl -w
use strict;
+
+# Make warnings fatal
+local $SIG{__WARN__} = sub { die @_ };
#
# $Id$
@@ -61,7 +64,6 @@
use XppConfig $init_dir;
my $unit_id;
my %opts;
-$ENV{XPP_BASE} = '/proc/xpp';
getopts('o:', \%opts);
@@ -77,6 +79,21 @@
$unit_id = "$ENV{XBUS_NAME}/UNIT-$ENV{UNIT_NUMBER}";
open (STDERR, "| logger -t $program -p kern.info") || die;
logit "Non Interactive startup";
+ foreach my $k (qw(
+ XBUS_NAME
+ XBUS_NUMBER
+ UNIT_NUMBER
+ UNIT_TYPE
+ UNIT_SUBUNITS
+ UNIT_SUBUNITS_DIR
+ XBUS_REVISION
+ XBUS_CONNECTOR
+ XBUS_LABEL)) {
+ unless(defined $ENV{$k}) {
+ logit "Missing ENV{$k}\n";
+ die;
+ }
+ }
}
sub select_subunit($) {
@@ -87,8 +104,14 @@
if($opts{o}) {
$output = $opts{o};
} else {
- my $xpd_name = sprintf("XPD-%1d%1d", $ENV{UNIT_NUMBER}, $subunit);
[... 3577 lines stripped ...]
More information about the svn-commits
mailing list