Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1306852ybm; Tue, 21 May 2019 11:52:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCQd8MuS1kaQR0Td2VXilL2lw/h9hBwGiIH+UuFVFDvBbC8wr+siFJflbLnHuL9/dzwkuu X-Received: by 2002:a63:f410:: with SMTP id g16mr53227656pgi.428.1558464746406; Tue, 21 May 2019 11:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558464746; cv=none; d=google.com; s=arc-20160816; b=YITSqxkIV2Cwrs9/W9WILGOI/C9ZN2RUuvlKBEgvPg0Kl5QMYG5R9pqR4LKaGveqkK o/l33F8iqpl7joufRvFzx5i460c+nl14IYzgZnDCSX0OBxvI2ACoaiAFrnYakVVX0XOx y838ntdDqL9HUA7Q8DgJqrV4jQI1WIzvIG3f0lSSYJiLeimkCgEUk26bh8vsHRv0Wl39 8RN12c3LgjoxurLjENQHjmcXZMKTxwEMyqazad74utJw8vs2nEGhn8PdlyyRj1DxFGn9 tHI/4fThYEE/Ye+gBConQq/PNCS75BqlYdWLtuBBF7gCNDXMNbuiBgshWKNLef0HzsuW 20SA== 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=uyW5JgqktOeQEaUw+A116CMaNFtMso5q/Jn1XmiRdLk=; b=Xw3oT3WBcWNqirYvvErhcTl4wnH8DRAboPjcQ4W0+xorySk6m5iCiUTD2xC5/HWyk9 8tpzgYI8V+m60hBDwfNsbbN5IcPJsIt1iMJaYDIR4vneffyhZcN+VhB7TUrIH9l/neLB z8ppOmvoOvTeOqVvfZGeMTIjCpNASduppJvuWkpgjjAN/LqheZToWZYYXMSYWR6v2lvF XY103/0VFRWzrNO91TnO7nm72/LV+s6GE67XD5TaJjB9gIggvlitggw8xk4L2r1hITIX bHt20unFLWQZbUuxIYbU9UpZLixLbWkbxb+zpQg1RbAhNJrWwGAz80Sajw6f70Rx+Zgh Z8bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=dDdIXaNA; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si11276304plo.212.2019.05.21.11.52.10; Tue, 21 May 2019 11:52:26 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=dDdIXaNA; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729170AbfEUSvE (ORCPT + 99 others); Tue, 21 May 2019 14:51:04 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:41260 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbfEUSvE (ORCPT ); Tue, 21 May 2019 14:51:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uyW5JgqktOeQEaUw+A116CMaNFtMso5q/Jn1XmiRdLk=; b=dDdIXaNASaq3WoLuurvMj9md7 p/iCtcLueRbPFYhFf0qk0VBRZWlhE5Aqp7tYt6UcvEUf6Tb5msHtjIncicKr2PpEcj4FlFzAv/dwH uyMFgIiKCI/cZQ7iFeglH7xxmiEBlishs+UuXJv/3+LNnC3icSCCPBwRg7RQrMJYcBJCM=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1hT9qk-0000WF-5e; Tue, 21 May 2019 18:50:58 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 8B8F51126D13; Tue, 21 May 2019 19:50:54 +0100 (BST) Date: Tue, 21 May 2019 19:50:54 +0100 From: Mark Brown To: Jeffrey Hugo Cc: lgirdwood@gmail.com, agross@kernel.org, david.brown@linaro.org, bjorn.andersson@linaro.org, jcrouse@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Jorge Ramirez-Ortiz Subject: Re: [PATCH 2/3] regulator: qcom_spmi: Add support for PM8005 Message-ID: <20190521185054.GD16633@sirena.org.uk> References: <20190521164932.14265-1-jeffrey.l.hugo@gmail.com> <20190521165315.14379-1-jeffrey.l.hugo@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="C+ts3FVlLX8+P6JN" Content-Disposition: inline In-Reply-To: <20190521165315.14379-1-jeffrey.l.hugo@gmail.com> X-Cookie: Do I have a lifestyle yet? User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --C+ts3FVlLX8+P6JN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 21, 2019 at 09:53:15AM -0700, Jeffrey Hugo wrote: > - spmi_vreg_read(vreg, SPMI_COMMON_REG_VOLTAGE_RANGE, &range_sel, 1); > + /* second common devices don't have VOLTAGE_RANGE register */ > + if (vreg->logical_type == SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS2) { > + spmi_vreg_read(vreg, SPMI_COMMON2_REG_VOLTAGE_LSB, &lsb, 1); > + spmi_vreg_read(vreg, SPMI_COMMON2_REG_VOLTAGE_MSB, &msb, 1); > + > + uV = (((int)msb << 8) | (int)lsb) * 1000; This overlaps with some changes that Jorge (CCed) was sending for the PMS405. As I was saying to him rather than shoving special cases for different regulator types into the ops (especially ones that don't have any of the range stuff) it'd be better to just define separate ops for the regulators that look quite different to the existing ones. > +static int spmi_regulator_common_list_voltage(struct regulator_dev *rdev, > + unsigned selector); > + > +static int spmi_regulator_common2_set_voltage(struct regulator_dev *rdev, > + unsigned selector) Eeew, can we not have better names? > +static unsigned int spmi_regulator_common2_get_mode(struct regulator_dev *rdev) > +{ > + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); > + u8 reg; > + > + spmi_vreg_read(vreg, SPMI_COMMON2_REG_MODE, ®, 1); > + > + if (reg == SPMI_COMMON2_MODE_HPM_MASK) > + return REGULATOR_MODE_NORMAL; > + > + if (reg == SPMI_COMMON2_MODE_AUTO_MASK) > + return REGULATOR_MODE_FAST; > + > + return REGULATOR_MODE_IDLE; > +} This looks like you want to write a switch statement. > +spmi_regulator_common2_set_mode(struct regulator_dev *rdev, unsigned int mode) > +{ > + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); > + u8 mask = SPMI_COMMON2_MODE_MASK; > + u8 val = SPMI_COMMON2_MODE_LPM_MASK; > + > + if (mode == REGULATOR_MODE_NORMAL) > + val = SPMI_COMMON2_MODE_HPM_MASK; > + else if (mode == REGULATOR_MODE_FAST) > + val = SPMI_COMMON2_MODE_AUTO_MASK; This needs to be a switch statement, then it can have a default case to catch errors too. --C+ts3FVlLX8+P6JN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlzkSI0ACgkQJNaLcl1U h9D4Pwf+N0VEAMaUrHu9DiDBqWU4jYSrQlR7BPtYN4DHzRzhYd/GSW4c1RhNMsz4 og7GQSz83ppbsfv22Sf1/2ivsR/0VihEhoOVduEnH2MJcowZwd4vUnNfTvOuAcvN nN/THjD7Nz4GpP9QBetIwsInrafl+bbpMedq0fI/u6EsUSNOmoHnFxgJM8aXxYJQ WzquUkwu8XTUi5UNspFDXXTRYmjfKAiY0fYSsATVZOZHtSCktsijI35IN77oxvSB l2UT7XH3xXPQ7UyeF64U4Yp7L+NeYrh7eX6qZGb5NaUq1k/CiruEZK/OUkNkkNsR sQWT5yGgYmgS2BOIlXy3SsNbouafeQ== =vCWU -----END PGP SIGNATURE----- --C+ts3FVlLX8+P6JN--