Commit e986b667 authored by Yisheng Xie's avatar Yisheng Xie Committed by Greg Kroah-Hartman

Staging: gdm724x: use match_string() helper

match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Quytelda Kahja <quytelda@tamalin.org>
Cc: devel@driverdev.osuosl.org
Signed-off-by: default avatarYisheng Xie <xieyisheng1@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 70ce2440
...@@ -33,7 +33,7 @@ static struct tty_driver *gdm_driver[TTY_MAX_COUNT]; ...@@ -33,7 +33,7 @@ static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
static DEFINE_MUTEX(gdm_table_lock); static DEFINE_MUTEX(gdm_table_lock);
static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; static const char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"};
static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"};
static void gdm_port_destruct(struct tty_port *port) static void gdm_port_destruct(struct tty_port *port)
...@@ -55,22 +55,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) ...@@ -55,22 +55,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
{ {
struct gdm *gdm = NULL; struct gdm *gdm = NULL;
int ret; int ret;
int i;
int j;
j = GDM_TTY_MINOR;
for (i = 0; i < TTY_MAX_COUNT; i++) {
if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) {
j = tty->index;
break;
}
}
if (j == GDM_TTY_MINOR) ret = match_string(DRIVER_STRING, TTY_MAX_COUNT,
tty->driver->driver_name);
if (ret < 0)
return -ENODEV; return -ENODEV;
mutex_lock(&gdm_table_lock); mutex_lock(&gdm_table_lock);
gdm = gdm_table[i][j]; gdm = gdm_table[ret][tty->index];
if (!gdm) { if (!gdm) {
mutex_unlock(&gdm_table_lock); mutex_unlock(&gdm_table_lock);
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment