diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2020-02-07 15:13:58 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-02-10 10:25:06 -0800 |
commit | e3b7ce73c578b77b592bd3f2da71b90f2c581c87 (patch) | |
tree | 7f385ab37de29e7582acc9af7a1ef4c29adfdf78 | |
parent | 075a329591540affcc32af0da09abd54549e1659 (diff) |
staging: comedi: ni_routes: Allow alternate board name for routes
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@delmic.com>
Cc: Spencer E. Olson <olsonse@umich.edu>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20200207151400.272678-3-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/ni_660x.c | 2 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_mio_common.c | 2 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_routes.c | 21 | ||||
-rw-r--r-- | 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); /* |