Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
e3b7ce73 075a3295

+22 -4
+1 -1
drivers/staging/comedi/drivers/ni_660x.c
··· 1035 1035 ni_660x_init_tio_chips(dev, board->n_chips); 1036 1036 1037 1037 /* prepare the device for globally-named routes. */ 1038 - if (ni_assign_device_routes("ni_660x", board->name, 1038 + if (ni_assign_device_routes("ni_660x", board->name, NULL, 1039 1039 &devpriv->routing_tables) < 0) { 1040 1040 dev_warn(dev->class_dev, "%s: %s device has no signal routing table.\n", 1041 1041 __func__, board->name);
+1 -1
drivers/staging/comedi/drivers/ni_mio_common.c
··· 5974 5974 : "ni_eseries"; 5975 5975 5976 5976 /* prepare the device for globally-named routes. */ 5977 - if (ni_assign_device_routes(dev_family, board->name, 5977 + if (ni_assign_device_routes(dev_family, board->name, NULL, 5978 5978 &devpriv->routing_tables) < 0) { 5979 5979 dev_warn(dev->class_dev, "%s: %s device has no signal routing table.\n", 5980 5980 __func__, board->name);
+19 -2
drivers/staging/comedi/drivers/ni_routes.c
··· 88 88 89 89 /* 90 90 * Find the proper route_values and ni_device_routes tables for this particular 91 - * device. 91 + * device. Possibly try an alternate board name if device routes not found 92 + * for the actual board name. 92 93 * 93 94 * Return: -ENODATA if either was not found; 0 if both were found. 94 95 */ 95 96 static int ni_find_device_routes(const char *device_family, 96 97 const char *board_name, 98 + const char *alt_board_name, 97 99 struct ni_route_tables *tables) 98 100 { 99 101 const struct ni_device_routes *dr; ··· 106 104 107 105 /* Second, find the set of routes valid for this device. */ 108 106 dr = ni_find_valid_routes(board_name); 107 + if (!dr && alt_board_name) 108 + dr = ni_find_valid_routes(alt_board_name); 109 109 110 110 tables->route_values = rv; 111 111 tables->valid_routes = dr; ··· 121 117 /** 122 118 * ni_assign_device_routes() - Assign the proper lookup table for NI signal 123 119 * routing to the specified NI device. 120 + * @device_family: Device family name (determines route values). 121 + * @board_name: Board name (determines set of routes). 122 + * @alt_board_name: Optional alternate board name to try on failure. 123 + * @tables: Pointer to assigned routing information. 124 + * 125 + * Finds the route values for the device family and the set of valid routes 126 + * for the board. If valid routes could not be found for the actual board 127 + * name and an alternate board name has been specified, try that one. 128 + * 129 + * On failure, the assigned routing information may be partially filled 130 + * (for example, with the route values but not the set of valid routes). 124 131 * 125 132 * Return: -ENODATA if assignment was not successful; 0 if successful. 126 133 */ 127 134 int ni_assign_device_routes(const char *device_family, 128 135 const char *board_name, 136 + const char *alt_board_name, 129 137 struct ni_route_tables *tables) 130 138 { 131 139 memset(tables, 0, sizeof(struct ni_route_tables)); 132 - return ni_find_device_routes(device_family, board_name, tables); 140 + return ni_find_device_routes(device_family, board_name, alt_board_name, 141 + tables); 133 142 } 134 143 EXPORT_SYMBOL_GPL(ni_assign_device_routes); 135 144
+1
drivers/staging/comedi/drivers/ni_routes.h
··· 76 76 */ 77 77 int ni_assign_device_routes(const char *device_family, 78 78 const char *board_name, 79 + const char *alt_board_name, 79 80 struct ni_route_tables *tables); 80 81 81 82 /*