X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Fgameport.h;h=afad95272841827445d8258043351ba0d23fcf4c;hb=refs%2Fheads%2Fvserver;hp=2401dea2b867c798808f0433f575db7e0888f9b6;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/include/linux/gameport.h b/include/linux/gameport.h index 2401dea2b..afad95272 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h @@ -9,8 +9,10 @@ * the Free Software Foundation. */ +#ifdef __KERNEL__ #include #include +#include #include #include @@ -40,7 +42,7 @@ struct gameport { struct gameport *parent, *child; struct gameport_driver *drv; - struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */ + struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */ struct device dev; unsigned int registered; /* port has been fully registered with driver core */ @@ -103,7 +105,7 @@ static inline void gameport_set_phys(struct gameport *gameport, static inline struct gameport *gameport_allocate_port(void) { - struct gameport *gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL); + struct gameport *gameport = kzalloc(sizeof(struct gameport), GFP_KERNEL); return gameport; } @@ -119,7 +121,7 @@ static inline void gameport_set_name(struct gameport *gameport, const char *name } /* - * Use the following fucntions to manipulate gameport's per-port + * Use the following functions to manipulate gameport's per-port * driver-specific data. */ static inline void *gameport_get_drvdata(struct gameport *gameport) @@ -133,16 +135,16 @@ static inline void gameport_set_drvdata(struct gameport *gameport, void *data) } /* - * Use the following fucntions to pin gameport's driver in process context + * Use the following functions to pin gameport's driver in process context */ static inline int gameport_pin_driver(struct gameport *gameport) { - return down_interruptible(&gameport->drv_sem); + return mutex_lock_interruptible(&gameport->drv_mutex); } static inline void gameport_unpin_driver(struct gameport *gameport) { - up(&gameport->drv_sem); + mutex_unlock(&gameport->drv_mutex); } void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); @@ -153,6 +155,8 @@ static inline void gameport_register_driver(struct gameport_driver *drv) void gameport_unregister_driver(struct gameport_driver *drv); +#endif /* __KERNEL__ */ + #define GAMEPORT_MODE_DISABLED 0 #define GAMEPORT_MODE_RAW 1 #define GAMEPORT_MODE_COOKED 2 @@ -168,6 +172,8 @@ void gameport_unregister_driver(struct gameport_driver *drv); #define GAMEPORT_ID_VENDOR_GRAVIS 0x0009 #define GAMEPORT_ID_VENDOR_GUILLEMOT 0x000a +#ifdef __KERNEL__ + static inline void gameport_trigger(struct gameport *gameport) { if (gameport->trigger) @@ -218,4 +224,5 @@ static inline void gameport_set_poll_interval(struct gameport *gameport, unsigne void gameport_start_polling(struct gameport *gameport); void gameport_stop_polling(struct gameport *gameport); +#endif /* __KERNEL__ */ #endif