From 5b9f520e78181ea59cb75dbb1f7c9a3201a2d92e Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Sun, 2 Apr 2017 18:03:03 +0300 Subject: [PATCH] xpp: re-add setting xpd->subunits The number of subunits per XPD (which is not trivial in BRI) has been accidentally left out in a previous commit. Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/xbus-core.c | 13 ++++++++++--- drivers/dahdi/xpp/xbus-core.h | 2 ++ drivers/dahdi/xpp/xpp_dahdi.c | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index 5b9e32a..f98a2b9 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -719,6 +719,15 @@ static xpd_type_t xpd_hw2xpd_type(const struct unit_descriptor *unit_descriptor) return xpd_type; } +int subunits_of_xpd(const struct unit_descriptor* unit_descriptor, + const xproto_table_t *proto_table) { + int ports = unit_descriptor->ports_per_chip * unit_descriptor->numchips; + + return + (ports + proto_table->ports_per_subunit - 1) + / proto_table->ports_per_subunit; +} + static int new_card(xbus_t *xbus, const struct unit_descriptor *unit_descriptor) { int unit = unit_descriptor->addr.unit; @@ -764,9 +773,7 @@ static int new_card(xbus_t *xbus, const struct unit_descriptor *unit_descriptor) xbus->echo_state.xpd_idx = XPD_IDX(unit, 0); } remaining_ports = ports; - subunits = - (ports + proto_table->ports_per_subunit - - 1) / proto_table->ports_per_subunit; + subunits = subunits_of_xpd(unit_descriptor, proto_table); XBUS_DBG(DEVICES, xbus, "CARD %d xpd_type=%d/hw_type=%d ports=%d (%dx%d), " "%d subunits, port-dir=0x%02X\n", diff --git a/drivers/dahdi/xpp/xbus-core.h b/drivers/dahdi/xpp/xbus-core.h index fbc0f94..26c0ba7 100644 --- a/drivers/dahdi/xpp/xbus-core.h +++ b/drivers/dahdi/xpp/xbus-core.h @@ -338,6 +338,8 @@ int waitfor_xpds(xbus_t *xbus, char *buf); int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit); int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd); +int subunits_of_xpd(const struct unit_descriptor* unit_descriptor, + const xproto_table_t *proto_table); /* sysfs */ int xpd_device_register(xbus_t *xbus, xpd_t *xpd); void xpd_device_unregister(xpd_t *xpd); diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index 03fb7e6..c58d720 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -572,6 +572,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, xpd->unit_descriptor = *unit_descriptor; xpd->xops = proto_table->xops; xpd->xpd_state = XPD_STATE_START; + xpd->subunits = subunits_of_xpd(unit_descriptor, proto_table); kref_init(&xpd->kref); /* For USB-1 disable some channels */