From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oliver@neukum.org>,
linux-usb@vger.kernel.org, Stefan Kopp <stefan_kopp@agilent.com>,
Marcel Janssen <korgull@home.nl>,
Felipe Balbi <me@felipebalbi.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: add USB test and measurement class driver - round 2
Date: Wed, 27 Aug 2008 11:36:15 -0700 [thread overview]
Message-ID: <20080827183615.GA15692@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0808271423030.17568-100000@iolanthe.rowland.org>
On Wed, Aug 27, 2008 at 02:28:22PM -0400, Alan Stern wrote:
> On Wed, 27 Aug 2008, Greg KH wrote:
>
> > Here's an updated version of the usbtmc driver, with all of the
> > different issues that have been raised, hopefully addressed.
>
> This is an example of what I was discussing with Oliver. In all
> likelihood you simply don't need usbtmc_mutex, and using it will cause
> a lockdep violation.
>
> That's why so many of the other USB class drivers don't have an
> analogous static mutex.
Ok, then it's just safe to drop this static mutex entirely, right?
> > +static int usbtmc_open(struct inode *inode, struct file *filp)
> > +{
> > + struct usb_interface *intf;
> > + struct usbtmc_device_data *data;
> > + int retval = -ENODEV;
> > +
> > + mutex_lock(&usbtmc_mutex);
>
> You must never acquire a lock in your open method if it will be held
> by your disconnect method while unregistering the minor.
>
> > +static int usbtmc_probe(struct usb_interface *intf,
> > + const struct usb_device_id *id)
> > +{
> ...
> > + retcode = usb_register_dev(intf, &usbtmc_class);
> > + if (retcode) {
> > + dev_err(&intf->dev, "Not able to get a minor"
> > + " (base %u, slice default): %d\n", USBTMC_MINOR_BASE,
> > + retcode);
> > + goto error_register;
> > + }
> > + dev_dbg(&intf->dev, "Using minor number %d\n", intf->minor);
>
> You do call usb_register_dev() during probe...
>
> > +
> > + return 0;
> > +
> > +error_register:
> > + sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
> > + sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
> > + kref_put(&data->kref, usbtmc_delete);
> > + return retcode;
> > +}
> > +
> > +static void usbtmc_disconnect(struct usb_interface *intf)
> > +{
> > + struct usbtmc_device_data *data;
> > +
> > + dev_dbg(&intf->dev, "usbtmc_disconnect called\n");
> > +
> > + mutex_lock(&usbtmc_mutex);
> > + data = usb_get_intfdata(intf);
> > + sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
> > + sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
> > + kref_put(&data->kref, usbtmc_delete);
> > + mutex_unlock(&usbtmc_mutex);
> > +}
>
> But you don't call usb_unregister_dev() during disconnect. An
> oversight?
Ah, yes, my fault, I converted this from using a private cdev to using
the usb_register_dev() call and forgot about this. Thanks for catching
it, I'll go fix this.
Oh, it's usb_deregister_dev(), stupid programmers with inconsitant
interfaces :)
thanks,
greg k-h
next prev parent reply other threads:[~2008-08-27 18:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 17:20 [PATCH] USB: add USB test and measurement class driver - round 2 Greg KH
2008-08-27 18:28 ` Alan Stern
2008-08-27 18:36 ` Greg KH [this message]
2008-08-27 18:58 ` Alan Stern
2008-08-27 19:05 ` Oliver Neukum
2008-08-27 19:16 ` Alan Stern
2008-08-27 23:48 ` Greg KH
2008-08-27 23:47 ` Greg KH
2008-08-28 10:10 ` Oliver Neukum
2008-08-28 16:17 ` Greg KH
2008-08-28 21:29 ` Oliver Neukum
2008-08-28 16:58 ` Marcel Janssen
2008-08-28 20:38 ` Greg KH
2008-08-29 6:57 ` stefan_kopp
2008-08-29 7:46 ` Oliver Neukum
2008-08-29 8:14 ` stefan_kopp
2008-08-29 8:34 ` Oliver Neukum
2008-08-29 9:13 ` stefan_kopp
2008-08-29 11:33 ` Oliver Neukum
2008-08-29 14:39 ` Greg KH
2008-08-29 16:41 ` Marcel Janssen
2008-08-29 20:01 ` Greg KH
2008-08-27 18:37 ` Oliver Neukum
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=20080827183615.GA15692@kroah.com \
--to=greg@kroah.com \
--cc=korgull@home.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=me@felipebalbi.com \
--cc=oliver@neukum.org \
--cc=stefan_kopp@agilent.com \
--cc=stern@rowland.harvard.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox