public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-08-31 23:29 Andries.Brouwer
@ 2002-09-04 21:44 ` Greg KH
  2002-09-04 22:04   ` Matthew Dharm
  2002-09-05  0:10 ` Greg KH
  1 sibling, 1 reply; 13+ messages in thread
From: Greg KH @ 2002-09-04 21:44 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: linux-kernel, linux-scsi, linux-usb-devel, mdharm-usb

On Sun, Sep 01, 2002 at 01:29:58AM +0200, Andries.Brouwer@cwi.nl wrote:
> 
> Without the patch the kernel crashes, or insmod usb-storage hangs.
> With the patch the CF part of the device works perfectly.

Matt, is it ok with you for me to add this patch to the tree?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 21:44 ` [linux-usb-devel] " Greg KH
@ 2002-09-04 22:04   ` Matthew Dharm
  0 siblings, 0 replies; 13+ messages in thread
From: Matthew Dharm @ 2002-09-04 22:04 UTC (permalink / raw)
  To: Greg KH; +Cc: Andries.Brouwer, linux-kernel, linux-scsi, linux-usb-devel

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

I'd like to hold off a few more days while I try to find out what the
'secret sauce' that the other OSes use for a device like this.

Oh, and I don't think the INQUIRY changes co-mingled in with the other
stuff is really any good.

Matt

On Wed, Sep 04, 2002 at 02:44:02PM -0700, Greg KH wrote:
> On Sun, Sep 01, 2002 at 01:29:58AM +0200, Andries.Brouwer@cwi.nl wrote:
> > 
> > Without the patch the kernel crashes, or insmod usb-storage hangs.
> > With the patch the CF part of the device works perfectly.
> 
> Matt, is it ok with you for me to add this patch to the tree?
> 
> thanks,
> 
> greg k-h

-- 
Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net 
Maintainer, Linux USB Mass Storage Driver

YOU SEE!!?? It's like being born with only one nipple!
					-- Erwin
User Friendly, 10/19/1998

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
@ 2002-09-04 22:56 Andries.Brouwer
  2002-09-04 23:09 ` Greg KH
  2002-09-04 23:10 ` Matthew Dharm
  0 siblings, 2 replies; 13+ messages in thread
From: Andries.Brouwer @ 2002-09-04 22:56 UTC (permalink / raw)
  To: greg, mdharm-kernel
  Cc: Andries.Brouwer, linux-kernel, linux-scsi, linux-usb-devel

>> Matt, is it ok with you for me to add this patch to the tree?

> I'd like to hold off a few more days while I try to find out what the
> 'secret sauce' that the other OSes use for a device like this.

Hmm. You do not confuse two situations, do you?
In the past few days I made two devices work.

One was a Feiya 5-in-1 CF / SM / SD card reader
(Vendor Id: 090c, Product Id: 1132, Revision 1.00).
It returned a capacity that is one too large, and becomes
very unhappy if one tries to read a sector past the end.
So, a flag was needed to tell that the result of READ CAPACITY
needs fixing.

The other was a Travelmate CF / SM / SD card reader
(Vendor Id: 3538, Product Id: 0001, Revision 2.05).
It became unhappy when MODE_SENSE asked for too much data.
A patch on sd.c solved this.

Andries

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 22:56 [linux-usb-devel] Feiya 5-in-1 Card Reader Andries.Brouwer
@ 2002-09-04 23:09 ` Greg KH
  2002-09-04 23:10 ` Matthew Dharm
  1 sibling, 0 replies; 13+ messages in thread
From: Greg KH @ 2002-09-04 23:09 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: mdharm-kernel, linux-kernel, linux-scsi, linux-usb-devel

On Thu, Sep 05, 2002 at 12:56:00AM +0200, Andries.Brouwer@cwi.nl wrote:
> >> Matt, is it ok with you for me to add this patch to the tree?
> 
> > I'd like to hold off a few more days while I try to find out what the
> > 'secret sauce' that the other OSes use for a device like this.
> 
> Hmm. You do not confuse two situations, do you?
> In the past few days I made two devices work.
> 
> One was a Feiya 5-in-1 CF / SM / SD card reader
> (Vendor Id: 090c, Product Id: 1132, Revision 1.00).
> It returned a capacity that is one too large, and becomes
> very unhappy if one tries to read a sector past the end.
> So, a flag was needed to tell that the result of READ CAPACITY
> needs fixing.

Seems reasonble, Matt, any objection?

> The other was a Travelmate CF / SM / SD card reader
> (Vendor Id: 3538, Product Id: 0001, Revision 2.05).
> It became unhappy when MODE_SENSE asked for too much data.
> A patch on sd.c solved this.

Linus already added this patch to his tree :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 22:56 [linux-usb-devel] Feiya 5-in-1 Card Reader Andries.Brouwer
  2002-09-04 23:09 ` Greg KH
