From patchwork Wed Oct 25 10:07:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10026359 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 0A0D060375 for ; Wed, 25 Oct 2017 10:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C9B283F9 for ; Wed, 25 Oct 2017 10:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA74728B35; Wed, 25 Oct 2017 10:08:24 +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 4F248283F9 for ; Wed, 25 Oct 2017 10:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932544AbdJYKHk (ORCPT ); Wed, 25 Oct 2017 06:07:40 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:56939 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932493AbdJYKHc (ORCPT ); Wed, 25 Oct 2017 06:07:32 -0400 Received: by mail-pg0-f68.google.com with SMTP id m18so16915394pgd.13 for ; Wed, 25 Oct 2017 03:07:32 -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=3JxBwtOm7VOxr38LqEFiAgAIWyo3fI5Wcrg8/EOdhJs=; b=hNbrAsm1b+wRJbZFLsikAJ6vzuaKbWSNCgLfwj3JvhU02hHeOmhWLTG49AMG7qOfZb bGCbAL2C+Dg+UkRz+Gnmhy6SkR3tV+1nsWFp0C6CGRx/pD2BsHRbxZxhvxxnMGTCHFlq hEuZZhpUg1V9uQ8N2jc7kGstA1WfVFqGM5bg8= 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=3JxBwtOm7VOxr38LqEFiAgAIWyo3fI5Wcrg8/EOdhJs=; b=bscyDh3yk0O/5cTMcC/K3GVK0p3Cjht8+pXzCqi4ilHx2toKD4mB8UBQZiYICH8dT0 LT2NRGsOSilQgN5WSCPkD5A4ybg8MwFxVNqUpx/9LqMIGcvvmTfN0Osw4e5XtmPZ8Lgh XeNYDbzamgER6TL+RCFBqQHgi7kR+tbbvLniSZhodmHiIv5zbrm1igzLQFVdhbJ6Hl8r Zx4NnCOSXDtLJrLlD54n0vPjvYXduSTuuCWiS/ZWabQHP+4GVtQpb1sLT7T4H9+Ei7Cg qqrkEqQpNtGDe6vLwOZlqWOmNL1S0eLpDDZGsDFggJXPb41yGCgsGFzCGqo7Wm9qGcbh FdqA== X-Gm-Message-State: AMCzsaWXbc6u6/l6MW0/FhkE3piVMnMwQJL1kWEysPEy1lPSoTxdcax0 KCSAgJx5JOWu2nrngH4TLGcEMw== X-Google-Smtp-Source: ABhQp+TZybulLNwhvNSX4D21SeQX64ZRE2rk2qUeD0CTF4u4FtchQnHIiAIcQQff1P8Qb7Vc4p4FSw== X-Received: by 10.159.229.136 with SMTP id az8mr1304180plb.133.1508926051723; Wed, 25 Oct 2017 03:07:31 -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 d8sm4945694pfh.178.2017.10.25.03.07.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 03:07:30 -0700 (PDT) Date: Wed, 25 Oct 2017 03:07:29 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: pmcraid: Convert timers to use timer_setup() Message-ID: <20171025100729.GA145083@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 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: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Martin K. Petersen --- drivers/scsi/pmcraid.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index b4d6cd8cd1ad..4f9f115fb6a0 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -348,7 +348,7 @@ static void pmcraid_init_cmdblk(struct pmcraid_cmd *cmd, int index) cmd->sense_buffer = NULL; cmd->sense_buffer_dma = 0; cmd->dma_handle = 0; - init_timer(&cmd->timer); + timer_setup(&cmd->timer, NULL, 0); } /** @@ -557,8 +557,9 @@ static void pmcraid_reset_type(struct pmcraid_instance *pinstance) static void pmcraid_ioa_reset(struct pmcraid_cmd *); -static void pmcraid_bist_done(struct pmcraid_cmd *cmd) +static void pmcraid_bist_done(struct timer_list *t) { + struct pmcraid_cmd *cmd = from_timer(cmd, t, timer); struct pmcraid_instance *pinstance = cmd->drv_inst; unsigned long lock_flags; int rc; @@ -572,9 +573,6 @@ static void pmcraid_bist_done(struct pmcraid_cmd *cmd) pmcraid_info("BIST not complete, waiting another 2 secs\n"); cmd->timer.expires = jiffies + cmd->time_left; cmd->time_left = 0; - cmd->timer.data = (unsigned long)cmd; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_bist_done; add_timer(&cmd->timer); } else { cmd->time_left = 0; @@ -605,9 +603,8 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd) doorbells, intrs); cmd->time_left = msecs_to_jiffies(PMCRAID_BIST_TIMEOUT); - cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + msecs_to_jiffies(PMCRAID_BIST_TIMEOUT); - cmd->timer.function = (void (*)(unsigned long))pmcraid_bist_done; + cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_bist_done; add_timer(&cmd->timer); } @@ -617,8 +614,9 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd) * Return value * None */ -static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd) +static void pmcraid_reset_alert_done(struct timer_list *t) { + struct pmcraid_cmd *cmd = from_timer(cmd, t, timer); struct pmcraid_instance *pinstance = cmd->drv_inst; u32 status = ioread32(pinstance->ioa_status); unsigned long lock_flags; @@ -637,10 +635,8 @@ static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd) pmcraid_info("critical op is not yet reset waiting again\n"); /* restart timer if some more time is available to wait */ cmd->time_left -= PMCRAID_CHECK_FOR_RESET_TIMEOUT; - cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_reset_alert_done; + cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_reset_alert_done; add_timer(&cmd->timer); } } @@ -676,10 +672,8 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd) * bit to be reset. */ cmd->time_left = PMCRAID_RESET_TIMEOUT; - cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT; - cmd->timer.function = - (void (*)(unsigned long))pmcraid_reset_alert_done; + cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_reset_alert_done; add_timer(&cmd->timer); iowrite32(DOORBELL_IOA_RESET_ALERT, @@ -704,8 +698,9 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd) * Return value: * None */ -static void pmcraid_timeout_handler(struct pmcraid_cmd *cmd) +static void pmcraid_timeout_handler(struct timer_list *t) { + struct pmcraid_cmd *cmd = from_timer(cmd, t, timer); struct pmcraid_instance *pinstance = cmd->drv_inst; unsigned long lock_flags; @@ -919,7 +914,7 @@ static void pmcraid_send_cmd( struct pmcraid_cmd *cmd, void (*cmd_done) (struct pmcraid_cmd *), unsigned long timeout, - void (*timeout_func) (struct pmcraid_cmd *) + void (*timeout_func) (struct timer_list *) ) { /* initialize done function */ @@ -927,9 +922,8 @@ static void pmcraid_send_cmd( if (timeout_func) { /* setup timeout handler */ - cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + timeout; - cmd->timer.function = (void (*)(unsigned long))timeout_func; + cmd->timer.function = (TIMER_FUNC_TYPE)timeout_func; add_timer(&cmd->timer); } @@ -1955,10 +1949,9 @@ static void pmcraid_soft_reset(struct pmcraid_cmd *cmd) * would re-initiate a reset */ cmd->cmd_done = pmcraid_ioa_reset; - cmd->timer.data = (unsigned long)cmd; cmd->timer.expires = jiffies + msecs_to_jiffies(PMCRAID_TRANSOP_TIMEOUT); - cmd->timer.function = (void (*)(unsigned long))pmcraid_timeout_handler; + cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_timeout_handler; if (!timer_pending(&cmd->timer)) add_timer(&cmd->timer);