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: 2847259 Return-Path: X-Original-To: patchwork-linux-omap@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 51C299F239 for ; Tue, 20 Aug 2013 18:07:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F073120528 for ; Tue, 20 Aug 2013 18:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EBA220525 for ; Tue, 20 Aug 2013 18:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453Ab3HTSHb (ORCPT ); Tue, 20 Aug 2013 14:07:31 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:43959 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266Ab3HTSHb (ORCPT ); Tue, 20 Aug 2013 14:07:31 -0400 Received: by mail-pa0-f41.google.com with SMTP id bj1so1019070pad.14 for ; Tue, 20 Aug 2013 11:07:30 -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=f/m7caQ8iLwneg9uYxKzRNLGOHTDPJvmL4op8/1RjkNZFY6iEo3gFAK1mGxb2ugfL8 5sn3d1SMBqCqi3UPHd0DKJ99bVJcvukG/yvXsG2QmuWi9oPGm+uv2P2oiqPeBfuJi1qe NdnmdNdGmKaZ/qYCL2HmY7Uixnz9p2+4/V/rAcr0Wdvw1RhOCmqiOU/yE5V8YwwKvQ3U TN4N4vqZEQZ1R0pqooaCaD5uPYmrfVE2Rj0uyCvGlqhJHltctJ3xsphEdaMDLkWUGt2y 5t/3189b9bUGq43IjCZhQUn+TYIwPo4fFtqc53djrUsEQ0Y22suL+tZ/mo3ryPntrT0+ j4DQ== X-Gm-Message-State: ALoCoQlysvq9gFsZaZkFAT2EflxHRPH5uL1RhNAaKltQOXqUQB0SeOiEtvmdWFD44UdgnUfRishc 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 Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org, Olof Johansson , Lokesh Vutla 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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,