Received: by 10.192.165.148 with SMTP id m20csp4897457imm; Tue, 24 Apr 2018 10:09:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx495okirB1tR+UO6yYqXEY9huyFoXj0re9rJgOI/Yp375xafOPV+OAaAo0EHFNCDsg55IN19 X-Received: by 2002:a17:902:5a5:: with SMTP id f34-v6mr25319407plf.288.1524589743750; Tue, 24 Apr 2018 10:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524589743; cv=none; d=google.com; s=arc-20160816; b=IYH2VC2uUqMj3pOrfOpxgcGYj7qCYmtskhxTuxtXDsTsWHQf/7ZqB5zN7Cc7yyasAm QFVLVn0JGBZ/lCuPz1BLb7flb/ezcgGKni8k9goSk02MzQAJ83J653yB+6sr4xbm31W+ os/qfNps7xtX/Mngfe0rbQ8tor0IZecW8n4pX6kRIbYfnZJRt8FhqbRQFVDNsGoHtIN8 hC1IAfvCatNTUvyT7RartHTgkgWJf7hSRkfhLQyiNeim897a5fjeUJkiIG5TGIlYw54v oz4EJKYd0FeCvarYJoyvVdAOVJY2yIkeHPSDSDknHI/nQl7TQ7poGeMeXbbWuyb9FrIa l8jw== 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:arc-authentication-results; bh=2Ghrr1sPQYgCuoLGwuQO3dIPr3XPyE4+W5krOKW5JQU=; b=nSMUFlN8G1jifsFlBkaz+qWHR00A2W0heZC0YMAIm81L5ZNjMxk+VRwfViQJzmFVlr rixwvqfcsCylBr/oHCecNIQ4N1e18Y+VaptNm3OmRWXhrJfWATvVELlkaRtDhSWvGmDr 5oT5zesWiiiZrUCibFJHVjr+yT5ddL7qurLWPSxfLbbqSRolB030SsAuGPAJdN+G7f/R BnBltewqERXABrHFUKg27QhDtWfMOUKaBV8q9nKjgIna5XctcXGLeNYc0As2I+mHibJ4 HppETk9lUC3p8i7isKyXHt/d8u3T/m8+jbCMolh54S5X37TjF1TNSLgcdrHioblFN5Mh cP4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=BXWlcNxh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f64si500547pfd.123.2018.04.24.10.08.49; Tue, 24 Apr 2018 10:09:03 -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=BXWlcNxh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751710AbeDXRHn (ORCPT + 99 others); Tue, 24 Apr 2018 13:07:43 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:34946 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbeDXRHl (ORCPT ); Tue, 24 Apr 2018 13:07:41 -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=2Ghrr1sPQYgCuoLGwuQO3dIPr3XPyE4+W5krOKW5JQU=; b=BXWlcNxhWk8gmSSLxH0Uk8d83 tCPwzG4oRhN3HRPc7b3RlN1N2zGVIbG+j2duK5TG6zVYrJxGgDZnYYJj2HraQqtYU+q4O9EFXjWfS OETWd+2Tx26k5SAPcGRAOha0IgQX6sEreiDgQ3QbsJLeitB0zT+nZPgFbc9oCzcjpZ1KA=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fB1Ph-0000OF-If; Tue, 24 Apr 2018 17:07:33 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1fB1Ph-0002Q2-1z; Tue, 24 Apr 2018 18:07:33 +0100 Date: Tue, 24 Apr 2018 18:07:33 +0100 From: Mark Brown To: Icenowy Zheng Cc: Liam Girdwood , Rob Herring , Maxime Ripard , Chen-Yu Tsai , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Ondrej Jirman Subject: Re: [PATCH v3 2/3] regulator: add support for SY8106A regulator Message-ID: <20180424170733.GD22073@sirena.org.uk> References: <20180423144657.63264-1-icenowy@aosc.io> <20180423144657.63264-3-icenowy@aosc.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BRE3mIcgqKzpedwo" Content-Disposition: inline In-Reply-To: <20180423144657.63264-3-icenowy@aosc.io> X-Cookie: Take your Senator to lunch this week. User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --BRE3mIcgqKzpedwo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 23, 2018 at 10:46:56PM +0800, Icenowy Zheng wrote: > --- /dev/null > +++ b/drivers/regulator/sy8106a-regulator.c > @@ -0,0 +1,176 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * sy8106a-regulator.c - Regulator device driver for SY8106A Just make the entire thing a C++ comment so it looks consistent and joined up. > +static int sy8106a_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel) > +{ > + /* We use our set_voltage_sel in order to avoid unnecessary I2C > + * chatter, because the regulator_get_voltage_sel_regmap using > + * apply_bit would perform 4 unnecessary transfers instead of one, > + * increasing the chance of error. > + */ > + return regmap_write(rdev->regmap, rdev->desc->vsel_reg, > + sel | SY8106A_GO_BIT); Why would it do these extra transfers? Is this just the fact that you didn't set up a register cache (though the r/m/w cycle should only add the read)? We could put some logic in the core regmap code to detect that an _update_bits() call is going to write to the whole register, though it'd be even easier to just let this register be cached. Generally if we can usefully optimize things we should do it at the framework level. > + if (reg & SY8106A_GO_BIT) > + return reg & rdev->desc->vsel_mask; > + else > + return (chip->fixed_voltage - rdev->desc->min_uV) / > + rdev->desc->uV_step; You could use the standard get_voltage_sel() if you provide a mapping operation that set everything with _GO_BIT set to return the fixed voltage. Though looking at this it seems that the fixed voltage will always be one that could be set via the register anyway so I'm wondering if the easiest thing here isn't to just have the driver turn off _GO_BIT during probe() and not worry about the special case at runtime. --BRE3mIcgqKzpedwo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlrfZFQACgkQJNaLcl1U h9ABoAf+MAY7wh6RxX+JxRaaZqaKm1sBzEsUizDdO0bmeMGUmy2XVE3nmGRUC5g9 5iEh9QeWock1uMhygZwIWNAudOUbzU2vj519R7fIDMSL/gSMs1pMGBOrQo/EYmpe 2yXh6dfVu1o3GJixqnwLlIEawT91IOqU7CzHq7LYLIn15FECsF9HqEI2+rEZokI4 zU5kqZTGwN6SAXCOTIgc/Rp7ZbwrL4vqyO9+lqNnG3sJKGmiwu/UzD1Ip6vU5Cuf nr9KJUX80xuINjo32OpZoMfw9CmL5Py6MU+GptiozCDnNDdRo+rBv8phvaUX+dly sFkRGlum9ixStWgoHz47moUxcOerxA== =Q4GJ -----END PGP SIGNATURE----- --BRE3mIcgqKzpedwo--