Re: creating a character driver

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Tue Mar 07 2000 - 16:57:22 EST


On Tue, 7 Mar 2000, Nathan Feldman wrote:

> Hello,
>
> I decided to learn to write character drivers, and searching for an
> on-line document, I found the linux kernel hackers' guide. However I
> want other documents to help me, so please send names or links.
>
> By the way, I have a problem with the file_operations structure. The
> compiler gets the error:
>
> variable `th_fops' has initializer but incomplete type
>
> the structure was declared this way:
>
> static struct file_operations th_fops = {
> NULL, /*lseek*/
> NULL, /*read*/
> th_write,
> NULL, /*readdir*/
> NULL, /*select*/
> NULL, /*ioctl*/
> NULL, /*mmap*/
> NULL, /*open*/
> NULL /*release*/
> };
>
> I included <linux/fs.h> wich I supose is the file where
> file_operations is declared. Thanks in advance for any help.
>

"struct file_operations" is larger than you show. Therefore, when
you initialize it, you either fill in all the blanks with NULLs or
you leave a trailing comma like.....

   NULL, }; /*release*/
       ^_______ Right here.

Trailing commas are allowed, but not good coding style. I suggest you
fill in all the blanks. There was a recent change in the kernel (six
months ago), that changed the size of this structure. The hack to
get around this, until the size stabilizes, is the trailing comma.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:23 EST