From patchwork Mon Oct 16 23:54:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010293 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 DE221600CC for ; Mon, 16 Oct 2017 23:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF96628713 for ; Mon, 16 Oct 2017 23:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2FE028715; Mon, 16 Oct 2017 23:56:02 +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 3E90228713 for ; Mon, 16 Oct 2017 23:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755987AbdJPXyW (ORCPT ); Mon, 16 Oct 2017 19:54:22 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:45122 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755322AbdJPXyT (ORCPT ); Mon, 16 Oct 2017 19:54:19 -0400 Received: by mail-pg0-f46.google.com with SMTP id b192so8092528pga.2 for ; Mon, 16 Oct 2017 16:54:19 -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=Z96Xc2D8CR7J41DTSQB7XN8WewzoDaDnlGrllFgBL2U=; b=mmjkcPaZx0tfDtxCqotF2X45ETUjxP/hFkEL5nflT25mrG59cngPJV++hkt10eY9PK YHBKNx6X6n2X1iKS1yDWumP3rJ8qkvO6ay8nf0A0aNby8sOQPxqO5MugOFtxi81Tb8y5 rJKnImi2VPV/Bi28lM2TRStQ8926QT0Wl9AxI= 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=Z96Xc2D8CR7J41DTSQB7XN8WewzoDaDnlGrllFgBL2U=; b=F69FcUm2O4EvvMddwADB+TSiYoa/ptFWgVs01hMy8U6pzNXfBP2AAcEluh0C7oHamF bzBcECK+r8mEKtbkWEX6sO4lVQqOQOqmYrBAYue+dJ/fqXT2/FSvuKQVVpduSxEQHLiy fM5kH1DqcGMUGWZOIDtwTh10KL109E+3i2ivB3xiFDGPPFgKp7FukzL78J27u5Fwr+xg 6k5JXlM4nwozbXzGUsICwOcxBzOkVmJ8MEQNKP4l6VPmXmR+zeksKY/grZHiK546/B+M r0osBQCuL1c31TQcH0PjBNCLSx/6vveKkXidyhteymoSwUmH/U2MZJpMS9kFS4te49FW UYRg== X-Gm-Message-State: AMCzsaWkTS7P/AzhIhHEG33mTDOOJwZGhl6CQR495J3HOHrMaBHzftzL Eokyj6hSIv6iJRdHSqHvxUYBYQ== X-Google-Smtp-Source: ABhQp+TnzU/NzOZY8E/BqdOLMqPf1DN2RhLS1s/fy5+dMgipsu2SpTuU2UhMfdcOtkd56ndmTRJj8w== X-Received: by 10.84.241.207 with SMTP id t15mr4234337plm.158.1508198058771; Mon, 16 Oct 2017 16:54:18 -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 m78sm18149281pfj.164.2017.10.16.16.54.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:54:17 -0700 (PDT) Date: Mon, 16 Oct 2017 16:54:16 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: QLogic-Storage-Upstream@qlogic.com, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi/bnx2i: Convert timers to use timer_setup() Message-ID: <20171016235416.GA102521@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. There was a seemingly missing call to initialize the timer in one handler, so this was added to remove the open-coded initialization. Cc: QLogic-Storage-Upstream@qlogic.com 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/bnx2i/bnx2i.h | 2 +- drivers/scsi/bnx2i/bnx2i_hwi.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_iscsi.c | 15 ++++----------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h index 89ef1a1678d1..663a63d4dae4 100644 --- a/drivers/scsi/bnx2i/bnx2i.h +++ b/drivers/scsi/bnx2i/bnx2i.h @@ -858,7 +858,7 @@ extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep); extern void bnx2i_free_qp_resc(struct bnx2i_hba *hba, struct bnx2i_endpoint *ep); -extern void bnx2i_ep_ofld_timer(unsigned long data); +extern void bnx2i_ep_ofld_timer(struct timer_list *t); extern struct bnx2i_endpoint *bnx2i_find_ep_in_ofld_list( struct bnx2i_hba *hba, u32 iscsi_cid); extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list( diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index e3f22cb4f7fa..e0640e0f259f 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -688,9 +688,9 @@ void bnx2i_update_iscsi_conn(struct iscsi_conn *conn) * * routine to handle connection offload/destroy request timeout */ -void bnx2i_ep_ofld_timer(unsigned long data) +void bnx2i_ep_ofld_timer(struct timer_list *t) { - struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) data; + struct bnx2i_endpoint *ep = from_timer(ep, t, ofld_timer); if (ep->state == EP_STATE_OFLD_START) { printk(KERN_ALERT "ofld_timer: CONN_OFLD timeout\n"); diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 03c104b47f31..de0a507577ef 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1611,9 +1611,8 @@ static int bnx2i_conn_start(struct iscsi_cls_conn *cls_conn) * this should normally not sleep for a long time so it should * not disrupt the caller. */ + timer_setup(&bnx2i_conn->ep->ofld_timer, bnx2i_ep_ofld_timer, 0); bnx2i_conn->ep->ofld_timer.expires = 1 * HZ + jiffies; - bnx2i_conn->ep->ofld_timer.function = bnx2i_ep_ofld_timer; - bnx2i_conn->ep->ofld_timer.data = (unsigned long) bnx2i_conn->ep; add_timer(&bnx2i_conn->ep->ofld_timer); /* update iSCSI context for this conn, wait for CNIC to complete */ wait_event_interruptible(bnx2i_conn->ep->ofld_wait, @@ -1729,10 +1728,8 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba, } ep->state = EP_STATE_CLEANUP_START; - init_timer(&ep->ofld_timer); + timer_setup(&ep->ofld_timer, bnx2i_ep_ofld_timer, 0); ep->ofld_timer.expires = hba->conn_ctx_destroy_tmo + jiffies; - ep->ofld_timer.function = bnx2i_ep_ofld_timer; - ep->ofld_timer.data = (unsigned long) ep; add_timer(&ep->ofld_timer); bnx2i_ep_destroy_list_add(hba, ep); @@ -1835,10 +1832,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost, bnx2i_ep->state = EP_STATE_OFLD_START; bnx2i_ep_ofld_list_add(hba, bnx2i_ep); - init_timer(&bnx2i_ep->ofld_timer); + timer_setup(&bnx2i_ep->ofld_timer, bnx2i_ep_ofld_timer, 0); bnx2i_ep->ofld_timer.expires = 2 * HZ + jiffies; - bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer; - bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep; add_timer(&bnx2i_ep->ofld_timer); if (bnx2i_send_conn_ofld_req(hba, bnx2i_ep)) { @@ -2054,10 +2049,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep) session = conn->session; } - init_timer(&bnx2i_ep->ofld_timer); + timer_setup(&bnx2i_ep->ofld_timer, bnx2i_ep_ofld_timer, 0); bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies; - bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer; - bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep; add_timer(&bnx2i_ep->ofld_timer); if (!test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))