Re: usb-storage: Wait less time for settling when a memory device is connected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, didn't know about checkpatch.pl and linux-usb@xxxxxxxxxxxxxxxx
Also I didn't see that delay_use is a module parameter.
So the patch didn't exactly do what it should. Now here is a new patch
which should work. The reason for the checks against manufacturer,
product and serial number is to detect memory devices. These devices are
ready for partition scanning much earlier than harddrives. So the scan
delay is set to a shorter time for these devices.

martin


Signed-off-by: Martin Bammer <mrbm74@xxxxxxxxx>

--- a/linux/drivers/usb/storage/usb.c	2009-03-03 23:33:37.000000000
+0100
+++ b/linux/drivers/usb/storage/usb.c	2009-03-06 19:15:32.000000000
+0100
@@ -907,19 +907,28 @@ static void release_everything(struct us
 static int usb_stor_scan_thread(void * __us)
 {
 	struct us_data *us = (struct us_data *)__us;
+	unsigned int    local_delay_use = delay_use;
 
 	printk(KERN_DEBUG
 		"usb-storage: device found at %d\n", us->pusb_dev->devnum);
 
 	set_freezable();
 
+	/* Shorten delay time for memory sticks/cards */
+	if ((us->pusb_dev->descriptor.iManufacturer == 1)
+	    && (us->pusb_dev->descriptor.iProduct == 2)
+	    && (us->pusb_dev->descriptor.iSerialNumber == 3)
+	    && (local_delay_use > 0))
+		local_delay_use = 1;
+
 	/* Wait for the timeout to expire or for a disconnect */
-	if (delay_use > 0) {
+	if (local_delay_use > 0) {
 		printk(KERN_DEBUG "usb-storage: waiting for device "
-				"to settle before scanning\n");
+				"to settle before scanning for %d seconds\n",
+				local_delay_use);
 		wait_event_freezable_timeout(us->delay_wait,
 				test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
-				delay_use * HZ);
+				local_delay_use * HZ);
 	}
 
 	/* If the device is still connected, perform the scanning */


> On Fri, Mar 06, 2009 at 11:34:07AM +0100, Martin Bammer wrote:
> > Hi,
> 
> First off, usb issues/patches should be sent to the
> linux-usb@xxxxxxxxxxxxxxx list so they don't get ignored.
> 
> > I was wondering why the usb-storage driver waits for my usb-stick and my
> > sdhc-card 5s before scanning. IMHO this is only needed for HDs. I've
> > created a patch for the driver which shortens the timeout to 1s when a
> > memory device is detected.
> > But I'm not shure if the detection code is right for all devices. This
> > maybe has to be tested and discussed.
> > I've tested it with a usb-stick, a sdhc-card and a usb-harddrive.
> > This patch is created for kernel 2.6.27.18.
> > 
> > Please CC me for answers to this thread.
> > 
> > --- a/drivers/usb/storage/usb.c 2009-03-03 23:33:37.000000000 +0100
> > +++ b/drivers/usb/storage/usb.c 2009-03-03 23:32:44.000000000 +0100
> > @@ -913,10 +913,16 @@ static int usb_stor_scan_thread(void * _
> >  
> >         set_freezable();
> >  
> > +       /* Shorten delay time for memory sticks/cards */
> > +       if ((1 == us->pusb_dev->descriptor.iManufacturer)
> > +           && (2 == us->pusb_dev->descriptor.iProduct)
> > +           && (3 == us->pusb_dev->descriptor.iSerialNumber)
> > +           && (delay_use > 0)) delay_use = 1;
> 
> Please always run your patches through scripts/checkpatch.pl first.
> 
> Why are you testing for the manufacturer and product here?
> 
> And what's wrong with just changing the module parameter for delay_use,
> that is what it is there for.  No kernel patch should be needed.
> 
> thanks,
> 
> greg k-h

--
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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux