From patchwork Mon Oct 30 22:26:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10033335 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 D543C600C5 for ; Mon, 30 Oct 2017 22:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F1D62897D for ; Mon, 30 Oct 2017 22:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D4C4289C9; Mon, 30 Oct 2017 22:27: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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 C686F2897D for ; Mon, 30 Oct 2017 22:26:44 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vgxe+Lt6HT3qWVZw4ONULSWwWUtuvXOIzWB+q079Grw=; b=kVhLC0e+bwvJIe ikekuWAbklV/vIL7fzyGzwS8IjVsk7CM6F0phNe7/COM0OPlJiJ3pMadzeT5G8K+8p61NIJtC7dve BduWxEwtcxlpzd94JaHuPQsb88blJs5xtBN61dhDyIGuQ4XC4e0iIVdBM/u6FWKb2UMw3Tf//gSsY syQE6JjJKvk5Nu2cKA8BpBqwaaLTMDWABy/Wh/y77IMgTC0uYci6hyhlEo9QZUInh5X+jasj1gp2k w5jTzYEgBF9R0GpCMT3EX49OTrheMhfmjUR2nx0ORgl2I5bv6ukWXlsGspJQC/Wbh2+y8A3rO/KTO +HQUMPYUghC+MnZDujZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e9IW2-0002WT-1Z; Mon, 30 Oct 2017 22:26:42 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e9IVz-0002Tj-CD for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2017 22:26:41 +0000 Received: by mail-pf0-x241.google.com with SMTP id i5so12153541pfe.6 for ; Mon, 30 Oct 2017 15:26:17 -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=YV0AGRkCFdKg9xtYzjGKoRKmLBOp9DNCaBRAmbtwawI=; b=LjGTiOxBUHKSy8azRRAZk1RTq/Wbwe79vEu5wvt/sXC1EDh+sLLvGRLyhVD6CZHdZJ h5nDk1YQzrq5QapSdFMru9xvBqzUlZmr1X3cei1Ip3bL/t03h5KK8shZMN3+3FHGfxEv lUOV7I1J4kh9wIWF1+nUFFxpo4CEA2A9Ls3Zg= 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=YV0AGRkCFdKg9xtYzjGKoRKmLBOp9DNCaBRAmbtwawI=; b=JiP3AKolBVSVDpkUWXXNgPJrsZeqyl7PCMmKaSGG3PhwBFipyoHpuIzNGNZ1H9iA0N u6es3btV1LMkyR93aEedEeYdmK6k3gxR0kboMoib66MNxAJe0cndyIxwbW+PLEcqIZ6i cPtls5/iF8bvy9QYFUyYNxotwF+2e+mxgzITVHI5cpbHijlwrCmBYh5hjG+wnPbr1cVo MTnpshIqMe7/WbmB04DO10xKV4q19MFjzHgAwtaKs7BMBAstLrvE44sVv14fSy73a6wl 4DJQ+Au4Ja9uK3Zizsu8QZvSampbsazOX6ZGew4lRuRXUG8TKXVmYGiN0bXQidtB9ILW pL+g== X-Gm-Message-State: AMCzsaXT9MEtYBe+XmaZw7/ypMwPBqPYZBZfptI14JWUHvNYDLURZufx R3P3sNkL0ru3e4ZmYpcDOJsoYw== X-Google-Smtp-Source: ABhQp+TUvmMiK/nHi4EMrp77mi72Ilay125QDFywiyTooLSjOmeupVuiwWbTCpHV7uhiH2L2ZuG01w== X-Received: by 10.99.124.87 with SMTP id l23mr9234156pgn.52.1509402377578; Mon, 30 Oct 2017 15:26:17 -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 h70sm30412078pfc.88.2017.10.30.15.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 15:26:16 -0700 (PDT) Date: Mon, 30 Oct 2017 15:26:15 -0700 From: Kees Cook To: Greg Kroah-Hartman Subject: [PATCH v2] staging: vc04_services: Convert timers to use timer_setup() Message-ID: <20171030222615.GA103602@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_152639_440787_F2798B3E X-CRM114-Status: GOOD ( 12.99 ) 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: Stefan Wahren , devel@driverdev.osuosl.org, Keerthi Reddy , linux-kernel@vger.kernel.org, Eric Anholt , Michael Zoran , linux-rpi-kernel@lists.infradead.org, Dan Carpenter , linux-arm-kernel@lists.infradead.org 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 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. Additionally removes invalid NULL check, as pointed out by Dan Carpenter. Cc: Greg Kroah-Hartman Cc: Eric Anholt Cc: Stefan Wahren Cc: Michael Zoran Cc: Keerthi Reddy Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: devel@driverdev.osuosl.org Signed-off-by: Kees Cook Tested-by: Stefan Wahren --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 17 +++++++---------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6fcc62603580..411539f8ff8c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -109,7 +109,7 @@ static const char *const resume_state_names[] = { * requested */ #define FORCE_SUSPEND_TIMEOUT_MS 200 -static void suspend_timer_callback(unsigned long context); +static void suspend_timer_callback(struct timer_list *t); typedef struct user_service_struct { VCHIQ_SERVICE_T *service; @@ -2184,8 +2184,9 @@ vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state) arm_state->suspend_timer_timeout = SUSPEND_TIMER_TIMEOUT_MS; arm_state->suspend_timer_running = 0; - setup_timer(&arm_state->suspend_timer, suspend_timer_callback, - (unsigned long)(state)); + arm_state->state = state; + timer_setup(&arm_state->suspend_timer, suspend_timer_callback, + 0); arm_state->first_connect = 0; @@ -3017,18 +3018,14 @@ vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) instance->trace = (trace != 0); } -static void suspend_timer_callback(unsigned long context) +static void suspend_timer_callback(struct timer_list *t) { - VCHIQ_STATE_T *state = (VCHIQ_STATE_T *)context; - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + VCHIQ_ARM_STATE_T *arm_state = from_timer(arm_state, t, suspend_timer); + VCHIQ_STATE_T *state = arm_state->state; - if (!arm_state) - goto out; vchiq_log_info(vchiq_susp_log_level, "%s - suspend timer expired - check suspend", __func__); vchiq_check_suspend(state); -out: - return; } VCHIQ_STATUS_T diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index a4cc0db899be..40bb0c63b1a9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -83,6 +83,7 @@ typedef struct vchiq_arm_state_struct { unsigned int wake_address; + VCHIQ_STATE_T *state; struct timer_list suspend_timer; int suspend_timer_timeout; int suspend_timer_running;