@ 2002-09-04 23:10 ` Matthew Dharm
  2002-09-04 23:46   ` Andries Brouwer
  2002-09-05  1:11   ` Phil Stracchino
  1 sibling, 2 replies; 13+ messages in thread
From: Matthew Dharm @ 2002-09-04 23:10 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: greg, linux-kernel, linux-scsi, linux-usb-devel

[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]

Nope, not confused.

I'm trying to find out why Windows doesn't choke on the strange
READ_CAPACITY value.  My guess is that there is code somewhere to
universally fixup READ_CAPACITY, and I'd like to know what the magic
formula is.

The MODE_SENSE bit is fine by me.  But it's a SCSI change, so I'm not the
person to ask.  The fix to sddr09.c for that seems reasonable, but you put
it all together and I haven't had time to split it up.  Of course, I fully
expect the changes to MODE_SENSE in the SCSI layer to break other USB
devices, but there is only one way to find out....

Matt

On Thu, Sep 05, 2002 at 12:56:00AM +0200, Andries.Brouwer@cwi.nl wrote:
> >> Matt, is it ok with you for me to add this patch to the tree?
> 
> > I'd like to hold off a few more days while I try to find out what the
> > 'secret sauce' that the other OSes use for a device like this.
> 
> Hmm. You do not confuse two situations, do you?
> In the past few days I made two devices work.
> 
> One was a Feiya 5-in-1 CF / SM / SD card reader
> (Vendor Id: 090c, Product Id: 1132, Revision 1.00).
> It returned a capacity that is one too large, and becomes
> very unhappy if one tries to read a sector past the end.
> So, a flag was needed to tell that the result of READ CAPACITY
> needs fixing.
> 
> The other was a Travelmate CF / SM / SD card reader
> (Vendor Id: 3538, Product Id: 0001, Revision 2.05).
> It became unhappy when MODE_SENSE asked for too much data.
> A patch on sd.c solved this.
> 
> Andries

-- 
Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net 
Maintainer, Linux USB Mass Storage Driver

It's not that hard.  No matter what the problem is, tell the customer 
to reinstall Windows.
					-- Nurse
User Friendly, 3/22/1998

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 23:10 ` Matthew Dharm
@ 2002-09-04 23:46   ` Andries Brouwer
  2002-09-04 23:57     ` Matthew Dharm
  2002-09-05  1:11   ` Phil Stracchino
  1 sibling, 1 reply; 13+ messages in thread
From: Andries Brouwer @ 2002-09-04 23:46 UTC (permalink / raw)
  To: Andries.Brouwer, greg, linux-kernel, linux-scsi, linux-usb-devel

On Wed, Sep 04, 2002 at 04:10:42PM -0700, Matthew Dharm wrote:

> I'm trying to find out why Windows doesn't choke on the strange
> READ_CAPACITY value.

That is an easy one.
It belongs to the recent partitioning discussion on l-k.

Windows knows the type of partition table, so reads the
partition table and the boot sector and the FAT and is happy.

Linux tries various things, depending on how you compiled your kernel,
and among other things also needs to examine the last sector.
So, only Linux will do bad things in case the capacity is off by one,
and only when your config includes partitioning types that use this
last sector.


Andries


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 23:46   ` Andries Brouwer
@ 2002-09-04 23:57     ` Matthew Dharm
  0 siblings, 0 replies; 13+ messages in thread
From: Matthew Dharm @ 2002-09-04 23:57 UTC (permalink / raw)
  To: Andries Brouwer
  Cc: Andries.Brouwer, greg, linux-kernel, linux-scsi, linux-usb-devel

[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]

Well, that's the best answer I've gotten so far.

I guess the patch can go in.

Matt

On Thu, Sep 05, 2002 at 01:46:53AM +0200, Andries Brouwer wrote:
> On Wed, Sep 04, 2002 at 04:10:42PM -0700, Matthew Dharm wrote:
> 
> > I'm trying to find out why Windows doesn't choke on the strange
> > READ_CAPACITY value.
> 
> That is an easy one.
> It belongs to the recent partitioning discussion on l-k.
> 
> Windows knows the type of partition table, so reads the
> partition table and the boot sector and the FAT and is happy.
> 
> Linux tries various things, depending on how you compiled your kernel,
> and among other things also needs to examine the last sector.
> So, only Linux will do bad things in case the capacity is off by one,
> and only when your config includes partitioning types that use this
> last sector.

-- 
Matthew Dharm                              Home: mdharm-usb@one-eyed-alien.net 
Maintainer, Linux USB Mass Storage Driver

I don't have a left mouse button.  I only have one mouse and it's on my right.
					-- Customer
User Friendly, 2/13/1999

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-08-31 23:29 Andries.Brouwer
  2002-09-04 21:44 ` [linux-usb-devel] " Greg KH
@ 2002-09-05  0:10 ` Greg KH
  1 sibling, 0 replies; 13+ messages in thread
From: Greg KH @ 2002-09-05  0:10 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: linux-kernel, linux-scsi, linux-usb-devel, mdharm-usb

On Sun, Sep 01, 2002 at 01:29:58AM +0200, Andries.Brouwer@cwi.nl wrote:
> 
> Without the patch the kernel crashes, or insmod usb-storage hangs.
> With the patch the CF part of the device works perfectly.

Applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-04 23:10 ` Matthew Dharm
  2002-09-04 23:46   ` Andries Brouwer
@ 2002-09-05  1:11   ` Phil Stracchino
  1 sibling, 0 replies; 13+ messages in thread
From: Phil Stracchino @ 2002-09-05  1:11 UTC (permalink / raw)
  To: Andries.Brouwer, greg, linux-kernel, linux-scsi, linux-usb-devel

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

On Wed, Sep 04, 2002 at 04:10:42PM -0700, Matthew Dharm wrote:
> The MODE_SENSE bit is fine by me.  But it's a SCSI change, so I'm not the
> person to ask.  The fix to sddr09.c for that seems reasonable, but you put
> it all together and I haven't had time to split it up.  Of course, I fully
> expect the changes to MODE_SENSE in the SCSI layer to break other USB
> devices, but there is only one way to find out....

Speaking of sddr09 devices (of which I possess one), what's the current
state of support for the sddr09?  Last I knew, at the time when I finally
got mine working, the sddr09 was only supported read-only, since there
were not-fully-understood issues that resulted in filesystem corruption 
if you tried to write to it.  Currently, the driver will still allow me
to mount it only as a read-only filesystem.  Can write support for the
sddr09 be expected any time soon?


-- 
  *********  Fight Back!  It may not be just YOUR life at risk.  *********
  phil stracchino   ::   alaric@babcom.com   ::   halmayne@sourceforge.net
    unix ronin     ::::   renaissance man   ::::   mystic zen biker geek
     2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)
       Linux Now! ...because friends don't let friends use Microsoft.

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
@ 2002-09-05  8:41 Andries.Brouwer
  2002-09-05 15:00 ` Phil Stracchino
  0 siblings, 1 reply; 13+ messages in thread
From: Andries.Brouwer @ 2002-09-05  8:41 UTC (permalink / raw)
  To: Andries.Brouwer, alaric, greg, linux-kernel, linux-scsi,
	linux-usb-devel

> Speaking of sddr09 devices (of which I possess one), what's the current
> state of support for the sddr09?  Last I knew, at the time when I finally
> got mine working, the sddr09 was only supported read-only

For me it works read-write and out-of-the-box on a vanilla kernel.
(I added this stuff a few months ago. Found in 2.5 (which I use).
Am not quite sure about 2.4.)

Andries


[In case you try 2.5, a warning: later tens and early twenties
will eat filesystems if you have the wrong IDE hardware. But
2.5.32, 2.5.33 are fine here.]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-05  8:41 Andries.Brouwer
@ 2002-09-05 15:00 ` Phil Stracchino
  2002-09-06 14:09   ` Alan Stern
  0 siblings, 1 reply; 13+ messages in thread
From: Phil Stracchino @ 2002-09-05 15:00 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: greg, linux-kernel, linux-scsi, linux-usb-devel

On Thu, Sep 05, 2002 at 10:41:48AM +0200, Andries.Brouwer@cwi.nl wrote:
> > Speaking of sddr09 devices (of which I possess one), what's the current
> > state of support for the sddr09?  Last I knew, at the time when I finally
> > got mine working, the sddr09 was only supported read-only
> 
> For me it works read-write and out-of-the-box on a vanilla kernel.
> (I added this stuff a few months ago. Found in 2.5 (which I use).
> Am not quite sure about 2.4.)


Hmm.  So if I was to grab 2.5.${LATEST} and try porting the sddr09
driver back to 2.4.${CURRENT} ....

Thanks for the pointer.


-- 
  *********  Fight Back!  It may not be just YOUR life at risk.  *********
  phil stracchino   ::   alaric@babcom.com   ::   halmayne@sourceforge.net
    unix ronin     ::::   renaissance man   ::::   mystic zen biker geek
     2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)
       Linux Now! ...because friends don't let friends use Microsoft.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-05 15:00 ` Phil Stracchino
@ 2002-09-06 14:09   ` Alan Stern
  2002-09-07 20:41     ` Phil Stracchino
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Stern @ 2002-09-06 14:09 UTC (permalink / raw)
  To: Phil Stracchino; +Cc: linux-kernel, linux-usb-devel, usb-storage

On Thu, 5 Sep 2002, Phil Stracchino wrote:

> On Thu, Sep 05, 2002 at 10:41:48AM +0200, Andries.Brouwer@cwi.nl wrote:
> > > Speaking of sddr09 devices (of which I possess one), what's the current
> > > state of support for the sddr09?  Last I knew, at the time when I finally
> > > got mine working, the sddr09 was only supported read-only
> >
> > For me it works read-write and out-of-the-box on a vanilla kernel.
> > (I added this stuff a few months ago. Found in 2.5 (which I use).
> > Am not quite sure about 2.4.)
>
>
> Hmm.  So if I was to grab 2.5.${LATEST} and try porting the sddr09
> driver back to 2.4.${CURRENT} ....
>
> Thanks for the pointer.

You might like to use the patch below, which I prepared a few weeks ago.
It is a backport for the (more-or-less) current 2.5.x usb-storage module
that should work under 2.4.x.  My copy of the 2.5 source is not exactly
synched with ${LATEST}, so you may have to massage the patch a little bit
to make it apply properly.  (Also, you have to apply the patch from within
the linux/drivers/usb directory rather than at the top level; sorry about
that.)

Alan Stern


diff -u storage-2.5/Makefile storage/Makefile
--- storage-2.5/Makefile	Fri Sep  6 09:38:52 2002
+++ storage/Makefile	Fri Sep  6 09:52:03 2002
@@ -5,8 +5,11 @@
 # Rewritten to use lists instead of if-statements.
 #

+O_TARGET	:= storage.o
 EXTRA_CFLAGS	:= -I../../scsi/

+list-multi	:= usb-storage.o
+
 obj-$(CONFIG_USB_STORAGE)	+= usb-storage.o

 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG)	+= debug.o
