[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1526903890-35761-4-git-send-email-xieyisheng1@huawei.com>
Date: Mon, 21 May 2018 19:57:40 +0800
From: Yisheng Xie <xieyisheng1@...wei.com>
To: <linux-kernel@...r.kernel.org>
CC: Yisheng Xie <xieyisheng1@...wei.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Quytelda Kahja <quytelda@...alin.org>,
<devel@...verdev.osuosl.org>
Subject: [PATCH 03/33] Staging: gdm724x: use match_string() helper
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Quytelda Kahja <quytelda@...alin.org>
Cc: devel@...verdev.osuosl.org
Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
---
drivers/staging/gdm724x/gdm_tty.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 3cdebb8..ba53a06 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -65,22 +65,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
{
struct gdm *gdm = NULL;
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((const char **)DRIVER_STRING,
+ TTY_MAX_COUNT, tty->driver->driver_name);
+ if (ret < 0 || tty->index == GDM_TTY_MINOR)
return -ENODEV;
mutex_lock(&gdm_table_lock);
- gdm = gdm_table[i][j];
+ gdm = gdm_table[ret][tty->index];
if (!gdm) {
mutex_unlock(&gdm_table_lock);
return -ENODEV;
--
1.7.12.4
Powered by blists - more mailing lists