On Thu, 3 Feb 2005, Nick Sillik wrote:

> I changed the filenames (monetouch.* -> onetouch.*). I also changed the
> description in the Kconfig to something a little more informative.

> +++ linux-2.6.10nsillik/drivers/usb/storage/onetouch.c        2005-02-03 
> 21:14:21.000000000 -0500

> +void onetouch_connect_input(struct us_data *ss)
> +void onetouch_release_input(struct us_data *ss)

Although it doesn't really matter, it's customary to use "us" as the local 
variable for struct us_data.


> +++ linux-2.6.10nsillik/drivers/usb/storage/onetouch.h        2005-02-03 
> 21:14:16.000000000 -0500

> +#include <linux/config.h>
> +#include "usb.h"
> +#include "linux/input.h"

This should be <linux/input.h>, not "linux/input.h".  And it should 
probably come before the line for "usb.h".


> +++ linux-2.6.10nsillik/drivers/usb/storage/usb.c     2005-02-03 
> 19:18:28.000000000 -0500
> +#ifdef CONFIG_USB_STORAGE_ONETOUCH
> +#include "monetouch.h"
> +#endif
> +#ifndef CONFIG_USB_STORAGE_ONETOUCH
> +static inline void onetouch_connect_input (struct us_data *ss) {}
> +static inline void onetouch_release_input (struct us_data *ss) {}
> +#endif

You can replace the #endif - #ifndef combination with a simple #else.

> @@ -994,6 +1000,8 @@ static int storage_probe(struct usb_inte
>       if (result)
>               goto BadDevice;
> 
> +     onetouch_connect_input(us);
> +
>       /* Acquire all the other resources and add the host */
>       result = usb_stor_acquire_resources(us);
>       if (result)
> @@ -1047,6 +1055,8 @@ static void storage_disconnect(struct us
>       up(&us->dev_semaphore);
>       scsi_remove_host(us->host);
> 
> +     onetouch_release_input(us);
> +
>       /* Wait for everything to become idle and release all our resources */
>       usb_stor_release_resources(us);
>       dissociate_dev(us);

By arranging the code like this, you have guaranteed that the onetouch 
device won't be released properly if something goes wrong during 
usb_stor_acquire_resources().  You should move the call to 
onetouch_connect_input() into usb_stor_acquire_resources() and the call to 
onetouch_release_input() into usb_stor_release_resources().

I don't know a lot about the input layer.  Can you guarantee that nothing 
will go wrong if a user opens the onetouch device at the same time as 
onetouch_release_input() is running?

For that matter, what happens if onetouch_release_input() runs while
onetouch->open_count > 0?  When the user closes the device sometime later, 
won't the resulting call to onetouch_close() cause an oops?

Alan Stern



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to