[patch 2.6.29] usb: musb, stop using workqueue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Krogerus Heikki <heikki.krogerus@xxxxxxxxx>

We can stop using a workqueue and shrink resource usage:

 - Use sysfs_notify_dirent() instead of sysfs_notify()
 - musb_check_mode() as replacement

Signed-off-by: Krogerus Heikki <heikki.krogerus@xxxxxxxxx>
Signed-off-by: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/usb/musb/musb_core.c   |   24 ++++++------------------
 drivers/usb/musb/musb_core.h   |   14 +++++++++++++-
 drivers/usb/musb/musb_gadget.c |    4 ++--
 drivers/usb/musb/tusb6010.c    |    6 +++---
 4 files changed, 24 insertions(+), 24 deletions(-)

--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -691,7 +691,7 @@ static irqreturn_t musb_stage0_irq(struc
 
 		handled = IRQ_HANDLED;
 	}
-	schedule_work(&musb->irq_work);
+	musb_check_mode(musb);
 
 	return handled;
 }
@@ -797,7 +797,7 @@ static irqreturn_t musb_stage2_irq(struc
 			break;
 		}
 
-		schedule_work(&musb->irq_work);
+		musb_check_mode(musb);
 	}
 
 	if (int_usb & MUSB_INTR_SUSPEND) {
@@ -847,7 +847,7 @@ static irqreturn_t musb_stage2_irq(struc
 			musb->is_active = 0;
 			break;
 		}
-		schedule_work(&musb->irq_work);
+		musb_check_mode(musb);
 	}
 
 
@@ -1743,18 +1743,6 @@ static DEVICE_ATTR(srp, 0644, NULL, musb
 
 #endif	/* sysfs */
 
-/* Only used to provide driver mode change events */
-static void musb_irq_work(struct work_struct *data)
-{
-	struct musb *musb = container_of(data, struct musb, irq_work);
-	static int old_state;
-
-	if (musb->xceiv.state != old_state) {
-		old_state = musb->xceiv.state;
-		sysfs_notify(&musb->controller->kobj, NULL, "mode");
-	}
-}
-
 /* --------------------------------------------------------------------------
  * Init support
  */
@@ -1968,9 +1956,6 @@ bad_config:
 	if (status < 0)
 		goto fail2;
 
-	/* Init IRQ workqueue before request_irq */
-	INIT_WORK(&musb->irq_work, musb_irq_work);
-
 	/* attach to the IRQ */
 	if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
 		dev_err(dev, "request_irq %d failed!\n", nIrq);
@@ -2054,6 +2039,9 @@ bad_config:
 	status = device_create_file(dev, &dev_attr_srp);
 #endif /* CONFIG_USB_GADGET_MUSB_HDRC */
 	status = 0;
+	musb->sysfs_mode = sysfs_get_dirent(musb->controller->kobj.sd, "mode");
+	if (!musb->sysfs_mode)
+		goto fail2;
 #endif
 	if (status)
 		goto fail2;
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -308,7 +308,6 @@ struct musb {
 	spinlock_t		lock;
 	struct clk		*clock;
 	irqreturn_t		(*isr)(int, void *);
-	struct work_struct	irq_work;
 
 /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
 #define MUSB_PORT_STAT_RESUME	(1 << 31)
@@ -433,6 +432,7 @@ struct musb {
 #ifdef MUSB_CONFIG_PROC_FS
 	struct proc_dir_entry *proc_entry;
 #endif
+	struct sysfs_dirent	*sysfs_mode;
 };
 
 static inline void musb_set_vbus(struct musb *musb, int is_on)
@@ -513,6 +513,18 @@ static inline void musb_configure_ep0(st
 }
 #endif /* CONFIG_BLACKFIN */
 
+/* Only used to provide driver mode change events */
+static inline void musb_check_mode(struct musb *musb)
+{
+#ifdef CONFIG_SYSFS
+	static int old_state;
+
+	if (musb->xceiv.state != old_state) {
+		old_state = musb->xceiv.state;
+		sysfs_notify_dirent(musb->sysfs_mode);
+	}
+#endif
+}
 
 /***************************** Glue it together *****************************/
 
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -982,7 +982,7 @@ static int musb_gadget_enable(struct usb
 			musb_ep->dma ? "dma, " : "",
 			musb_ep->packet_sz);
 
-	schedule_work(&musb->irq_work);
+	musb_check_mode(musb);
 
 fail:
 	spin_unlock_irqrestore(&musb->lock, flags);
@@ -1027,7 +1027,7 @@ static int musb_gadget_disable(struct us
 	/* abort all pending DMA and requests */
 	nuke(musb_ep, -ESHUTDOWN);
 
-	schedule_work(&musb->irq_work);
+	musb_check_mode(musb);
 
 	spin_unlock_irqrestore(&(musb->lock), flags);
 
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -712,7 +712,7 @@ tusb_otg_ints(struct musb *musb, u32 int
 			DBG(2, "vbus change, %s, otg %03x\n",
 				otg_state_string(musb), otg_stat);
 			idle_timeout = jiffies + (1 * HZ);
-			schedule_work(&musb->irq_work);
+			musb_check_mode(musb);
 
 		} else /* A-dev state machine */ {
 			DBG(2, "vbus change, %s, otg %03x\n",
@@ -801,7 +801,7 @@ tusb_otg_ints(struct musb *musb, u32 int
 			break;
 		}
 	}
-	schedule_work(&musb->irq_work);
+	musb_check_mode(musb);
 
 	return idle_timeout;
 }
@@ -851,7 +851,7 @@ static irqreturn_t tusb_interrupt(int ir
 		musb_writel(tbase, TUSB_PRCM_WAKEUP_CLEAR, reg);
 		if (reg & ~TUSB_PRCM_WNORCS) {
 			musb->is_active = 1;
-			schedule_work(&musb->irq_work);
+			musb_check_mode(musb);
 		}
 		DBG(3, "wake %sactive %02x\n",
 				musb->is_active ? "" : "in", reg);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux