Re: required header files not #included in cdev.h

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

 



On Wed, 31 Jan 2007, Daniel Rodrick wrote:

> Hi,
>
> This referes to the file include/linux/cdev.h whose contents are listed below:
>
> #ifndef _LINUX_CDEV_H
> #define _LINUX_CDEV_H
> #ifdef __KERNEL__
>
> struct cdev {
>        struct kobject kobj;
>        struct module *owner;
>        const struct file_operations *ops;
>        struct list_head list;
>        dev_t dev;
>        unsigned int count;
> };
>
> void cdev_init(struct cdev *, const struct file_operations *);
>
> struct cdev *cdev_alloc(void);
>
> void cdev_put(struct cdev *p);
>
> int cdev_add(struct cdev *, dev_t, unsigned);
>
> void cdev_del(struct cdev *);
>
> void cd_forget(struct inode *);
>
> #endif
> #endif
>
> It is a little strange to me that it uses certain kernel structure
> types like kobject, module, list_head etc without #including
> appropriate headers. The result is that when I try to use struct cdev
> in my module by simply #including cdev.h, it flags an error. As a
> result I need to manually figure out which all headers do I need to
> (additionally) #include and in what order.
>
> Is this OK?

typically, this is not OK, but you must be looking at an old version
of cdev.h.  the latest "git pull" version does, in fact, include the
appropriate header files:

#include <linux/kobject.h>
#include <linux/kdev_t.h>
#include <linux/list.h>

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://www.fsdev.dreamhosters.com/wiki/index.php?title=Main_Page
========================================================================

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux