V4l Api: video_register() fails. <-- Consider this please..

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



The following code fails when i try to register the v4l device and a 
'Segmentation fault' message occurs.  I tested my code using both linux 
2.4.19 and linux 2.4.20. The video_device structure seems to be filled 
properly, i don't know what is wrong...
Below the source code there's also the kernel message.

Essentially this is the code:

/* Main structure */
struct my_device {
        struct video_device v4l; 
        .....
        .....;
};

int  my_probe(..., ...)
{
	...
        camera = (struct my_device*) 
                         kmalloc(sizeof(struct my_device), GFP_KERNEL);

        strcpy(camera->v4l.name,  "My device");
        camera->v4l.type = MY_CAP_TYPE;
        camera->v4l.hardware = MY_VID_HARDWARE;
        camera->v4l.fops = &my_fops;  /* new interface */
        camera->v4l.priv = (void*)camera;
        camera->v4l.minor = -1; /* or whatever */

        printk(KERN_INFO "My device: Registering...");

        /* This function never returns...why?  */
        err = video_register_device(&camera->v4l, 
	                                                VFL_TYPE_GRABBER,
	                                                -1); /* or whatever */

        /* The code below is never reached */
        if  (err)  
                printk(KERN_ERR "Video register failed.");
        else
                printk(KERN_INFO "My device registered. ");
	...
}


*Kernel error message*

My device:  Registering...
Unable to handle kernel paging request at virtual address 00050338
 printing eip:
00050338
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<00050338>]    Not tainted
EFLAGS: 00010202
eax: 00050338   ebx: 00000001   ecx: d1aee1e0   edx: d1aee280
esi: 00000000   edi: c8e91c00   ebp: 00000004   esp: c46b1e40
ds: 0018   es: 0018   ss: 0018
Process insmod (pid: 1482, stackpage=c46b1000)
Stack: d1aedafb c8e91c00 d1aee08c c02fa889 00000246 00000049 c46b1e98 c8e91c00
       d2443c9d d2443e0c c46b1e98 d2443167 c8e91c00 00000000 ffffffff c0299e10
       c0299fd0 00000000 000001d2 d2443458 d2443ea0 d2443ebc c1321b60 c02081ae
Call Trace:    [<d1aedafb>] [<d1aee08c>] [<d2443c9d>] [<d2443e0c>] 
[<d2443167>]
  [<d2443458>] [<d2443ea0>] [<d2443ebc>] [<c02081ae>] [<d2443458>] 
[<c0207e88>]
  [<c0207e5c>] [<c020764e>] [<d2443ea0>] [<c0207615>] [<d2443350>] 
[<d2443ea0>]
  [<c011a785>] [<d2443d7c>] [<d2441060>] [<c010881b>]

Code:  Bad EIP value.





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux