* [rft]suspend/resume support for yealink
@ 2008-06-30 14:08 Oliver Neukum
2008-06-30 21:39 ` Alfred E. Heggestad
[not found] ` <200806301608.03788.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
0 siblings, 2 replies; 7+ messages in thread
From: Oliver Neukum @ 2008-06-30 14:08 UTC (permalink / raw)
To: Alfred E. Heggestad
Cc: linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
Henk.Vergonet-Re5JQEeQqe8AvxtiuMwx3w
This implements basic suspend/resume support for yealink.
Could somebody test it?
Regards
Oliver
---
--- linux-2.6.26-sierra/drivers/input/misc/yealink.alt2.c 2008-06-30 14:13:58.000000000 +0200
+++ linux-2.6.26-sierra/drivers/input/misc/yealink.c 2008-06-30 16:02:30.000000000 +0200
@@ -120,6 +120,7 @@ struct yealink_dev {
u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */
int key_code; /* last reported key */
int shutdown:1;
+ int open:1;
int stat_ix;
union {
@@ -128,6 +129,7 @@ struct yealink_dev {
} master, copy;
};
+static DECLARE_RWSEM(sysfs_rwsema);
/*******************************************************************************
* Yealink lcd interface
@@ -530,12 +532,16 @@ static int input_open(struct input_dev *
yld->ctl_data->cmd = CMD_INIT;
yld->ctl_data->size = 10;
yld->ctl_data->sum = 0x100-CMD_INIT-10;
- if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0) {
+ down_write(&sysfs_rwsema);
+ if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0)
dbg("%s - usb_submit_urb failed with result %d",
__FUNCTION__, ret);
- return ret;
- }
- return 0;
+ else
+ yld->open = 1;
+
+ up_write(&sysfs_rwsema);
+
+ return ret;
}
static void stop_traffic(struct yealink_dev *yld)
@@ -556,6 +562,9 @@ static void input_close(struct input_dev
{
struct yealink_dev *yld = input_get_drvdata(dev);
+ down_write(&sysfs_rwsema);
+ yld->open = 0;
+ up_write(&sysfs_rwsema);
stop_traffic(yld);
}
@@ -563,8 +572,6 @@ static void input_close(struct input_dev
* sysfs interface
******************************************************************************/
-static DECLARE_RWSEM(sysfs_rwsema);
-
/* Interface to the 7-segments translation table aka. char set.
*/
static ssize_t show_map(struct device *dev, struct device_attribute *attr,
@@ -856,6 +863,25 @@ static int usb_cleanup(struct yealink_de
return err;
}
+static int usb_suspend(struct usb_interface *intf, pm_message_t message)
+{
+ struct yealink_dev *yld = usb_get_intfdata(intf);
+
+ stop_traffic(yld);
+ return 0;
+}
+
+static int usb_resume(struct usb_interface *intf)
+{
+ struct yealink_dev *yld = usb_get_intfdata(intf);
+ int rv = 0;
+
+ down_read(&sysfs_rwsema);
+ if (yld->open)
+ rv = usb_submit_urb(yld->urb_ctl, GFP_NOIO);
+ up_read(&sysfs_rwsema);
+ return rv;
+}
static void usb_disconnect(struct usb_interface *intf)
{
struct yealink_dev *yld;
@@ -1002,6 +1028,8 @@ static struct usb_driver yealink_driver
.name = "yealink",
.probe = usb_probe,
.disconnect = usb_disconnect,
+ .suspend = usb_suspend,
+ .resume = usb_resume,
.id_table = usb_table,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rft]suspend/resume support for yealink
2008-06-30 14:08 [rft]suspend/resume support for yealink Oliver Neukum
@ 2008-06-30 21:39 ` Alfred E. Heggestad
[not found] ` <200806301608.03788.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
1 sibling, 0 replies; 7+ messages in thread
From: Alfred E. Heggestad @ 2008-06-30 21:39 UTC (permalink / raw)
To: Oliver Neukum, Thomas Reitmayr; +Cc: linux-input, linux-usb, Henk.Vergonet
Oliver Neukum wrote:
> This implements basic suspend/resume support for yealink.
> Could somebody test it?
>
(copied Thomas)
Hi Thomas, could you please test this patch with your Yealink device?
/alfred
> Regards
> Oliver
>
> ---
>
> --- linux-2.6.26-sierra/drivers/input/misc/yealink.alt2.c 2008-06-30 14:13:58.000000000 +0200
> +++ linux-2.6.26-sierra/drivers/input/misc/yealink.c 2008-06-30 16:02:30.000000000 +0200
> @@ -120,6 +120,7 @@ struct yealink_dev {
> u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */
> int key_code; /* last reported key */
> int shutdown:1;
> + int open:1;
>
> int stat_ix;
> union {
> @@ -128,6 +129,7 @@ struct yealink_dev {
> } master, copy;
> };
>
> +static DECLARE_RWSEM(sysfs_rwsema);
>
> /*******************************************************************************
> * Yealink lcd interface
> @@ -530,12 +532,16 @@ static int input_open(struct input_dev *
> yld->ctl_data->cmd = CMD_INIT;
> yld->ctl_data->size = 10;
> yld->ctl_data->sum = 0x100-CMD_INIT-10;
> - if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0) {
> + down_write(&sysfs_rwsema);
> + if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0)
> dbg("%s - usb_submit_urb failed with result %d",
> __FUNCTION__, ret);
> - return ret;
> - }
> - return 0;
> + else
> + yld->open = 1;
> +
> + up_write(&sysfs_rwsema);
> +
> + return ret;
> }
>
> static void stop_traffic(struct yealink_dev *yld)
> @@ -556,6 +562,9 @@ static void input_close(struct input_dev
> {
> struct yealink_dev *yld = input_get_drvdata(dev);
>
> + down_write(&sysfs_rwsema);
> + yld->open = 0;
> + up_write(&sysfs_rwsema);
> stop_traffic(yld);
> }
>
> @@ -563,8 +572,6 @@ static void input_close(struct input_dev
> * sysfs interface
> ******************************************************************************/
>
> -static DECLARE_RWSEM(sysfs_rwsema);
> -
> /* Interface to the 7-segments translation table aka. char set.
> */
> static ssize_t show_map(struct device *dev, struct device_attribute *attr,
> @@ -856,6 +863,25 @@ static int usb_cleanup(struct yealink_de
> return err;
> }
>
> +static int usb_suspend(struct usb_interface *intf, pm_message_t message)
> +{
> + struct yealink_dev *yld = usb_get_intfdata(intf);
> +
> + stop_traffic(yld);
> + return 0;
> +}
> +
> +static int usb_resume(struct usb_interface *intf)
> +{
> + struct yealink_dev *yld = usb_get_intfdata(intf);
> + int rv = 0;
> +
> + down_read(&sysfs_rwsema);
> + if (yld->open)
> + rv = usb_submit_urb(yld->urb_ctl, GFP_NOIO);
> + up_read(&sysfs_rwsema);
> + return rv;
> +}
> static void usb_disconnect(struct usb_interface *intf)
> {
> struct yealink_dev *yld;
> @@ -1002,6 +1028,8 @@ static struct usb_driver yealink_driver
> .name = "yealink",
> .probe = usb_probe,
> .disconnect = usb_disconnect,
> + .suspend = usb_suspend,
> + .resume = usb_resume,
> .id_table = usb_table,
> };
>
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <200806301608.03788.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>]
* Re: [rft]suspend/resume support for yealink
[not found] ` <200806301608.03788.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2008-06-30 21:47 ` Thomas Reitmayr
2008-07-01 6:04 ` Oliver Neukum
2008-07-02 14:26 ` Oliver Neukum
0 siblings, 2 replies; 7+ messages in thread
From: Thomas Reitmayr @ 2008-06-30 21:47 UTC (permalink / raw)
To: Oliver Neukum
Cc: Alfred E. Heggestad, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
Henk.Vergonet-Re5JQEeQqe8AvxtiuMwx3w
Hi Oliver,
I tested the suspend/resume support with my Yealink USB-P1K doing the
following:
* Suspend to RAM:
The device suspends properly, I hear the audio subsystem turning off
while the display keeps its current state.
Apparently the USB root hub gets reset during suspend/resume according
to the kernel log. Then after resume the input events are generated
again and the display can be updated. I noticed however that the display
is reset to its default text, possibly because of the USB reset? Anyway,
I appended a filtered kernel log about this scenario below.
* Suspend the device by "echo suspend > power/level"
Works too with the difference that the display is not modified during
resume.
Note that during all my tests the input device was opened when the
device got suspended, i.e. I did not try to explicitly open the input
device only after resume. Neglecting this missing test case I would say
your code works fine!
Regards,
-Thomas
PS: Here is some part of the kernel log generated by suspend to RAM +
resume:
> cat yl-suspend-resume.txt | grep -i 'yealink\|5-2\|usb5'
yealink 5-2:1.3: suspend
usb 5-2:1.2: suspend
usb 5-2:1.1: suspend
usb 5-2:1.0: suspend
usb 5-2: suspend
yealink: urb_ctl_callback - urb status -2
usb usb5: suspend, may wakeup
usb usb5: root hub lost power or was reset
usb usb5: resuming
usb 5-2: resuming
usb 5-2:1.0: resuming
usb 5-2:1.1: resuming
usb 5-2:1.2: resuming
yealink 5-2:1.3: resuming
Restarting tasks ... <6>usb 5-2: USB disconnect, address 4
PM: Removing info for usb:5-2:1.0
PM: Removing info for usb:5-2:1.1
PM: Removing info for usb:5-2:1.2
PM: Removing info for usb:5-2:1.3
PM: Removing info for usb:5-2
usb 5-2: new full speed USB device using uhci_hcd and address 5
usb 5-2: not running at top speed; connect to a high speed hub
PM: Adding info for usb:5-2
usb 5-2: configuration #1 chosen from 1 choice
PM: Adding info for usb:5-2:1.0
PM: Adding info for usb:5-2:1.1
PM: Adding info for usb:5-2:1.2
PM: Adding info for usb:5-2:1.3
input: Yealink usb-p1k
as /devices/pci0000:00/0000:00:1a.2/usb5/5-2/5-2:1.3/input/input8
usb 5-2: New USB device found, idVendor=6993, idProduct=b001
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 5-2: Product: VOIP USB Phone
usb 5-2: Manufacturer: Yealink Network Technology Ltd.
Am Montag, den 30.06.2008, 16:08 +0200 schrieb Oliver Neukum:
> This implements basic suspend/resume support for yealink.
> Could somebody test it?
>
> Regards
> Oliver
>
> ---
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rft]suspend/resume support for yealink
2008-06-30 21:47 ` Thomas Reitmayr
@ 2008-07-01 6:04 ` Oliver Neukum
2008-07-02 14:26 ` Oliver Neukum
1 sibling, 0 replies; 7+ messages in thread
From: Oliver Neukum @ 2008-07-01 6:04 UTC (permalink / raw)
To: Thomas Reitmayr
Cc: Alfred E. Heggestad, linux-input, linux-usb, Henk.Vergonet
Am Montag 30 Juni 2008 23:47:08 schrieb Thomas Reitmayr:
> Hi Oliver,
> I tested the suspend/resume support with my Yealink USB-P1K doing the
> following:
>
> * Suspend to RAM:
> The device suspends properly, I hear the audio subsystem turning off
> while the display keeps its current state.
> Apparently the USB root hub gets reset during suspend/resume according
> to the kernel log. Then after resume the input events are generated
> again and the display can be updated. I noticed however that the display
> is reset to its default text, possibly because of the USB reset? Anyway,
> I appended a filtered kernel log about this scenario below.
Yes, the reset triggers a disconnect because the driver doesn't implement
reset_resume().
> * Suspend the device by "echo suspend > power/level"
> Works too with the difference that the display is not modified during
> resume.
OK, it works. Thank you for testing.
Regards
Oliver
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [rft]suspend/resume support for yealink
2008-06-30 21:47 ` Thomas Reitmayr
2008-07-01 6:04 ` Oliver Neukum
@ 2008-07-02 14:26 ` Oliver Neukum
[not found] ` <200807021626.50883.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
1 sibling, 1 reply; 7+ messages in thread
From: Oliver Neukum @ 2008-07-02 14:26 UTC (permalink / raw)
To: Thomas Reitmayr
Cc: Alfred E. Heggestad, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
Henk.Vergonet-Re5JQEeQqe8AvxtiuMwx3w
Am Montag 30 Juni 2008 23:47:08 schrieb Thomas Reitmayr:
> * Suspend to RAM:
> The device suspends properly, I hear the audio subsystem turning off
> while the display keeps its current state.
> Apparently the USB root hub gets reset during suspend/resume according
> to the kernel log. Then after resume the input events are generated
This patch may help.
Regards
Oliver
---
--- linux-2.6.26-sierra/drivers/input/misc/yealink.alt3.c 2008-07-02 15:42:35.000000000 +0200
+++ linux-2.6.26-sierra/drivers/input/misc/yealink.c 2008-07-02 16:14:57.000000000 +0200
@@ -122,6 +122,9 @@ struct yealink_dev {
int shutdown:1;
int open:1;
+ u8 *old_ringtone;
+ int tonecount;
+
int stat_ix;
union {
struct yld_status s;
@@ -564,6 +567,8 @@ static void input_close(struct input_dev
down_write(&sysfs_rwsema);
yld->open = 0;
+ kfree(yld->old_ringtone),
+ yld->old_ringtone = NULL;
up_write(&sysfs_rwsema);
stop_traffic(yld);
}
@@ -767,6 +772,9 @@ static ssize_t store_ringtone(struct dev
{
struct yealink_dev *yld;
+ if (!count)
+ return 0;
+
down_write(&sysfs_rwsema);
yld = dev_get_drvdata(dev);
if (yld == NULL) {
@@ -776,6 +784,14 @@ static ssize_t store_ringtone(struct dev
/* TODO locking with async usb control interface??? */
yealink_set_ringtone(yld, (char *)buf, count);
+ kfree(yld->old_ringtone);
+ yld->old_ringtone = kmalloc(count, GFP_KERNEL);
+ if (!yld->old_ringtone)
+ goto error_bail;
+ memcpy(yld->old_ringtone, buf, count);
+ yld->tonecount = count;
+
+error_bail:
up_write(&sysfs_rwsema);
return count;
}
@@ -882,6 +898,30 @@ static int usb_resume(struct usb_interfa
up_read(&sysfs_rwsema);
return rv;
}
+
+static int usb_reset_resume(struct usb_interface *intf)
+{
+ struct yealink_dev *yld = usb_get_intfdata(intf);
+ int rv = 0;
+
+ down_read(&sysfs_rwsema);
+ if (!yld->open)
+ goto skip_io;
+ if (yld->old_ringtone)
+ rv = yealink_set_ringtone(yld,
+ yld->old_ringtone,
+ yld->tonecount);
+ else
+ rv = yealink_set_ringtone(yld,
+ default_ringtone,
+ sizeof(default_ringtone));
+
+skip_io:
+ up_read(&sysfs_rwsema);
+
+ return rv;
+}
+
static void usb_disconnect(struct usb_interface *intf)
{
struct yealink_dev *yld;
@@ -1030,6 +1070,7 @@ static struct usb_driver yealink_driver
.disconnect = usb_disconnect,
.suspend = usb_suspend,
.resume = usb_resume,
+ .reset_resume = usb_reset_resume,
.id_table = usb_table,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-07-09 20:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-30 14:08 [rft]suspend/resume support for yealink Oliver Neukum
2008-06-30 21:39 ` Alfred E. Heggestad
[not found] ` <200806301608.03788.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-06-30 21:47 ` Thomas Reitmayr
2008-07-01 6:04 ` Oliver Neukum
2008-07-02 14:26 ` Oliver Neukum
[not found] ` <200807021626.50883.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-07-03 18:27 ` Thomas Reitmayr
2008-07-09 20:33 ` Thomas Reitmayr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).