From patchwork Mon Oct 9 13:26:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 115230 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2563715qgn; Mon, 9 Oct 2017 06:32:00 -0700 (PDT) X-Received: by 10.99.177.75 with SMTP id g11mr6291548pgp.326.1507555816302; Mon, 09 Oct 2017 06:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555816; cv=none; d=google.com; s=arc-20160816; b=T3kplY7uG3nsVda7BDiUL3/3Ap8R3bf4hx3H1rgobWHWkXNWPuoDx3A7P/Kn33OF9U CGNPT3sA4e2O3K44rst9r9vCfnedY9RqDWP/y0WUM1CW217t/HfOoj6JvmloFP8il2vQ f5TDSzTU4VfaKNseUmeuJNL0pQKWemitOXzazjZgI3ZPxuIHda1RzA2b6IjwrwJNbqNy JRKmWg5sR45/QjEyaaQhh4OGDUQXGrorLZj7h6exwI+epQMhEM4vI4ynP1BmYFA6Beml yvOoJ7I/P4QWJYVFImUX+RNISXoIKqC5GIs5oUnk7fbGoq2OKG3A5w3SU2rOXToyqzvT ctPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=l+vi4NNAjVk/ovvtN3R1RIkCmMchBeCMxQSJdmHVLbE=; b=LuuHxFB9XkErCXhbOMxLF7oIyGAecLjCJBxT50ZFCiSloYx3lam6CZIgLzVpzzZMC+ 0Xnw7Wqn+5NEQ/Ys9gX7ayRQWSQ0LRQSBUbnBVjcddxFd/SEd3Hpxiu4Q7G9GqhNH4S+ ggQrSL1PmtZq5yO2jdPlCQw5AvN4mp0WXVxky0Ftj8sTVDH53chs/t+2B/vJXcBJlqkQ R94NY70Fc0TUk8mPvsRpiQJS/vemCoRL8woMTTP4J/F777Zkjsq0h4e6PmkxxYotStMR sroOvFxUWsDWODYb4UKfOMX7qygwgBhstc0dzHvs9hhlXXXda1cjhMcIyYg8zoAI3HG2 7IkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=av+pB3RF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10si6371519pgp.718.2017.10.09.06.30.16; Mon, 09 Oct 2017 06:30:16 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=av+pB3RF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755263AbdJINaN (ORCPT + 26 others); Mon, 9 Oct 2017 09:30:13 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:45215 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755131AbdJIN0y (ORCPT ); Mon, 9 Oct 2017 09:26:54 -0400 Received: by mail-wm0-f45.google.com with SMTP id q124so22592782wmb.0 for ; Mon, 09 Oct 2017 06:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l+vi4NNAjVk/ovvtN3R1RIkCmMchBeCMxQSJdmHVLbE=; b=av+pB3RFv9XAgSwZkUyjQ2lFsT1xbuIbEqIOhwnsq0Kxy+WhMEq3GJlIBavarFtCY6 hTDpo5FFNKyK4ztpaBKAw86VkDOIpudb9iA4BUpjE/d5uwW5GeQPBUpPpezVyAK56/Lf CDdYeBqD87pZ5U5gK/i7uqEEfpPV9olqDXmps= 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:in-reply-to :references; bh=l+vi4NNAjVk/ovvtN3R1RIkCmMchBeCMxQSJdmHVLbE=; b=GJtqfUTU7+3Om0uZTks6KpZa0Lo1wfQhjxliiQQk9SqwSu2MkbjTEVE+DwVaJb47gC FbK4bRk6zP4eIbpOhgHGMh/kegz1vAgW3rl4zjPsRM8K5JUAcI4sG9PWlvRk8G4ciqd3 LmXD5zBoqbd5hl23aaMKXE6d00ARGdAAOIOBYShZ8/oobsg17C0gaE00/iuQApf0pX3W /kWJLx8jpXyB5566kvzOUSr+tnq+0lyzV5/gDIAuNAf+zmOXTV8DRf4KiPcep4wPYgYh IWjpPSSo2W9ZMJ3JX2Cl++Btv7EpQPpVb9dAE+uNWXxMcUJl9uWTLTq/9Os5w0QByeKq imEQ== X-Gm-Message-State: AMCzsaVfBFp9vHFQMTmNd14TYXP/G3CL3FZFnzhF+s6oR/v0FP57Bmv2 UVuCiu8Rn48w89Hqxhk5hAtqUQ== X-Google-Smtp-Source: AOwi7QBpFTIRTyBrxo/w1YgJMoQA3y+d6TRNu6INLPXAegJYYOyvSI/fbUHzJV43WCBmOgkDilqVKQ== X-Received: by 10.28.220.132 with SMTP id t126mr9428205wmg.51.1507555613257; Mon, 09 Oct 2017 06:26:53 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id 31sm3775340wrm.0.2017.10.09.06.26.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 06:26:52 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Masahiro Yamada Subject: [PATCH 03/12] nvmem: mtk-efuse: fix different address space warnings of sparse Date: Mon, 9 Oct 2017 15:26:32 +0200 Message-Id: <20171009132641.27169-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132641.27169-1-srinivas.kandagatla@linaro.org> References: <20171009132641.27169-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada Fix the following sparse warnings: drivers/nvmem/mtk-efuse.c:24:30: warning: incorrect type in initializer (different address spaces) drivers/nvmem/mtk-efuse.c:24:30: expected void [noderef] *base drivers/nvmem/mtk-efuse.c:24:30: got void *context drivers/nvmem/mtk-efuse.c:37:30: warning: incorrect type in initializer (different address spaces) drivers/nvmem/mtk-efuse.c:37:30: expected void [noderef] *base drivers/nvmem/mtk-efuse.c:37:30: got void *context drivers/nvmem/mtk-efuse.c:69:23: warning: incorrect type in assignment (different address spaces) drivers/nvmem/mtk-efuse.c:69:23: expected void *priv drivers/nvmem/mtk-efuse.c:69:23: got void [noderef] *[assigned] base The type of nvmem_config->priv is (void *), so sparse complains about assignment of the base address with (void __iomem *) type. Even if we cast it out, sparse still warns: warning: cast removes address space of expression Of course, we can shut up the sparse by marking __force, but a more correct way is to put the base address into driver private data. Signed-off-by: Masahiro Yamada Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/mtk-efuse.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) -- 2.11.0 diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c index fa7a0f66b37e..c4058b598703 100644 --- a/drivers/nvmem/mtk-efuse.c +++ b/drivers/nvmem/mtk-efuse.c @@ -18,15 +18,19 @@ #include #include +struct mtk_efuse_priv { + void __iomem *base; +}; + static int mtk_reg_read(void *context, unsigned int reg, void *_val, size_t bytes) { - void __iomem *base = context; + struct mtk_efuse_priv *priv = context; u32 *val = _val; int i = 0, words = bytes / 4; while (words--) - *val++ = readl(base + reg + (i++ * 4)); + *val++ = readl(priv->base + reg + (i++ * 4)); return 0; } @@ -34,12 +38,12 @@ static int mtk_reg_read(void *context, static int mtk_reg_write(void *context, unsigned int reg, void *_val, size_t bytes) { - void __iomem *base = context; + struct mtk_efuse_priv *priv = context; u32 *val = _val; int i = 0, words = bytes / 4; while (words--) - writel(*val++, base + reg + (i++ * 4)); + writel(*val++, priv->base + reg + (i++ * 4)); return 0; } @@ -50,19 +54,23 @@ static int mtk_efuse_probe(struct platform_device *pdev) struct resource *res; struct nvmem_device *nvmem; struct nvmem_config econfig = {}; - void __iomem *base; + struct mtk_efuse_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + priv->base = devm_ioremap_resource(dev, res); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); econfig.stride = 4; econfig.word_size = 4; econfig.reg_read = mtk_reg_read; econfig.reg_write = mtk_reg_write; econfig.size = resource_size(res); - econfig.priv = base; + econfig.priv = priv; econfig.dev = dev; econfig.owner = THIS_MODULE; nvmem = nvmem_register(&econfig);