Received: by 10.223.185.116 with SMTP id b49csp3624880wrg; Mon, 26 Feb 2018 03:19:57 -0800 (PST) X-Google-Smtp-Source: AH8x226gDWviy74luUg2ash+2ZgbIyh1pJDQk2t8j8sw+z3dM7dNne1och5EjPne4U5C+ZZm4S4i X-Received: by 2002:a17:902:66e6:: with SMTP id e93-v6mr10350337plk.312.1519643997269; Mon, 26 Feb 2018 03:19:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519643997; cv=none; d=google.com; s=arc-20160816; b=HnWge3OcnK9guokyOEUORBDyJVB47oSBy0A1P5D2Bx7H+VPEE5EFY7bTtNk6vumXOT FNk5R9yGGmqEzvSOPiXAydP3gH+gWUhJ3KqBXFNaMALD3dQm17gc003dbiWFYwnL9C40 R3mZ0g7yfUvW+MvxbRLy/2XL48e2w5RyPscm6qjKSQx/l/3sbemMfUd9s4IH5Rzv4CVO oyPBwAZKbweeoANiEv243L4YpxoD/LTlBgSCxlxwuGFveTLYHHVNe+JGzMVgbg8YALRo YWCa+mtsFIJYM/giZky6VNuyO+Uhot5JgfvO7sWJy5dscYHm/OZWss6mo/y7XU3NhCAZ 2NvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=qvSbJuTON7KFMltL+gAGnR9c5YsQobxR1bI96rLQJn0=; b=x1h53RnYx9iYIyruf1BISmXlcGEqSHggz2Fw6S8/J6zYfx9PeHEilJ7MXL6GAiDcQp YS4ycEM3osZxCh6XTEM9YUsI3z7tLvUH//ssrJ+tzAudHe2Ir/EhakXKGU2jakrR4Jub VWH2CK8PhRMIspGirMhGt0BODvmLRUBni1qZBU8fXtT0P6LqCqu5aDFlYxZjQN4KltAz 0jSqof8gLeWkUnaXgvmzVRlhDrlTcE3jmtkL7fNoQySPTzDZaekxbpdFUQQN8d8EdBXi dRf542/Gr9KW1U8OlxAMVTqJ7nNcbYRbWDAs+yu2uNzvZDVspwRRx9zMfK45+NmS1bQW 8r/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=SRcSZ9G7; 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 5-v6si6619027plt.371.2018.02.26.03.19.42; Mon, 26 Feb 2018 03:19:57 -0800 (PST) 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=SRcSZ9G7; 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 S1752864AbeBZLSK (ORCPT + 99 others); Mon, 26 Feb 2018 06:18:10 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:52114 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752815AbeBZLR7 (ORCPT ); Mon, 26 Feb 2018 06:17:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=qvSbJuTON7KFMltL+gAGnR9c5YsQobxR1bI96rLQJn0=; b=SRcSZ9G7OrCk twc8EzHgeymPdsTKIaoBIW2NfbLAm5a7saMlRpsXRKMgyusrB5AXvATPhIIclSLKvWCvQw78bNLY3 eJR0WWIoCt5KimFL4P1pXpBTM92I8KdAnI5LCYywFKc5d6g721ewK9pErFHjDAWHHiIDXOX+a6wXm IeHVU=; 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 1eqGn6-0007wQ-GC; Mon, 26 Feb 2018 11:17:56 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1eqGn6-0005b6-1c; Mon, 26 Feb 2018 11:17:56 +0000 From: Mark Brown To: Charles Keepax Cc: Mark Brown , broonie@kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org Subject: Applied "regmap: Tidy up regmap_raw_write chunking code" to the regmap tree In-Reply-To: <20180222125914.17016-4-ckeepax@opensource.cirrus.com> Message-Id: Date: Mon, 26 Feb 2018 11:17:56 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regmap: Tidy up regmap_raw_write chunking code has been applied to the regmap tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 364e378b8d1679f91a29a9537a881bba17931cfb Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 22 Feb 2018 12:59:13 +0000 Subject: [PATCH] regmap: Tidy up regmap_raw_write chunking code Raw writes may need to be split into small chunks if max_raw_write is set. Tidy up the code implementing this, the new code is slightly clearer, slightly shorter and slightly more efficient. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index e82ea77849fb..bfdd66dd3766 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1812,40 +1812,35 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, { size_t val_bytes = map->format.val_bytes; size_t val_count = val_len / val_bytes; - int chunk_stride = map->reg_stride; - size_t chunk_size = val_bytes; - size_t chunk_count = val_count; + size_t chunk_count, chunk_bytes; + size_t chunk_regs = val_count; int ret, i; if (!val_count) return -EINVAL; - if (!map->use_single_write) { - if (map->max_raw_write) - chunk_size = map->max_raw_write; - else - chunk_size = val_len; - if (chunk_size % val_bytes) - chunk_size -= chunk_size % val_bytes; - chunk_count = val_len / chunk_size; - chunk_stride *= chunk_size / val_bytes; - } + if (map->use_single_write) + chunk_regs = 1; + else if (map->max_raw_write && val_len > map->max_raw_write) + chunk_regs = map->max_raw_write / val_bytes; + + chunk_count = val_count / chunk_regs; + chunk_bytes = chunk_regs * val_bytes; /* Write as many bytes as possible with chunk_size */ for (i = 0; i < chunk_count; i++) { - ret = _regmap_raw_write_impl(map, - reg + (i * chunk_stride), - val + (i * chunk_size), - chunk_size); + ret = _regmap_raw_write_impl(map, reg, val, chunk_bytes); if (ret) return ret; + + reg += regmap_get_offset(map, chunk_regs); + val += chunk_bytes; + val_len -= chunk_bytes; } /* Write remaining bytes */ - if (!ret && chunk_size * i < val_len) - ret = _regmap_raw_write_impl(map, reg + (i * chunk_stride), - val + (i * chunk_size), - val_len - i * chunk_size); + if (val_len) + ret = _regmap_raw_write_impl(map, reg, val, val_len); return ret; } -- 2.16.1