From patchwork Sat Dec 22 01:56:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1905291 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A8628DFAC4 for ; Sat, 22 Dec 2012 02:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752174Ab2LVB6G (ORCPT ); Fri, 21 Dec 2012 20:58:06 -0500 Received: from mail-ie0-f179.google.com ([209.85.223.179]:65027 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916Ab2LVB6C (ORCPT ); Fri, 21 Dec 2012 20:58:02 -0500 Received: by mail-ie0-f179.google.com with SMTP id k14so7059147iea.38 for ; Fri, 21 Dec 2012 17:58:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=+xWKLQUizDn0XOr5jMq9XaJlFg8oCFXWFuhYvT4yTQ8=; b=yVUn9ORVtF0kP8MHhyOJh+istG8c0OuaxRFJ+uLTb9JZN1Ggbm8TS0obV9fwdnDVuU TIJd6J3Oo1i2LxwR4BkxQgvXvILoS7I6K5fQxMWw/ol4/zuRWSDkHY+v6EpYu+tHYcxU bIJSLbYOeOu+NIyuHSYLZsSsRHVLuwiGBDanxmiiOZ3EohS6bRcPo/ilgX5YJ6Lw2Hkw 9nqAn3q7CswgKNr60MBl4gHokuJ0Gtd7WvSkYyCC+ukCJuOCAm9qshKEbTZVivpDEQjp MzjLvPx9NGApHUOVzT/a4xStZr3MdcfFF1Os6CrODkjotY6npa0g+VaKMvkMG37QtdEF lqtg== X-Received: by 10.50.196.227 with SMTP id ip3mr10106751igc.97.1356141481323; Fri, 21 Dec 2012 17:58:01 -0800 (PST) Received: from htj.dyndns.org.com (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id v12sm10975374igv.3.2012.12.21.17.57.58 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Dec 2012 17:58:00 -0800 (PST) From: Tejun Heo To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Stanislav Yakovlev , linux-wireless@vger.kernel.org Subject: [PATCH 04/25] ipw2x00: simplify scan_event handling Date: Fri, 21 Dec 2012 17:56:54 -0800 Message-Id: <1356141435-17340-5-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1356141435-17340-1-git-send-email-tj@kernel.org> References: <1356141435-17340-1-git-send-email-tj@kernel.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org * Drop unnesssary delayd_work_pending() tests. * Unify scan_event_{now|later} by using mod_delayed_work() w/ 0 delay for scan_event_now. * Make ipw2200 scan_event handling match ipw2100 - use mod_delayed_work() w/ 0 delay for immediate scanning. Only compile tested. Signed-off-by: Tejun Heo Cc: Stanislav Yakovlev Cc: linux-wireless@vger.kernel.org Acked-by: Stanislav Yakovlev --- Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary. Thanks. drivers/net/wireless/ipw2x00/ipw2100.c | 31 ++++++++----------------------- drivers/net/wireless/ipw2x00/ipw2100.h | 3 +-- drivers/net/wireless/ipw2x00/ipw2200.c | 13 +++---------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index d92b21a..b3ab7b7 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c @@ -2181,9 +2181,10 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) mod_delayed_work(system_wq, &priv->rf_kill, round_jiffies_relative(HZ)); } -static void send_scan_event(void *data) +static void ipw2100_scan_event(struct work_struct *work) { - struct ipw2100_priv *priv = data; + struct ipw2100_priv *priv = container_of(work, struct ipw2100_priv, + scan_event.work); union iwreq_data wrqu; wrqu.data.length = 0; @@ -2191,18 +2192,6 @@ static void send_scan_event(void *data) wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); } -static void ipw2100_scan_event_later(struct work_struct *work) -{ - send_scan_event(container_of(work, struct ipw2100_priv, - scan_event_later.work)); -} - -static void ipw2100_scan_event_now(struct work_struct *work) -{ - send_scan_event(container_of(work, struct ipw2100_priv, - scan_event_now)); -} - static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) { IPW_DEBUG_SCAN("scan complete\n"); @@ -2212,13 +2201,11 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) /* Only userspace-requested scan completion events go out immediately */ if (!priv->user_requested_scan) { - if (!delayed_work_pending(&priv->scan_event_later)) - schedule_delayed_work(&priv->scan_event_later, - round_jiffies_relative(msecs_to_jiffies(4000))); + schedule_delayed_work(&priv->scan_event, + round_jiffies_relative(msecs_to_jiffies(4000))); } else { priv->user_requested_scan = 0; - cancel_delayed_work(&priv->scan_event_later); - schedule_work(&priv->scan_event_now); + mod_delayed_work(system_wq, &priv->scan_event, 0); } } @@ -4459,8 +4446,7 @@ static void ipw2100_kill_works(struct ipw2100_priv *priv) cancel_delayed_work_sync(&priv->wx_event_work); cancel_delayed_work_sync(&priv->hang_check); cancel_delayed_work_sync(&priv->rf_kill); - cancel_work_sync(&priv->scan_event_now); - cancel_delayed_work_sync(&priv->scan_event_later); + cancel_delayed_work_sync(&priv->scan_event); } static int ipw2100_tx_allocate(struct ipw2100_priv *priv) @@ -6195,8 +6181,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work); INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check); INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill); - INIT_WORK(&priv->scan_event_now, ipw2100_scan_event_now); - INIT_DELAYED_WORK(&priv->scan_event_later, ipw2100_scan_event_later); + INIT_DELAYED_WORK(&priv->scan_event, ipw2100_scan_event); tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) ipw2100_irq_tasklet, (unsigned long)priv); diff --git a/drivers/net/wireless/ipw2x00/ipw2100.h b/drivers/net/wireless/ipw2x00/ipw2100.h index 5fe17cb..c6d7879 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.h +++ b/drivers/net/wireless/ipw2x00/ipw2100.h @@ -577,8 +577,7 @@ struct ipw2100_priv { struct delayed_work wx_event_work; struct delayed_work hang_check; struct delayed_work rf_kill; - struct work_struct scan_event_now; - struct delayed_work scan_event_later; + struct delayed_work scan_event; int user_requested_scan; diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 844f201..2c2d6db 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c @@ -4480,18 +4480,11 @@ static void handle_scan_event(struct ipw_priv *priv) { /* Only userspace-requested scan completion events go out immediately */ if (!priv->user_requested_scan) { - if (!delayed_work_pending(&priv->scan_event)) - schedule_delayed_work(&priv->scan_event, - round_jiffies_relative(msecs_to_jiffies(4000))); + schedule_delayed_work(&priv->scan_event, + round_jiffies_relative(msecs_to_jiffies(4000))); } else { - union iwreq_data wrqu; - priv->user_requested_scan = 0; - cancel_delayed_work(&priv->scan_event); - - wrqu.data.length = 0; - wrqu.data.flags = 0; - wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); + mod_delayed_work(system_wq, &priv->scan_event, 0); } }