On Mon, 2009-12-07 at 17:34 +0100, Oliver Neukum wrote: > Am Montag, 7. Dezember 2009 17:26:41 schrieb Francesco Lavra: > > Hi, > > this patch adds support for reset_resume in cdc-acm. This function simply > > calls tty_hangup() if there was any user of the tty at suspend time, and > > then calls the normal resume function. Tested with a Samsung SGH-U900 > > device. Without reset_resume, every time the system is hibernated during a > > PPP connection, the device moves from ttyACMx to ttyACM(x+1), an it must > > be unplugged and replugged in order for its original node ttyACMx to > > re-appear. Instead, with reset_resume the device retains its node name > > across hibernation cycles. > > Hi, > > it would be better if you made calling hangup conditional on the device > having been opened. Could you do that? > > Regards > Oliver The check on tty being non NULL serves that purpose (in addition to making the code safe), because when close() is called on the last open device, tty_port_tty_set() is called with NULL as its second argument, thus NULLifying tty. BTW, I took that piece of code from acm_disconnect(). An equally working alternative would be the patch below, which is slightly less efficient, though. Signed-off-by: Francesco Lavra <francescolavra@xxxxxxxxxxxx> --- a/drivers/usb/class/cdc-acm.c 2009-12-07 16:22:20.000000000 +0100 +++ b/drivers/usb/class/cdc-acm.c 2009-12-07 18:16:55.000000000 +0100 @@ -1460,6 +1460,21 @@ err_out: return rv; } +static int acm_reset_resume(struct usb_interface *intf) +{ + struct acm *acm = usb_get_intfdata(intf); + struct tty_struct *tty; + + if (acm->port.count) { + tty = tty_port_tty_get(&acm->port); + if (tty) { + tty_hangup(tty); + tty_kref_put(tty); + } + } + return acm_resume(intf); +} + #endif /* CONFIG_PM */ /* * USB driver structure. @@ -1546,6 +1561,7 @@ static struct usb_driver acm_driver = { #ifdef CONFIG_PM .suspend = acm_suspend, .resume = acm_resume, + .reset_resume = acm_reset_resume, #endif .id_table = acm_ids, #ifdef CONFIG_PM -- 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