Hello,
        
        t am trying to create native driver for subj. I used dx200.c as my 
inspiration. Everything is working fine for me but !!!!!!


When i connect camera & power up driver is initialized thru  probe function 
and new device  major/minor  (180/96) is added to the system. So i decide 
make a simple test. I wrote simple userspace program which tries open new 
device ( i made node in /dev for it using mknod of course ).  In this code i 
only use fopen and fclose.

Fisrt time when i run user space program it looks ok. fopen succed file 
handle pointer is not NULL !! But function fclose which is called after fopen 
fails !!! and in syslog appears folowing message : Sep 16 12:46:24 ak47 
kernel: VFS: Close: file count is 0 . Next time when i try to execute same 
code it fails on fopen with SIGSEGV. What i am doing wrong ? Any suggestions ?

                                                                                       
 Thanx & Bye Sam 

static int canon_camera_open(struct inode *inode,struct file *file) {
  struct canon_camera_state *camera = NULL;
  int value;
  int subminor;
 
  MOD_INC_USE_COUNT;
 
  down( &state_table_mutex );
  subminor = MINOR(inode->i_rdev) - USB_CAMERA_MINOR_BASE;
 
  if ( subminor <0 || subminor > MAX_CAMERAS || 
!(camera=minor_data[subminor])) {
    up( &state_table_mutex );
    MOD_DEC_USE_COUNT;
    return -ENODEV;
  }
 
  down( &camera->sem );
  up( &state_table_mutex );
 
  if ( camera->buffer ) {
    MOD_DEC_USE_COUNT;
    value = -EBUSY;
    goto done;
  }
 
  if (!(camera->buffer = (char *)kmalloc (MAX_PACKET_SIZE,GFP_KERNEL))) {
    MOD_DEC_USE_COUNT;
    value = -ENOMEM;
    goto done;
  }
 
  dbg("open %d",subminor);
 
  file->private_data = camera;
 
  done:
  up( &camera->sem );
  return value;
}
 
My configuration:
Kernel 2.4.9 on RH7.1 Toshiba Statellite Pro 43000 series with 192MB Ram.

Syslog:
Sep 16 12:31:48 ak47 kernel: usb.c: registered new driver cpwsa20
Sep 16 12:31:48 ak47 kernel: cpwsa20.c: v0.0.1:USB Camera Driver for Canon 
Powershot A20
Sep 16 12:33:23 ak47 kernel: hub.c: USB new device connect on bus1/1, 
assigned device number 2
Sep 16 12:33:23 ak47 kernel: Manufacturer: Canon Inc.
Sep 16 12:33:23 ak47 kernel: Product: PowerShot A20
Sep 16 12:33:23 ak47 kernel: cpwsa20.c: Numconf=1, NumInterfaces=1
Sep 16 12:33:23 ak47 kernel: cpwsa20.c: Class=255, Subclass=255, Endpoints=3
Sep 16 12:33:23 ak47 kernel: cpwsa20.c: inEP=1, outEP=2, miscEP=3
Sep 16 12:33:23 ak47 kernel: cpwsa20.c: USB camera #0 coneceted, major/minor 
180/96
Sep 16 12:33:23 ak47 /sbin/hotplug: arguments (usb) env (PWD=/etc/hotplug 
HOSTNAME=ak47 DEVICE=/proc/bus/usb/001/002 ACTION=add DEBUG=kernel 
MACHTYPE=i386-redhat-linux-gnu OLDPWD=/ DEVFS=/proc/bus/usb TYPE=255/255/255 
SHLVL=1 SHELL=/bin/bash HOSTTYPE=i386 OSTYPE=linux-gnu HOME=/ TERM=dumb 
PATH=/bin:/sbin:/usr/sbin:/usr/bin PRODUCT=4a9/304e/1 _=/usr/bin/env)
Sep 16 12:33:23 ak47 /sbin/hotplug: invoke /etc/hotplug/usb.agent
Sep 16 12:33:23 ak47 /etc/hotplug/usb.agent: Modprobe and setup cpwsa20 for 
USB product 4a9/304e/1

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to