From patchwork Tue Aug 20 18:07:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 2847260 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1A24C9F239 for ; Tue, 20 Aug 2013 18:08:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48A7720549 for ; Tue, 20 Aug 2013 18:08:03 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0FC42054F for ; Tue, 20 Aug 2013 18:08:01 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBqLX-0001k3-Ho; Tue, 20 Aug 2013 18:07:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBqLV-0003xE-7q; Tue, 20 Aug 2013 18:07:57 +0000 Received: from mail-pd0-f171.google.com ([209.85.192.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBqLS-0003wt-9d for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2013 18:07:55 +0000 Received: by mail-pd0-f171.google.com with SMTP id g10so713456pdj.30 for ; Tue, 20 Aug 2013 11:07:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=t4HIySIC210j6CRDsdP10Ec5l2ssDNrSGVpXgzfapmY=; b=ECO+iZIo3TO1Rqyd3rm3c5XJnv/LFTyikmskcvCZKXyLQpd20rHJv3OIaAPz6Isfow m64E831e0hB83bb5GeNTcY7ljG1ApwcKL9p5j8H7zK6leJGo/+mdBzciwDUsL7bQGo+e 8B+MhtSYNEfafOMvxTYlLkYXBJSAZk85022Hja/827g+fE9OTQooLMdhE4O/Bg0tGlZP 0SFZuzem/cwgEDPry9QbvLkU5pnG3zFie0N/tBFEMjvcv7SraJ//qQUbm4mIrzgjMWld HUYSAy/Ip6MnyHPC9l5sDaG4AfqX4FmU/lz9FXztROQLhPpzmW+AyeaMLM2a9mseilIo kDig== X-Gm-Message-State: ALoCoQnM1fVsXVavr2TUPesbvW0jRvKFpXi1a3GrA3n3MCMrC7Xpu/VyJo4COht++RHxrhF144ve X-Received: by 10.67.14.67 with SMTP id fe3mr5232112pad.134.1377022050618; Tue, 20 Aug 2013 11:07:30 -0700 (PDT) Received: from brutus.lixom.net (173-13-129-225-sfba.hfc.comcastbusiness.net. [173.13.129.225]) by mx.google.com with ESMTPSA id py4sm3419278pbb.33.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Aug 2013 11:07:29 -0700 (PDT) From: Olof Johansson To: herbert@gondor.hengli.com.au Subject: [PATCH] hwrng: reorder OMAP TRNG driver code Date: Tue, 20 Aug 2013 11:07:53 -0700 Message-Id: <1377022073-28198-1-git-send-email-olof@lixom.net> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130820_140754_456136_4AFA15ED X-CRM114-Status: GOOD ( 13.98 ) X-Spam-Score: -1.9 (-) Cc: Olof Johansson , Lokesh Vutla , linux-omap@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 The newly added omap4 support in the driver was added without consideration for building older configs. When building omap1_defconfig, it resulted in: drivers/char/hw_random/omap-rng.c:190:12: warning: 'omap4_rng_init' defined but not used [-Wunused-function] drivers/char/hw_random/omap-rng.c:215:13: warning: 'omap4_rng_cleanup' defined but not used [-Wunused-function] drivers/char/hw_random/omap-rng.c:251:20: warning: 'omap4_rng_irq' defined but not used [-Wunused-function] Move the code around so it is grouped with its operations struct, which for the omap4 case means also under the #ifdef CONFIG_OF, where it needs to be. Signed-off-by: Olof Johansson Cc: Lokesh Vutla Reviewed-by: Lokesh Vutla --- drivers/char/hw_random/omap-rng.c | 108 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index f3f7142..9b89ff4 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c @@ -140,16 +140,6 @@ static inline void omap_rng_write(struct omap_rng_dev *priv, u16 reg, __raw_writel(val, priv->base + priv->pdata->regs[reg]); } -static inline u32 omap2_rng_data_present(struct omap_rng_dev *priv) -{ - return omap_rng_read(priv, RNG_STATUS_REG) ? 0 : 1; -} - -static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv) -{ - return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY; -} - static int omap_rng_data_present(struct hwrng *rng, int wait) { struct omap_rng_dev *priv; @@ -187,6 +177,60 @@ static int omap_rng_data_read(struct hwrng *rng, u32 *data) return data_size; } +static int omap_rng_init(struct hwrng *rng) +{ + struct omap_rng_dev *priv; + + priv = (struct omap_rng_dev *)rng->priv; + return priv->pdata->init(priv); +} + +static void omap_rng_cleanup(struct hwrng *rng) +{ + struct omap_rng_dev *priv; + + priv = (struct omap_rng_dev *)rng->priv; + priv->pdata->cleanup(priv); +} + +static struct hwrng omap_rng_ops = { + .name = "omap", + .data_present = omap_rng_data_present, + .data_read = omap_rng_data_read, + .init = omap_rng_init, + .cleanup = omap_rng_cleanup, +}; + +static inline u32 omap2_rng_data_present(struct omap_rng_dev *priv) +{ + return omap_rng_read(priv, RNG_STATUS_REG) ? 0 : 1; +} + +static int omap2_rng_init(struct omap_rng_dev *priv) +{ + omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x1); + return 0; +} + +static void omap2_rng_cleanup(struct omap_rng_dev *priv) +{ + omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x0); +} + +static struct omap_rng_pdata omap2_rng_pdata = { + .regs = (u16 *)reg_map_omap2, + .data_size = OMAP2_RNG_OUTPUT_SIZE, + .data_present = omap2_rng_data_present, + .init = omap2_rng_init, + .cleanup = omap2_rng_cleanup, +}; + +#if defined(CONFIG_OF) +static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv) +{ + return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY; +} + static int omap4_rng_init(struct omap_rng_dev *priv) { u32 val; @@ -221,33 +265,6 @@ static void omap4_rng_cleanup(struct omap_rng_dev *priv) omap_rng_write(priv, RNG_CONFIG_REG, val); } -static int omap2_rng_init(struct omap_rng_dev *priv) -{ - omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x1); - return 0; -} - -static void omap2_rng_cleanup(struct omap_rng_dev *priv) -{ - omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x0); -} - -static int omap_rng_init(struct hwrng *rng) -{ - struct omap_rng_dev *priv; - - priv = (struct omap_rng_dev *)rng->priv; - return priv->pdata->init(priv); -} - -static void omap_rng_cleanup(struct hwrng *rng) -{ - struct omap_rng_dev *priv; - - priv = (struct omap_rng_dev *)rng->priv; - priv->pdata->cleanup(priv); -} - static irqreturn_t omap4_rng_irq(int irq, void *dev_id) { struct omap_rng_dev *priv = dev_id; @@ -275,23 +292,6 @@ static irqreturn_t omap4_rng_irq(int irq, void *dev_id) return IRQ_HANDLED; } -static struct hwrng omap_rng_ops = { - .name = "omap", - .data_present = omap_rng_data_present, - .data_read = omap_rng_data_read, - .init = omap_rng_init, - .cleanup = omap_rng_cleanup, -}; - -static struct omap_rng_pdata omap2_rng_pdata = { - .regs = (u16 *)reg_map_omap2, - .data_size = OMAP2_RNG_OUTPUT_SIZE, - .data_present = omap2_rng_data_present, - .init = omap2_rng_init, - .cleanup = omap2_rng_cleanup, -}; - -#if defined(CONFIG_OF) static struct omap_rng_pdata omap4_rng_pdata = { .regs = (u16 *)reg_map_omap4, .data_size = OMAP4_RNG_OUTPUT_SIZE,