linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Distinguish between kernel and user space
@ 2010-08-16 12:22 Ravi Gupta
  2010-08-16 15:22 ` Ira W. Snyder
  0 siblings, 1 reply; 2+ messages in thread
From: Ravi Gupta @ 2010-08-16 12:22 UTC (permalink / raw)
  To: linuxppc-dev, linuxppc-dev, Ira W. Snyder, MJ embd,
	Anton Vorontsov

[-- Attachment #1: Type: text/plain, Size: 942 bytes --]

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_ */

Thanks in advance
Ravi Gupta

[-- Attachment #2: Type: text/html, Size: 1073 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Distinguish between kernel and user space
  2010-08-16 12:22 Distinguish between kernel and user space Ravi Gupta
@ 2010-08-16 15:22 ` Ira W. Snyder
  0 siblings, 0 replies; 2+ messages in thread
From: Ira W. Snyder @ 2010-08-16 15:22 UTC (permalink / raw)
  To: Ravi Gupta; +Cc: linuxppc-dev, MJ embd, linuxppc-dev

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-16 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 12:22 Distinguish between kernel and user space Ravi Gupta
2010-08-16 15:22 ` Ira W. Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).