From patchwork Fri Jun 9 12:07:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 9778321 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 C1DD160350 for ; Fri, 9 Jun 2017 12:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B16D82810E for ; Fri, 9 Jun 2017 12:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A62D52860A; Fri, 9 Jun 2017 12:07:37 +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 46DEA2810E for ; Fri, 9 Jun 2017 12:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbdFIMHg (ORCPT ); Fri, 9 Jun 2017 08:07:36 -0400 Received: from mga01.intel.com ([192.55.52.88]:4036 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751694AbdFIMHg (ORCPT ); Fri, 9 Jun 2017 08:07:36 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2017 05:07:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,317,1493708400"; d="scan'208";a="1139606507" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2017 05:07:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E84841E7; Fri, 9 Jun 2017 15:07:27 +0300 (EEST) From: Andy Shevchenko To: linux-pm@vger.kernel.org Cc: Andy Shevchenko , Sebastian Reichel Subject: [PATCH v1] power: supply: twl4030_charger: Use sysfs_match_string() helper Date: Fri, 9 Jun 2017 15:07:27 +0300 Message-Id: <20170609120727.21910-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 --- drivers/power/supply/twl4030_charger.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 785a07bc4f39..2c2d1f457487 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -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;