From patchwork Mon Oct 16 23:38:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010243 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 99839601D5 for ; Mon, 16 Oct 2017 23:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A60E286E7 for ; Mon, 16 Oct 2017 23:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F0AE286FF; Mon, 16 Oct 2017 23:38:40 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 005B1286E7 for ; Mon, 16 Oct 2017 23:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932901AbdJPXii (ORCPT ); Mon, 16 Oct 2017 19:38:38 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:47162 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932690AbdJPXih (ORCPT ); Mon, 16 Oct 2017 19:38:37 -0400 Received: by mail-pg0-f48.google.com with SMTP id r25so8066829pgn.4 for ; Mon, 16 Oct 2017 16:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=Hb8w0hXPSDo3C5PuAtESiBA1jojgdYCjN/7ulsCuHDo=; b=I9sz6GnbstYdHbv8WBT0V2F/sHNF7t1CEcDrvGEPSZibfFqXUh4u7Hb7OZPdkJK9xv VgnDRJ1pvnTdQHWa0aP806JPn48UZL6YOHYIs5LY1AqMWVf+N0ET4XXjLqb8QCSku2+W EurY8o9KQMO0QSNQCt20btykWey/YSVa2CKDc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=Hb8w0hXPSDo3C5PuAtESiBA1jojgdYCjN/7ulsCuHDo=; b=CRY3570UKR94NVJJ6zDKI2VENIFfH1C0b0NKHPzUbQ4YmVfYSqif6eDCis2MkAve6e 8mXMOFeFi1Msae6WP4e6H8jNEe9FMlKjK33wyOMh4kdlMnL8boGp9bppDb7OISbh2NkJ 6a9fUHhYrdSr+hcxyHyELRAcg77sfrpwbQYybKQD1QvQXtVoarpbEFXoJCm0kW8LDiWY pE5s2OZxk0zpGhMhtuXsNC+IevglWTS0ByEf3pZlNOdb34u/07JyoRwex+W1IOtGXeNP TqHk+SV4WI2BrLIZnTMAGyd3QA9MU9awF94gz8/7p10+62fEC/5EDngSMiL5J6ZvHchI tHdg== X-Gm-Message-State: AMCzsaXdV7dgwP9Vuh18zZkVbagIcY4I8g7jtgJOA95iqdQVCit4ZO0I AbjKRn2sFdnDw/n+EAiH/pMV5w== X-Google-Smtp-Source: AOwi7QDOYg9lboj4BLy1E1jW5YKoJqzotrSBpMtnATlyhfpNt6bESs1cP+AfXuo2S+U1VKQPGaGR3g== X-Received: by 10.99.52.196 with SMTP id b187mr9797808pga.222.1508197116601; Mon, 16 Oct 2017 16:38:36 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id e71sm16518129pfk.55.2017.10.16.16.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:38:35 -0700 (PDT) Date: Mon, 16 Oct 2017 16:38:34 -0700 From: Kees Cook To: Herbert Xu Cc: Matt Mackall , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwrng/xgene-rng: Convert timers to use timer_setup() Message-ID: <20171016233834.GA101719@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Matt Mackall Cc: Herbert Xu Cc: linux-crypto@vger.kernel.org Signed-off-by: Kees Cook --- drivers/char/hw_random/xgene-rng.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c index 3c77645405e5..71755790c32b 100644 --- a/drivers/char/hw_random/xgene-rng.c +++ b/drivers/char/hw_random/xgene-rng.c @@ -100,9 +100,9 @@ struct xgene_rng_dev { struct clk *clk; }; -static void xgene_rng_expired_timer(unsigned long arg) +static void xgene_rng_expired_timer(struct timer_list *t) { - struct xgene_rng_dev *ctx = (struct xgene_rng_dev *) arg; + struct xgene_rng_dev *ctx = from_timer(ctx, t, failure_timer); /* Clear failure counter as timer expired */ disable_irq(ctx->irq); @@ -113,8 +113,6 @@ static void xgene_rng_expired_timer(unsigned long arg) static void xgene_rng_start_timer(struct xgene_rng_dev *ctx) { - ctx->failure_timer.data = (unsigned long) ctx; - ctx->failure_timer.function = xgene_rng_expired_timer; ctx->failure_timer.expires = jiffies + 120 * HZ; add_timer(&ctx->failure_timer); } @@ -292,7 +290,7 @@ static int xgene_rng_init(struct hwrng *rng) struct xgene_rng_dev *ctx = (struct xgene_rng_dev *) rng->priv; ctx->failure_cnt = 0; - init_timer(&ctx->failure_timer); + timer_setup(&ctx->failure_timer, xgene_rng_expired_timer, 0); ctx->revision = readl(ctx->csr_base + RNG_EIP_REV);