Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7018986ybi; Thu, 13 Jun 2019 08:14:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwckyxpFwkpDnB9ECOF1AdTaPIHYa0f9KALgbqCgo/MZQU8WGDPAm8KJUvRAM1eVNvKT1PI X-Received: by 2002:a65:4cce:: with SMTP id n14mr11806016pgt.251.1560438857077; Thu, 13 Jun 2019 08:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560438857; cv=none; d=google.com; s=arc-20160816; b=oa/1jCAXkk2L5jlDa3gtcDY7Ycr5s+SYWthN7JGhZf+P3kd0+xJfHeQAcoV/iyE/BE wfSbyU7cNFqRXSU68fmST0BN1Mai5mAjCqXf/Z5iAsH9fh/Y0D1HAxX4V57HJdhVEGMX /cgZhjaDQBXuDuVqkWYeuuuieldLHLNG+iSzDzwTBctM/HPaBo+eadCw7w7gh68CnYLf /Z6afUTcEIS/X/CsfnFGI1VTLWP98W0ojllPZ5K6dV6s7zLVQbfGdc6PeJKMCsDqbHfy tiJ/bQ88Kui8ssIwHaHyRM+6HYQOMcqeo/VdqAVhc2eCspn4Y14Bs7omQ8VCrQygZ3Py 3HSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=whmO4VHJLH3yhLw88WoBAtjYDYrD7FKUhcW2qIhfTgQ=; b=qaQlzYJRZj7JVhYfKnzgfSCFgaPRDBQYkWb//rQXxrqRyV+0S0mwSxwOwsaWQDTFpq GSTKvDTVI7+3szxrz277dFOhXKIspLRjli90rEMa/fqHf/oMaPZxQkKmcJX7L2Dm8wdl XKfZcGRzzudbE7yF01IK8KZFCiRk/+9TKPixKRdfIsXgdcwX1F4prH+VgEOjpbDklimq 6idPWoFxetY0iytAdYMyY8QVa9j6uOG2FK84alvp7IFAdO/N3KEJdZUv900Zqdj23SF7 LgeseM4P+OLXtJcGejzP7dFqPnfaNxGNhr8zCtF1Ohu28vXobB57htBESNCXJrvJqa8m mYng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tlOOQm+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m25si31605pgv.481.2019.06.13.08.14.01; Thu, 13 Jun 2019 08:14:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=tlOOQm+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1732340AbfFMPMN (ORCPT + 99 others); Thu, 13 Jun 2019 11:12:13 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35629 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732330AbfFMPMM (ORCPT ); Thu, 13 Jun 2019 11:12:12 -0400 Received: by mail-pl1-f194.google.com with SMTP id p1so8292504plo.2 for ; Thu, 13 Jun 2019 08:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=whmO4VHJLH3yhLw88WoBAtjYDYrD7FKUhcW2qIhfTgQ=; b=tlOOQm+9yvPlQK5EZ1zeDGAddCr36NZ94jYyPKZ2ztLXivCoKRdHBC4dlDcTC1Kgyu 7wUgtEAItK8J1ttV38DaXqd1byZFOAlM3SOVfIhRI87d8nVKSamRrYK/633Yoc3gOwYv 6K1MvQl0ZwpenunM3yUjBHCbWwLtr/cArA3DdXKVRtquu4ggCw3uFe6dDA0Ox1IQ0fq6 8KIvoLHQL0h3iVJrtkjs+HTv3CsLOkbQysUKhYw9b7qq9+FlZ9jS4l3cEfRL+4QfkA+U CdUw8GAVk/5jcOTaxtyXMQjnGWNPM/D0H8KoEd52ir+7EhvqwI7XmxhwXYfypKtPBCB2 +RYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=whmO4VHJLH3yhLw88WoBAtjYDYrD7FKUhcW2qIhfTgQ=; b=lK5bFHWcQwobDeIWYk1lnKJzC1+GuScxEPLqA73VOhX3WU10Jf+OIXOe33g2hc4atr UrPkdJVghKBc6IViEQVkHI1WvRuTrGDhYl2U3H7SYGdmah0rajieSgAu/V4nQqUwoxur ElJGvXPvIQi4HRUXQQgKf4mLyhq2uH1h61VwRSzPyBDTD6f4bdL6sJNFGUZGs9e2hhwI ifZ6oBA2vvIaD9lCAAkOZIDHItaHCh94kI179cU24DDQS99+7p7NQqQCan0MgCGUzVMU //ARMzLuJ5d8x7CGM2QPEP5aVXruxLEsQNpvx2A3uRusi4KTTJn7tfFARCqC3NjGasTP nZSw== X-Gm-Message-State: APjAAAUKuqObNG9ugRpNv5XHpUjZBTywf9GdMIo6ABJ6RyXaFtPrWS5O Zu7D86nqMXENjf8x5CGfNMXZE0WI4xI= X-Received: by 2002:a17:902:868b:: with SMTP id g11mr85657934plo.183.1560438732172; Thu, 13 Jun 2019 08:12:12 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id m24sm117215pgh.75.2019.06.13.08.12.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 08:12:11 -0700 (PDT) Date: Thu, 13 Jun 2019 08:12:09 -0700 From: Bjorn Andersson To: Jeffrey Hugo Cc: lgirdwood@gmail.com, broonie@kernel.org, agross@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 2/7] drivers: regulator: qcom_spmi: Refactor get_mode/set_mode Message-ID: <20190613151209.GB6792@builder> References: <20190613142157.8674-1-jeffrey.l.hugo@gmail.com> <20190613142239.8779-1-jeffrey.l.hugo@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190613142239.8779-1-jeffrey.l.hugo@gmail.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 13 Jun 07:22 PDT 2019, Jeffrey Hugo wrote: > spmi_regulator_common_get_mode and spmi_regulator_common_set_mode use > multi-level ifs which mirror a switch statement. Refactor to use a switch > statement to make the code flow more clear. > > Signed-off-by: Jeffrey Hugo > --- > drivers/regulator/qcom_spmi-regulator.c | 28 ++++++++++++++++--------- > 1 file changed, 18 insertions(+), 10 deletions(-) > > diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c > index fd55438c25d6..1c18fe5969b5 100644 > --- a/drivers/regulator/qcom_spmi-regulator.c > +++ b/drivers/regulator/qcom_spmi-regulator.c > @@ -911,13 +911,14 @@ static unsigned int spmi_regulator_common_get_mode(struct regulator_dev *rdev) > > spmi_vreg_read(vreg, SPMI_COMMON_REG_MODE, ®, 1); > > - if (reg & SPMI_COMMON_MODE_HPM_MASK) > + switch (reg) { > + case SPMI_COMMON_MODE_HPM_MASK: > return REGULATOR_MODE_NORMAL; > - > - if (reg & SPMI_COMMON_MODE_AUTO_MASK) > + case SPMI_COMMON_MODE_AUTO_MASK: > return REGULATOR_MODE_FAST; > - > - return REGULATOR_MODE_IDLE; > + default: > + return REGULATOR_MODE_IDLE; > + } > } > > static int > @@ -925,12 +926,19 @@ spmi_regulator_common_set_mode(struct regulator_dev *rdev, unsigned int mode) > { > struct spmi_regulator *vreg = rdev_get_drvdata(rdev); > u8 mask = SPMI_COMMON_MODE_HPM_MASK | SPMI_COMMON_MODE_AUTO_MASK; > - u8 val = 0; > + u8 val; > > - if (mode == REGULATOR_MODE_NORMAL) > + switch (mode) { > + case REGULATOR_MODE_NORMAL: > val = SPMI_COMMON_MODE_HPM_MASK; > - else if (mode == REGULATOR_MODE_FAST) > + break; > + case REGULATOR_MODE_FAST: > val = SPMI_COMMON_MODE_AUTO_MASK; > + break; > + default: > + val = 0; > + break; > + } For this part: Reviewed-by: Bjorn Andersson > > return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_MODE, val, mask); > } > @@ -1834,9 +1842,9 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) > } > } > > - if (vreg->logical_type == SPMI_REGULATOR_LOGICAL_TYPE_HFS430) { Squash this into patch 1. Regards, Bjorn > + if (vreg->set_points->count == 1) { > /* since there is only one range */ > - range = spmi_regulator_find_range(vreg); > + range = vreg->set_points->range; > vreg->desc.uV_step = range->step_uV; > } > > -- > 2.17.1 >