From patchwork Wed Sep 20 23:27:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9962989 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 85A7060208 for ; Wed, 20 Sep 2017 23:40:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7800729267 for ; Wed, 20 Sep 2017 23:40:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C6092926F; Wed, 20 Sep 2017 23:40:15 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 CE5E829267 for ; Wed, 20 Sep 2017 23:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752173AbdITXkB (ORCPT ); Wed, 20 Sep 2017 19:40:01 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:57289 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbdITXiC (ORCPT ); Wed, 20 Sep 2017 19:38:02 -0400 Received: by mail-pf0-f182.google.com with SMTP id g65so2296147pfe.13 for ; Wed, 20 Sep 2017 16:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=85OshiLqcZS76nEssz4oAD0SA+j+h7w+f1Tvf1XHpvg=; b=UM3TsTjJF5FE+YUeZhbeLgbmVSVwrL9XDQ/G7z0f8wkvnlnkhfTz4Ngt/W9ccSCRws C+6a1Rjc8hXgaZkbA4CoEcOhDsvpgD9CPHdXKQ1WWdM7FJGnCfiUWOO3ZcWNbtoZRVkW P3d4rFnmIefO8AmWFJUDIPajlysTzuHQ0psc0= 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=85OshiLqcZS76nEssz4oAD0SA+j+h7w+f1Tvf1XHpvg=; b=cMjBzs3PSSB4SlhFW8ek2l1uLu2wtcDsv/PARZjW1r4gJChwdz1NoA7c1qkG5KS96d ltFWoVDcXUgW9LA4GmGNmfv7oUGlWWsVeLD0zbJn1RateTRFq3Ujwd6dhxIijnxMXDrM tqEwONKaKAmdtV4R4c1cnqoDINCqi3L6JSU+wUWC07m63kz2iZeKgehObjPMtog5uwD9 d0c6k+LeJU/cxVZd40DCWlg8FE4wP24t78FDb8e707Zo3a/pCOFg2yZJ49p53YY+BzQ3 CRen/cMmCj0biIUCCXtMdRQzTdjQTUGf+gxup6ARbxsRUmz7Tc7P2ZhDsygRJi3AAKOr wepA== X-Gm-Message-State: AHPjjUgOJMPcAxOAO2jFtLdJB7FLf1jxND1V6//INXHm07e0wU1ZD3qt 43My4B3TgXxYFzjFs1/HTTPE4RKr9DY= X-Google-Smtp-Source: AOwi7QBAAlvJmZbcTm77NMjQzqhFAXKb3LjUUOqIUdmJcWeRGGFuRpmSE/jd2G2zxG0kgIw6ASMXJQ== X-Received: by 10.84.129.193 with SMTP id b59mr3623652plb.147.1505950682165; Wed, 20 Sep 2017 16:38:02 -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 d124sm75479pfc.42.2017.09.20.16.37.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 16:37:54 -0700 (PDT) From: Kees Cook To: Thomas Gleixner Cc: Kees Cook , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 18/31] scsi/aic7xxx: Clean up timer usage Date: Wed, 20 Sep 2017 16:27:42 -0700 Message-Id: <1505950075-50223-19-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505950075-50223-1-git-send-email-keescook@chromium.org> References: <1505950075-50223-1-git-send-email-keescook@chromium.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP stat_timer only ever assigns the same function and data, so consolidate to a setup_timer() call and drop everything else used to pass things around. reset_timer is unused; remove it. Cc: Hannes Reinecke Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Signed-off-by: Kees Cook --- drivers/scsi/aic7xxx/aic79xx.h | 5 +---- drivers/scsi/aic7xxx/aic79xx_core.c | 29 ++++++++--------------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h index d47b527b25dd..31f2bb9d7146 100644 --- a/drivers/scsi/aic7xxx/aic79xx.h +++ b/drivers/scsi/aic7xxx/aic79xx.h @@ -1046,8 +1046,6 @@ typedef enum { typedef uint8_t ahd_mode_state; -typedef void ahd_callback_t (void *); - struct ahd_completion { uint16_t tag; @@ -1122,8 +1120,7 @@ struct ahd_softc { /* * Timer handles for timer driven callbacks. */ - ahd_timer_t reset_timer; - ahd_timer_t stat_timer; + struct timer_list stat_timer; /* * Statistics. diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 95d8f25cbcca..a9fcc40eabcc 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -207,7 +207,7 @@ static void ahd_add_scb_to_free_list(struct ahd_softc *ahd, static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid, u_int prev, u_int next, u_int tid); static void ahd_reset_current_bus(struct ahd_softc *ahd); -static ahd_callback_t ahd_stat_timer; +static void ahd_stat_timer(unsigned long data); #ifdef AHD_DUMP_SEQ static void ahd_dumpseq(struct ahd_softc *ahd); #endif @@ -6104,8 +6104,7 @@ ahd_alloc(void *platform_arg, char *name) ahd->bugs = AHD_BUGNONE; ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A | AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A; - ahd_timer_init(&ahd->reset_timer); - ahd_timer_init(&ahd->stat_timer); + setup_timer(&ahd->stat_timer, ahd_stat_timer, (unsigned long)ahd); ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT; ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT; ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT; @@ -6235,8 +6234,7 @@ ahd_shutdown(void *arg) /* * Stop periodic timer callbacks. */ - ahd_timer_stop(&ahd->reset_timer); - ahd_timer_stop(&ahd->stat_timer); + del_timer_sync(&ahd->stat_timer); /* This will reset most registers to 0, but not all */ ahd_reset(ahd, /*reinit*/FALSE); @@ -7039,20 +7037,11 @@ static const char *termstat_strings[] = { }; /***************************** Timer Facilities *******************************/ -#define ahd_timer_init init_timer -#define ahd_timer_stop del_timer_sync -typedef void ahd_linux_callback_t (u_long); - static void -ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg) +ahd_timer_reset(ahd_timer_t *timer, int usec) { - struct ahd_softc *ahd; - - ahd = (struct ahd_softc *)arg; del_timer(timer); - timer->data = (u_long)arg; timer->expires = jiffies + (usec * HZ)/1000000; - timer->function = (ahd_linux_callback_t*)func; add_timer(timer); } @@ -7279,8 +7268,7 @@ ahd_init(struct ahd_softc *ahd) } init_done: ahd_restart(ahd); - ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US, - ahd_stat_timer, ahd); + ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); return (0); } @@ -8878,9 +8866,9 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset) /**************************** Statistics Processing ***************************/ static void -ahd_stat_timer(void *arg) +ahd_stat_timer(unsigned long data) { - struct ahd_softc *ahd = arg; + struct ahd_softc *ahd = (struct ahd_softc *)data; u_long s; int enint_coal; @@ -8907,8 +8895,7 @@ ahd_stat_timer(void *arg) ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1); ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]; ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0; - ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US, - ahd_stat_timer, ahd); + ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US); ahd_unlock(ahd, &s); }