From patchwork Fri Nov 16 11:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 151332 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp279038ljp; Fri, 16 Nov 2018 03:02:12 -0800 (PST) X-Google-Smtp-Source: AJdET5db57dpB02gl+RlwidL19eZJL7GtVKfVyFtF0map1FN4bx2jChngqp4FoEdY5CwiLL8+cbd X-Received: by 2002:a17:902:e085:: with SMTP id cb5mr5928345plb.24.1542366131957; Fri, 16 Nov 2018 03:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542366131; cv=none; d=google.com; s=arc-20160816; b=YX7KDrFRr7hQIhnvnQUXkoMF2rNtbbSCXqZfLqHT7pgla4QHH6kp8BsJjjsUsiN2p/ AquNoa+vWf+MR0YVl+c3QJvUKHkV+AiRMV+7jEtf1kJRxuNLViqAXGAMxdli4ZhL4XkQ 9L0hMt4ouwo6YMuEgR4Ob43PMesy+7R223Ee8NCZq0wRYYSNWKyAeVjxOFvj3hLs2cq2 T3yh8JNxt9xm3gqgr/tH6xBVTCyCHxOZktQhJFINknTgU/I/Wy6FBFjDOJB9m7Avf2vJ 6ldTNj+4hKJ5I3obKTvcp9NJi2Qf9Z778By9mV0f0uEYauHcBKAVF1KMZFmoMIuNyVUF W86w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=L0xxyPjE8jBaIz9DC2r/ZKc+hYCfYlfYhlTPplJ8+20=; b=VxyM26ComyPADNMWicO1NGOQ/ko62Ub+Hnec1YV58JzRzg89yjKAkuDNlpupaTAdcw n7nOrN9UP/vaAJARuAqoIthxtvM1YWgdUA06gFWrs2aK1kgmUiG36S3sZuyoT0wn/giS m0StFn890RqgJkakh2SxHs3oPYKz2DUBVJRyYra3SpazT9xPL8tYYVnoSy0lQtsHy9Ml zIkHTTW6QSLcBbOLvIj0y2BVsqYEF+Ml5Ymis68jAmsBZtnTNIgz7Evf08NDYqX6koNd q5ICpVDtv3k5qoNDO/NgLQlP4OQaBwdbG77XY2gTGXdInWtjolDcHA68G6cW7NKFmq7U qBkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gTp6Rlk8; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si32799795pfm.118.2018.11.16.03.02.11; Fri, 16 Nov 2018 03:02:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gTp6Rlk8; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389548AbeKPVOB (ORCPT + 6 others); Fri, 16 Nov 2018 16:14:01 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44933 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389550AbeKPVOA (ORCPT ); Fri, 16 Nov 2018 16:14:00 -0500 Received: by mail-pl1-f194.google.com with SMTP id s5-v6so11003118plq.11 for ; Fri, 16 Nov 2018 03:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=L0xxyPjE8jBaIz9DC2r/ZKc+hYCfYlfYhlTPplJ8+20=; b=gTp6Rlk8HY7VLKjMhf6stj3PTnfOgE97FBcG62ZQAdB/Af8TqsQXH2pIH4adcwWGCB yBaeFJZl3fu+4VdwiydWoTWIaO2oIHnnsFEITi7b7QYr4ueIZhAfTdJgOFb6o5ZXDWgk ChlLSlhlxfKW+zj8fOS9RBOdsIEEzGtE552uI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=L0xxyPjE8jBaIz9DC2r/ZKc+hYCfYlfYhlTPplJ8+20=; b=UFMQhKFhtFXf+NN27woCKxl/DZGTkFD5gnXWoWkT0uts2EbtYZdKCYiL+EZinYYEuH CZ50z2JYAnTq8XgkbciW4X6vongKLUQDCM1/Qp73wMgZtY9OhgTK304K/sjJrHQtZwsg r5RoH7hBxUOyjqgHxVfZ2M4X84Ld8ySwMIpWyH3nQYAieT6dGfEv9wn/GXN121IMqf5m qAn0Ja2XdZuYMbwMeCC7rXj+dK8S6socUjdy7YPaI2cETkjrh92jsFTe2Sx0qf/ZbVmU pf5OkzDzrgqpT1xKMofq7iy2CisyJ3LtoCJ2T77YH2WWr31ZXMTh0xAUaUhWUVVWTlow RtfA== X-Gm-Message-State: AGRZ1gJZnmBxm1Ndy1ECPE6dTOUKwF5b0hbyOUZnxCoSAl6D6fLBXCth dG9hJcyEBSU1DZYmcvH0iSpI3A== X-Received: by 2002:a17:902:be07:: with SMTP id r7-v6mr10284545pls.137.1542366129680; Fri, 16 Nov 2018 03:02:09 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 202sm21268106pfy.87.2018.11.16.03.02.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Nov 2018 03:02:08 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, linus.walleij@linaro.org Subject: [PATCH 4/6] power: supply: charger-manager: Make code more readable Date: Fri, 16 Nov 2018 19:01:11 +0800 Message-Id: <12b1b583c3da503be4ad7bed01e7b07a0a2b2126.1542362262.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> In-Reply-To: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> References: <4ea9eaf85d780afb190cb45da2df8ff5fd86d449.1542362262.git.baolin.wang@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Make code more readable. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 1.7.9.5 diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index a52bc77..dc0c9a6 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1520,19 +1520,19 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) /* chargers */ of_property_read_u32(np, "cm-num-chargers", &num_chgs); if (num_chgs) { + int i; + /* Allocate empty bin at the tail of array */ desc->psy_charger_stat = devm_kcalloc(dev, num_chgs + 1, sizeof(char *), GFP_KERNEL); - if (desc->psy_charger_stat) { - int i; - for (i = 0; i < num_chgs; i++) - of_property_read_string_index(np, "cm-chargers", - i, &desc->psy_charger_stat[i]); - } else { + if (!desc->psy_charger_stat) return ERR_PTR(-ENOMEM); - } + + for (i = 0; i < num_chgs; i++) + of_property_read_string_index(np, "cm-chargers", + i, &desc->psy_charger_stat[i]); } of_property_read_string(np, "cm-fuel-gauge", &desc->psy_fuel_gauge);