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

usb driver and probe function (is never called)



  I realize that this is not strictly debian-devel question but it is
related to both debian and development so while I don't expect big
discussion I would appreciate RT _specify_which_one_ FM.

  so far I have read the relevant parts of Linux device drivers, 2nd
edition (O'Reilly), the info about usb in linux/Documentation, parts of
some other linux kernel & setup books.

  I am trying to make the USB work on my debian unstable system, using
kernel 2.4.14 and it just doesn't work. the specific problem is that the
function 'probe' (specified when registering driver) is NEVER called and
therefore driver doesn't manage any usb devices. as far as I can tell
the system is set up correctly, see below for modules, kernel settings
etc.

  so far I have tried the sample usb driver from linux device driver,
2nd edition (o'reilly) and personal jukebox (www.pjbox.com) drivers,
both behave in exactly the same way - I get a message in syslog that the
driver was registered and that's it, the message from probe function is
never printed and the driver doesn't work (cat says No such device)

  the sample drivers are available from:

http://examples.oreilly.com/linuxdrive2/

  the pjb-100 drivers are available from various places (I have tried
few, official ones from compaq, various drivers included with personal
jukebox managers (they are all same or almost the same), none of them
work even though I have reports that the driver works with 2.4.14), this
is one of the places where the driver can be downloaded:

http://www.kolumbus.fi/toni.tammisalo/pjbsdk-3.1.3.tar.gz

-----------------------------------------------------
  cpqpjb (personal jukebox driver), system setup is below
-----------------------------------------------------

  I checked how the cpqpjb works, added some debug messages and here's
what I have found:

  the following structure is used to register the driver using
usb_register (&pjb_driver):

static struct usb_driver pjb_driver = {
        name:       "cpqpjb",
        probe:      pjb_probe,
        disconnect: pjb_disconnect,
};

  so I guess that the pjb_probe should be called by kernel but it's
never called, there is:

printk(KERN_INFO "pjb_probe: looking for devices\n");

  statement right in the beginning of the function but I never see it in
syslog (I see other messages from cpqpjb printed using the same
function & KERN_INFO).

  this is what happens when I try to open the /dev/cpqpjb for reading:

  pjb_open sets the static (on file level) variable static_pjb_state as
file->private_data.

  pjb_read gets the above mentioned file (I guess it's the same one,
otherwise it all wouldn't make any sense), casts file->private_data to
pjb (pjb = (struct pjb_state *) file->private_data;) and checks for
pjb->device, which is unfortunately 0, so -ENODEV is returned (and cat
/dev/cpqpjb prints out the No such device message)
[=static_pjb_state->device is 0]

  the static_pjb_state should have been set by pjb_probe, but pjb_probe
is never called!

  this is where I hit the wall, who is supposed to call pjb_probe (well,
kernel, but how exactly)? what are possible reasons it wasn't called?
any ideas? I checked the usb.c briefly and it looks like it should have
been called but it's not...

------------------------------------------------------------
  settings & messages
------------------------------------------------------------

  here are my kernel config settings related to usb:

jojda:/usr/src/linux# grep -i usb ./.config | grep -v '^#'
CONFIG_USB=m
CONFIG_USB_DEBUG=y
CONFIG_USB_DEVICEFS=y
CONFIG_USB_UHCI=m
CONFIG_USB_AUDIO=m
CONFIG_USB_ACM=m
CONFIG_USB_PRINTER=m
CONFIG_USB_HID=m
CONFIG_USB_HIDDEV=y
CONFIG_USB_DC2XX=m
CONFIG_USB_SCANNER=m
CONFIG_USB_SERIAL=m
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_VISOR=m

  these are my system settings:

debian unstable

jojda:~>uname -a
Linux jojda 2.4.14 #1 Fri Nov 23 16:28:37 PST 2001 i686 unknown

jojda:~>grep cpqpjb /etc/modules.conf
### update-modules: start processing /etc/modutils/erik.cpqpjb
alias char-major-10-176 cpqpjb
### update-modules: end processing /etc/modutils/erik.cpqpjb

jojda:~>ls -l /dev/cpqpjb 
crw-rw-rw-    1 root     root      10, 176 Dec 20 04:43 /dev/cpqpjb

jojda:/home/erik# lsmod | egrep '(usb)|(cpqpjb)'
cpqpjb                  2688   0 
usb-uhci               20932   0  (unused)
usbcore                50848   1  [cpqpjb usb-uhci]

jojda:/home/erik# lspci|grep -i usb
00:07.2 USB Controller: VIA Technologies, Inc. UHCI USB (rev 16)
00:07.3 USB Controller: VIA Technologies, Inc. UHCI USB (rev 16)

jojda:~>mount | grep usb
usb on /proc/bus/usb type usbdevfs (rw,noexec,nosuid,nodev)

  running cat /dev/cpqpjb and watching the syslog (I enabled PJB_DEBUG
in currently used driver, which is btw the one from Toni Tammisalo's
page, see the link above):

jojda:/home/erik# date;cat /dev/cpqpjb 
Sat Dec 22 01:41:52 PST 2001
cat: /dev/cpqpjb: No such device

  there are following lines in /var/log/syslog (same time):

Dec 22 01:41:52 localhost kernel: pjb.open
Dec 22 01:41:52 localhost kernel: pjb.close

  as far as I can see the crucial part is that I never get the pjb_probe
message when I insert cpqpjb module:

jojda:/home/erik/skusobna/pjb/pjbsdk-3.1.3/usbdrv# date;insmod
./cpqpjb.o
Sat Dec 22 01:44:41 PST 2001
Warning: loading ./cpqpjb.o will taint the kernel: no license

  and the syslog messages:

Dec 22 01:44:41 localhost kernel: Initializing PJB driver
Dec 22 01:44:41 localhost kernel: usb.c: registered new driver cpqpjb

  per docs there should have been another message or two, first one of
them from pjb_probe.

  when I unplug usb cable the syslog says:

Dec 22 01:46:26 localhost kernel: hub.c: port 1 connection change
Dec 22 01:46:26 localhost kernel: hub.c: port 1, portstatus 301, change
1, 1.5 Mb/s
Dec 22 01:46:27 localhost kernel: hub.c: port 1, portstatus 300, change
0, 1.5 Mb/s

  when I plug it back in:

Dec 22 01:46:55 localhost kernel: hub.c: port 1 connection change
Dec 22 01:46:55 localhost kernel: hub.c: port 1, portstatus 301, change
1, 1.5 Mb/s
Dec 22 01:46:55 localhost kernel: hub.c: port 1, portstatus 300, change
0, 1.5 Mb/s

  when I plug in/out another device (logitech optical wireless mouse) I
get the same messages (it just says port 1 or port 2 depending on which
port I use), I don't have drivers for mouse though.

  this is what /proc thinks I have:

---------------------------------------------------------
jojda:/home/erik# ls -lR /proc/bus/usb/
/proc/bus/usb/:
total 0
dr-xr-xr-x    1 root     root            0 Dec 21 16:43 001
dr-xr-xr-x    1 root     root            0 Dec 21 16:43 002
-r--r--r--    1 root     root            0 Dec 21 16:43 devices
-r--r--r--    1 root     root            0 Dec 21 16:43 drivers

/proc/bus/usb/001:
total 1
-rw-r--r--    1 root     root           18 Dec 22 01:48 001

/proc/bus/usb/002:
total 1
-rw-r--r--    1 root     root           18 Dec 22 01:48 001

---------------------------------------------------------
jojda:/home/erik# cat /proc/bus/usb/devices 
T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Product=USB UHCI Root Hub
S:  SerialNumber=c800
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms
T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Product=USB UHCI Root Hub
S:  SerialNumber=c400
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms

---------------------------------------------------------
jojda:/home/erik# cat /proc/bus/usb/drivers 
         usbdevfs
         hub
         cpqpjb

---------------------------------------------------------
  lsusb (usbview show the same info) output:

Bus 002 Device 001: ID 0000:0000 Virtual Hub
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0000 Virtual
  idProduct          0x0000 Hub
  bcdDevice            0.00
  iManufacturer           0 
  iProduct                2 USB UHCI Root Hub
  iSerial                 1 c800
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x40
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               none
        wMaxPacketSize          8
        bInterval             255
  Language IDs: (length=4)
     0000 (null)((null))

Bus 001 Device 001: ID 0000:0000 Virtual Hub
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0000 Virtual
  idProduct          0x0000 Hub
  bcdDevice            0.00
  iManufacturer           0 
  iProduct                2 USB UHCI Root Hub
  iSerial                 1 c400
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x40
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               none
        wMaxPacketSize          8
        bInterval             255
  Language IDs: (length=4)
     0000 (null)((null))

  any ideas? TIA

        erik



Reply to: