summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2010-11-17 12:09:10 -0600
committerShaun Ruffell <sruffell@digium.com>2011-04-15 14:21:13 -0500
commitb3c86b81ae638d90ee27a821e962e297ab85cbe4 (patch)
treec70e2c6b0e74c5bc3a20e6c597df1f9fbc7ca891 /drivers/dahdi/xpp
parent9c8aa9db7eca1c91bd37bd5b55add0cee40d7cd9 (diff)
dahdi: register/unregister devices as opposed to individual spans.
Increasingly, spans are implemented by devices that support more than a single span. Introduce a 'struct dahdi_device' object which explicitly contains multiple spans. This will also allow a cleaner representation of spans and devices in sysfs since order of arrival will not determine the layout of the devices. This also gives the core of dahdi a way to know the relationship between spans. Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Diffstat (limited to 'drivers/dahdi/xpp')
-rw-r--r--drivers/dahdi/xpp/card_pri.c2
-rw-r--r--drivers/dahdi/xpp/xpd.h1
-rw-r--r--drivers/dahdi/xpp/xpp_dahdi.c25
3 files changed, 22 insertions, 6 deletions
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index c283cbe..6780621 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -1855,7 +1855,7 @@ static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
spin_unlock_irqrestore(&xpd->lock, flags);
}
-int PRI_timing_priority(xpd_t *xpd)
+static int PRI_timing_priority(xpd_t *xpd)
{
struct PRI_priv_data *priv;
diff --git a/drivers/dahdi/xpp/xpd.h b/drivers/dahdi/xpp/xpd.h
index 2d4b6eb..66ba88c 100644
--- a/drivers/dahdi/xpp/xpd.h
+++ b/drivers/dahdi/xpp/xpd.h
@@ -154,6 +154,7 @@ const char *xpd_statename(enum xpd_state st);
struct phonedev {
const struct phoneops *phoneops; /* Card level operations */
+ struct dahdi_device *ddev;
struct dahdi_span span;
struct dahdi_chan *chans[32];
#define XPD_CHAN(xpd,chan) (PHONEDEV(xpd).chans[(chan)])
diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index 5a27f45..99fb62d 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -513,6 +513,7 @@ static void phonedev_cleanup(xpd_t *xpd)
KZFREE(phonedev->chans[x]);
}
}
+ dahdi_free_device(phonedev->ddev);
}
__must_check static int phonedev_init(xpd_t *xpd, const xproto_table_t *proto_table,
@@ -1086,7 +1087,7 @@ int dahdi_unregister_xpd(xpd_t *xpd)
CALL_PHONE_METHOD(card_dahdi_preregistration, xpd, 0);
atomic_dec(&PHONEDEV(xpd).dahdi_registered);
atomic_dec(&num_registered_spans);
- dahdi_unregister(&PHONEDEV(xpd).span);
+ dahdi_unregister_device(PHONEDEV(xpd).ddev);
if(xpd->card_present)
CALL_PHONE_METHOD(card_dahdi_postregistration, xpd, 0);
return 0;
@@ -1115,6 +1116,7 @@ int dahdi_register_xpd(xpd_t *xpd)
xbus_t *xbus;
int cn;
int i;
+ struct phonedev *phonedev;
BUG_ON(!xpd);
@@ -1124,10 +1126,16 @@ int dahdi_register_xpd(xpd_t *xpd)
XPD_ERR(xpd, "Not a telephony device\n");
return -EBADF;
}
+
+ phonedev = &PHONEDEV(xpd);
+
if (SPAN_REGISTERED(xpd)) {
XPD_ERR(xpd, "Already registered\n");
return -EEXIST;
}
+
+ phonedev->ddev = dahdi_create_device();
+
cn = PHONEDEV(xpd).channels;
XPD_DBG(DEVICES, xpd, "Initializing span: %d channels.\n", cn);
memset(&PHONEDEV(xpd).span, 0, sizeof(struct dahdi_span));
@@ -1152,7 +1160,7 @@ int dahdi_register_xpd(xpd_t *xpd)
* A bunch of unrelated data exported via a modified ioctl()
* What a bummer...
*/
- span->manufacturer = "Xorcom Inc."; /* OK, that's obvious */
+ phonedev->ddev->manufacturer = "Xorcom Inc."; /* OK, that's obvious */
/* span->spantype = "...."; set in card_dahdi_preregistration() */
/*
* Yes, this basically duplicates information available
@@ -1160,10 +1168,14 @@ int dahdi_register_xpd(xpd_t *xpd)
* why not add it there?
* OK, let's add to the kernel more useless info.
*/
- snprintf(span->devicetype, sizeof(span->devicetype) - 1,
+ phonedev->ddev->devicetype = kasprintf(GFP_KERNEL,
"Astribank: Unit %x Subunit %x: %s",
XBUS_UNIT(xpd->xbus_idx), XBUS_SUBUNIT(xpd->xbus_idx),
xpd->type_name);
+
+ if (!phonedev->ddev->devicetype)
+ return -ENOMEM;
+
/*
* location is the only usefull new data item.
* For our devices it was available for ages via:
@@ -1172,7 +1184,8 @@ int dahdi_register_xpd(xpd_t *xpd)
* - The modern "/sys/bus/astribanks/devices/xbus-??/connector" attribute
* So let's also export it via the newfangled "location" field.
*/
- snprintf(span->location, sizeof(span->location) - 1, "%s", xbus->connector);
+ phonedev->ddev->location = xbus->connector;
+
/*
* Who said a span and irq have 1-1 relationship?
* Also exporting this low-level detail isn't too wise.
@@ -1184,7 +1197,9 @@ int dahdi_register_xpd(xpd_t *xpd)
xbus->num, xpd->addr.unit, xpd->addr.subunit, xpd->type_name);
XPD_DBG(GENERAL, xpd, "Registering span '%s'\n", PHONEDEV(xpd).span.desc);
CALL_PHONE_METHOD(card_dahdi_preregistration, xpd, 1);
- if(dahdi_register(&PHONEDEV(xpd).span, prefmaster)) {
+ list_add_tail(&span->device_node, &phonedev->ddev->spans);
+
+ if (dahdi_register_device(phonedev->ddev, &xpd->xpd_dev)) {
XPD_ERR(xpd, "Failed to dahdi_register span\n");
return -ENODEV;
}