Received: by 10.223.164.202 with SMTP id h10csp3672128wrb; Sat, 25 Nov 2017 14:11:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMZiYjwEaQ4V4O437uYAPGHAWQXStXmUOJAPjD3ZI2HuTBoxUgCMvHLCj19Br2qtEagAZvlp X-Received: by 10.84.240.70 with SMTP id h6mr15005653plt.349.1511647906849; Sat, 25 Nov 2017 14:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511647906; cv=none; d=google.com; s=arc-20160816; b=ovZPblMrPVskGPQcN92DY6ogSGt202jqK0HpyOmDsIBkZNJYoxqJJzHfoKejoMLY0Q hB2SNIrEyJQDiu/k4/ZA53qg3sRGRkgFH+2fs6EHty3/54olsg3knHdYNGoPceN5OmiN ID/mqEzJTQS+rBIOKNqR6Us3Kh3Gq0w4Xue18+7P0RrYPRZxndPSrt727ggqJf37JEcc Cklq98JynaNLGQlCTgdxnH5SgfU0vT7RFeOg95fu7K48hyQW0oNpA9a8CC9+vQhV0r1f i1VKppisHvmKXtT30D/v/x2rafX33aVha+fRqL2vZeD0TaINZOO5o7uE9xxfHsdi5wjT KSyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1H8WWcBVCf8cneBm3r+WEz8krTQVcnl5Oy6L35g7w00=; b=J8b1I9KjcaNMrY3tcP00Z8/IC/VPcAwezNzt0qy42RK34oI4vDwhEMSyT262fddbjT 8aKjHofK+R2dlUF8MWy9JnCYLKY+gPgzBRK0A1q9AZllCILAb1dGphXsxvIJUn4KldH2 v9Y8whB9XfCBSE2EhOBe/p3QXU7OkCWvt6g7rG79aVbiuXpJMilaNGLrORgI0AF6lpwd hQcE5j7I1nu7QrRAoQboRKVnEfwflZJOEYwBilweoAYivXaKt1c/RiFqS+/T8IgKedS/ jtJ4GuPmnkFflD/PMY14WQD2queCvgBVvM01tzKjaBuvFHxQNaRkWYJNAoSiLJWor0pP Q/LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kdWMzcOi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w63si20115199pgb.612.2017.11.25.14.11.32; Sat, 25 Nov 2017 14:11:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kdWMzcOi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751683AbdKYWKr (ORCPT + 81 others); Sat, 25 Nov 2017 17:10:47 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41576 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbdKYWKp (ORCPT ); Sat, 25 Nov 2017 17:10:45 -0500 Received: by mail-lf0-f65.google.com with SMTP id f134so28758647lfg.8; Sat, 25 Nov 2017 14:10:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1H8WWcBVCf8cneBm3r+WEz8krTQVcnl5Oy6L35g7w00=; b=kdWMzcOiwiNiOc0BhNxuaDPIy9FEXaGPyeki0Qgz3W1qye25ikvNJnihU1GhPojkLC Mm2+XXzyiy0tUEL/EqoV0EHegLilQ5ICY5pitGEZr2JUDudbt0IEV04n7q1mrFwMHUk8 aD8rPBaQh4uBkK5gIqSFEfLXUzuJoGkTqFbDo/QzSMH+PRZfy0mOh4ZWWtIhZaqFgsIR rya/V9CKpHpkON5Uvo230utiwvc/Wf+v/3jIfQY8ELu8xsmGdyTZOpuizEmyO11+XsU7 6K3wFgDAtayAONNoB2oMVr5x2sgiePBjvnW2q+l/NgDtzi34CY0p4XvjALBYxCO+16uB bewA== 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; bh=1H8WWcBVCf8cneBm3r+WEz8krTQVcnl5Oy6L35g7w00=; b=RzuhR5hF0Ifsk8BGEAQg3eny/c2vnc6sxjGmHqhaeeXIp3Tdh79VyOFpn0NqEtMRfO MRf/i2YxwYD/g2yK8u1lQ4o7xjrY7fuhELUtNwNnfS6GAbK+OA4Zf8XK6v2ye847+3rm c9cJj+sjO4IMhNNv+HxmhVZS24ItcG5MRh2g7/gkaqPo1xGnWBux33/0eA8YID7AEtU1 z+DY1EZ4s1/zE/7PJ9LrpBsHqzLtO3dtTKZmma9XNTNEMtMCAW4BYIht+YKB8ocRRMV/ HdAY/zbu4jGLVmt9CT2zZNqZtUuk5r0UV02/y4p6zwUWImcEH2Q+C8rMy1u07bDaqNk3 k5pw== X-Gm-Message-State: AJaThX67PDIOTtNKMZCrCW3uGMI5WMHiad3nxroKYQPK4MttAz7MuWo6 Gti6OUClpskfG01glF2Yh6Q= X-Received: by 10.25.222.154 with SMTP id i26mr10002377lfl.102.1511647843552; Sat, 25 Nov 2017 14:10:43 -0800 (PST) Received: from localhost.localdomain ([195.254.138.66]) by smtp.gmail.com with ESMTPSA id f78sm4601363lje.20.2017.11.25.14.10.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 14:10:41 -0800 (PST) From: Vasyl Gomonovych To: sameo@linux.intel.com, davem@davemloft.net, johannes.berg@intel.com, stephen@networkplumber.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gomonovych@gmail.com Subject: [PATCH] NFC: use timer_setup() helper Date: Sat, 25 Nov 2017 23:10:25 +0100 Message-Id: <1511647825-24378-1-git-send-email-gomonovych@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use timer_setup function instead of initializing timer with the function and data fields. net/nfc/core.c:1097:2-12: Use setup_timer function for function on line 1098 net/nfc/hci/core.c:1007:1-11: Use setup_timer function for function on line 1008 net/nfc/hci/llc_shdlc.c:766:1-11: Use setup_timer function for function on line 767 net/nfc/hci/llc_shdlc.c:766:1-11: Use setup_timer function for function on line 767 net/nfc/llcp_core.c:1576:1-11: Use setup_timer function for function on line 1577 Generated by: scripts/coccinelle/api/setup_timer.cocci Signed-off-by: Vasyl Gomonovych --- net/nfc/core.c | 8 +++----- net/nfc/hci/core.c | 8 +++----- net/nfc/hci/llc_shdlc.c | 26 +++++++++----------------- net/nfc/llcp_core.c | 16 ++++++---------- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/net/nfc/core.c b/net/nfc/core.c index 5cf33df888c3..b220b0406b57 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -1015,9 +1015,9 @@ static void nfc_check_pres_work(struct work_struct *work) device_unlock(&dev->dev); } -static void nfc_check_pres_timeout(unsigned long data) +static void nfc_check_pres_timeout(struct timer_list *t) { - struct nfc_dev *dev = (struct nfc_dev *)data; + struct nfc_dev *dev = from_timer(dev, t, check_pres_timer); schedule_work(&dev->check_pres_work); } @@ -1094,9 +1094,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, dev->targets_generation = 1; if (ops->check_presence) { - init_timer(&dev->check_pres_timer); - dev->check_pres_timer.data = (unsigned long)dev; - dev->check_pres_timer.function = nfc_check_pres_timeout; + timer_setup(&dev->check_pres_timer, nfc_check_pres_timeout, 0); INIT_WORK(&dev->check_pres_work, nfc_check_pres_work); } diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index b740fef0acc5..ac8030c4bcf8 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c @@ -428,9 +428,9 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, nfc_hci_driver_failure(hdev, r); } -static void nfc_hci_cmd_timeout(unsigned long data) +static void nfc_hci_cmd_timeout(struct timer_list *t) { - struct nfc_hci_dev *hdev = (struct nfc_hci_dev *)data; + struct nfc_hci_dev *hdev = from_timer(hdev, t, cmd_timer); schedule_work(&hdev->msg_tx_work); } @@ -1004,9 +1004,7 @@ int nfc_hci_register_device(struct nfc_hci_dev *hdev) INIT_WORK(&hdev->msg_tx_work, nfc_hci_msg_tx_work); - init_timer(&hdev->cmd_timer); - hdev->cmd_timer.data = (unsigned long)hdev; - hdev->cmd_timer.function = nfc_hci_cmd_timeout; + timer_setup(&hdev->cmd_timer, nfc_hci_cmd_timeout, 0); skb_queue_head_init(&hdev->rx_hcp_frags); diff --git a/net/nfc/hci/llc_shdlc.c b/net/nfc/hci/llc_shdlc.c index 17e59a009ce6..fe988936ad92 100644 --- a/net/nfc/hci/llc_shdlc.c +++ b/net/nfc/hci/llc_shdlc.c @@ -580,27 +580,27 @@ static void llc_shdlc_handle_send_queue(struct llc_shdlc *shdlc) } } -static void llc_shdlc_connect_timeout(unsigned long data) +static void llc_shdlc_connect_timeout(struct timer_list *t) { - struct llc_shdlc *shdlc = (struct llc_shdlc *)data; + struct llc_shdlc *shdlc = from_timer(shdlc, t, connect_timer); pr_debug("\n"); schedule_work(&shdlc->sm_work); } -static void llc_shdlc_t1_timeout(unsigned long data) +static void llc_shdlc_t1_timeout(struct timer_list *t) { - struct llc_shdlc *shdlc = (struct llc_shdlc *)data; + struct llc_shdlc *shdlc = from_timer(shdlc, t, t1_timer); pr_debug("SoftIRQ: need to send ack\n"); schedule_work(&shdlc->sm_work); } -static void llc_shdlc_t2_timeout(unsigned long data) +static void llc_shdlc_t2_timeout(struct timer_list *t) { - struct llc_shdlc *shdlc = (struct llc_shdlc *)data; + struct llc_shdlc *shdlc = from_timer(shdlc, t, t2_timer); pr_debug("SoftIRQ: need to retransmit\n"); @@ -763,17 +763,9 @@ static void *llc_shdlc_init(struct nfc_hci_dev *hdev, xmit_to_drv_t xmit_to_drv, mutex_init(&shdlc->state_mutex); shdlc->state = SHDLC_DISCONNECTED; - init_timer(&shdlc->connect_timer); - shdlc->connect_timer.data = (unsigned long)shdlc; - shdlc->connect_timer.function = llc_shdlc_connect_timeout; - - init_timer(&shdlc->t1_timer); - shdlc->t1_timer.data = (unsigned long)shdlc; - shdlc->t1_timer.function = llc_shdlc_t1_timeout; - - init_timer(&shdlc->t2_timer); - shdlc->t2_timer.data = (unsigned long)shdlc; - shdlc->t2_timer.function = llc_shdlc_t2_timeout; + timer_setup(&shdlc->connect_timer, llc_shdlc_connect_timeout, 0); + timer_setup(&shdlc->t1_timer, llc_shdlc_t1_timeout, 0); + timer_setup(&shdlc->t2_timer, llc_shdlc_t2_timeout, 0); shdlc->w = SHDLC_MAX_WINDOW; shdlc->srej_support = SHDLC_SREJ_SUPPORT; diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index 02eef5cf3cce..ef4026a23e80 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -242,9 +242,9 @@ static void nfc_llcp_timeout_work(struct work_struct *work) nfc_dep_link_down(local->dev); } -static void nfc_llcp_symm_timer(unsigned long data) +static void nfc_llcp_symm_timer(struct timer_list *t) { - struct nfc_llcp_local *local = (struct nfc_llcp_local *) data; + struct nfc_llcp_local *local = from_timer(local, t, link_timer); pr_err("SYMM timeout\n"); @@ -285,9 +285,9 @@ static void nfc_llcp_sdreq_timeout_work(struct work_struct *work) nfc_genl_llc_send_sdres(local->dev, &nl_sdres_list); } -static void nfc_llcp_sdreq_timer(unsigned long data) +static void nfc_llcp_sdreq_timer(struct timer_list *t) { - struct nfc_llcp_local *local = (struct nfc_llcp_local *) data; + struct nfc_llcp_local *local = from_timer(local, t, sdreq_timer); schedule_work(&local->sdreq_timeout_work); } @@ -1573,9 +1573,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) INIT_LIST_HEAD(&local->list); kref_init(&local->ref); mutex_init(&local->sdp_lock); - init_timer(&local->link_timer); - local->link_timer.data = (unsigned long) local; - local->link_timer.function = nfc_llcp_symm_timer; + timer_setup(&local->link_timer, nfc_llcp_symm_timer, 0); skb_queue_head_init(&local->tx_queue); INIT_WORK(&local->tx_work, nfc_llcp_tx_work); @@ -1601,9 +1599,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) mutex_init(&local->sdreq_lock); INIT_HLIST_HEAD(&local->pending_sdreqs); - init_timer(&local->sdreq_timer); - local->sdreq_timer.data = (unsigned long) local; - local->sdreq_timer.function = nfc_llcp_sdreq_timer; + timer_setup(&local->sdreq_timer, nfc_llcp_sdreq_timer, 0); INIT_WORK(&local->sdreq_timeout_work, nfc_llcp_sdreq_timeout_work); list_add(&local->list, &llcp_devices); -- 1.9.1 From 1585336290440929999@xxx Tue Nov 28 18:41:43 +0000 2017 X-GM-THRID: 1585324376564884825 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread