Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1421445pxj; Fri, 21 May 2021 13:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnXfLUZpRNABdrTRYSKCaGZyZ55GaP8WKPKMX38rlRhh7hxg8H8IvYQO+Ch8L6MZQr1kLt X-Received: by 2002:a02:b107:: with SMTP id r7mr7567541jah.8.1621630680821; Fri, 21 May 2021 13:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621630680; cv=none; d=google.com; s=arc-20160816; b=z/5+7+BOfv55CEselR9kSpuzQOH5bT2cI1edpGiTcDguWS2YPq8ZzkWX6kE9u/gJQt hsFV0HUllbRxrQs93/AMdixr70gNf4sjphWTrdAam210QuGfJFXkN90csO9Ou7LX0v+Q y5Dm432qJLp0vcAcp3APAEbJorezTUFAjbkBpW6ATDo+OFIVEQlb4k5SGL2KbICuUGJg pf1JalIlC1QAnYa47AlyftdTvv/1yFGPd2g/JrMldDw9B3SMzHbKQZEQt2xUI6BJTIXq +rUJXb9tW8u7jQtzmq6kyhLssxwOtQWrB1ffO9GPqYhE4z/mC02ydWJpi/8OkLByEllM cHhA== 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=igzFIccuiFriowe2kh28IcK5gIIDPMZQzahZDG5tSm0=; b=I6lrXuP9FRxfep9PELa9dbpnLtUbQhqoqQuq5TyQnfy2BV0ZAUM44oDPy5uqqrqn4W aY13rnCUyN9dWNukWQlAenxwTPivn3zQSWA5zWKqBopNWiJ2kV6W4OpiTmRMVy6zs5/M zPK5Y5AmvpDoyX2WeDcD/TWcn0RCHeZemogkl0F1a6dU8MH1/BXfFALDkfiiDyHgQIhF qQcCItVY/BhSiu7bKwSPQ2RSsS8L2rjFnEPK+pcQvlI+lsGyh53gm1FNLYjJ9OauHlt4 qFd8PAnv+6xjpL/OF6tTioeJh7y3NGOXXdsSV7tT4jJD0MOst8hH49LJUu8rzmpDqGWF KDow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LETZk6m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o67si7185028jao.17.2021.05.21.13.57.47; Fri, 21 May 2021 13:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LETZk6m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbhEUUqb (ORCPT + 99 others); Fri, 21 May 2021 16:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbhEUUq3 (ORCPT ); Fri, 21 May 2021 16:46:29 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 089EAC0613CE for ; Fri, 21 May 2021 13:45:06 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id u7so3040643plq.4 for ; Fri, 21 May 2021 13:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=igzFIccuiFriowe2kh28IcK5gIIDPMZQzahZDG5tSm0=; b=LETZk6m+q6FDNRsX65WTrupTI3FZ/EaQiq9mZPlX5+fjhzMiZjoJ72TwI78eYo6ABF v0xtJzjuccrXPBC9B64tc2CjjeLeRuLBm+FxFhV8kp92IknNf3COW34W3dCYecvXC4nB PXWpx9tg4j5vGdXj8AyC9eRqGeMHTCOLfYumo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=igzFIccuiFriowe2kh28IcK5gIIDPMZQzahZDG5tSm0=; b=L3A/2ZgNrPF2QSwvO3D3llKtsJNq5+3sTdc/vzEgJGENU6nk1FQ81BiLEk0uUO6ttl PVKj0W1sRA/EEpcJTgf4n3gAaXAC28847f0g1sveRKS8BF46Zd0nYpyjDAP+GnDAvLfR DOjZq0j8WEVBxGwPSLNSbPy2MWzZGWQEUkm2wY4iou6yMqHriQASNQlsxztrYPzQH5rs xH5nlvQACMFvUK+Yb4z6gVyDIqZA3M/wm3WbfAzPv2hCfa2SCYe0cHM78r+pIOwe0gGS Ca4SnWmsPOG09gPSfAfvsOzQF/yFKLXlIDPrl8bHV3o2LGdGf8lOukS+wtcJEy6WRFnp YHLw== X-Gm-Message-State: AOAM530FV3hJfoE8pTHeobie4MnOmZeS2X8TprthHvUlqgPSPht2MxPx 8e2bTTxVpRXUj60nEUb9Zwrt4Q== X-Received: by 2002:a17:902:db09:b029:f4:8d37:8d12 with SMTP id m9-20020a170902db09b02900f48d378d12mr14481362plx.52.1621629905561; Fri, 21 May 2021 13:45:05 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:10e9:a6cd:727f:561e]) by smtp.gmail.com with ESMTPSA id l62sm5055928pfl.88.2021.05.21.13.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 13:45:05 -0700 (PDT) From: Douglas Anderson To: "Rafael J . Wysocki" Cc: Bjorn Andersson , Niklas Cassel , Akhil P Oommen , linux-arm-msm@vger.kernel.org, Ulf Hansson , Douglas Anderson , Andy Gross , Niklas Cassel , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2] PM: AVS: qcom-cpr: Use nvmem_cell_read_variable_le_u32() Date: Fri, 21 May 2021 13:44:53 -0700 Message-Id: <20210521134437.v2.1.Id1c70158722750aec0673d60c12e46a9c66bbfed@changeid> X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's delete the private function cpr_read_efuse() since it does the basically the same thing as the new API call nvmem_cell_read_variable_le_u32(). Differences between the new API call and the old private function: * less error printing (I assume this is OK). * will give an error if the value doesn't fit in 32-bits (the old code would have truncated silently). Signed-off-by: Douglas Anderson --- I haven't done any more than compile-test this. Mostly I'm just writing this patch because it helped provide inspiration for the general API function. Changes in v2: - Resending v1 as a singleton patch; dependency is merged in mainline. drivers/soc/qcom/cpr.c | 43 +++++------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/drivers/soc/qcom/cpr.c b/drivers/soc/qcom/cpr.c index b24cc77d1889..4ce8e816154f 100644 --- a/drivers/soc/qcom/cpr.c +++ b/drivers/soc/qcom/cpr.c @@ -801,38 +801,6 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, return ret; } -static int cpr_read_efuse(struct device *dev, const char *cname, u32 *data) -{ - struct nvmem_cell *cell; - ssize_t len; - char *ret; - int i; - - *data = 0; - - cell = nvmem_cell_get(dev, cname); - if (IS_ERR(cell)) { - if (PTR_ERR(cell) != -EPROBE_DEFER) - dev_err(dev, "undefined cell %s\n", cname); - return PTR_ERR(cell); - } - - ret = nvmem_cell_read(cell, &len); - nvmem_cell_put(cell); - if (IS_ERR(ret)) { - dev_err(dev, "can't read cell %s\n", cname); - return PTR_ERR(ret); - } - - for (i = 0; i < len; i++) - *data |= ret[i] << (8 * i); - - kfree(ret); - dev_dbg(dev, "efuse read(%s) = %x, bytes %zd\n", cname, *data, len); - - return 0; -} - static int cpr_populate_ring_osc_idx(struct cpr_drv *drv) { @@ -843,8 +811,7 @@ cpr_populate_ring_osc_idx(struct cpr_drv *drv) int ret; for (; fuse < end; fuse++, fuses++) { - ret = cpr_read_efuse(drv->dev, fuses->ring_osc, - &data); + ret = nvmem_cell_read_variable_le_u32(drv->dev, fuses->ring_osc, &data); if (ret) return ret; fuse->ring_osc_idx = data; @@ -863,7 +830,7 @@ static int cpr_read_fuse_uV(const struct cpr_desc *desc, u32 bits = 0; int ret; - ret = cpr_read_efuse(drv->dev, init_v_efuse, &bits); + ret = nvmem_cell_read_variable_le_u32(drv->dev, init_v_efuse, &bits); if (ret) return ret; @@ -932,7 +899,7 @@ static int cpr_fuse_corner_init(struct cpr_drv *drv) } /* Populate target quotient by scaling */ - ret = cpr_read_efuse(drv->dev, fuses->quotient, &fuse->quot); + ret = nvmem_cell_read_variable_le_u32(drv->dev, fuses->quotient, &fuse->quot); if (ret) return ret; @@ -1001,7 +968,7 @@ static int cpr_calculate_scaling(const char *quot_offset, prev_fuse = fuse - 1; if (quot_offset) { - ret = cpr_read_efuse(drv->dev, quot_offset, "_diff); + ret = nvmem_cell_read_variable_le_u32(drv->dev, quot_offset, "_diff); if (ret) return ret; @@ -1701,7 +1668,7 @@ static int cpr_probe(struct platform_device *pdev) * initialized after attaching to the power domain, * since it depends on the CPU's OPP table. */ - ret = cpr_read_efuse(dev, "cpr_fuse_revision", &cpr_rev); + ret = nvmem_cell_read_variable_le_u32(dev, "cpr_fuse_revision", &cpr_rev); if (ret) return ret; -- 2.31.1.818.g46aad6cb9e-goog