From patchwork Tue Oct 10 00:15:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9994663 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 381BA60216 for ; Tue, 10 Oct 2017 00:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 295B0286DA for ; Tue, 10 Oct 2017 00:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E06E287B4; Tue, 10 Oct 2017 00:16:03 +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=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 9BC24286DA for ; Tue, 10 Oct 2017 00:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755610AbdJJAPu (ORCPT ); Mon, 9 Oct 2017 20:15:50 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:52694 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755457AbdJJAPt (ORCPT ); Mon, 9 Oct 2017 20:15:49 -0400 Received: by mail-pf0-f170.google.com with SMTP id a1so12157193pfj.9 for ; Mon, 09 Oct 2017 17:15:49 -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=EEh4y25wpK2Q4d0Ffmxw1pSD6wA+Krwx8wNgRQ7jPc0=; b=AqoytghdC5nwwLytV3EL+vKloDoIaaARb+erkAAA+gnmIIpXjcnVVYSI0mTi44wmUX c8lGJqPhfef8RnA98Dn/vbEXEYBrgGVhidg1iIju8CHL5SZ5ulB0unvWHjNk69ALIkuE e7EbMcD/r6Y5zY3rwjCwytcexzj92PgEXNQp8= 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=EEh4y25wpK2Q4d0Ffmxw1pSD6wA+Krwx8wNgRQ7jPc0=; b=ZHhSqWDDXxtmCrHGfC16hFJkDcxRIpXdK+4Nz9zjf96q+afS0tSm5vC+aLOGv3uavC bzC50ySxYbn5pPZf5MD1aLbPS1mhCA9AAXziGLvv5WDG7uAxY3VIiQLaVj43rpAhS1jI kK277HzdTmY4rV5bpKUtNGPrTsiKzIYX/yrD2oJR2JHhm5RQ0K5jxqk3oCCJ7Qq04Bl6 VdmhWWPjC+1+2OvthCg7Pl8sNjr/niLQ5RX8UPLVe5z9Gtva1TGdD34tz0x24tOgUn0Z Vp47FFPzWYaz9YCHvSCwBqZxzm1ELHZzwylNXuslvgMA9yDGG+yFwspntGrrVtqSPAWs NGKA== X-Gm-Message-State: AMCzsaVYtKqIY3Q8Sw5/uF+VhpRau94DZ2cXX02m46zZqxH8sfPADMNH 3dfltlMWLQTcas50tNGbgPEotA== X-Google-Smtp-Source: AOwi7QBjsrSCnh/kKKJiTo0fbROOKfLD/UKd1PadlyhsfazKzw5wtATAKfQ7AsJuJihnA/Y2OJakFQ== X-Received: by 10.99.125.90 with SMTP id m26mr10604795pgn.280.1507594548900; Mon, 09 Oct 2017 17:15:48 -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 r22sm15518157pfl.15.2017.10.09.17.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 17:15:47 -0700 (PDT) Date: Mon, 9 Oct 2017 17:15:46 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: Hannes Reinecke , "James E.J. Bottomley" , linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Thomas Gleixner Subject: [PATCH] scsi/aic7xxx: Convert timers to use timer_setup() Message-ID: <20171010001546.GA120288@beast> MIME-Version: 1.0 Content-Disposition: inline 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 using timer_setup(), adjust callback, drop everything else used to pass things around, and remove needless typedefs. reset_timer is unused; remove it. Cc: Hannes Reinecke Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Thomas Gleixner Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- drivers/scsi/aic7xxx/aic79xx.h | 5 +---- drivers/scsi/aic7xxx/aic79xx_core.c | 29 ++++++++--------------------- drivers/scsi/aic7xxx/aic79xx_osm.h | 7 ------- 3 files changed, 9 insertions(+), 32 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..b560f396ee99 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(struct timer_list *t); #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); + timer_setup(&ahd->stat_timer, ahd_stat_timer, 0); 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(struct timer_list *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(struct timer_list *t) { - struct ahd_softc *ahd = arg; + struct ahd_softc *ahd = from_timer(ahd, t, stat_timer); 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); } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 728193a42e6e..8a8b7ae7aed3 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -203,9 +203,6 @@ int ahd_dmamap_unload(struct ahd_softc *, bus_dma_tag_t, bus_dmamap_t); */ #define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op) -/************************** Timer DataStructures ******************************/ -typedef struct timer_list ahd_timer_t; - /********************************** Includes **********************************/ #ifdef CONFIG_AIC79XX_REG_PRETTY_PRINT #define AIC_DEBUG_REGISTERS 1 @@ -214,10 +211,6 @@ typedef struct timer_list ahd_timer_t; #endif #include "aic79xx.h" -/***************************** Timer Facilities *******************************/ -#define ahd_timer_init init_timer -#define ahd_timer_stop del_timer_sync - /***************************** SMP support ************************************/ #include