/* This file is part of the Simba project.  */
int board_pin_string_to_device_index(const char *str_p)
/* This file is part of the Simba project.  */
int board_pin_string_to_device_index(const char *str_p)
{
    int port;
    int gpio;
    long bit;
    if (str_p[0] != 'p') {
        return (-ENODEV);
    }
    port = tolower((int)str_p[1]);
    if ((port < 'a') || (port > 'd')) {
        return (-ENODEV);
    }
    gpio = (port - 'a');
    if (std_strtol(&str_p[2], &bit) == NULL) {
        return (-ENODEV);
    }
    if (bit < 0) {
        return (-ENODEV);
    }
    if ((gpio == 'd' && bit > 3) || (bit > 15)) {
        return (-ENODEV);
    }
    return (16 * gpio + bit);
}