Re: Fwd: Composite USB devices

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.user
Message-ID <[email protected]>
On Sun, 30 Sep 2007, The Almighty Pegasus Epsilon wrote:

> sg1 is a character device, not a block device. sg1 is the HID device
> in the composite device, where I need the mass storage device, which
> is a block device.

Strictly speaking, "character" and "block" are properties of the 
driver, not of the device.  It's perfectly possible to have both a 
character driver and a block driver for the same device (although they 
better not both be loaded at the same time!).

Anyway, only SCSI devices get sg nodes; HID devices don't.  In thie
case sg0 refers to the mass-storage interface of the WD MyBook device,
not the HID interface.  (The HID interface corresponds to the
/class/input/input1 device, as you can see in the log.)  sg1 refers to
the other, working USB device.  But this isn't particularly helpful for
solving your main problem.

> On Sun, 30 Sep 2007, The Almighty Pegasus Epsilon wrote:
> 
> > On 9/30/07, Alan Stern <[email protected]> wrote:
> >> "more information"?!  You have provided hardly any, beyond the fact
> >> that it doesn't work!
> >
> > I'll have to disagree, I provided a rather verbose description of the
> > problem in plain english rather than technical babble, along with a
> > theory or two as to why it doesn't work, and how it might be fixed.

It's not worth arguing over.

> > input: Western Digital My Book as /class/input/input1
> > input: USB HID v1.11 Device [Western Digital My Book] on usb-0000:00:07.2-1
> > usbcore: registered new interface driver usbhid
> > drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver

That's the HID interface in the composite WD MyBook device.

> > Initializing USB Mass Storage driver...
> > scsi0 : SCSI emulation for USB Mass Storage devices
> > usb-storage: device found at 2
> > usb-storage: waiting for device to settle before scanning
> > scsi1 : SCSI emulation for USB Mass Storage devices
> > usbcore: registered new interface driver usb-storage
> > USB Mass Storage support registered.
> > usb-storage: device found at 3
> > usb-storage: waiting for device to settle before scanning
> > scsi 0:0:0:0: Enclosure         WD       My Book Device   104a PQ: 0 ANSI: 4
> > scsi 1:0:0:0: Direct-Access     WDC WD80 0BB-40BSA0       0000 PQ: 0 ANSI: 0

So both devices were registered with the SCSI core, as they would have 
to be in order for both sg0 and sg1 to appear.

> > usb-storage: device scan complete
> > usb-storage: device scan complete
> > sd 1:0:0:0: [sda] 156301488 512-byte hardware sectors (80026 MB)
> > scsi 0:0:0:0: Attached scsi generic sg0 type 13
> > sd 1:0:0:0: Attached scsi generic sg1 type 0
> > sd 1:0:0:0: [sda] Write Protect is off
> > sd 1:0:0:0: [sda] Mode Sense: 27 00 00 00
> > sd 1:0:0:0: [sda] Assuming drive cache: write through
> > sd 1:0:0:0: [sda] 156301488 512-byte hardware sectors (80026 MB)
> > sd 1:0:0:0: [sda] Write Protect is off
> > sd 1:0:0:0: [sda] Mode Sense: 27 00 00 00
> > sd 1:0:0:0: [sda] Assuming drive cache: write through
> > sda: unknown partition table
> > sd 1:0:0:0: [sda] Attached SCSI disk

But only the other device worked with the SCSI disk driver.  It's
undoubtedly because the other device (sg1) reports itself as type 0 =
disk drive and the WD device (sg0) reports itself as type 13 =
enclosure -- I don't know what that's supposed to mean.  Whatever it 
is, the SCSI disk driver doesn't accept it.

Now I don't know if this will work or if it's the right thing to do,
but you can try it.  Edit the kernel source file drivers/scsi/sd.c.  
Near the beginning is a line saying

MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);

You can add a line saying

MODULE_ALIAS_SCSI_DEVICE(TYPE_ENCLOSURE);

Also, at the start of the sd_probe() function is this line:

	if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC)

You should add into that an extra test:

	if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC
			&& sdp->type != TYPE_ENCLOSURE)

That will allow the SCSI disk driver to recognize the WD device.  
Whether it will end up working correctly is a different question...

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.