We do not have or provide routing information available for all supported boards. Some of the boards for which we do not currently provide routing information actually have identical routes to a similar board for which we do provide routing information. To avoid having to provide duplicate routing information, add an "alternate board name" parameter (possibly `NULl`) to `ni_assign_device_routes()` and `ni_find_device_routes()`. If the routing information cannot be found for the actual board name, try finding it using the alternate board name. Cc: Éric Piel <piel@xxxxxxxxxx> Cc: Spencer E. Olson <olsonse@xxxxxxxxx> Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx> --- drivers/staging/comedi/drivers/ni_660x.c | 2 +- .../staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_routes.c | 21 +++++++++++++++++-- drivers/staging/comedi/drivers/ni_routes.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 4ee9b260eab0..75d5c9c24596 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -1035,7 +1035,7 @@ static int ni_660x_auto_attach(struct comedi_device *dev, ni_660x_init_tio_chips(dev, board->n_chips); /* prepare the device for globally-named routes. */ - if (ni_assign_device_routes("ni_660x", board->name, + if (ni_assign_device_routes("ni_660x", board->name, NULL, &devpriv->routing_tables) < 0) { dev_warn(dev->class_dev, "%s: %s device has no signal routing table.\n", __func__, board->name); diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index f98e3ae27bff..a1578868ee96 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -5974,7 +5974,7 @@ static int ni_E_init(struct comedi_device *dev, : "ni_eseries"; /* prepare the device for globally-named routes. */ - if (ni_assign_device_routes(dev_family, board->name, + if (ni_assign_device_routes(dev_family, board->name, NULL, &devpriv->routing_tables) < 0) { dev_warn(dev->class_dev, "%s: %s device has no signal routing table.\n", __func__, board->name); diff --git a/drivers/staging/comedi/drivers/ni_routes.c b/drivers/staging/comedi/drivers/ni_routes.c index 508f76c5c574..07cb970340db 100644 --- a/drivers/staging/comedi/drivers/ni_routes.c +++ b/drivers/staging/comedi/drivers/ni_routes.c @@ -88,12 +88,14 @@ ni_find_valid_routes(const char *board_name) /* * Find the proper route_values and ni_device_routes tables for this particular - * device. + * device. Possibly try an alternate board name if device routes not found + * for the actual board name. * * Return: -ENODATA if either was not found; 0 if both were found. */ static int ni_find_device_routes(const char *device_family, const char *board_name, + const char *alt_board_name, struct ni_route_tables *tables) { const struct ni_device_routes *dr; @@ -104,6 +106,8 @@ static int ni_find_device_routes(const char *device_family, /* Second, find the set of routes valid for this device. */ dr = ni_find_valid_routes(board_name); + if (!dr && alt_board_name) + dr = ni_find_valid_routes(alt_board_name); tables->route_values = rv; tables->valid_routes = dr; @@ -117,15 +121,28 @@ static int ni_find_device_routes(const char *device_family, /** * ni_assign_device_routes() - Assign the proper lookup table for NI signal * routing to the specified NI device. + * @device_family: Device family name (determines route values). + * @board_name: Board name (determines set of routes). + * @alt_board_name: Optional alternate board name to try on failure. + * @tables: Pointer to assigned routing information. + * + * Finds the route values for the device family and the set of valid routes + * for the board. If valid routes could not be found for the actual board + * name and an alternate board name has been specified, try that one. + * + * On failure, the assigned routing information may be partially filled + * (for example, with the route values but not the set of valid routes). * * Return: -ENODATA if assignment was not successful; 0 if successful. */ int ni_assign_device_routes(const char *device_family, const char *board_name, + const char *alt_board_name, struct ni_route_tables *tables) { memset(tables, 0, sizeof(struct ni_route_tables)); - return ni_find_device_routes(device_family, board_name, tables); + return ni_find_device_routes(device_family, board_name, alt_board_name, + tables); } EXPORT_SYMBOL_GPL(ni_assign_device_routes); diff --git a/drivers/staging/comedi/drivers/ni_routes.h b/drivers/staging/comedi/drivers/ni_routes.h index 3211a16adc6f..b7680fd2afe1 100644 --- a/drivers/staging/comedi/drivers/ni_routes.h +++ b/drivers/staging/comedi/drivers/ni_routes.h @@ -76,6 +76,7 @@ struct ni_route_tables { */ int ni_assign_device_routes(const char *device_family, const char *board_name, + const char *alt_board_name, struct ni_route_tables *tables); /* -- 2.24.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel