summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/xpp_dahdi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dahdi/xpp/xpp_dahdi.c')
-rw-r--r--drivers/dahdi/xpp/xpp_dahdi.c25
1 files changed, 20 insertions, 5 deletions
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;
}