* 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; 8+ 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] 8+ 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; 8+ 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] 8+ 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 ` [linux-usb-devel] " Phil Stracchino
1 sibling, 2 replies; 8+ 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] 8+ messages in thread
* Re: 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 ` [linux-usb-devel] " Phil Stracchino
1 sibling, 1 reply; 8+ 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
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Feiya 5-in-1 Card Reader
2002-09-04 23:46 ` Andries Brouwer
@ 2002-09-04 23:57 ` Matthew Dharm
0 siblings, 0 replies; 8+ 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] 8+ 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; 8+ 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] 8+ messages in thread
* Re: Feiya 5-in-1 Card Reader
@ 2002-09-05 8:41 Andries.Brouwer
0 siblings, 0 replies; 8+ 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.]
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Feiya 5-in-1 Card Reader
@ 2002-08-31 23:29 Andries.Brouwer
0 siblings, 0 replies; 8+ messages in thread
From: Andries.Brouwer @ 2002-08-31 23:29 UTC (permalink / raw)
To: linux-kernel, linux-scsi, linux-usb-devel, mdharm-usb
I have a USB 5-in-1 Card Reader, that will read CF and SM and SD/MMC.
Under Linux it appears as three SCSI devices.
For today, the report is on the CF part.
The CF part works fine under ordinary usb-storage SCSI simulation,
with one small problem: 8 and 32 MB cards, that are detected as
having 15872 and 63488 sectors by other readers, are detected as
having 15873 and 63489 sectors by this Feiya reader
(0x090c / 0x1132).
In the good old days probably nobody would have noticed, but these
days the partition reading code also wants to read the last sector.
This results in the SCSI code taking the device off line:
[USB storage does a READ_10, which fails since the sector is past
the end of the disk. Then it tries a READ_6 and nothing ever happens,
probably because the device does not support READ_6. Then the
error handler does an abort which triggers some bugs in scsiglue.c
and transport.c, then the error handler does a device reset, then
a host reset, then a bus reset, and finally the device is taken offline.]
The patch below does not address any bugs in the SCSI error code
(a big improvement would be just to rip it all out - this error code
never achieves anything useful but has crashed many a machine)
and does not fix the USB code either.
It just adds a flag to the unusual_devices section mentioning that
this device (my revision is 1.00) has this bug.
Without the patch the kernel crashes, or insmod usb-storage hangs.
With the patch the CF part of the device works perfectly.
(Another change is to only print "Fixing INQUIRY data" when
really something is changed, not when the data was OK already.)
Andries
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
--- a/drivers/usb/storage/protocol.c Sun Jun 9 07:26:30 2002
+++ b/drivers/usb/storage/protocol.c Sun Sep 1 00:23:37 2002
@@ -54,10 +54,27 @@
* Helper routines
***********************************************************************/
-/* Fix-up the return data from an INQUIRY command to show
+static void *
+find_data_location(Scsi_Cmnd *srb) {
+ if (srb->use_sg) {
+ /*
+ * This piece of code only works if the first page is
+ * big enough to hold more than 3 bytes -- which is
+ * _very_ likely.
+ */
+ struct scatterlist *sg;
+
+ sg = (struct scatterlist *) srb->request_buffer;
+ return (void *) page_address(sg[0].page) + sg[0].offset;
+ } else
+ return (void *) srb->request_buffer;
+}
+
+/*
+ * Fix-up the return data from an INQUIRY command to show
* ANSI SCSI rev 2 so we don't confuse the SCSI layers above us
*/
-void fix_inquiry_data(Scsi_Cmnd *srb)
+static void fix_inquiry_data(Scsi_Cmnd *srb)
{
unsigned char *data_ptr;
@@ -65,24 +82,43 @@
if (srb->cmnd[0] != INQUIRY)
return;
- US_DEBUGP("Fixing INQUIRY data to show SCSI rev 2\n");
+ data_ptr = find_data_location(srb);
- /* find the location of the data */
- if (srb->use_sg) {
- /* this piece of code only works if the first page is big enough to
- * hold more than 3 bytes -- which is _very_ likely
- */
- struct scatterlist *sg;
+ if ((data_ptr[2] & 7) == 2)
+ return;
- sg = (struct scatterlist *) srb->request_buffer;
- data_ptr = (unsigned char *) page_address(sg[0].page) + sg[0].offset;
- } else
- data_ptr = (unsigned char *)srb->request_buffer;
+ US_DEBUGP("Fixing INQUIRY data to show SCSI rev 2 - was %d\n",
+ data_ptr[2] & 7);
/* Change the SCSI revision number */
data_ptr[2] = (data_ptr[2] & ~7) | 2;
}
+/*
+ * Fix-up the return data from a READ CAPACITY command. My Feiya reader
+ * returns a value that is 1 too large.
+ */
+static void fix_read_capacity(Scsi_Cmnd *srb)
+{
+ unsigned char *dp;
+ unsigned long capacity;
+
+ /* verify that it's a READ CAPACITY command */
+ if (srb->cmnd[0] != READ_CAPACITY)
+ return;
+
+ dp = find_data_location(srb);
+
+ capacity = (dp[0]<<24) + (dp[1]<<16) + (dp[2]<<8) + (dp[3]);
+ US_DEBUGP("US: Fixing capacity: from %ld to %ld\n",
+ capacity+1, capacity);
+ capacity--;
+ dp[0] = (capacity >> 24);
+ dp[1] = (capacity >> 16);
+ dp[2] = (capacity >> 8);
+ dp[3] = (capacity);
+}
+
/***********************************************************************
* Protocol routines
***********************************************************************/
@@ -346,8 +382,11 @@
if ((us->flags & US_FL_MODE_XLATE) && (old_cmnd == MODE_SENSE))
usb_stor_scsiSense10to6(srb);
- /* fix the INQUIRY data if necessary */
+ /* Fix the INQUIRY data if necessary */
fix_inquiry_data(srb);
+
+ /* Fix the READ CAPACITY result if necessary */
+ if (us->flags & US_FL_FIX_CAPACITY)
+ fix_read_capacity(srb);
}
}
-
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
--- a/drivers/usb/storage/unusual_devs.h Tue Aug 27 23:58:37 2002
+++ b/drivers/usb/storage/unusual_devs.h Sun Sep 1 00:30:30 2002
@@ -507,6 +507,13 @@
US_SC_8070, US_PR_CB, NULL,
US_FL_FIX_INQUIRY ),
+/* aeb */
+UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff,
+ "Feiya",
+ "5-in-1 Card Reader",
+ US_SC_SCSI, US_PR_BULK, NULL,
+ US_FL_FIX_CAPACITY ),
+
UNUSUAL_DEV( 0x097a, 0x0001, 0x0000, 0x0001,
"Minds@Work",
"Digital Wallet",
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h Tue Aug 27 23:58:37 2002
+++ b/drivers/usb/storage/usb.h Sun Sep 1 00:18:31 2002
@@ -102,6 +102,7 @@
#define US_FL_IGNORE_SER 0x00000010 /* Ignore the serial number given */
#define US_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */
#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs fixing */
+#define US_FL_FIX_CAPACITY 0x00000080 /* READ CAPACITY response too big */
#define US_FL_DEV_ATTACHED 0x00010000 /* is the device attached? */
#define US_FLIDX_IP_WANTED 17 /* 0x00020000 is an IRQ expected? */
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-09-05 8:41 UTC | newest]
Thread overview: 8+ 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 ` [linux-usb-devel] " Phil Stracchino
-- strict thread matches above, loose matches on Subject: below --
2002-09-05 8:41 Andries.Brouwer
2002-08-31 23:29 Andries.Brouwer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox