From patchwork Tue May 5 22:14:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cernekee X-Patchwork-Id: 6344511 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6CBCEBEEE1 for ; Tue, 5 May 2015 22:15:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B71E20259 for ; Tue, 5 May 2015 22:15:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 445B420265 for ; Tue, 5 May 2015 22:15:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 71FBE2654C3; Wed, 6 May 2015 00:15:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 8B7A02605EA; Wed, 6 May 2015 00:14:35 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DEA37260A50; Wed, 6 May 2015 00:14:31 +0200 (CEST) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by alsa0.perex.cz (Postfix) with ESMTP id B4BF72604AB for ; Wed, 6 May 2015 00:14:24 +0200 (CEST) Received: by ieczm2 with SMTP id zm2so905010iec.2 for ; Tue, 05 May 2015 15:14:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1EaUo3phuxCP+VjO2qX3/P+PQ9/wW0G6/XswJUcXM8g=; b=FA0GvtndY3o1LA/2z9HegmFFDp9UgT+LD4m8PdVAQSE3INY6LEbroQDgXiPjEZsBU9 tyvsSMZ4Quk0ov1kHBu7fYXtvZ7BznCWiWxn4XsvrIIjd939tjgy4pdSGYbkuXQyfA1k XLRN4B4/590MoDZWAVrqlrMCFTegIbvGm9b4yKYSjwnP5ulU1p+uAGYaEYBRczx8aFs2 lNt+a9PRl6msAQzIrscU5NTC2msLaLavJnbhRXZwEgwZExA09l1lJB5iJEj41/rcVk65 lu8LfGni0y+SRu9++qb4Tq4gke4C5U8w5VAyhOyKpcJmT3ju1A2Gl0bwCsQ6+cU7b4Pj sJWg== X-Gm-Message-State: ALoCoQmr0H/A7QxG6XR09SOujGyNVdsEJxJVZYIVb3po1/g/HUBX8GKrsm+RM6wYr3MkCvwRaJfs X-Received: by 10.107.136.89 with SMTP id k86mr34742696iod.63.1430864063867; Tue, 05 May 2015 15:14:23 -0700 (PDT) Received: from kcl.mtv.corp.google.com ([172.22.66.15]) by mx.google.com with ESMTPSA id 9sm12629669iom.29.2015.05.05.15.14.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 May 2015 15:14:22 -0700 (PDT) From: Kevin Cernekee To: lgirdwood@gmail.com, broonie@kernel.org Date: Tue, 5 May 2015 15:14:13 -0700 Message-Id: <1430864057-3848-2-git-send-email-cernekee@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1430864057-3848-1-git-send-email-cernekee@chromium.org> References: <1430864057-3848-1-git-send-email-cernekee@chromium.org> Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, lars@metafoo.de, abrestic@chromium.org, linux-kernel@vger.kernel.org, dgreid@chromium.org, olofj@chromium.org Subject: [alsa-devel] [PATCH V4 1/5] regmap: Add a helper function for regcache sync test X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP We're going to add another "does this register need syncing?" check, so rather than repeating it in three places, we'll separate all of the relevant logic into a helper function. Signed-off-by: Kevin Cernekee --- drivers/base/regmap/regcache.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 7eb7b3b98794..c58493eaf050 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -249,6 +249,18 @@ int regcache_write(struct regmap *map, return 0; } +static bool regcache_reg_needs_sync(struct regmap *map, unsigned int reg, + unsigned int val) +{ + int ret; + + /* Is this the hardware default? If so skip. */ + ret = regcache_lookup_reg(map, reg); + if (ret >= 0 && val == map->reg_defaults[ret].def) + return false; + return true; +} + static int regcache_default_sync(struct regmap *map, unsigned int min, unsigned int max) { @@ -266,9 +278,7 @@ static int regcache_default_sync(struct regmap *map, unsigned int min, if (ret) return ret; - /* Is this the hardware default? If so skip. */ - ret = regcache_lookup_reg(map, reg); - if (ret >= 0 && val == map->reg_defaults[ret].def) + if (!regcache_reg_needs_sync(map, reg, val)) continue; map->cache_bypass = 1; @@ -613,10 +623,7 @@ static int regcache_sync_block_single(struct regmap *map, void *block, continue; val = regcache_get_val(map, block, i); - - /* Is this the hardware default? If so skip. */ - ret = regcache_lookup_reg(map, regtmp); - if (ret >= 0 && val == map->reg_defaults[ret].def) + if (!regcache_reg_needs_sync(map, regtmp, val)) continue; map->cache_bypass = 1; @@ -688,10 +695,7 @@ static int regcache_sync_block_raw(struct regmap *map, void *block, } val = regcache_get_val(map, block, i); - - /* Is this the hardware default? If so skip. */ - ret = regcache_lookup_reg(map, regtmp); - if (ret >= 0 && val == map->reg_defaults[ret].def) { + if (!regcache_reg_needs_sync(map, regtmp, val)) { ret = regcache_sync_block_raw_flush(map, &data, base, regtmp); if (ret != 0)