@@ -20,6 +23,9 @@
 usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT)	+= jumpshot.o raw_bulk.o

 usb-storage-objs :=	scsiglue.o protocol.o transport.o usb.o \
-			initializers.o $(usb-storage-obj-y)
+			initializers.o $(sort $(usb-storage-obj-y))

 include $(TOPDIR)/Rules.make
+
+usb-storage.o: $(usb-storage-objs)
+	$(LD) -r -o $@ $(usb-storage-objs)
diff -u storage-2.5/debug.c storage/debug.c
--- storage-2.5/debug.c	Fri Sep  6 09:38:52 2002
+++ storage/debug.c	Fri Sep  6 09:53:08 2002
@@ -189,7 +189,7 @@
 	US_DEBUGP("Buffer has %d scatterlists.\n", cmd->use_sg );
 	for ( i=0; i<cmd->use_sg; i++ )
 	{
-		char *adr = page_address(sg[i].page) + sg[i].offset;
+		char *adr = sg_address(sg[i]);

 		US_DEBUGP("Length of scatterlist %d is %d.\n",i,sg[i].length);
 		US_DEBUGP("%02x %02x %02x %02x %02x %02x %02x %02x\n"
diff -u storage-2.5/debug.h storage/debug.h
--- storage-2.5/debug.h	Fri Sep  6 09:38:52 2002
+++ storage/debug.h	Fri Sep  6 09:53:08 2002
@@ -48,7 +48,7 @@
 #include <linux/kernel.h>
 #include <linux/blk.h>
 #include <linux/cdrom.h>
-#include "scsi.h"
+#include "usb.h"

 #define USB_STORAGE "usb-storage: "

diff -u storage-2.5/freecom.c storage/freecom.c
--- storage-2.5/freecom.c	Fri Sep  6 09:38:52 2002
+++ storage/freecom.c	Fri Sep  6 09:53:08 2002
@@ -144,11 +144,11 @@
 			if (transfer_amount - total_transferred >=
 					sg[i].length) {
 				result = usb_stor_transfer_partial(us,
-						page_address(sg[i].page) + sg[i].offset, sg[i].length);
+						sg_address(sg[i]), sg[i].length);
 				total_transferred += sg[i].length;
 			} else {
 				result = usb_stor_transfer_partial(us,
-						page_address(sg[i].page) + sg[i].offset,
+						sg_address(sg[i]),
 						transfer_amount - total_transferred);
 				total_transferred += transfer_amount - total_transferred;
 			}
diff -u storage-2.5/isd200.c storage/isd200.c
--- storage-2.5/isd200.c	Fri Sep  6 09:38:52 2002
+++ storage/isd200.c	Fri Sep  6 09:53:08 2002
@@ -49,7 +49,7 @@
 #include "scsiglue.h"
 #include "isd200.h"

-#include <linux/jiffies.h>
+#include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/hdreg.h>
@@ -501,13 +501,13 @@
                             sg[i].length) {
                                 result = isd200_transfer_partial(us,
                                                                  srb->sc_data_direction,
-                                                                 page_address(sg[i].page) + sg[i].offset,
+                                                                 sg_address(sg[i]),
                                                                  sg[i].length);
                                 total_transferred += sg[i].length;
                         } else
                                 result = isd200_transfer_partial(us,
                                                                  srb->sc_data_direction,
-                                                                 page_address(sg[i].page) + sg[i].offset,
+                                                                 sg_address(sg[i]),
                                                                  transfer_amount - total_transferred);

                         /* if we get an error, end the loop here */
@@ -1271,7 +1271,7 @@
 				/* ATA Command Identify successful */
 				int i;
 				__u16 *src, *dest;
-				ata_fix_driveid(&info->drive);
+				ide_fix_driveid(&info->drive);

 				US_DEBUGP("   Identify Data Structure:\n");
 				US_DEBUGP("      config = 0x%x\n", info->drive.config);
@@ -1409,10 +1409,10 @@
 				/* transfer the lesser of the next buffer or the
 				 * remaining data */
 				if (len - total >= sg[i].length) {
-					memcpy(page_address(sg[i].page) + sg[i].offset, src + total, sg[i].length);
+					memcpy(sg_address(sg[i]), src + total, sg[i].length);
 					total += sg[i].length;
 				} else {
-					memcpy(page_address(sg[i].page) + sg[i].offset, src + total, len - total);
+					memcpy(sg_address(sg[i]), src + total, len - total);
 					total = len;
 				}
 			}
diff -u storage-2.5/protocol.c storage/protocol.c
--- storage-2.5/protocol.c	Fri Sep  6 09:38:52 2002
+++ storage/protocol.c	Fri Sep  6 09:54:21 2002
@@ -65,7 +65,7 @@
 		struct scatterlist *sg;

 		sg = (struct scatterlist *) srb->request_buffer;
-		return (void *) page_address(sg[0].page) + sg[0].offset;
+		return (void *) sg_address(sg[0]);
 	} else
 		return (void *) srb->request_buffer;
 }
diff -u storage-2.5/raw_bulk.c storage/raw_bulk.c
--- storage-2.5/raw_bulk.c	Fri Sep  6 09:38:52 2002
+++ storage/raw_bulk.c	Fri Sep  6 09:53:08 2002
@@ -191,7 +191,7 @@
 			unsigned char *buf;
 			unsigned int length;

