Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7031503ybi; Thu, 13 Jun 2019 08:25:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCM7BddcjCpbgGeOGGXDEzMifgCsBuediBOQwNdCb2A2syYAZI/zZzHL5BgssSPprqyvOG X-Received: by 2002:a65:41c6:: with SMTP id b6mr30550036pgq.399.1560439550390; Thu, 13 Jun 2019 08:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560439550; cv=none; d=google.com; s=arc-20160816; b=jgqwGGcWEYDuAXa3KOsG+vJEQyx+iKMfPE0Cb5HRNqlDFo+m5WxZz34M3yr1eNtmpZ zz8o7hE1GjuagYq3LOV9968GAZto3gqMLseDbMkBONsDuyrGvxZkb5583pLEHJSq61HT D9q0WxMSpSDFEVxw0xu4KgHQAzCKckZa9Z7Pn2mONHrkO86YLKI9RTC+5Jy3fgcILBZU lByY2FbrpYyGNcg9tu7+cbgkF6NcdeY1zg39b3tEkiy+1ZpTTEKhpNeouicshCpCHEFg D8Q7nksXZRVR6ni65ngSDLOurGP2oMk8GO7hbj8tzsd1Y/nZB3ud7f2RjhxliRtSeEHP 210Q== 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=UhkxS9OzbQDJW8EmelqSilqPcjj3tM4tLTV73e7d2yw=; b=yOf6Gr0bYcGPsK+e+D5a615qOOCj5luQ0RgFoaBi1xVJoL3UwjO7twb9udhlg7XS+H jJ43JJhn8KcoFG63LQ/WmOPPn97tTfzjgWZuJfH3NYNXgUo3+vzn8viIkqQ5Bdb8L+5h nOIHf4kLL90a4FzPdNCE43spXzzJypLRbTlvLauLmmgAQAw1xlUDuQ8v9RgouWbe2otp oQYKkdsnpvXZ+y8cvcbI3TD3RSb326a4Sv+9zMr3CadANeQ+RetGOERq0C9caDkJbhqG c1ZFR0568h1GW3222jQod68teGXHM8EMZHw+zfh+fvqzTD/zfqWEQxvtuRHTdUCOxxHR b2Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dzKFboS9; 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 g125si1195589pfb.232.2019.06.13.08.25.34; Thu, 13 Jun 2019 08:25:50 -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=dzKFboS9; 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 S1727262AbfFMPYr (ORCPT + 99 others); Thu, 13 Jun 2019 11:24:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37450 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbfFMPYe (ORCPT ); Thu, 13 Jun 2019 11:24:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id 19so11224797pfa.4 for ; Thu, 13 Jun 2019 08:24:33 -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=UhkxS9OzbQDJW8EmelqSilqPcjj3tM4tLTV73e7d2yw=; b=dzKFboS9GO1hDmlm9GccLJ3JLpjQDc/PCv8UzpB/mtMxyIqA2B4c0jEhTsRq3dS+Pw 3OH3S9ZWwN191V8aO4SrYk/U+ugTOq3+d3oBnBYUHH3ZMNikRQARD079yVR+1lrb4pjJ YZg4HDp0qFkB3nAuRt9UVPV322Ne054lKEyvyeaFZISy6fxVTXPHHiZ/5B7XQRz2Df74 NfAYxnn5RWzPJE0+S1KQA4WGD/FTIOtrHEZzPHA6Va87X7vkY2nn/vWh6XqDReVbAzyR F7hQkH0TOTOYgwCIls/RcI0yYQtfJkQ7wAoRnNIq0AZSxD/N7z9IoysNJSo0ZaxrUY9Q EQYg== 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=UhkxS9OzbQDJW8EmelqSilqPcjj3tM4tLTV73e7d2yw=; b=WBwMh+/8xj5vVx+1kWT0YeKk0TAQ3GO+AgsbqqmKuZTiH8lkRQc8RIPtKCiu2HLUZ5 nHT0zVzOhCTxWua1RotY6vMD733cVeD7EQUwEf5b/jbwbyasAFERaYpB/nzDX/dw3pQJ Rt+z1J+yYa4Mpd9Y1s4zuPaZX4mmfRNuzb5104D7iIYggXFEqC9xSHHRqN/XaBUP52EX u1FaXIAPcCOOAAiszlDsYYmvBEMjPVcIdIH47DwqxeQrQl0KpZ5yO1BqDpVIVCs+Us7I BC6M59hk1/CzE8thX9uttNER5IkfPlocqTkLMYWhGL4UvLk4OBYqKVv5f/sCUDeUl4re NpqA== X-Gm-Message-State: APjAAAUMnoNEFXGSsyHrbz8B+L38dEPrFsTCXpBgGaCsJg5rxmGmvPGG OA4G+NI1T6q3ZBh/+uyDzKIGoA== X-Received: by 2002:a17:90a:f498:: with SMTP id bx24mr6275180pjb.91.1560439473353; Thu, 13 Jun 2019 08:24:33 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id a13sm119140pgl.84.2019.06.13.08.24.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 08:24:32 -0700 (PDT) Date: Thu, 13 Jun 2019 08:24:30 -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: <20190613152430.GC6792@builder> References: <20190613142157.8674-1-jeffrey.l.hugo@gmail.com> <20190613142239.8779-1-jeffrey.l.hugo@gmail.com> <20190613151209.GB6792@builder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190613151209.GB6792@builder> 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 08:12 PDT 2019, Bjorn Andersson wrote: > 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) Sorry, didn't see the & here. Don't you need to mask out the mode bits before turning this into a switch? > > + 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 > >