Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp595443ybl; Wed, 14 Aug 2019 03:02:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7nnISDsTBHuIxS7K6ds3atk2qvzhaHtdpWB+UzuGb3JivnbOmvK6Z/KRomegwcnLWvZAG X-Received: by 2002:a17:902:29e9:: with SMTP id h96mr2300634plb.110.1565776933796; Wed, 14 Aug 2019 03:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565776933; cv=none; d=google.com; s=arc-20160816; b=n8WTQUkdkQeSjMMYzQrOZlMWZBgfm9o1wd3ELeh59FZ3uV2fzeFeHgznP7cUfQspef i33kGEhAhevlBI71Sld6/d26k05EDex47beUqNlTdBuJmExTa75UXfMtFi8sCQPYlPy7 0lGbHq5v2s0fTqEoG+boHtTR/XDSOqicLylguQD+jmWxd0OLphmvWgRL7hW8Quxyt7ik lplRHwSEhbXyonzQrtMCTj6i+BeBaPcz1eRKPVZYhl/rhuFmxsAD+qHssg6+hy5sO0q0 KqAxqBcb1Svq3Hg8RiMNjUed/Ma8IjeLS6XqL/f78rK/gPCINMK/D2Mo5+RLvLRkKI4j IMWw== 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; bh=cxebrAA4qwXUsrw/utWWY2iCY1zg8Q+R46d3aRf1h38=; b=JjtC4H+mGyGhdR6ejxnfyfpJfv9C30yiAA0dFXGjJHe30hNqPUjhUUcHPrOay38u8C WSTYm9gk96oIAMh82kE2JDUDmPguO4Xxwzjumg82eg8oUKwkqks5ml06is484af7IX/t 6dvcV2HNjRtDI+G7lg5I5YAXt41gAyTjzHUPpTlYvB8ZFcr0xM5Atyp0E5R0IXy4kVOU CZesJCMj50PKaABGiIoufmDle4m034wIpx5z3QXK8/t1A49Mb27tKfsqpPmYvfVaETbM tUXE9nNLlSpDq20YeZfI5SSi/myMWPcGv/Kb4C8gIVMSJP2gqZtNgdMYkBZNlAHic0WA kc5g== ARC-Authentication-Results: i=1; mx.google.com; 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 12si72639537pgu.469.2019.08.14.03.01.54; Wed, 14 Aug 2019 03:02:13 -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; 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 S1726121AbfHNKBT (ORCPT + 99 others); Wed, 14 Aug 2019 06:01:19 -0400 Received: from mail-wr1-f99.google.com ([209.85.221.99]:34409 "EHLO mail-wr1-f99.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbfHNKBS (ORCPT ); Wed, 14 Aug 2019 06:01:18 -0400 Received: by mail-wr1-f99.google.com with SMTP id 31so110542376wrm.1 for ; Wed, 14 Aug 2019 03:01:17 -0700 (PDT) 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=cxebrAA4qwXUsrw/utWWY2iCY1zg8Q+R46d3aRf1h38=; b=XfPZxGgKlEiAajzjYREZgTLsk+du4uemSgzn9sbvYQ+Rqw6HuIZTorqP37WGYj++0K 3ltUoyWpLW3THWQ6WiqCNIiLwsBeRW1ZdVpL8TFhaP2/MA6PztBH/1JdzUjIAkvpK/Jj xH/prxBXksqVrIULh9eMCcXEgdI7GQSJey/+SiJGGzmU69V/Cx8eR38++MMmkpjArXaA ll49oBgydFfZ/v6/dC6xx6LiKadHlNDBGd1tS3VV3lOOT1ip1QqNk+GO0YJvNtF//cY/ hceTKsZplUy01+9GbzI05sDT4OWes+45mUQ2C/16OloSSLwGlr7PTGVAzwfjXf5IgMkk 6y4w== X-Gm-Message-State: APjAAAWo9djGXeCGYOSKwP/0OIIsxvHJ+4XJc9qbY+0ZLVLIzMhvlSir XnuoxdFAhv7/1msvv+6y8Bdsv3FH3FnICptUI9QzzbXMqBvYFLwwwlhjFW4Iav2Eaw== X-Received: by 2002:a5d:45cb:: with SMTP id b11mr10300129wrs.117.1565776876953; Wed, 14 Aug 2019 03:01:16 -0700 (PDT) Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk. [2a01:7e01::f03c:91ff:fed4:a3b6]) by smtp-relay.gmail.com with ESMTPS id y6sm29162wmi.15.2019.08.14.03.01.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 03:01:16 -0700 (PDT) X-Relaying-Domain: sirena.org.uk Received: from ypsilon.sirena.org.uk ([2001:470:1f1d:6b5::7]) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hxq5k-0004tf-N4; Wed, 14 Aug 2019 10:01:16 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id E0AAA2742B4F; Wed, 14 Aug 2019 11:01:15 +0100 (BST) Date: Wed, 14 Aug 2019 11:01:15 +0100 From: Mark Brown To: Ben Whitten Cc: linux-kernel@vger.kernel.org, afaerber@suse.de, Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: Re: [PATCH] regmap: fix writes to non incrementing registers Message-ID: <20190814100115.GF4640@sirena.co.uk> References: <20190813212251.12316-1-ben.whitten@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xaMk4Io5JJdpkLEb" Content-Disposition: inline In-Reply-To: <20190813212251.12316-1-ben.whitten@gmail.com> X-Cookie: Bridge ahead. Pay troll. 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 --xaMk4Io5JJdpkLEb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 13, 2019 at 10:22:51PM +0100, Ben Whitten wrote: > @@ -1489,10 +1489,11 @@ static int _regmap_raw_write_impl(struct regmap *= map, unsigned int reg, > WARN_ON(!map->bus); > =20 > /* Check for unwritable registers before we start */ > - for (i =3D 0; i < val_len / map->format.val_bytes; i++) > - if (!regmap_writeable(map, > - reg + regmap_get_offset(map, i))) > - return -EINVAL; > + if (!regmap_writeable_noinc(map, reg)) > + for (i =3D 0; i < val_len / map->format.val_bytes; i++) > + if (!regmap_writeable(map, > + reg + regmap_get_offset(map, i))) > + return -EINVAL; This feels like we're getting ourselves confused about nonincrementing registers and probably have other breakage somewhere else - we're already checking for nonincrementability in regmap_write_noinc(), and here we're only checking if the first register in the block has that property which might blow up on us if there's a register in the middle of the block that is nonincrementable. If we're going to check this here I think we should check on every register, but this is _raw_write_impl() which is part of the call path for implementing regmap_noinc_write() so checking here will break the API purpose designed for nonincrementing writes. --xaMk4Io5JJdpkLEb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl1T2+sACgkQJNaLcl1U h9DiCAf+NkGrG44e6bBSmbdGlvwEH+uWw3YNmF8ZBR0BQ2PEj+JHd0Pmg+7mrtmi SYF2DD/vUbZkALAWQWlo+/+bK96VutNUbuo1poKUEPbZt2f949bWi8XOCBkWRpgw N0t8BbhjqSqv9eMtYdqukU8sXg3Jjwtp1ctnU/R/Y5sXGIBYaZnvrTUFPaJh42av kyjurYlhXMIgwL25RTwwAoQelR7izDuktSg7f6J87OtUFJTSfdBzKvMgDcNo0k/a 68SvK7TpClIQyI3GJ0diwc8RUp7fAtS+9eStBdKRURFirPqqoyQF/QDa57PThX7y NLciOVJy82hAyaJCQGgIM44v3iT5AQ== =dgtC -----END PGP SIGNATURE----- --xaMk4Io5JJdpkLEb--