required header files not #included in cdev.h
required header files not #included in cdev.h
am 31.01.2007 09:28:29 von Daniel Rodrick
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/
Re: required header files not #included in cdev.h
am 31.01.2007 09:36:28 von rpjday
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
#include
#include
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/
Re: required header files not #included in cdev.h
am 31.01.2007 10:26:04 von Erik Mouw
--DSayHWYpDlRfCAAQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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?
>=20
> 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:
>=20
> #include
> #include
> #include
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/cd=
ev.h
commit 5ec68b2e310437e99c297ba04e1afc5297aa6de1
Author: Jan Engelhardt
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 incl=
udes
itself, or, in case a module includes other headers already, needs to p=
ut
last, which goes against a alphabetically-sorted include
list.
Signed-off-by: Jan Engelhardt
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
Erik
--=20
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
--DSayHWYpDlRfCAAQ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFwGCs/PlVHJtIto0RAkWgAJ4uFm9UcxPB3iK+GnBeyv3LBCYH1wCf cIzl
Xi5MKswMy4V4SDVrgBUKW1Y=
=dsnn
-----END PGP SIGNATURE-----
--DSayHWYpDlRfCAAQ--
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/