1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2009 by Zachary T Welch <zw@superlucidity.net> *
5 ***************************************************************************/
12 #include <helper/log.h>
14 unsigned get_flash_name_index(const char *name)
16 const char *name_index = strrchr(name, '.');
19 if (name_index[1] < '0' || name_index[1] > '9')
22 int retval = parse_uint(name_index + 1, &requested);
23 /* detect parsing error by forcing past end of bank list */
24 return (retval == ERROR_OK) ? requested : ~0U;
27 bool flash_driver_name_matches(const char *name, const char *expected)
29 unsigned blen = strlen(name);
30 /* only match up to the length of the driver name... */
31 if (strncmp(name, expected, blen) != 0)
34 /* ...then check that name terminates at this spot. */
35 return expected[blen] == '.' || expected[blen] == '\0';