Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7046331ybi; Thu, 13 Jun 2019 08:40:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqytK3vMWh7s4/kiHEbVB9ayjhGeiFTxqqd1TAaKHe/MOqL6UEYg/j+33czZhA+jg49+0z1M X-Received: by 2002:a17:90a:290b:: with SMTP id g11mr6248227pjd.122.1560440409979; Thu, 13 Jun 2019 08:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440409; cv=none; d=google.com; s=arc-20160816; b=GVk+5O/kz9iAZ9JaSOmUJTnnics1u+/XkPVrrJX74iLkDxQcOKhgeSid1BjCeBsbwR 7iGQq7H0qdQ51SaGOfbNecAlsYyhJqhlgrTnPx6GB6qp3SAupgaAtbSj9Bu7c0YYbrQ/ PTpev8ISiajGUV8bhnXoHsBdhL2jl3MuHfZH1fi/wMmIrsZQl8thjJfw8cYxKWfaUXog +GPVGvQZ1yl3UvHExOVv9GDE1ConYfcONNmY6WSW2qXNlOnEDLZ7eGeRv0f1eBIrNS1r VSC687S1r/NrKRU3qm1BhGuMp8zeFL0aQrSXtqX8LRu2cB4jSIqG2vnFkyZSurxpt30e jiug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5i3fllaM3zGVPRCjpemlXnZ90CuYrEwzTiEoElVhFe8=; b=iKgBL429yYbGpFxzGntxVFQnymETABn5TvvpT/6tOv3n3p7/hnCqbvfbwUI3YD63hk tCJZ01LD3hziDeAL6xplp/hv1ylRlugmwtWEvaDSKBghvIZ3tzC/grYkPq/cgolt+Vv8 QZroWqD+aSg8b66b8TPCDkL6WyVHtPXZe9J7+zzNwoyDC+PkFGMpD2p/AxgsruxhZpyz E3ohzKnZf5RVDA2eEuEFcphhl/zpyfTY/TWSvL3X7gLRnxNBcjJkrVE5JaIblXrYWGwL QKuMJEtyuUqa3ToZupcjF78dqCJGe6WpnhdpD6L6c2l3x3BMcBfumhdaCoDlV+vBQvLu /hpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Opg/Cz53"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v36si101349pgl.91.2019.06.13.08.39.55; Thu, 13 Jun 2019 08:40:09 -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=@gmail.com header.s=20161025 header.b="Opg/Cz53"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733090AbfFMPhv (ORCPT + 99 others); Thu, 13 Jun 2019 11:37:51 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:43694 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732619AbfFMPht (ORCPT ); Thu, 13 Jun 2019 11:37:49 -0400 Received: by mail-io1-f66.google.com with SMTP id k20so17874871ios.10; Thu, 13 Jun 2019 08:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5i3fllaM3zGVPRCjpemlXnZ90CuYrEwzTiEoElVhFe8=; b=Opg/Cz53GyZCtD8gdSvINfrJq82ClNEH2vJpIYLZbDB0mFJSOBPNRSnMuvc/ETy/u7 3YSWspqqmO5FLQQeR1kCnj+/U4ZHiJsRiCJRNMNw1L0SF2wJHkafnoo29cUd6kie8j30 5cyuXzzbbW2FEKDfoz7nPqdZ5xYVR8xXomfI9tUNAvmNdPLMvBspKsVE1PSfi4WSUW7m 9OGHjF5Ed29skI3yLFbkvr9rhcWepSFeBIx63dE4dhB1orw7jkqAPJhyJ9Lo/9yM96oq B9pdy6+hEleo9Fbds6FkIa+8+xYNaINnWxBFiYG74h+rQS1l1Hkdvg2cnxXoieNejmna j2mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5i3fllaM3zGVPRCjpemlXnZ90CuYrEwzTiEoElVhFe8=; b=AG77fa0gpED2GrZZelJP35nnYpFduYMOQVQ5R6egnc1nfiSlxxsm7oz3evsoGOqSaZ X8fwtvyUzg5x5zuhRdLlLVBg8OifZO2Ytp7y8+yfCmVDorC6pGU9H1o3MRriZ4izObk9 oqoi+pYwwWh/G4bExw4NcQgJFbAKcdQJL97SJgpJoWnoVYuLdo9oO0FJr01cmAxJsB8H aVW2p9mA5eMvaI9uo1l0mru/L29ONkA0jCnliSU6KgBAjiVywLdB4pf7lmlV7gA2JePC XGlWHrukOhzO4jrwPqyotGim7FjuMr++nuJkRlEkPLrqSxhuBbo+RiwFVBHHZWaKYGMO MJ9g== X-Gm-Message-State: APjAAAUOy5XDJjf4OdwyzATII34LyCQWscjwQ3c+9jpP+G1m4oXigU90 sMeHpYFBBk0dAbhfm9niSLYn8QZD7IKIcLB55Uk= X-Received: by 2002:a02:c50a:: with SMTP id s10mr30311468jam.106.1560440268724; Thu, 13 Jun 2019 08:37:48 -0700 (PDT) MIME-Version: 1.0 References: <20190613142157.8674-1-jeffrey.l.hugo@gmail.com> <20190613142239.8779-1-jeffrey.l.hugo@gmail.com> <20190613151209.GB6792@builder> <20190613152430.GC6792@builder> In-Reply-To: <20190613152430.GC6792@builder> From: Jeffrey Hugo Date: Thu, 13 Jun 2019 09:37:38 -0600 Message-ID: Subject: Re: [PATCH v3 2/7] drivers: regulator: qcom_spmi: Refactor get_mode/set_mode To: Bjorn Andersson Cc: lgirdwood@gmail.com, broonie@kernel.org, Andy Gross , Rob Herring , Mark Rutland , MSM , lkml , devicetree@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 13, 2019 at 9:24 AM Bjorn Andersson wrote: > > 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? Ah. Yes. I read the documentation wrong when doing this. Will fix. > > > > + 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 > > >