From patchwork Sun Apr 24 19:28:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8921191 Return-Path: X-Original-To: patchwork-linux-mediatek@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 0DFA4BF29F for ; Sun, 24 Apr 2016 19:47:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D16320222 for ; Sun, 24 Apr 2016 19:47:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5B5920219 for ; Sun, 24 Apr 2016 19:47:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auQ0V-0001p5-J2; Sun, 24 Apr 2016 19:47:51 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auQ05-0001Qb-KB for linux-mediatek@bombadil.infradead.org; Sun, 24 Apr 2016 19:47:25 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1auPiL-0005yW-Et for linux-mediatek@lists.infradead.org; Sun, 24 Apr 2016 19:29:07 +0000 Received: by mail-wm0-x229.google.com with SMTP id e201so65592508wme.0 for ; Sun, 24 Apr 2016 12:28:41 -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=uR5SLF2YS7bviyk3m39eaJmkwmSN/t1AKnqc1GlWGWk=; b=Q1rUl22ROmdJBeuKYpt8tdBrK+BVxRUdbywGaEMVmiFY0wJDdxuCY46VcnUq2tGo7O SHX8bcxU6RIT224B8txdrbUEluzZ+UlQ775BSs4OOer0UDQxiFAMYQbshAC4Y45030kp J0yhWv0ER+MrYQ/2JHeUD+8yyXxObndwIa+2s= 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=uR5SLF2YS7bviyk3m39eaJmkwmSN/t1AKnqc1GlWGWk=; b=bFNrM1AWST+LGaDmYMvL3YNv3UBEDFAr4Eq+atLEQpUP6vx9TFCz+LWnkvVcxXSfXt QyinPxhcD2o2x6JFm7PxUG9TlpBjaMbjArUHSNkm/x5G8MQORG/eQb3h/kGnQEmOEP8O j1CS2ibJvsV+maJ2L2O+WB4aI5xokxsflDPicNss2pZJSNw+TvoJu+7bhgZMmuQXqQno TR7A/xVwOUxIBSiGvk3phmyRCKGKXzRzf6OsCdgLPLEFNkWw5+dJ7LLfSq79JyD1Ynnn uy37NVEjIYv0wOGLpHjQEbOYSDB9Ha7VguTGf78qypJDiIWwPe1ITbfRsUGAM7fLSWd1 VdSw== X-Gm-Message-State: AOPr4FWlLovJjluDnhQd/2hDiSsP+ycb9qjHsmtztZA3r3Gas/DotPO0xQ/hFMXfTrhflrA4 X-Received: by 10.28.94.5 with SMTP id s5mr8424941wmb.26.1461526120613; Sun, 24 Apr 2016 12:28:40 -0700 (PDT) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id q127sm15007708wmd.13.2016.04.24.12.28.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 12:28:39 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Subject: [PATCH 06/12] nvmem: sunxi-sid: remove nvmem regmap dependency Date: Sun, 24 Apr 2016 20:28:10 +0100 Message-Id: <1461526096-29584-7-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461526096-29584-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1461526096-29584-1-git-send-email-srinivas.kandagatla@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160424_202905_537968_6C5AFE1C X-CRM114-Status: GOOD ( 17.35 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, Heiko Stuebner , Wolfram Sang , Joachim Eastwood , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Mark Brown , Srinivas Kandagatla , linux-i2c@vger.kernel.org, Matthias Brugger , linux-mediatek@lists.infradead.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch moves to nvmem support in the driver to use callback instead of regmap. Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 1 - drivers/nvmem/sunxi_sid.c | 54 ++++++++--------------------------------------- 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index a87273b..377bc21 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -81,7 +81,6 @@ config ROCKCHIP_EFUSE config NVMEM_SUNXI_SID tristate "Allwinner SoCs SID support" depends on ARCH_SUNXI - select REGMAP_MMIO help This is a driver for the 'security ID' available on various Allwinner devices. diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index bc88b40..1567ccc 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -21,13 +21,14 @@ #include #include #include -#include #include #include static struct nvmem_config econfig = { .name = "sunxi-sid", .read_only = true, + .stride = 4, + .word_size = 1, .owner = THIS_MODULE, }; @@ -51,54 +52,23 @@ static u8 sunxi_sid_read_byte(const struct sunxi_sid *sid, return sid_key; /* Only return the last byte */ } -static int sunxi_sid_read(void *context, - const void *reg, size_t reg_size, - void *val, size_t val_size) +static int sunxi_sid_read(void *context, unsigned int offset, + void *val, size_t bytes) { struct sunxi_sid *sid = context; - unsigned int offset = *(u32 *)reg; u8 *buf = val; - while (val_size) { - *buf++ = sunxi_sid_read_byte(sid, offset); - val_size--; - offset++; - } - - return 0; -} + while (bytes--) + *buf++ = sunxi_sid_read_byte(sid, offset++); -static int sunxi_sid_write(void *context, const void *data, size_t count) -{ - /* Unimplemented, dummy to keep regmap core happy */ return 0; } -static struct regmap_bus sunxi_sid_bus = { - .read = sunxi_sid_read, - .write = sunxi_sid_write, - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, -}; - -static bool sunxi_sid_writeable_reg(struct device *dev, unsigned int reg) -{ - return false; -} - -static struct regmap_config sunxi_sid_regmap_config = { - .reg_bits = 32, - .val_bits = 8, - .reg_stride = 1, - .writeable_reg = sunxi_sid_writeable_reg, -}; - static int sunxi_sid_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; struct nvmem_device *nvmem; - struct regmap *regmap; struct sunxi_sid *sid; int ret, i, size; char *randomness; @@ -113,16 +83,10 @@ static int sunxi_sid_probe(struct platform_device *pdev) return PTR_ERR(sid->base); size = resource_size(res) - 1; - sunxi_sid_regmap_config.max_register = size; - - regmap = devm_regmap_init(dev, &sunxi_sid_bus, sid, - &sunxi_sid_regmap_config); - if (IS_ERR(regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(regmap); - } - + econfig.size = resource_size(res); econfig.dev = dev; + econfig.reg_read = sunxi_sid_read; + econfig.priv = sid; nvmem = nvmem_register(&econfig); if (IS_ERR(nvmem)) return PTR_ERR(nvmem);