From patchwork Fri Oct 20 16:57:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116518 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1907082qgn; Fri, 20 Oct 2017 10:01:52 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RVuyZoo5QZzC1EbuB3Mahk30Hxno7a4v1RtYKPH7WTcSL3KMMwnDyZBQfJUEJCaalBWUxc X-Received: by 10.98.201.207 with SMTP id l76mr5686825pfk.337.1508518912047; Fri, 20 Oct 2017 10:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508518912; cv=none; d=google.com; s=arc-20160816; b=OO/GJjh69L6yfORgQWctyfKb0qfmFMa7kFR/06sc7z+/0GpXXIcQsgDBZJSeBxpXEz hDsOphUmbqDc5nbvA7eEhUwPK1XItddH/TveDYitEsjRLgeTmwDfhqL5PMuXpDvtZ4g0 agoMLV1dgRsjXWswEY0I6JGRlrk+KExbdrC0C/mRk5Ck93mhgWjGVNV7BUwYSSDlbA37 etxIQAgCF6Q9c6R3WY5NP5g/9Rx3sT/HzFWRUxXrgyPPlrzvShrnBiFUYzY7nJ2eoHUJ ZEEgzTfeOD4lyU8qPMOfzia4uCDrjy4aq1AQK9nCx6VTWQ1iuWho8KVhTg+Wfdrdh4DW TTXw== 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:dkim-filter :arc-authentication-results; bh=jhMSTQcQn5KFwxHLvoabjZDmH0r3qvgKX2jnM5bQ/jk=; b=eR1pn+4FYbpJhFpAvpBb4Db8C3B2vFBAy0qZcu13+KVSkLxrCk5Uw2OdZahQOYoBMn 8admzrK1AFCWo6R2NAZP/3sdr4Vv6OT6TkFLhBqHyhDEuP60JQ1rnw0PbxS0xC9nEl2R bI+kCHlF2p4QiCGbSY8XjXC9oe49YRwEaqbvmZB2Nb7mPhj43vIMNWoU2KE9Bt+G1CGS Dn+f+orutpEon7WYC8Yl43wb+Wn8ilBvW3C0HgJUbFxKrcOwfSgBNJUsWeRFkYuOvrxP 3E6VA2vraK3y08GU8xmAO8ajAjt9KZ3MK9f5ToAec25YevJCO5poph2QVLeLUdu+jI/k eA1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Rdeo8nTR; 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 b26si933712pgf.731.2017.10.20.10.01.51; Fri, 20 Oct 2017 10:01:52 -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=@nifty.com header.s=dec2015msa header.b=Rdeo8nTR; 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 S1753362AbdJTQ7D (ORCPT + 27 others); Fri, 20 Oct 2017 12:59:03 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:25127 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753254AbdJTQ65 (ORCPT ); Fri, 20 Oct 2017 12:58:57 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-07.nifty.com with ESMTP id v9KGwC3b005656; Sat, 21 Oct 2017 01:58:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9KGwC3b005656 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508518694; bh=jhMSTQcQn5KFwxHLvoabjZDmH0r3qvgKX2jnM5bQ/jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rdeo8nTRmyeLZorLEnoTdYMmfVIXhMqRhbj2Qgy11bVBwdalgOWMR08uRY5uFXg7k 4SOGveBRpEWv7gfm1cCu1iTMIjPsg6LEOq+gHKVmf/YlB9HRt7bjCsoQ/Ew/ugvWx5 lUWDqM8EOV6O/W4UqJT0n+vG75HkpGhZP4WXFaMcjggxealp737ECRJTf/y1ewxJBH PaPVj6j9ElR1eQVj3du8L4UY8c+MjrQmenGEsKNJRJcjm6U3MU6rDCM2yh+feGnnHX 4krGUDz+zzgGEJsqCwC9nesKFyHVYAIeLRDbYrMZUIwq5/afepit8em4g3tRMqCN+a ZSaosVacpIElQ== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Srinivas Kandagatla , Masahiro Yamada Subject: [RESEND PATCH 3/5] nvmem: mtk-efuse: fix different address space warnings of sparse Date: Sat, 21 Oct 2017 01:57:40 +0900 Message-Id: <1508518662-8800-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508518662-8800-1-git-send-email-yamada.masahiro@socionext.com> References: <1508518662-8800-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.7.4 diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c index fa7a0f6..c4058b5 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);