-			buf = page_address(sg[i].page) + sg[i].offset;
+			buf = sg_address(sg[i]);
 			length = len-transferred;
 			if (length > sg[i].length)
 				length = sg[i].length;
@@ -261,7 +261,7 @@
 		unsigned char *ptr;
 		unsigned int length, room;

-		ptr = page_address(sg[i].page) + sg[i].offset + *offset;
+		ptr = sg_address(sg[i]) + *offset;

 		room = sg[i].length - *offset;
 		length = len - transferred;
@@ -310,7 +310,7 @@
 		unsigned char *ptr;
 		unsigned int length, room;

-		ptr = page_address(sg[i].page) + sg[i].offset + *offset;
+		ptr = sg_address(sg[i]) + *offset;

 		room = sg[i].length - *offset;
 		length = buflen - transferred;
diff -u storage-2.5/scsiglue.c storage/scsiglue.c
--- storage-2.5/scsiglue.c	Fri Sep  6 09:38:52 2002
+++ storage/scsiglue.c	Fri Sep  6 09:53:08 2002
@@ -117,7 +117,6 @@
 	 * notification that it has exited.
 	 */
 	US_DEBUGP("-- sending exit command to thread\n");
-	BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE);
 	us->srb = NULL;
 	up(&(us->sema));
 	wait_for_completion(&(us->notify));
@@ -147,7 +146,6 @@
 	srb->host_scribble = (unsigned char *)us;

 	/* enqueue the command */
-	BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE || us->srb != NULL);
 	srb->scsi_done = done;
 	us->srb = srb;

@@ -188,7 +186,6 @@
 	int result;

 	US_DEBUGP("device_reset() called\n" );
-	BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE);

 	/* set the state and release the lock */
 	atomic_set(&us->sm_state, US_STATE_RESETTING);
@@ -562,8 +559,8 @@

 	  /* copy one byte */
 	  {
-		char *src = page_address(sg[sb].page) + sg[sb].offset + si;
-		char *dst = page_address(sg[db].page) + sg[db].offset + di;
+		char *src = sg_address(sg[sb]) + si;
+		char *dst = sg_address(sg[db]) + di;

 		 *dst = *src;
 	  }
@@ -604,7 +601,7 @@
 	      break;
 	    }

-	  *(char*)(page_address(sg[db].page) + sg[db].offset) = 0;
+	  *(char*)(sg_address(sg[db])) = 0;

 	  /* get next destination */
 	  if ( sg[db].length-1 == di )
@@ -755,8 +752,8 @@

 	  /* copy one byte */
 	  {
-		char *src = page_address(sg[sb].page) + sg[sb].offset + si;
-		char *dst = page_address(sg[db].page) + sg[db].offset + di;
+		char *src = sg_address(sg[sb]) + si;
+		char *dst = sg_address(sg[db]) + di;

 		 *dst = *src;
 	  }
@@ -797,7 +794,7 @@
 	    }

 	 {
-		 char *dst = page_address(sg[db].page) + sg[db].offset + di;
+		 char *dst = sg_address(sg[db]) + di;

 		 *dst = tempBuffer[element-USB_STOR_SCSI_SENSE_HDRSZ];
 	 }
@@ -851,17 +848,14 @@
 		  if ( element < USB_STOR_SCSI_SENSE_HDRSZ )
 		    {
 		      /* fill in the pointers for both header types */
-		      the6->array[element] = page_address(sg[i].page) +
-			      			sg[i].offset + j;
-		      the10->array[element] = page_address(sg[i].page) +
-						sg[i].offset + j;
+		      the6->array[element] = sg_address(sg[i]) + j;
+		      the10->array[element] = sg_address(sg[i]) + j;

 		    }
 		  else if ( element < USB_STOR_SCSI_SENSE_10_HDRSZ )
 		    {
 		      /* only the longer headers still cares now */
-		      the10->array[element] = page_address(sg[i].page) +
-						sg[i].offset + j;
+		      the10->array[element] = sg_address(sg[i]) + j;

 		    }
 		  /* increase element counter */
diff -u storage-2.5/sddr09.c storage/sddr09.c
--- storage-2.5/sddr09.c	Fri Sep  6 09:38:52 2002
+++ storage/sddr09.c	Fri Sep  6 09:53:08 2002
@@ -1091,25 +1091,23 @@
 		return 0;

 	for (i=0; i<alloc_blocks; i++) {
-		if (i<alloc_blocks-1) {
-			char *vaddr = kmalloc(1 << 17, GFP_NOIO);
-			sg[i].page = virt_to_page(vaddr);
-			sg[i].offset = ((unsigned long)vaddr & ~PAGE_MASK);
-			sg[i].length = (1<<17);
-		} else {
-			char *vaddr = kmalloc(alloc_len, GFP_NOIO);
-			sg[i].page = virt_to_page(vaddr);
-			sg[i].offset = ((unsigned long)vaddr & ~PAGE_MASK);
-			sg[i].length = alloc_len;
-		}
-		alloc_len -= sg[i].length;
+		int alloc_req = (i < alloc_blocks-1 ? 1 << 17 : alloc_len);
+		char *vaddr = kmalloc(alloc_req, GFP_NOIO);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
+		sg[i].page = virt_to_page(vaddr);
+		sg[i].offset = ((unsigned long)vaddr & ~PAGE_MASK);
+#else
+		sg[i].address = vaddr;
+#endif
+		sg[i].length = alloc_req;
+		alloc_len -= alloc_req;
 	}

 	for (i=0; i<alloc_blocks; i++)
 		if (sg[i].page == NULL) {
 			for (i=0; i<alloc_blocks; i++)
 				if (sg[i].page != NULL)
-					kfree(page_address(sg[i].page) + sg[i].offset);
+					kfree(sg_address(sg[i]));
 			kfree(sg);
 			return 0;
 		}
