Distinguish between kernel and user space
Ira W. Snyder
iws at ovro.caltech.edu
Tue Aug 17 01:22:44 EST 2010
On Mon, Aug 16, 2010 at 05:52:41PM +0530, Ravi Gupta wrote:
> Hi,
>
> I have defined a header file for ioctls macros definitions. I am including
> it in both, my user space application as well as in my device driver. Now
> there are some macros that I want to be visible only in device drive and
> some only in user space application. Is there any set of macros defined in
> linux for such purpose? This is my present header file
>
> gpio_ioctl.h
>
> #ifndef _GPIO_IOCTL_H_
> #define _GPIO_IOCTL_H_
>
> /*
> * Ioctl definitions
> */
>
> /* Use 250 as type/magic number */
> #define GPIO_IOC_MAGIC 250
> #define GPIO_READ _IOW (GPIO_IOC_MAGIC, 0, int)
> #define GPIO_WRITE _IOW (GPIO_IOC_MAGIC, 1, int)
> #define GPIO_IOC_MAXNR 2
>
>
> #ifdef _DEVICE_DRIVE_ ---> these macros should not be visible in user space
> application
> #define ...
> ...
> ..
> #endif
>
> #ifdef _USER_SPACE_ ---> these macros should not be visible in device driver
> i.e kernel space
> #define ...
> ...
> ..
>
> #endif /*_GPIO_IOCTL_H_ */
>
#ifdef __KERNEL__
/* kernel only definitions here */
#else
/* userspace only definitions here */
#endif
See tons of headers in include/linux/ for examples.
Ira
More information about the Linuxppc-dev
mailing list