From patchwork Thu Nov 2 20:30:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Wolsieffer X-Patchwork-Id: 161118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp625584vqu; Thu, 2 Nov 2023 13:31:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaYoQ5IXXbriGfM6hVQOJZ9QQsUi0PfYYOUmg73iRIonhyg6MShOfAuHm0baSljcf12oUL X-Received: by 2002:a05:6a00:14cc:b0:6c3:45bc:41f8 with SMTP id w12-20020a056a0014cc00b006c345bc41f8mr1772999pfu.33.1698957077244; Thu, 02 Nov 2023 13:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698957077; cv=none; d=google.com; s=arc-20160816; b=dzyXXooElv6yZJJtoSTa1pzKZW0zvQXnTd7kXHDAfesZM2nux0RtnpPUsUxK9qaqUQ XgSyxQLnQrT2gnpcYWtadBiqBNsNywBvBEQJ0S6bmclsNuhF3RENUT2NlvJSzIp5wyIZ adN9L5gousCSzcdZao6BiTEfQM9EVjK+USqxcPqNaZSMsWgQZ4ul3maH+ROZekBcN1qE /BR3O7yj5QliATni02PX726tCMKpBlDSH7kX8sKCfjad769kfxYKNaQ4YmYWsM6mJ3v/ +Ifr5UL57RotfsNshuHfD7D6BlERtDl+roYRlHCaXrvgOsRqg4S9iRrwB8MKQ4ZtJCkL IJiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gaCHdvbA7W42TY/eQsjS/Lhc+W/VnCugrlrNsZjT78A=; fh=P8ttbGuC/XWTD7VY66WZWyD5R5kef/rXuA/6MggBIwc=; b=Dq/4LhGYcWmLWUj4BKZ2e1R/ykrxWlMByswN/lw0F6JXq80zaOrIBMfSgEa31KCBCw tJvrVl9Os/RYikEvLEBQYkDEl4EN9vv8ArPCYe7AtXOKel0ztR44H51xA2cTG7X6CP9L wQ6xeH70WEsauTlx6GOtfGouHrkfaZZbBQKLNVv/epFCurC7alBk8jVaHNZRg5IL3RgS NhPM+hi+42MF1ohWNbBqO6ZTD+pW8fgVZ8vES+RaZqiZWM9GTc9rkvR3t20P3cLn2b/x 6eD1VMFAGofHcxLGGAYjWZJKks4DEbqenB7oLBM8qjznpwHj0aXsUPlftKEodj7HnRrJ i7yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=AdSl+2M6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j64-20020a638b43000000b005ab776a4d4csi205233pge.610.2023.11.02.13.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 13:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=AdSl+2M6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2510B824299F; Thu, 2 Nov 2023 13:31:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345031AbjKBUbH (ORCPT + 35 others); Thu, 2 Nov 2023 16:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232715AbjKBUbG (ORCPT ); Thu, 2 Nov 2023 16:31:06 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69FF181 for ; Thu, 2 Nov 2023 13:31:01 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-778925998cbso79298585a.0 for ; Thu, 02 Nov 2023 13:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hefring-com.20230601.gappssmtp.com; s=20230601; t=1698957060; x=1699561860; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gaCHdvbA7W42TY/eQsjS/Lhc+W/VnCugrlrNsZjT78A=; b=AdSl+2M6tSCRPHS7/6YzOLh6JtVadUDc03EuQaAx/u9cRXu/jk0+quxX4GIZNOy+Fo Fcn7Faloh8DOYkIHzhZ0SDk6tOKdcAsYinSgesjIqNJz4wgv24J/sZzogOYOLjtwHBKN h2GDHW/sLRk+s2puHE6OuWNF7kkFAqVWDFmlIQYCbQmZ0ljYnDdFF9hKoASdQ8eWvJWa 7TiIWazfFZqjEn6lvqyUB3TNqkQ4//OlW1fdrir/tUBnkfMJYCNNd5Fs+ueJAGctH1xN LKAGQexCh9z0DKLFocQiMDwOuQq3LqtZuSuXQeQW8xIAvh+Xawvv0kRe//6Ug0Oc83Zj acvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698957060; x=1699561860; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gaCHdvbA7W42TY/eQsjS/Lhc+W/VnCugrlrNsZjT78A=; b=EQGb1zMAg3MaHYaoKTgLHPhse0mMD5W+mMibO7GGXlrz+w3fCSjzpR63Jb2Sk70ClK WOSzkO8WOHarWkcV39kJMIaeOgc28xg/+Ogdo4PLoADUy8yWwSnRGk11AA+xdEyAinqd 8OwXSm1rIiqtdEV76HnF+h5fD4T8BLtmsmHb6i8LlEMyN9s/CJXXrUyzp538532pI2XJ td6FhRmnlRJ0aKfKhy+zvdBcla8dWYu8YYPMr1TpwFU+5gzihkut8sTP+0iV/svFZuz5 Ot/E29M5S9hnxIByaCZtmqmwSfw3yRzaj1O+kLh536HVyl+TigJwCk4bzEX5vTw+HzZN ev0A== X-Gm-Message-State: AOJu0Yw37AUdowSgIzOPjH9X5DL59d117xHeTuIJ07eDEktWrcNcBOmp NMoaJI/stpXWjxi51MQQXSAVt555ns8XkoEe6GA= X-Received: by 2002:a05:620a:472a:b0:767:923:48e7 with SMTP id bs42-20020a05620a472a00b00767092348e7mr23720188qkb.5.1698957060317; Thu, 02 Nov 2023 13:31:00 -0700 (PDT) Received: from localhost.localdomain ([50.212.55.89]) by smtp.gmail.com with ESMTPSA id m17-20020a05620a24d100b00774292e636dsm92164qkn.63.2023.11.02.13.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 13:30:59 -0700 (PDT) From: Ben Wolsieffer To: linux-kernel@vger.kernel.org Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ben Wolsieffer Subject: [PATCH 1/2] regmap: ram: support noinc semantics Date: Thu, 2 Nov 2023 16:30:38 -0400 Message-ID: <20231102203039.3069305-1-ben.wolsieffer@hefring.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 13:31:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781485616380482640 X-GMAIL-MSGID: 1781485616380482640 Support noinc semantics in RAM backed regmaps, for testing purposes. Add a new callback that selects registers which should have noinc behavior. Bulk writes to a noinc register will cause the last value in the buffer to be assigned to the register, while bulk reads will copy the same value repeatedly into the buffer. This patch only adds support to regmap-raw-ram, since regmap-ram does not support bulk operations. Signed-off-by: Ben Wolsieffer --- drivers/base/regmap/internal.h | 1 + drivers/base/regmap/regmap-raw-ram.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 9a9ea514c2d8..583dd5d7d46b 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -318,6 +318,7 @@ struct regmap_ram_data { bool *read; bool *written; enum regmap_endian reg_endian; + bool (*noinc_reg)(struct regmap_ram_data *data, unsigned int reg); }; /* diff --git a/drivers/base/regmap/regmap-raw-ram.c b/drivers/base/regmap/regmap-raw-ram.c index c9b800885f3b..463adafa9532 100644 --- a/drivers/base/regmap/regmap-raw-ram.c +++ b/drivers/base/regmap/regmap-raw-ram.c @@ -41,10 +41,15 @@ static int regmap_raw_ram_gather_write(void *context, return -EINVAL; r = decode_reg(data->reg_endian, reg); - memcpy(&our_buf[r], val, val_len); - - for (i = 0; i < val_len / 2; i++) - data->written[r + i] = true; + if (data->noinc_reg && data->noinc_reg(data, r)) { + memcpy(&our_buf[r], val + val_len - 2, 2); + data->written[r] = true; + } else { + memcpy(&our_buf[r], val, val_len); + + for (i = 0; i < val_len / 2; i++) + data->written[r + i] = true; + } return 0; } @@ -70,10 +75,16 @@ static int regmap_raw_ram_read(void *context, return -EINVAL; r = decode_reg(data->reg_endian, reg); - memcpy(val, &our_buf[r], val_len); - - for (i = 0; i < val_len / 2; i++) - data->read[r + i] = true; + if (data->noinc_reg && data->noinc_reg(data, r)) { + for (i = 0; i < val_len; i += 2) + memcpy(val + i, &our_buf[r], 2); + data->read[r] = true; + } else { + memcpy(val, &our_buf[r], val_len); + + for (i = 0; i < val_len / 2; i++) + data->read[r + i] = true; + } return 0; } From patchwork Thu Nov 2 20:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Wolsieffer X-Patchwork-Id: 161119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp625634vqu; Thu, 2 Nov 2023 13:31:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHZZCEu1kGEWmiy48N7QvJ9ceqhgNb23yoEaI0kWo0pDRRqDLfgM/a5O4heo2sbntOVXuK X-Received: by 2002:a17:90b:1648:b0:280:a69e:45ec with SMTP id il8-20020a17090b164800b00280a69e45ecmr1103006pjb.5.1698957083114; Thu, 02 Nov 2023 13:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698957083; cv=none; d=google.com; s=arc-20160816; b=Ernh6amkRphMXGUYdHIKXr9gHBjEfoeuOZvX4KbWAEdEpphJOsKTtVCuyawKzkQEVQ kUXAwgiUN9TSa88geOAnST9rNTazT9l5FiLLwdJdj1bfAHZ+BZlkcPhaADOyVtRFCkvB vtY8Sbya0p0HOf4xNzqPsGYEhxy4PnD+zFxgHthjCMbgoC9y/PGbX+MVWBnJyFeGeYm3 7hsfZl6zkz7ysti7m+1JdQQJB5dZzFY/vpItDqkPDHfkoQWOl+NBZotY9xIQKTY7b294 oy059MU6olWRgbgu6fwXEG+cvtKnGpagZAxI6wNreAwdjNbVncCKmLbY6nWoLe9xm6bl 9QnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CDmEeaAuqX9A7RBszMcn1w/iYiD0m14dhC0ZJpYnrrA=; fh=P8ttbGuC/XWTD7VY66WZWyD5R5kef/rXuA/6MggBIwc=; b=ZX96+orkrQzlOs+F13Nl9/fnHejDdFCkLqE0Mhzfq8FXrrRpIq/Lnz/B0szNfFGtcq ACV1zj8FJbDaFii/wNDpkYMv2kjule6AeQPWhx0PSwBHLCmcQNHVWn5ErXgRjrpGTrtA qH1gd6Y6O+IcYcKWmLsY63v/E8lIYxfAH1upcOxZQUfJdWKg/i9y/TE4398cqG2owreH qLQUd6dGgs5iQZO87Z7hSR4n8yQdFY2y3mq2js2Gt97REOMoNNw6K/RpNcVne9tqWxAV s33pxbm7aJ+Cen0eRABW0lmJVpvDjV3Z0HSqtFcbVR422uwLUXd8rNvg+/UhAQrlsSeh Lkzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=qFuUOkMu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id qe8-20020a17090b4f8800b00277e0d7163asi286309pjb.32.2023.11.02.13.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 13:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=qFuUOkMu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9A15A824299F; Thu, 2 Nov 2023 13:31:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345561AbjKBUbJ (ORCPT + 35 others); Thu, 2 Nov 2023 16:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234015AbjKBUbG (ORCPT ); Thu, 2 Nov 2023 16:31:06 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085F7188 for ; Thu, 2 Nov 2023 13:31:03 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-77891f362cfso114478385a.1 for ; Thu, 02 Nov 2023 13:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hefring-com.20230601.gappssmtp.com; s=20230601; t=1698957061; x=1699561861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CDmEeaAuqX9A7RBszMcn1w/iYiD0m14dhC0ZJpYnrrA=; b=qFuUOkMuwaciRNT22gtJS1+0AVrXItsinfImhIGnRHaDgPSPsjIZxhiUluzeLgmQDT xgsD3RyV4RJc8LpySplQOlAkS9mGKe66S+Rb3S20VQI9fMPv/9an59zdve2V4OZLflAQ LLTe2/iy3elzMzXpU0mizXM7LC3qgb4Isx6cgPHoHimE4d7JnjM7Ri2jd0tj59kwXviH vtGyE+5i0SK/61N5QBGIYoxz4QQL2GAwa+aKQWo1rur/ddAmNvGeJeLZGLOkuzv5DegG 2lS1pQfqYp1niYjs6BO8dZ0LdMOD108SGBvzGoEyHC59J9NNv93R0Nwsbx68s7U+YeU9 SRIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698957061; x=1699561861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CDmEeaAuqX9A7RBszMcn1w/iYiD0m14dhC0ZJpYnrrA=; b=qa6wEz4EzLUf82lcMqzgIUGA0TV3+G9ZendM5OPyIxpe18HPUgTman96Gj+f00f5Ri kLhL1muZTfvlD4Xnf7xkl2Vspt1bzehhWrROmOBm4NM3yz3jt4F6fSXQfs9hscQ9EQX6 fcFHBVdayPhxWkSxQY6FOSsdm4d1WqFpfnnyQsD+/UEhV6EXetQkTpM8VcsZQ89QUqrG KRQNW8fIwiAt0uP0NDMNptGmRrVc4cI1BG74DgglWC4g/xsFWCFYGT2fCSM9burZmhNl dGzhBcAnjSOFrcGSuhvYRLVJnqMzCJwJq4WF2KN5+TyY9awffDtIeY2GXpHXF7apFrhN cD9Q== X-Gm-Message-State: AOJu0Ywlwzqc4IaGHj0hyuiDg6ScwuDxP7GmHfirB6dIZdOycG3NYSKD XzG1CaKJ/WE35a2U1u/K+bqi5Drez47mE1JKZz4= X-Received: by 2002:a05:620a:4110:b0:779:d1a6:ee5c with SMTP id j16-20020a05620a411000b00779d1a6ee5cmr993034qko.32.1698957061253; Thu, 02 Nov 2023 13:31:01 -0700 (PDT) Received: from localhost.localdomain ([50.212.55.89]) by smtp.gmail.com with ESMTPSA id m17-20020a05620a24d100b00774292e636dsm92164qkn.63.2023.11.02.13.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 13:31:00 -0700 (PDT) From: Ben Wolsieffer To: linux-kernel@vger.kernel.org Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ben Wolsieffer Subject: [PATCH 2/2] regmap: kunit: add noinc write test Date: Thu, 2 Nov 2023 16:30:39 -0400 Message-ID: <20231102203039.3069305-2-ben.wolsieffer@hefring.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102203039.3069305-1-ben.wolsieffer@hefring.com> References: <20231102203039.3069305-1-ben.wolsieffer@hefring.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 13:31:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781485622257859107 X-GMAIL-MSGID: 1781485622257859107 Add a test for writing to a noinc register, which verifies that the write does not touch adjacent registers. This test succeeds with [1] applied and fails without it. [1] 984a4afdc87a ("regmap: prevent noinc writes from clobbering cache") Signed-off-by: Ben Wolsieffer --- drivers/base/regmap/regmap-kunit.c | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c index e14cc03a17f6..026bdcb45127 100644 --- a/drivers/base/regmap/regmap-kunit.c +++ b/drivers/base/regmap/regmap-kunit.c @@ -1186,6 +1186,65 @@ static void raw_write(struct kunit *test) regmap_exit(map); } +static bool reg_zero(struct device *dev, unsigned int reg) +{ + return reg == 0; +} + +static bool ram_reg_zero(struct regmap_ram_data *data, unsigned int reg) +{ + return reg == 0; +} + +static void raw_noinc_write(struct kunit *test) +{ + struct raw_test_types *t = (struct raw_test_types *)test->param_value; + struct regmap *map; + struct regmap_config config; + struct regmap_ram_data *data; + unsigned int val, val_test, val_last; + u16 val_array[BLOCK_TEST_SIZE]; + + config = raw_regmap_config; + config.volatile_reg = reg_zero; + config.writeable_noinc_reg = reg_zero; + config.readable_noinc_reg = reg_zero; + + map = gen_raw_regmap(&config, t, &data); + KUNIT_ASSERT_FALSE(test, IS_ERR(map)); + if (IS_ERR(map)) + return; + + data->noinc_reg = ram_reg_zero; + + get_random_bytes(&val_array, sizeof(val_array)); + + if (config.val_format_endian == REGMAP_ENDIAN_BIG) { + val_test = be16_to_cpu(val_array[1]) + 100; + val_last = be16_to_cpu(val_array[BLOCK_TEST_SIZE - 1]); + } else { + val_test = le16_to_cpu(val_array[1]) + 100; + val_last = le16_to_cpu(val_array[BLOCK_TEST_SIZE - 1]); + } + + /* Put some data into the register following the noinc register */ + KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 1, val_test)); + + /* Write some data to the noinc register */ + KUNIT_EXPECT_EQ(test, 0, regmap_noinc_write(map, 0, val_array, + sizeof(val_array))); + + /* We should read back the last value written */ + KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 0, &val)); + KUNIT_ASSERT_EQ(test, val_last, val); + + /* Make sure we didn't touch the register after the noinc register */ + KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 1, &val)); + KUNIT_ASSERT_EQ(test, val_test, val); + + regmap_exit(map); +} + static void raw_sync(struct kunit *test) { struct raw_test_types *t = (struct raw_test_types *)test->param_value; @@ -1284,6 +1343,7 @@ static struct kunit_case regmap_test_cases[] = { KUNIT_CASE_PARAM(raw_read_defaults, raw_test_types_gen_params), KUNIT_CASE_PARAM(raw_write_read_single, raw_test_types_gen_params), KUNIT_CASE_PARAM(raw_write, raw_test_types_gen_params), + KUNIT_CASE_PARAM(raw_noinc_write, raw_test_types_gen_params), KUNIT_CASE_PARAM(raw_sync, raw_test_cache_types_gen_params), {} };