@@ -1120,7 +1118,7 @@
 				     (unsigned char *)sg, alloc_blocks);
 	if (result != USB_STOR_TRANSPORT_GOOD) {
 		for (i=0; i<alloc_blocks; i++)
-			kfree(page_address(sg[i].page) + sg[i].offset);
+			kfree(sg_address(sg[i]));
 		kfree(sg);
 		return -1;
 	}
@@ -1136,7 +1134,7 @@
 		info->lba_to_pba = NULL;
 		info->pba_to_lba = NULL;
 		for (i=0; i<alloc_blocks; i++)
-			kfree(page_address(sg[i].page) + sg[i].offset);
+			kfree(sg_address(sg[i]));
 		kfree(sg);
 		return 0;
 	}
@@ -1144,7 +1142,7 @@
 	for (i = 0; i < numblocks; i++)
 		info->lba_to_pba[i] = info->pba_to_lba[i] = UNDEF;

-	ptr = page_address(sg[0].page)+sg[0].offset;
+	ptr = sg_address(sg[0]);

 	/*
 	 * Define lba-pba translation table
@@ -1153,8 +1151,7 @@
 	// scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11)

 	for (i=0; i<numblocks; i++) {
-		ptr = page_address(sg[i>>11].page) +
-			sg[i>>11].offset + ((i&0x7ff)<<6);
+		ptr = sg_address(sg[i>>11]) + ((i&0x7ff)<<6);

 		if (i == 0 || i == 1) {
 			info->pba_to_lba[i] = UNUSABLE;
@@ -1264,7 +1261,7 @@
 	US_DEBUGP("Found %d LBA's\n", lbact);

 	for (i=0; i<alloc_blocks; i++)
-		kfree(page_address(sg[i].page) + sg[i].offset);
+		kfree(sg_address(sg[i]));
 	kfree(sg);
 	return 0;
 }
diff -u storage-2.5/transport.c storage/transport.c
--- storage-2.5/transport.c	Fri Sep  6 09:39:38 2002
+++ storage/transport.c	Fri Sep  6 09:53:08 2002
@@ -348,7 +348,6 @@
 	 * violates this invariant is a bug.  In the hopes of removing
 	 * all the complex logic above, let's find them and eliminate them.
 	 */
-	BUG_ON(len != srb->request_bufflen);

 	return len;
 }
@@ -423,7 +422,7 @@

 	/* lock and submit the URB */
 	down(&(us->current_urb_sem));
-	status = usb_submit_urb(us->current_urb, GFP_NOIO);
+	status = usb_submit_urb(us->current_urb);
 	if (status) {
 		/* something went wrong */
 		up(&(us->current_urb_sem));
@@ -458,11 +457,11 @@
 	int status;

 	/* fill in the devrequest structure */
-	us->dr->bRequestType = requesttype;
-	us->dr->bRequest = request;
-	us->dr->wValue = cpu_to_le16(value);
-	us->dr->wIndex = cpu_to_le16(index);
-	us->dr->wLength = cpu_to_le16(size);
+	us->dr->requesttype = requesttype;
+	us->dr->request = request;
+	us->dr->value = cpu_to_le16(value);
+	us->dr->index = cpu_to_le16(index);
+	us->dr->length = cpu_to_le16(size);

 	/* fill and submit the URB */
 	FILL_CONTROL_URB(us->current_urb, us->pusb_dev, pipe,
@@ -632,11 +631,11 @@
 			if (transfer_amount - total_transferred >=
 					sg[i].length) {
 				result = usb_stor_transfer_partial(us,
-						page_address(sg[i].page) + sg[i].offset, sg[i].length);
+						sg_address(sg[i]), sg[i].length);
 				total_transferred += sg[i].length;
 			} else
 				result = usb_stor_transfer_partial(us,
-						page_address(sg[i].page) + sg[i].offset,
+						sg_address(sg[i]),
 						transfer_amount - total_transferred);

 			/* if we get an error, end the loop here */
@@ -848,14 +847,12 @@
  * This must be called with scsi_lock(us->srb->host) held */
 void usb_stor_abort_transport(struct us_data *us)
 {
-	int state = atomic_read(&us->sm_state);

 	US_DEBUGP("usb_stor_abort_transport called\n");

 	/* Normally the current state is RUNNING.  If the control thread
 	 * hasn't even started processing this command, the state will be
 	 * IDLE.  Anything else is a bug. */
-	BUG_ON((state != US_STATE_RUNNING && state != US_STATE_IDLE));

 	/* set state to abort and release the lock */
 	atomic_set(&us->sm_state, US_STATE_ABORTING);
@@ -879,6 +876,9 @@
 		US_DEBUGP("-- simulating missing IRQ\n");
 		usb_stor_CBI_irq(us->irq_urb);
 	}
+
+	/* Wait for the aborted command to finish */
+	wait_for_completion(&us->notify);

 	/* Reacquire the lock */
 	scsi_lock(us->srb->host);
diff -u storage-2.5/usb.c storage/usb.c
--- storage-2.5/usb.c	Fri Sep  6 09:38:52 2002
+++ storage/usb.c	Fri Sep  6 09:53:08 2002
@@ -283,13 +283,13 @@
 	if (us->srb->use_sg) {
 		sg = (struct scatterlist *)us->srb->request_buffer;
 		for (i=0; i<us->srb->use_sg; i++)
-			memset(page_address(sg[i].page) + sg[i].offset, 0, sg[i].length);
+			memset(sg_address(sg[i]), 0, sg[i].length);
 		for (i=0, transferred=0;
 				i<us->srb->use_sg && transferred < len;
 				i++) {
 			amt = sg[i].length > len-transferred ?
 					len-transferred : sg[i].length;
-			memcpy(page_address(sg[i].page) + sg[i].offset, data+transferred, amt);
+			memcpy(sg_address(sg[i]), data+transferred, amt);
 			transferred -= amt;
 		}
 	} else {
@@ -314,9 +314,8 @@
 	/* avoid getting signals */
 	spin_lock_irq(&current->sigmask_lock);
 	flush_signals(current);
-	current->flags |= PF_IOTHREAD;
 	sigfillset(&current->blocked);
-	recalc_sigpending();
+	recalc_sigpending(current);
 	spin_unlock_irq(&current->sigmask_lock);

 	/* set our name for identification purposes */
@@ -513,7 +512,7 @@
 	return 0;
 }

-/* Set up the URB, the usb_ctrlrequest, and the IRQ pipe and handler.
+/* Set up the URB, the devrequest, and the IRQ pipe and handler.
  * ss->dev_semaphore must already be locked.
  * Note that this function assumes that all the data in the us_data
  * strucuture is current.  This includes the ep_int field, which gives us
@@ -526,9 +525,9 @@
 	int maxp;
 	int result;

-	/* allocate the usb_ctrlrequest for control packets */
-	US_DEBUGP("Allocating usb_ctrlrequest\n");
-	ss->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
+	/* allocate the devrequest for control packets */
+	US_DEBUGP("Allocating devrequest\n");
+	ss->dr = kmalloc(sizeof(devrequest), GFP_NOIO);
 	if (!ss->dr) {
 		US_DEBUGP("allocation failed\n");
 		return 1;
@@ -536,7 +535,7 @@

 	/* allocate the URB we're going to use */
 	US_DEBUGP("Allocating URB\n");
-	ss->current_urb = usb_alloc_urb(0, GFP_KERNEL);
+	ss->current_urb = usb_alloc_urb(0);
 	if (!ss->current_urb) {
 		US_DEBUGP("allocation failed\n");
 		return 2;
@@ -550,7 +549,7 @@
 		down(&(ss->irq_urb_sem));

 		/* allocate the URB */
-		ss->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
+		ss->irq_urb = usb_alloc_urb(0);
 		if (!ss->irq_urb) {
 			up(&(ss->irq_urb_sem));
 			US_DEBUGP("couldn't allocate interrupt URB");
@@ -569,7 +568,7 @@
 			maxp, usb_stor_CBI_irq, ss, ss->ep_int->bInterval);

 		/* submit the URB for processing */
-		result = usb_submit_urb(ss->irq_urb, GFP_KERNEL);
+		result = usb_submit_urb(ss->irq_urb);
 		US_DEBUGP("usb_submit_urb() returns %d\n", result);
 		if (result) {
 			up(&(ss->irq_urb_sem));
@@ -584,7 +583,7 @@
 	return 0;	/* success */
 }

-/* Deallocate the URB, the usb_ctrlrequest, and the IRQ pipe.
+/* Deallocate the URB, the devrequest, and the IRQ pipe.
  * ss->dev_semaphore must already be locked.
  */
 static void usb_stor_deallocate_urbs(struct us_data *ss)
@@ -611,7 +610,7 @@
 		ss->current_urb = NULL;
 	}

-	/* free the usb_ctrlrequest buffer */
+	/* free the devrequest buffer */
 	if (ss->dr) {
 		kfree(ss->dr);
 		ss->dr = NULL;
@@ -619,7 +618,7 @@

 	/* mark the device as gone */
 	ss->flags &= ~ US_FL_DEV_ATTACHED;
-	usb_put_dev(ss->pusb_dev);
+	usb_dec_dev_use(ss->pusb_dev);
 	ss->pusb_dev = NULL;
 }

@@ -742,7 +741,7 @@
 	}

 	/* At this point, we've decided to try to use the device */
-	usb_get_dev(dev);
+	usb_inc_dev_use(dev);

 	/* clear the GUID and fetch the strings */
 	GUID_CLEAR(guid);
@@ -798,7 +797,7 @@
 			USB_ENDPOINT_NUMBER_MASK;
 		ss->ep_int = ep_int;

-		/* allocate the URB, the usb_ctrlrequest, and the IRQ URB */
+		/* allocate the URB, the devrequest, and the IRQ URB */
 		if (usb_stor_allocate_urbs(ss))
 			goto BadDevice;

@@ -816,7 +815,7 @@
 		if ((ss = (struct us_data *)kmalloc(sizeof(struct us_data),
 						    GFP_KERNEL)) == NULL) {
 			printk(KERN_WARNING USB_STORAGE "Out of memory\n");
-			usb_put_dev(dev);
+			usb_dec_dev_use(dev);
 			return NULL;
 		}
 		memset(ss, 0, sizeof(struct us_data));
@@ -1018,7 +1017,7 @@
 		}
 		US_DEBUGP("Protocol: %s\n", ss->protocol_name);

