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: 10685911 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 01BFC109C for ; Fri, 16 Nov 2018 11:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFACD2D0D5 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2D032D122; Fri, 16 Nov 2018 11:02:28 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 896922D0D5 for ; Fri, 16 Nov 2018 11:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389552AbeKPVOB (ORCPT ); Fri, 16 Nov 2018 16:14:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33035 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389430AbeKPVOA (ORCPT ); Fri, 16 Nov 2018 16:14:00 -0500 Received: by mail-pl1-f196.google.com with SMTP id w22-v6so11027841plk.0 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=Famihop+PrzAYUkrxNgY9FvnoVSFY8X3HkSMLIDSnv/eyLsc37pVTD0XD6IgUMub/f e25VLCMNEGzn4/jy4VGD+KiXbPFbcZ8oNC/isEcShqTOEB/8UDhPqo2ofBXepobEdR/5 ItCd5s0pHQ3pdy4Fk8EgHvVd4q4Cz9/C+J6bGiLUJtCAhIGtG34cqKrYM6i23cYNRW04 NwWLqyg355LYGahS0pjyZJfku/HaTClISFG8nEKyELqyrsRp3mLnv9kxNEr/NFJBjlGR cx/nxFJ+9kUmqffZw51YyvU4FgzDbS0Czz0Bk/CMPg/It1YSz0T11pG96kozaIwcMs+D PonQ== X-Gm-Message-State: AGRZ1gKVMBmWH14nP+71zyuXUgk8oKCnw+tbQTMQNAvo1d7SWV5DVRCn pLtFYSh2vcwlbvvGd2U/05/fCA== X-Google-Smtp-Source: AJdET5ecI8xeHd96IbsUVDWxyijJGYzDgELZQqV+WowqMjKAuSs6K/mwt37V3vFW8y4VYqqNIOrRxQ== 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: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make code more readable. Signed-off-by: Baolin Wang --- drivers/power/supply/charger-manager.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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);