From patchwork Wed Mar 20 13:22:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10861741 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E11414DE for ; Wed, 20 Mar 2019 13:22:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3594329BF1 for ; Wed, 20 Mar 2019 13:22:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29E4F29C06; Wed, 20 Mar 2019 13:22:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A969129BDB for ; Wed, 20 Mar 2019 13:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfCTNW3 (ORCPT ); Wed, 20 Mar 2019 09:22:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:11260 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbfCTNW3 (ORCPT ); Wed, 20 Mar 2019 09:22:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 06:22:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,249,1549958400"; d="scan'208";a="127046646" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 20 Mar 2019 06:22:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BA9654D6; Wed, 20 Mar 2019 15:22:25 +0200 (EET) From: Andy Shevchenko To: =?utf-8?q?Bruno_Pr=C3=A9mont?= , linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Andy Shevchenko Subject: [PATCH v1] HID: picolcd: Convert to use sysfs_streq() Date: Wed, 20 Mar 2019 15:22:25 +0200 Message-Id: <20190320132225.76955-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert to use sysfs_streq() instead of custom approach. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-picolcd_core.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c index c1b29a9eb41a..482c24f0e078 100644 --- a/drivers/hid/hid-picolcd_core.c +++ b/drivers/hid/hid-picolcd_core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "hid-picolcd.h" @@ -275,27 +276,20 @@ static ssize_t picolcd_operation_mode_store(struct device *dev, { struct picolcd_data *data = dev_get_drvdata(dev); struct hid_report *report = NULL; - size_t cnt = count; int timeout = data->opmode_delay; unsigned long flags; - if (cnt >= 3 && strncmp("lcd", buf, 3) == 0) { + if (sysfs_streq(buf, "lcd")) { if (data->status & PICOLCD_BOOTLOADER) report = picolcd_out_report(REPORT_EXIT_FLASHER, data->hdev); - buf += 3; - cnt -= 3; - } else if (cnt >= 10 && strncmp("bootloader", buf, 10) == 0) { + } else if (sysfs_streq(buf, "bootloader")) { if (!(data->status & PICOLCD_BOOTLOADER)) report = picolcd_out_report(REPORT_EXIT_KEYBOARD, data->hdev); - buf += 10; - cnt -= 10; - } - if (!report || report->maxfield != 1) + } else { return -EINVAL; + } - while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r')) - cnt--; - if (cnt != 0) + if (!report || report->maxfield != 1) return -EINVAL; spin_lock_irqsave(&data->lock, flags);