Commit c4881928 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Dmitry Torokhov

Input: complete gameport sysfs integration, ports are now

       devices in driver model. Implemented similarly to serio.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent bee3129f
This diff is collapsed.
......@@ -17,10 +17,8 @@ struct gameport {
void *private; /* Private pointer for joystick drivers */
void *port_data; /* Private pointer for gameport drivers */
char *name;
char name_buf[32];
char *phys;
char phys_buf[32];
char name[32];
char phys[32];
int io;
int speed;
......@@ -33,14 +31,17 @@ struct gameport {
int (*open)(struct gameport *, int);
void (*close)(struct gameport *);
struct gameport *parent, *child;
struct gameport_driver *drv;
struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */
struct device dev;
unsigned int registered; /* port has been fully registered with driver core */
struct list_head node;
/* temporary, till sysfs transition is complete */
int dyn_alloc;
};
#define to_gameport_port(d) container_of(d, struct gameport, dev)
struct gameport_driver {
......@@ -48,10 +49,12 @@ struct gameport_driver {
char *description;
int (*connect)(struct gameport *, struct gameport_driver *drv);
int (*reconnect)(struct gameport *);
void (*disconnect)(struct gameport *);
struct device_driver driver;
struct list_head node;
unsigned int ignore;
};
#define to_gameport_driver(d) container_of(d, struct gameport_driver, driver)
......@@ -59,13 +62,18 @@ int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mo
void gameport_close(struct gameport *gameport);
void gameport_rescan(struct gameport *gameport);
void __gameport_register_port(struct gameport *gameport, struct module *owner);
static inline void gameport_register_port(struct gameport *gameport)
{
__gameport_register_port(gameport, THIS_MODULE);
}
void gameport_unregister_port(struct gameport *gameport);
static inline struct gameport *gameport_allocate_port(void)
{
struct gameport *gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL);
if (gameport)
gameport->dyn_alloc = 1;
return gameport;
}
......@@ -76,17 +84,31 @@ static inline void gameport_free_port(struct gameport *gameport)
static inline void gameport_set_name(struct gameport *gameport, const char *name)
{
gameport->name = gameport->name_buf;
strlcpy(gameport->name, name, sizeof(gameport->name_buf));
strlcpy(gameport->name, name, sizeof(gameport->name));
}
void gameport_set_phys(struct gameport *gameport, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
void gameport_register_port(struct gameport *gameport);
void gameport_unregister_port(struct gameport *gameport);
/*
* Use the following fucntions to pin gameport's driver in process context
*/
static inline int gameport_pin_driver(struct gameport *gameport)
{
return down_interruptible(&gameport->drv_sem);
}
static inline void gameport_unpin_driver(struct gameport *gameport)
{
up(&gameport->drv_sem);
}
void __gameport_register_driver(struct gameport_driver *drv, struct module *owner);
static inline void gameport_register_driver(struct gameport_driver *drv)
{
__gameport_register_driver(drv, THIS_MODULE);
}
void gameport_register_driver(struct gameport_driver *drv);
void gameport_unregister_driver(struct gameport_driver *drv);
#define GAMEPORT_MODE_DISABLED 0
......@@ -104,7 +126,7 @@ void gameport_unregister_driver(struct gameport_driver *drv);
#define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
#define GAMEPORT_ID_VENDOR_GUILLEMOT 0x000a
static __inline__ void gameport_trigger(struct gameport *gameport)
static inline void gameport_trigger(struct gameport *gameport)
{
if (gameport->trigger)
gameport->trigger(gameport);
......@@ -112,7 +134,7 @@ static __inline__ void gameport_trigger(struct gameport *gameport)
outb(0xff, gameport->io);
}
static __inline__ unsigned char gameport_read(struct gameport *gameport)
static inline unsigned char gameport_read(struct gameport *gameport)
{
if (gameport->read)
return gameport->read(gameport);
......@@ -120,7 +142,7 @@ static __inline__ unsigned char gameport_read(struct gameport *gameport)
return inb(gameport->io);
}
static __inline__ int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
static inline int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons)
{
if (gameport->cooked_read)
return gameport->cooked_read(gameport, axes, buttons);
......@@ -128,7 +150,7 @@ static __inline__ int gameport_cooked_read(struct gameport *gameport, int *axes,
return -1;
}
static __inline__ int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
static inline int gameport_calibrate(struct gameport *gameport, int *axes, int *max)
{
if (gameport->calibrate)
return gameport->calibrate(gameport, axes, max);
......@@ -136,7 +158,7 @@ static __inline__ int gameport_calibrate(struct gameport *gameport, int *axes, i
return -1;
}
static __inline__ int gameport_time(struct gameport *gameport, int time)
static inline int gameport_time(struct gameport *gameport, int time)
{
return (time * gameport->speed) / 1000;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment