From patchwork Fri Oct 20 16:57:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116512 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1903716qgn; Fri, 20 Oct 2017 09:59:01 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qo1ogcoqOauN8imkhlATnllGaumYJh2mVoYbxQ8drKOOdal6Z9nAeYgXI/zaw7PHYc1qRG X-Received: by 10.99.1.129 with SMTP id 123mr5202480pgb.320.1508518741814; Fri, 20 Oct 2017 09:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508518741; cv=none; d=google.com; s=arc-20160816; b=mM2euWEepKNP5RD5kZ3SgMyTJRdLIdOdpMpBy4TbmCGo2ccCofeYI6FTYoIE8i314E 6/eWJFWr6u4/q/h59Ixm1eJeQcX3TtqrnFZzC25dSv/jax5VwF4KXdlJAazXDbkTx/JC ignvCvjslqjMguiyxU/fZkyXjJ8b3wBc1P74NUskATYL7/r66Y3Q7aU6asYL3mtkMCp6 NpdO398cXkRzoFtBvDwfORvKP1sS+NqrVlP/vdyTDnB16bwQ4j1odF9I3cMfTJgCvJSI 8EzpZNqdmgza19BS5I4q5+0tLbbGEGFEbP3Q+fwLnWO43DwamLc6zHc1wSM6AyvWOQDq 8UmA== 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=NYABBeKjsd2WSunJC+/c4cX+0FHLr6Uv81WH48gqBBQ=; b=xZGnzsedO9T6/qDH4NQFrNzmg/YCE21ZWNjoWBMdCszIBdtQICrqKK7Z1VRD8rYejs oNNVshTPoM2Jdp1QJGWjcr+k5vmoR77yhZjZvkenzoxt7n8pRkH4RVoYEOKfyfA0CKhK MHLBHMLKdJy0QQEGfsoTxdEip9KAwgh3h4fxMAZGdEHCQ54ombzXowsVsKZ2NjgV7eo4 KGy3wdFuBIyCRJXV4p4w96ijt/F/hpGDD3JjKRp4oepfaV1mZ5ZyjnSmGApM5Duf2Ufr /B8J3bhwwdnEK18VmPySHuoa9oz4tpE0XNzEQElmen4/rdv/8p6KFaEaN7q1nTcve2Bb a76g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=aNWKZ+Ox; 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 d127si929819pgc.372.2017.10.20.09.59.01; Fri, 20 Oct 2017 09:59:01 -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=aNWKZ+Ox; 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 S1753325AbdJTQ67 (ORCPT + 27 others); Fri, 20 Oct 2017 12:58:59 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:25128 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdJTQ65 (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 v9KGwC3c005656; Sat, 21 Oct 2017 01:58:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9KGwC3c005656 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508518695; bh=NYABBeKjsd2WSunJC+/c4cX+0FHLr6Uv81WH48gqBBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNWKZ+OxLj+Y/fLm3DD8xViIK08Ovi7qtn8StQ3IxtovOhVhAW1xvoe+9Oz7ObOkg HhjR8UzHdQjQcbQ+AHmyd0o4SzWribV+xPIVGMz0Z4GeJpkFci2AVMMisfTCttzVnL cJOuAgYWwfssG5axZTMiEmIc8XYXhZId3tX6JsXvzFmYhl4z1h9qsB3RJlCFq0tfNG 3UDfzxxTAzkuEXKSuUu/TIgeZAeNm4gfEQxxjZ+tFIpmup4B76F2vkzIYePG32XNG0 dxrhGO7XEVTuntNLZLvByfpBCaDii0psM5GazmDcFvWeuVVBvF6uQ5OLviY0wZG3Sh IL0v9Rwo3O5QQ== 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 4/5] nvmem: qfprom: fix different address space warnings of sparse Date: Sat, 21 Oct 2017 01:57:41 +0900 Message-Id: <1508518662-8800-5-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/qfprom.c:23:30: warning: incorrect type in initializer (different address spaces) drivers/nvmem/qfprom.c:23:30: expected void [noderef] *base drivers/nvmem/qfprom.c:23:30: got void *context drivers/nvmem/qfprom.c:36:30: warning: incorrect type in initializer (different address spaces) drivers/nvmem/qfprom.c:36:30: expected void [noderef] *base drivers/nvmem/qfprom.c:36:30: got void *context drivers/nvmem/qfprom.c:76:22: warning: incorrect type in assignment (different address spaces) drivers/nvmem/qfprom.c:76:22: expected void *static [toplevel] [assigned] priv drivers/nvmem/qfprom.c:76:22: 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/qfprom.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c index 2bdb6c3..b96730e 100644 --- a/drivers/nvmem/qfprom.c +++ b/drivers/nvmem/qfprom.c @@ -17,15 +17,19 @@ #include #include +struct qfprom_priv { + void __iomem *base; +}; + static int qfprom_reg_read(void *context, unsigned int reg, void *_val, size_t bytes) { - void __iomem *base = context; + struct qfprom_priv *priv = context; u8 *val = _val; int i = 0, words = bytes; while (words--) - *val++ = readb(base + reg + i++); + *val++ = readb(priv->base + reg + i++); return 0; } @@ -33,12 +37,12 @@ static int qfprom_reg_read(void *context, static int qfprom_reg_write(void *context, unsigned int reg, void *_val, size_t bytes) { - void __iomem *base = context; + struct qfprom_priv *priv = context; u8 *val = _val; int i = 0, words = bytes; while (words--) - writeb(*val++, base + reg + i++); + writeb(*val++, priv->base + reg + i++); return 0; } @@ -64,16 +68,20 @@ static int qfprom_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; struct nvmem_device *nvmem; - void __iomem *base; + struct qfprom_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.size = resource_size(res); econfig.dev = dev; - econfig.priv = base; + econfig.priv = priv; nvmem = nvmem_register(&econfig); if (IS_ERR(nvmem))