From patchwork Thu Oct 5 00:47:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986267 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 D730A605A8 for ; Thu, 5 Oct 2017 01:11:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F8828C21 for ; Thu, 5 Oct 2017 01:11:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE02828C2E; Thu, 5 Oct 2017 01:11:17 +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 5A30B28C21 for ; Thu, 5 Oct 2017 01:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbdJEAr4 (ORCPT ); Wed, 4 Oct 2017 20:47:56 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:51013 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421AbdJEArw (ORCPT ); Wed, 4 Oct 2017 20:47:52 -0400 Received: by mail-pg0-f46.google.com with SMTP id p5so7411894pgn.7 for ; Wed, 04 Oct 2017 17:47:51 -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=66iwTQ3hkqr6fLIj14TRevNWi0LcGhjr9cUJrWef0bk=; b=HGrOqmCw3GWqw/zmT9yfTVCD+03P7EGmpFUdtE4ivjMJ+mLYfsEwTPbGIinZVr7llc +qfzp7nKfbX6M2Fr8swsa2T/svHzwqhUyoAX622tymIfOENZBm7YOw/StMgmtBJexJT5 rPe/W1ECAda4xdDRims7mCwYdeehNpweimi+I= 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=66iwTQ3hkqr6fLIj14TRevNWi0LcGhjr9cUJrWef0bk=; b=ad8SgSEkUAFJMyR4VZG5gx31f3eMYQuzMbRVEx+CUuKwGS/TdIK37a+xc717WIE6l0 23l4bj3Trz2HE1+QgzR/qoeXpjP6B2QJ3K5IawZm8dePsG5zswzYTGVsiyasC1aBsXlX NH1ZD1iTo4SZ/yLDhDjupOzw3WOq/nI08TyNx72OJam9TbOBK28vT/6qru8h5HWNsDOE 0wPPOk9GxhwACF3LgDBmCQjlgQ+efwkBpOAdN/R6rvoHyDaAdrw9kgao/leHgr4z4Tnu 4JgFLqvM8zFsCs1464tYIOY31kdbMTIoSehaSM1TGB+BeQJmfZfREVFDcPaZVuNufYql IH2g== X-Gm-Message-State: AHPjjUhInXPqRpkCSYZnlEgiighobeCyGj+3fJObgMR//6DtzM/DUt6D MfO8kJJTz7uiExXpdE/yjLC3sQ== X-Google-Smtp-Source: AOwi7QDtNKc01+5S5cuyEg14R1fhX0gZOq7tFufJXoLBax6bWYHxsuvRzcTCSxpOhd54p5RdjkJENg== X-Received: by 10.101.91.1 with SMTP id y1mr15438250pgq.214.1507164471608; Wed, 04 Oct 2017 17:47:51 -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 l23sm24849350pgu.34.2017.10.04.17.47.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:47:50 -0700 (PDT) Date: Wed, 4 Oct 2017 17:47:49 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Thomas Gleixner Subject: [PATCH] scsi/pmcraid: Convert timers to use timer_setup() Message-ID: <20171005004749.GA22898@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 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/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);