mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-15 11:26:36 +07:00
staging: comedi: ni_routes: Refactor ni_find_valid_routes()
Split out the loops in `ni_find_valid_routes()` into separate functions: * ni_find_route_values(device_family) to find the list of route values for a device family (e.g "ni-mseries"); and * ni_find_valid_routes(board_name) to find the set of valid routes for a board name. The functions above return `NULL` if the information is not found (as we do not currently have the routing information available for all supported boards). 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-2-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0e3ee7f10a
commit
075a329591
@ -49,6 +49,43 @@
|
|||||||
/* Helper for accessing data. */
|
/* Helper for accessing data. */
|
||||||
#define RVi(table, src, dest) ((table)[(dest) * NI_NUM_NAMES + (src)])
|
#define RVi(table, src, dest) ((table)[(dest) * NI_NUM_NAMES + (src)])
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the route values for a device family.
|
||||||
|
*/
|
||||||
|
static const u8 *ni_find_route_values(const char *device_family)
|
||||||
|
{
|
||||||
|
const u8 *rv = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; ni_all_route_values[i]; ++i) {
|
||||||
|
if (memcmp(ni_all_route_values[i]->family, device_family,
|
||||||
|
strnlen(device_family, 30)) == 0) {
|
||||||
|
rv = &ni_all_route_values[i]->register_values[0][0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the valid routes for a board.
|
||||||
|
*/
|
||||||
|
static const struct ni_device_routes *
|
||||||
|
ni_find_valid_routes(const char *board_name)
|
||||||
|
{
|
||||||
|
const struct ni_device_routes *dr = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; ni_device_routes_list[i]; ++i) {
|
||||||
|
if (memcmp(ni_device_routes_list[i]->device, board_name,
|
||||||
|
strnlen(board_name, 30)) == 0) {
|
||||||
|
dr = ni_device_routes_list[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dr;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the proper route_values and ni_device_routes tables for this particular
|
* Find the proper route_values and ni_device_routes tables for this particular
|
||||||
* device.
|
* device.
|
||||||
@ -59,27 +96,14 @@ static int ni_find_device_routes(const char *device_family,
|
|||||||
const char *board_name,
|
const char *board_name,
|
||||||
struct ni_route_tables *tables)
|
struct ni_route_tables *tables)
|
||||||
{
|
{
|
||||||
const struct ni_device_routes *dr = NULL;
|
const struct ni_device_routes *dr;
|
||||||
const u8 *rv = NULL;
|
const u8 *rv;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* First, find the register_values table for this device family */
|
/* First, find the register_values table for this device family */
|
||||||
for (i = 0; ni_all_route_values[i]; ++i) {
|
rv = ni_find_route_values(device_family);
|
||||||
if (memcmp(ni_all_route_values[i]->family, device_family,
|
|
||||||
strnlen(device_family, 30)) == 0) {
|
|
||||||
rv = &ni_all_route_values[i]->register_values[0][0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Second, find the set of routes valid for this device. */
|
/* Second, find the set of routes valid for this device. */
|
||||||
for (i = 0; ni_device_routes_list[i]; ++i) {
|
dr = ni_find_valid_routes(board_name);
|
||||||
if (memcmp(ni_device_routes_list[i]->device, board_name,
|
|
||||||
strnlen(board_name, 30)) == 0) {
|
|
||||||
dr = ni_device_routes_list[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tables->route_values = rv;
|
tables->route_values = rv;
|
||||||
tables->valid_routes = dr;
|
tables->valid_routes = dr;
|
||||||
|
Loading…
Reference in New Issue
Block a user