From patchwork Sun Jun 11 15:15:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 9780173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD3CF602DA for ; Sun, 11 Jun 2017 15:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0F92209CE for ; Sun, 11 Jun 2017 15:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2BFF28528; Sun, 11 Jun 2017 15:15:54 +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=-6.9 required=2.0 tests=BAYES_00,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 3DA4A209CE for ; Sun, 11 Jun 2017 15:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751743AbdFKPPx (ORCPT ); Sun, 11 Jun 2017 11:15:53 -0400 Received: from mga06.intel.com ([134.134.136.31]:53268 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbdFKPPw (ORCPT ); Sun, 11 Jun 2017 11:15:52 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 11 Jun 2017 08:15:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,329,1493708400"; d="scan'208";a="866778026" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jun 2017 08:15:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 93BEAD7; Sun, 11 Jun 2017 18:15:49 +0300 (EEST) From: Andy Shevchenko To: linux-pm@vger.kernel.org Cc: Andy Shevchenko , Sebastian Reichel Subject: [PATCH v2] power: supply: twl4030_charger: Use sysfs_match_string() helper Date: Sun, 11 Jun 2017 18:15:48 +0300 Message-Id: <20170611151548.7153-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use sysfs_match_string() helper instead of open coded variant. Cc: Sebastian Reichel Signed-off-by: Andy Shevchenko --- - constify array of mode names drivers/power/supply/twl4030_charger.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 785a07bc4f39..07c70e59f31a 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -153,7 +153,7 @@ struct twl4030_bci { }; /* strings for 'usb_mode' values */ -static char *modes[] = { "off", "auto", "continuous" }; +static const char *modes[] = { "off", "auto", "continuous" }; /* * clear and set bits on an given register on a given module @@ -669,14 +669,10 @@ twl4030_bci_mode_store(struct device *dev, struct device_attribute *attr, int mode; int status; - if (sysfs_streq(buf, modes[0])) - mode = 0; - else if (sysfs_streq(buf, modes[1])) - mode = 1; - else if (sysfs_streq(buf, modes[2])) - mode = 2; - else - return -EINVAL; + mode = sysfs_match_string(modes, buf); + if (mode < 0) + return mode; + if (dev == &bci->ac->dev) { if (mode == 2) return -EINVAL;