[PATCH v2 5/6] usb/dummy_hcd: move common bits of suspend/resume into one function

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

 



Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
v1..v2:
* Alan Stern | 2011-06-16 16:33:44 [-0400]:

>I meant you should do this:
>
>static int dummy_udc_suspend(struct platform_device *pdev, pm_message_t state)
>{
>	dev_dbg(&pdev->dev, "%s\n", __func__);
>	dummy_udc_pm(pdev, 1);
>	usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
>	return 0;
>}

Now I'm adding more than I remove but atleast the common bits are in one
place.

 drivers/usb/gadget/dummy_hcd.c |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 865faf0..3c62f64 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1040,34 +1040,35 @@ static int dummy_udc_remove (struct platform_device *pdev)
 	return 0;
 }
 
-static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state)
+static void dummy_udc_pm(struct platform_device *pdev, int suspend)
 {
-	struct dummy	*dum = platform_get_drvdata(pdev);
-	struct dummy_hcd *dum_hcd;
+	struct dummy		*dum = platform_get_drvdata(pdev);
+	struct dummy_hcd	*dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
 
-	dev_dbg (&pdev->dev, "%s\n", __func__);
-	dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
 	spin_lock_irq (&dum->lock);
-	dum->udc_suspended = 1;
+	dum->udc_suspended = suspend;
 	set_link_state(dum_hcd);
 	spin_unlock_irq (&dum->lock);
+}
 
+static int dummy_udc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct dummy		*dum = platform_get_drvdata(pdev);
+	struct dummy_hcd	*dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
+
+	dev_dbg(&pdev->dev, "%s\n", __func__);
+	dummy_udc_pm(pdev, 1);
 	usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
 	return 0;
 }
 
-static int dummy_udc_resume (struct platform_device *pdev)
+static int dummy_udc_resume(struct platform_device *pdev)
 {
-	struct dummy	*dum = platform_get_drvdata(pdev);
-	struct dummy_hcd *dum_hcd;
-
-	dev_dbg (&pdev->dev, "%s\n", __func__);
-	dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
-	spin_lock_irq (&dum->lock);
-	dum->udc_suspended = 0;
-	set_link_state(dum_hcd);
-	spin_unlock_irq (&dum->lock);
+	struct dummy		*dum = platform_get_drvdata(pdev);
+	struct dummy_hcd	*dum_hcd = gadget_to_dummy_hcd(&dum->gadget);
 
+	dev_dbg(&pdev->dev, "%s\n", __func__);
+	dummy_udc_pm(pdev, 0);
 	usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
 	return 0;
 }
-- 
1.7.4.4

--
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