* required header files not #included in cdev.h
@ 2007-01-31 8:28 Daniel Rodrick
2007-01-31 8:36 ` Robert P. J. Day
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Rodrick @ 2007-01-31 8:28 UTC (permalink / raw)
To: kernelnewbies, linux-newbie
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?
Dan
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: required header files not #included in cdev.h
2007-01-31 8:28 required header files not #included in cdev.h Daniel Rodrick
@ 2007-01-31 8:36 ` Robert P. J. Day
2007-01-31 9:26 ` Erik Mouw
0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2007-01-31 8:36 UTC (permalink / raw)
To: Daniel Rodrick; +Cc: kernelnewbies, linux-newbie
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: required header files not #included in cdev.h
2007-01-31 8:36 ` Robert P. J. Day
@ 2007-01-31 9:26 ` Erik Mouw
0 siblings, 0 replies; 3+ messages in thread
From: Erik Mouw @ 2007-01-31 9:26 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Daniel Rodrick, kernelnewbies, linux-newbie
[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]
On Wed, Jan 31, 2007 at 03:36:28AM -0500, Robert P. J. Day wrote:
> On Wed, 31 Jan 2007, Daniel Rodrick wrote:
> > 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>
I guess his "old version" is linux-2.6.19. The include files were fixed
during development from 2.6.19 to 2.6.20-rc1:
erik@arthur:~/git/linux-2.6 > git-log v2.6.19..v2.6.20-rc1 include/linux/cdev.h
commit 5ec68b2e310437e99c297ba04e1afc5297aa6de1
Author: Jan Engelhardt <jengelh@linux01.gwdg.de>
Date: Wed Dec 6 20:36:14 2006 -0800
[PATCH] pull in necessary header files for cdev.h
linux/cdev.h uses struct kobject and other structs and should therefore
include them. Currently, a module either needs to add the missing includes
itself, or, in case a module includes other headers already, needs to put
<linux/cdev.h> last, which goes against a alphabetically-sorted include
list.
Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Erik
--
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-01-31 9:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-31 8:28 required header files not #included in cdev.h Daniel Rodrick
2007-01-31 8:36 ` Robert P. J. Day
2007-01-31 9:26 ` Erik Mouw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox