From patchwork Mon Apr 23 12:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10356933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8ADA2601D3 for ; Mon, 23 Apr 2018 12:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AB0128AA4 for ; Mon, 23 Apr 2018 12:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E5C628AAE; Mon, 23 Apr 2018 12:43:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F40BD28AA4 for ; Mon, 23 Apr 2018 12:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7GTo5saMkBhhbEjgJncyL4Wwl5t09Rq6+hGw93+2qrA=; b=aIBHQtFfLOJzVsD5bWU/1KOw+F I56Rjx8ZFu4WQ1fOUlrhZRzhru/evXrGGeLGdnYsgdrWc2IiNCIrrmQENUqORAgmdllo6fXgAClem 58vljPOVAyAOzMT7hoTEvCw6bdxp4pRhRIyGdEz3GVv6/gqT0JdzkUjLwWBA81oHuway7fQQQPPe0 jA3t45q8VBFfNxvvGEL0nUyzj6HGepLfaf2xQKOT/B9lQFdAoHwxps1h6QkwOLa4mxTqZ+QJs9Akx w4PbOtsR54r5TwHo2qm/DW2NJceX7XrM6kiw0gl4nViH+tSwgnCIhh+PUQn99bOVOeN4eryv433bq SJR/YxXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAaoF-0006mq-K9; Mon, 23 Apr 2018 12:43:07 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAanF-0006DH-QQ for linux-arm-kernel@lists.infradead.org; Mon, 23 Apr 2018 12:42:11 +0000 Received: by mail-wr0-x241.google.com with SMTP id w3-v6so40849519wrg.2 for ; Mon, 23 Apr 2018 05:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o3Nfz8TRGBKldp1ZMsDKLhUaER/cVEDFiibMEH4/3I0=; b=xGWlrcoD7lNkelRWlJg+JvD1HrU3PYp9MN8gmmmOOu1AP3A4oQY4muheqaXCrO9tp/ iJu2/DLlFBUjPWkWJKwT9TZ4+1JHXnAG9qFmirmQs2SY3FJ8ULeVjp1+H2sKy/pT8MiA vgLluYOGEm3hYDqe2hK5DSE90+txHcPGcIxbNMImAvbHLLLDc/zWdGGSrelrCXz3MRWO yBY2JO+SZMRkNoqQeQ8RYY1mneFPMgR6MptcG75MwIoEBOVBLptQwAiC6jnjp7Q1w+kd VtJ41p2EtRl7IT21zUN0tgPfI9Gh4bub5w2jmsllLuRDtro4lVEmOJ4x2aFpOIDdLEXe 4h9Q== 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=o3Nfz8TRGBKldp1ZMsDKLhUaER/cVEDFiibMEH4/3I0=; b=mK0Cou3Kz9ECCk6iAHxc1f3A7XeV479vU0g1QuqaLWYzW67oO1eFRffo4TViv4CQug dqr4a1ZHc4UsYISQ/xGfA/yFhvPCijqC2Mf/RHWxN4EHoUuD5dqQiTk6HFT8L2dEe9B3 Sjs9e9Gs/qE2btCUDuMGjQv/LFBkVHC+u4qKD6ikFvv+Y20G0qzJ3D5Tv/9DxpgU9QPC 2TIfmQEd/0dNIJjWy4wtXIhEQyhV5uTOjgH1MkEEXS78dXLspkrMbZcPn8VDFNYZok6u yRPzA5IfVLtVq/yEdGyalRFV02CifKrDalSjLK3YTTwnW2gd2zZXuNrupZ//l5FBqjeY 5SYA== X-Gm-Message-State: ALQs6tCf6Q0sF9psUu0AuJJpNDg6e81qo7kiEexdysLa5SXOvnEJeqXv FtwJbaLuVZsyz3BW3Y8TCw47tg== X-Google-Smtp-Source: AIpwx4+5LJTIBg6vyPqMyF0rRBENIISD4uXDKi+pBVtjOsY0kBbqTbCroQJRMxENUkNZ/hqT+rL6mQ== X-Received: by 10.28.26.83 with SMTP id a80mr9599474wma.36.1524487314153; Mon, 23 Apr 2018 05:41:54 -0700 (PDT) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id e202sm8727927wma.43.2018.04.23.05.41.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 05:41:53 -0700 (PDT) From: Jerome Brunet To: Srinivas Kandagatla , Carlo Caione , Kevin Hilman Subject: [PATCH v2 1/3] nvmem: meson-efuse: remove econfig global Date: Mon, 23 Apr 2018 14:41:47 +0200 Message-Id: <20180423124149.3077-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180423124149.3077-1-jbrunet@baylibre.com> References: <20180423124149.3077-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180423_054205_886758_D5808F6F X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Having a global structure holding a reference to the device structure is not very nice. Allocate the econfig instead and fill the nvmem information as before Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet --- drivers/nvmem/meson-efuse.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 71823d1403c5..2df9b0094f45 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -35,13 +35,6 @@ static int meson_efuse_read(void *context, unsigned int offset, return 0; } -static struct nvmem_config econfig = { - .name = "meson-efuse", - .stride = 1, - .word_size = 1, - .read_only = true, -}; - static const struct of_device_id meson_efuse_match[] = { { .compatible = "amlogic,meson-gxbb-efuse", }, { /* sentinel */ }, @@ -50,17 +43,27 @@ MODULE_DEVICE_TABLE(of, meson_efuse_match); static int meson_efuse_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct nvmem_device *nvmem; + struct nvmem_config *econfig; unsigned int size; if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) return -EINVAL; - econfig.dev = &pdev->dev; - econfig.reg_read = meson_efuse_read; - econfig.size = size; + econfig = devm_kzalloc(dev, sizeof(*econfig), GFP_KERNEL); + if (!econfig) + return -ENOMEM; + + econfig->dev = dev; + econfig->name = dev_name(dev); + econfig->stride = 1; + econfig->word_size = 1; + econfig->read_only = true; + econfig->reg_read = meson_efuse_read; + econfig->size = size; - nvmem = devm_nvmem_register(&pdev->dev, &econfig); + nvmem = devm_nvmem_register(&pdev->dev, econfig); return PTR_ERR_OR_ZERO(nvmem); }