From patchwork Thu May 3 17:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10378783 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 375A160327 for ; Thu, 3 May 2018 17:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D791291AB for ; Thu, 3 May 2018 17:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FF11291FF; Thu, 3 May 2018 17:42:09 +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 8FE8A291AB for ; Thu, 3 May 2018 17:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751115AbeECRmH (ORCPT ); Thu, 3 May 2018 13:42:07 -0400 Received: from mga02.intel.com ([134.134.136.20]:1037 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbeECRmH (ORCPT ); Thu, 3 May 2018 13:42:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 10:42:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="42851501" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 May 2018 10:42:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B4B6ECE; Thu, 3 May 2018 20:42:04 +0300 (EEST) From: Andy Shevchenko To: Sebastian Reichel , linux-pm@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1] power: supply: Convert to use match_string() helper Date: Thu, 3 May 2018 20:42:04 +0300 Message-Id: <20180503174204.21266-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.17.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 The new helper returns index of the matching string in an array. We are going to use it here. Signed-off-by: Andy Shevchenko --- drivers/power/supply/power_supply_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index ecd68c2053c5..c695d151695e 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -36,8 +36,6 @@ static struct device_type power_supply_dev_type; static bool __power_supply_is_supplied_by(struct power_supply *supplier, struct power_supply *supply) { - int i; - if (!supply->supplied_from && !supplier->supplied_to) return false; @@ -45,15 +43,15 @@ static bool __power_supply_is_supplied_by(struct power_supply *supplier, if (supply->supplied_from) { if (!supplier->desc->name) return false; - for (i = 0; i < supply->num_supplies; i++) - if (!strcmp(supplier->desc->name, supply->supplied_from[i])) - return true; + if (match_string(supply->supplied_from, supply->num_supplies, + supplier->desc->name) >= 0) + return true; } else { if (!supply->desc->name) return false; - for (i = 0; i < supplier->num_supplicants; i++) - if (!strcmp(supplier->supplied_to[i], supply->desc->name)) - return true; + if (match_string(supplier->supplied_to, supplier->num_supplicants, + supply->desc->name) >= 0) + return true; } return false;