mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Ben Whitten <ben.whitten@gmail.com>
Cc: linux-kernel@vger.kernel.org, afaerber@suse.de,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH] regmap: fix writes to non incrementing registers
Date: Wed, 14 Aug 2019 11:01:15 +0100	[thread overview]
Message-ID: <20190814100115.GF4640@sirena.co.uk> (raw)
In-Reply-To: <20190813212251.12316-1-ben.whitten@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

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);
>  
>  	/* Check for unwritable registers before we start */
> -	for (i = 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 = 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-08-14 10:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 21:22 Ben Whitten
2019-08-14 10:01 ` Mark Brown [this message]
2019-08-14 13:09   ` Ben Whitten
2019-08-14 13:32     ` Andreas Färber
2019-08-14 16:05       ` Mark Brown
2019-08-14 16:44         ` Andreas Färber
2019-08-14 16:19     ` Mark Brown
2019-09-03  9:42       ` Ben Whitten
2019-09-03 12:12         ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190814100115.GF4640@sirena.co.uk \
    --to=broonie@kernel.org \
    --cc=afaerber@suse.de \
    --cc=ben.whitten@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®