X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=include%2Flinux%2Fgameport.h;h=1bc08541c2b9cff63e3ae58267244321034edb5b;hb=f653398c86a1c104f0992bd788dd4bb065449be4;hp=b1272f822cfa15cd0b1acca21267c9a73174ee37;hpb=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2;p=safe%2Fjmp%2Flinux-2.6 diff --git a/include/linux/gameport.h b/include/linux/gameport.h index b1272f8..1bc0854 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h @@ -9,9 +9,13 @@ * the Free Software Foundation. */ +#ifdef __KERNEL__ #include +#include #include +#include #include +#include struct gameport { @@ -39,7 +43,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 */ @@ -59,13 +63,14 @@ struct gameport_driver { struct device_driver driver; - unsigned int ignore; + bool ignore; }; #define to_gameport_driver(d) container_of(d, struct gameport_driver, driver) int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode); void gameport_close(struct gameport *gameport); -void gameport_rescan(struct gameport *gameport); + +#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) void __gameport_register_port(struct gameport *gameport, struct module *owner); static inline void gameport_register_port(struct gameport *gameport) @@ -75,9 +80,32 @@ static inline void gameport_register_port(struct gameport *gameport) void gameport_unregister_port(struct gameport *gameport); +void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); + +#else + +static inline void gameport_register_port(struct gameport *gameport) +{ + return; +} + +static inline void gameport_unregister_port(struct gameport *gameport) +{ + return; +} + +static inline void gameport_set_phys(struct gameport *gameport, + const char *fmt, ...) +{ + return; +} + +#endif + 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; } @@ -92,11 +120,8 @@ static inline void gameport_set_name(struct gameport *gameport, const char *name strlcpy(gameport->name, name, sizeof(gameport->name)); } -void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); - /* - * 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) @@ -110,26 +135,29 @@ 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); -static inline void gameport_register_driver(struct gameport_driver *drv) +int __gameport_register_driver(struct gameport_driver *drv, + struct module *owner, const char *mod_name); +static inline int __must_check gameport_register_driver(struct gameport_driver *drv) { - __gameport_register_driver(drv, THIS_MODULE); + return __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME); } 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 @@ -145,6 +173,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) @@ -195,4 +225,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