Skip to contentSkip to conversation

usb_gigaset: suspend support

PATCH Alan Stern 4 participants 8 messages Oct 29, 2007 – Nov 1, 2007 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Alan Stern

author
#1 lore raw
Quoted 5 lines · Tilman Schmidt

From: Tilman Schmidt <[email protected]>

Add basic suspend/resume support to the usb_gigaset driver.

Review static struct usb_driver gigaset_usb_dri · line 130

Quoted 9 lines
(quoted diff) +5 -0
@@ -117,6 +122,11 @@ static struct usb_driver gigaset_usb_dri
 	.probe =	gigaset_probe,
 	.disconnect =	gigaset_disconnect,
 	.id_table =	gigaset_table,
+	.suspend =	gigaset_suspend,
+	.resume =	gigaset_resume,
+	.reset_resume =	gigaset_resume,
+	.pre_reset =	gigaset_suspend,
+	.post_reset =	gigaset_resume,
 };

Does this really compile? The .pre_reset and .suspend members are pointers to functions with different prototypes; I don't see how you can assign the same function to both pointers.

Alan Stern

#2 lore raw

Am 29.10.2007 20:10 schrieb Alan Stern:

Quoted 6 lines · Tilman Schmidt
Quoted 4 lines

From: Tilman Schmidt <[email protected]>

Add basic suspend/resume support to the usb_gigaset driver.

Quoted 14 lines

Review static struct usb_driver gigaset_usb_dri · line 130

Quoted 10 lines
(quoted diff) +5 -0
@@ -117,6 +122,11 @@ static struct usb_driver gigaset_usb_dri
 	.probe =	gigaset_probe,
 	.disconnect =	gigaset_disconnect,
 	.id_table =	gigaset_table,
+	.suspend =	gigaset_suspend,
+	.resume =	gigaset_resume,
+	.reset_resume =	gigaset_resume,
+	.pre_reset =	gigaset_suspend,
+	.post_reset =	gigaset_resume,
 };

Does this really compile? The .pre_reset and .suspend members are pointers to functions with different prototypes; I don't see how you can assign the same function to both pointers.

Oops, you're right. Yes, it does compile, but with a warning "initialization from incompatible pointer type" which I foolishly ignored.

I'll produce a corrected version promptly.

Thanks,
Tilman

Signature · 4 lines
Tilman Schmidt                          E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
#3 lore raw
In reply to a message not in the archive

Am Montag 29 Oktober 2007 schrieb Tilman Schmidt:

Quoted 65 lines

From: Tilman Schmidt <[email protected]>

Add basic suspend/resume support to the usb_gigaset driver.

---

 drivers/isdn/gigaset/usb-gigaset.c |   69 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)
drivers/isdn/gigaset/usb-gigaset.c +23 -1
@@ -104,10 +104,15 @@ MODULE_DEVICE_TABLE(usb, gigaset_table);
  * flags per packet.
  */
 
+/* functions called if a device of this driver is connected/disconnected */
 static int gigaset_probe(struct usb_interface *interface,
 			 const struct usb_device_id *id);
 static void gigaset_disconnect(struct usb_interface *interface);
 
+/* functions called before/after suspend */
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message);
+static int gigaset_resume(struct usb_interface *intf);
+
 static struct gigaset_driver *driver = NULL;
 static struct cardstate *cardstate = NULL;
 
@@ -117,6 +122,11 @@ static struct usb_driver gigaset_usb_dri
 	.probe =	gigaset_probe,
 	.disconnect =	gigaset_disconnect,
 	.id_table =	gigaset_table,
+	.suspend =	gigaset_suspend,
+	.resume =	gigaset_resume,
+	.reset_resume =	gigaset_resume,
+	.pre_reset =	gigaset_suspend,
+	.post_reset =	gigaset_resume,
 };
 
 struct usb_cardstate {
@@ -831,7 +843,7 @@ static void gigaset_disconnect(struct us
 	usb_set_intfdata(interface, NULL);
 	tasklet_kill(&cs->write_tasklet);
 
-	usb_kill_urb(ucs->bulk_out_urb);	/* FIXME: only if active? */
+	usb_kill_urb(ucs->bulk_out_urb);
 
 	kfree(ucs->bulk_out_buffer);
 	usb_free_urb(ucs->bulk_out_urb);
@@ -847,6 +859,63 @@ static void gigaset_disconnect(struct us
 	gigaset_unassign(cs);
 }
 
+/* gigaset_suspend
+ * This function is called before the USB connection is suspended or reset.
+ */
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
+	int rc;
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);

drivers/isdn/gigaset/usb-gigaset.c static void gigaset_disconnect(struct us · line 883

Quoted 10 lines
drivers/isdn/gigaset/usb-gigaset.c +10 -0
+		return -EFAULT;
+	}
+
+	//FIXME stop common module activities? ISDN_STAT_STOP? block open()?
+
+	/* stop submitting bulk URBs */
+	tasklet_disable(&cs->write_tasklet);
+
+	/* kill pending read URB */
+	usb_kill_urb(ucs->read_urb);

no pending write URB?

Regards
Oliver

#4 lore raw

Am 30.10.2007 09:52 schrieb Oliver Neukum:

Quoted 24 lines

Am Montag 29 Oktober 2007 schrieb Tilman Schmidt:

Quoted 22 lines
drivers/isdn/gigaset/usb-gigaset.c +16 -0
@@ -847,6 +859,63 @@ static void gigaset_disconnect(struct us
 	gigaset_unassign(cs);
 }
 
+/* gigaset_suspend
+ * This function is called before the USB connection is suspended or reset.
+ */
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
+	int rc;
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);
+		return -EFAULT;
+	}
+
+	//FIXME stop common module activities? ISDN_STAT_STOP? block open()?
Quoted 8 lines

