All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: Tejun Heo <tj@kernel.org>, Brent Casavant <bcasavan@sgi.com>
Subject: [PATCH 2/6] ioc4: use static work_struct for ioc4_load_modules()
Date: Sun, 12 Dec 2010 17:48:15 +0100	[thread overview]
Message-ID: <1292172499-21633-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1292172499-21633-1-git-send-email-tj@kernel.org>

There is no reason to dynamically allocate work_struct for
ioc4_load_modules().  It makes the code more complex and makes it
impossible to flush the work directly.  Use static work
ioc4_load_modules_work instead and flush it directly on exit.

This removes the use of flush_scheduled_work() which is being
deprecated.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Brent Casavant <bcasavan@sgi.com>
---
This is part of a series to remove flush_scheduled_work() usage to
prepare for deprecation of flush_scheduled_work().  Patches in this
series are self contained and mostly straight-forward.

Please feel free to take it into the appropriate tree, or just ack it.
In the latter case, I'll merge the patch through the workqueue tree
during the next merge window.

Thank you.

 drivers/misc/ioc4.c |   29 +++++++++--------------------
 1 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 1932066..668d41e 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -273,13 +273,11 @@ ioc4_variant(struct ioc4_driver_data *idd)
 static void __devinit
 ioc4_load_modules(struct work_struct *work)
 {
-	/* arg just has to be freed */
-
 	request_module("sgiioc4");
-
-	kfree(work);
 }
 
+static DECLARE_WORK(ioc4_load_modules_work, ioc4_load_modules);
+
 /* Adds a new instance of an IOC4 card */
 static int __devinit
 ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
@@ -396,21 +394,12 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	 * PCI device.
 	 */
 	if (idd->idd_variant != IOC4_VARIANT_PCI_RT) {
-		struct work_struct *work;
-		work = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
-		if (!work) {
-			printk(KERN_WARNING
-			       "%s: IOC4 unable to allocate memory for "
-			       "load of sub-modules.\n", __func__);
-		} else {
-			/* Request the module from a work procedure as the
-			 * modprobe goes out to a userland helper and that
-			 * will hang if done directly from ioc4_probe().
-			 */
-			printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n");
-			INIT_WORK(work, ioc4_load_modules);
-			schedule_work(work);
-		}
+		/* Request the module from a work procedure as the modprobe
+		 * goes out to a userland helper and that will hang if done
+		 * directly from ioc4_probe().
+		 */
+		printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n");
+		schedule_work(&ioc4_load_modules_work);
 	}
 
 	return 0;
@@ -498,7 +487,7 @@ static void __exit
 ioc4_exit(void)
 {
 	/* Ensure ioc4_load_modules() has completed before exiting */
-	flush_scheduled_work();
+	flush_work_sync(&ioc4_load_modules_work);
 	pci_unregister_driver(&ioc4_driver);
 }
 
-- 
1.7.1


  parent reply	other threads:[~2010-12-12 16:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 16:48 [PATCHSET] workqueue: another assorted flush_scheduled_work() removals Tejun Heo
2010-12-12 16:48 ` [PATCH 1/6] init: don't call flush_scheduled_work() from do_initcalls() Tejun Heo
2010-12-12 16:48 ` Tejun Heo [this message]
2010-12-12 16:48 ` [PATCH 3/6] media/video: explicitly flush request_module work Tejun Heo
2010-12-12 16:48 ` [PATCH 4/6] media/video: don't use flush_scheduled_work() Tejun Heo
2010-12-12 16:48 ` [PATCH 5/6] speedtch: don't abuse struct delayed_work Tejun Heo
2010-12-16 21:30   ` Greg KH
2010-12-17 11:05     ` Tejun Heo
2010-12-12 16:48 ` [PATCH 6/6] usb: don't use flush_scheduled_work() Tejun Heo
2010-12-17 13:51 ` speedtch: don't abuse struct delayed_work Nicolas Kaiser
2010-12-18 11:58   ` Nicolas Kaiser
2010-12-18 16:32   ` [PATCH UPDATED 5/6] " Tejun Heo
2010-12-18 17:59     ` Nicolas Kaiser
2010-12-24 15:14 ` [PATCHSET] workqueue: another assorted flush_scheduled_work() removals Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292172499-21633-3-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bcasavan@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.