From: fschaefer.oss@googlemail.com (Frank Schäfer)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Workqueue and kernel panic on device disconnect
Date: Tue, 25 Oct 2011 23:29:58 +0200 [thread overview]
Message-ID: <4EA72A56.20308@googlemail.com> (raw)
Hi,
I'm trying to use a workqueue in a usb driver for polling the states of
the device buttons.
That works fine, but when I disconnect the device, the kernel sometimes
explodes.
The machine turns off immediately, without saving a backtrace (I will
try to make a photo tomorrow)
The code:
static struct delayed_work poll_work;
static const struct usb_device_id device_table[] = {
{USB_DEVICE(0x1234, 0x5678)},
{}
};
static void poll(struct work_struct *work)
{
schedule_delayed_work(&poll_work,
msecs_to_jiffies(100));
}
MODULE_DEVICE_TABLE(usb, device_table);
static int test_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
INIT_DELAYED_WORK(&poll_work, poll);
schedule_delayed_work(&poll_work,
msecs_to_jiffies(100));
return 0;
}
static void test_disconnect(struct usb_interface *intf)
{
cancel_delayed_work_sync(&poll_work);
}
static struct usb_driver test_driver = {
.name = MODULE_NAME,
.id_table = device_table,
.probe = test_probe,
.disconnect = test_disconnect,
};
static int __init test_mod_init(void)
{
return usb_register(&test_driver);
}
static void __exit test_mod_exit(void)
{
usb_deregister(&test_driver);
}
module_init(test_mod_init);
module_exit(test_mod_exit);
What am I doing wrong ?
Is there anything else I have to do in addition to calling
cancel_delayed_work_sync() in the disconnect fcn ?
Thanks,
Frank Schaefer
next reply other threads:[~2011-10-25 21:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 21:29 Frank Schäfer [this message]
2011-10-26 17:07 ` Workqueue and kernel panic on device disconnect Frank Schäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EA72A56.20308@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.