drivers/isdn/gigaset/usb-gigaset.c static void gigaset_disconnect(struct us · line 883

Quoted 6 lines
drivers/isdn/gigaset/usb-gigaset.c +6 -0
+
+	/* stop submitting bulk URBs */
+	tasklet_disable(&cs->write_tasklet);
+
+	/* kill pending read URB */
+	usb_kill_urb(ucs->read_urb);

no pending write URB?

There shouldn't be. A read URB is always posted in case the device sends anything, even while the device is idle, but a write URB is only submitted if there's actual activity. But you're right, it's safer to add a "usb_kill_urb(ucs->bulk_out_urb);" here just in case.

Thanks,
Tilman

Signature · 4 lines
Tilman Schmidt                          E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 1/2] usb_gigaset: suspend support [v2]

Quoted 5 lines · On Mon, 29 Oct 2007 22:41:30 +0100 (CET) Tilman Schmidt <[email protected]> wrote:

From: Tilman Schmidt <[email protected]>

Add basic suspend/resume support to the usb_gigaset driver. (Corrected version.)

You're not a big fan of checkpatch, I see.

Review

Quoted 10 lines
(quoted diff) +10 -0
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);
+		return -EFAULT;
+	}

Is the above reeeeeely needed? I bet it never happens.

Review

Quoted 11 lines
(quoted diff) +11 -0
+static int gigaset_resume(struct usb_interface *intf)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
+	int rc;
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);
+		return -EFAULT;
+	}

ditto.

#7 lore raw

Re: [PATCH 1/2] usb_gigaset: suspend support [v2]

Am 30.10.2007 22:01 schrieb Andrew Morton:

Quoted 10 lines
Quoted 5 lines · On Mon, 29 Oct 2007 22:41:30 +0100 (CET) Tilman Schmidt <[email protected]> wrote:

From: Tilman Schmidt <[email protected]>

Add basic suspend/resume support to the usb_gigaset driver. (Corrected version.)

You're not a big fan of checkpatch, I see.

Sorry. I promise to mend my ways.

Quoted 4 lines
Quoted 4 lines
(quoted diff) +4 -0
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);
+		return -EFAULT;
+	}

Is the above reeeeeely needed? I bet it never happens.

I'm a great believer in defensive programming. :-)

Anyway, to be sure these checks aren't needed, I would need the assurance that the suspend and resume methods are serialized with the probe and disconnect methods. Are they?

Thanks,
Tilman

Signature · 4 lines
Tilman Schmidt                          E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
#8 lore raw

Re: [PATCH 1/2] usb_gigaset: suspend support [v2]

Quoted 13 lines · On Thu, 01 Nov 2007 19:20:07 +0100 Tilman Schmidt <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4 -0
+static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	struct cardstate *cs;
+	struct usb_cardstate *ucs;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+
+	if ((cs = usb_get_intfdata(intf)) == NULL ||
+	    (ucs = cs->hw.usb) == NULL) {
+		err("%s: no cardstate", __func__);
+		return -EFAULT;
+	}

Is the above reeeeeely needed? I bet it never happens.

Quoted 5 lines

I'm a great believer in defensive programming. :-)

Anyway, to be sure these checks aren't needed, I would need the assurance that the suspend and resume methods are serialized with the probe and disconnect methods. Are they?

dunno it beats me. Not to my knowledge. Perhaps Greg and Rafael would know?

author
#9 lore raw

Re: [linux-usb-devel] [PATCH 1/2] usb_gigaset: suspend support [v2]

In reply to Tilman Schmidt
Quoted 3 lines · Tilman Schmidt

Anyway, to be sure these checks aren't needed, I would need the assurance that the suspend and resume methods are serialized with the probe and disconnect methods. Are they?

Yes. See Documentation/usb/power-management.txt.

Alan Stern