-		/* allocate the URB, the usb_ctrlrequest, and the IRQ URB */
+		/* allocate the URB, the devrequest, and the IRQ URB */
 		if (usb_stor_allocate_urbs(ss))
 			goto BadDevice;

@@ -1063,7 +1062,7 @@

 		/* now register	 - our detect function will be called */
 		ss->htmplt.module = THIS_MODULE;
-		result = scsi_register_host(&(ss->htmplt));
+		result = scsi_register_module(MODULE_SCSI_HA, &(ss->htmplt));
 		if (result) {
 			printk(KERN_WARNING USB_STORAGE
 				"Unable to register the scsi host\n");
@@ -1167,7 +1166,7 @@
 	 */
 	for (next = us_list; next; next = next->next) {
 		US_DEBUGP("-- calling scsi_unregister_host()\n");
-		scsi_unregister_host(&(next->htmplt));
+		scsi_unregister_module(MODULE_SCSI_HA, &(next->htmplt));
 	}

 	/* While there are still structures, free them.  Note that we are
diff -u storage-2.5/usb.h storage/usb.h
--- storage-2.5/usb.h	Fri Sep  6 09:38:52 2002
+++ storage/usb.h	Fri Sep  6 09:53:08 2002
@@ -179,7 +179,7 @@
 	/* control and bulk communications data */
 	struct semaphore	current_urb_sem; /* protect current_urb  */
 	struct urb		*current_urb;	 /* non-int USB requests */
-	struct usb_ctrlrequest	*dr;		 /* control requests	 */
+	devrequest		*dr;		 /* control requests	 */

 	/* the semaphore for sleeping the control thread */
 	struct semaphore	sema;		 /* to sleep thread on   */
@@ -208,12 +208,12 @@
 #define scsi_unlock(host)	spin_unlock_irq(host->host_lock)
 #define scsi_lock(host)		spin_lock_irq(host->host_lock)

-#define sg_address(psg)		(page_address((psg)->page) + (psg)->offset)
+#define sg_address(sg)		(page_address((sg).page) + (sg).offset)
 #else
 #define scsi_unlock(host)	spin_unlock_irq(&io_request_lock)
 #define scsi_lock(host)		spin_lock_irq(&io_request_lock)

-#define sg_address(psg)		((psg)->address)
+#define sg_address(sg)		((sg).address)
 #endif

 #endif



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [linux-usb-devel] Feiya 5-in-1 Card Reader
  2002-09-06 14:09   ` Alan Stern
@ 2002-09-07 20:41     ` Phil Stracchino
  0 siblings, 0 replies; 13+ messages in thread
From: Phil Stracchino @ 2002-09-07 20:41 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-kernel, linux-usb-devel, usb-storage

On Fri, Sep 06, 2002 at 10:09:51AM -0400, Alan Stern wrote:
> On Thu, 5 Sep 2002, Phil Stracchino wrote:
> > Hmm.  So if I was to grab 2.5.${LATEST} and try porting the sddr09
> > driver back to 2.4.${CURRENT} ....
> >
> > Thanks for the pointer.
> 
> You might like to use the patch below, which I prepared a few weeks ago.
> It is a backport for the (more-or-less) current 2.5.x usb-storage module
> that should work under 2.4.x.  My copy of the 2.5 source is not exactly
> synched with ${LATEST}, so you may have to massage the patch a little bit
> to make it apply properly.  (Also, you have to apply the patch from within
> the linux/drivers/usb directory rather than at the top level; sorry about
> that.)


Sir, you are a scholar and a gentleman.  Thank you.  :)


-- 
  *********  Fight Back!  It may not be just YOUR life at risk.  *********
  phil stracchino   ::   alaric@babcom.com   ::   halmayne@sourceforge.net
    unix ronin     ::::   renaissance man   ::::   mystic zen biker geek
     2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)
       Linux Now! ...because friends don't let friends use Microsoft.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-09-07 20:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-04 22:56 [linux-usb-devel] Feiya 5-in-1 Card Reader Andries.Brouwer
2002-09-04 23:09 ` Greg KH
2002-09-04 23:10 ` Matthew Dharm
2002-09-04 23:46   ` Andries Brouwer
2002-09-04 23:57     ` Matthew Dharm
2002-09-05  1:11   ` Phil Stracchino
  -- strict thread matches above, loose matches on Subject: below --
2002-09-05  8:41 Andries.Brouwer
2002-09-05 15:00 ` Phil Stracchino
2002-09-06 14:09   ` Alan Stern
2002-09-07 20:41     ` Phil Stracchino
2002-08-31 23:29 Andries.Brouwer
2002-09-04 21:44 ` [linux-usb-devel] " Greg KH
2002-09-04 22:04   ` Matthew Dharm
2002-09-05  0:10 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox