2 * Copyright (C) 1999-2002 Vojtech Pavlik
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
12 #include <linux/types.h>
13 #include <linux/interrupt.h>
14 #include <linux/list.h>
15 #include <linux/spinlock.h>
16 #include <linux/mutex.h>
17 #include <linux/device.h>
18 #include <linux/mod_devicetable.h>
19 #include <uapi/linux/serio.h>
26 char firmware_id
[128];
30 struct serio_device_id id
;
32 spinlock_t lock
; /* protects critical sections from port's interrupt handler */
34 int (*write
)(struct serio
*, unsigned char);
35 int (*open
)(struct serio
*);
36 void (*close
)(struct serio
*);
37 int (*start
)(struct serio
*);
38 void (*stop
)(struct serio
*);
41 struct list_head child_node
; /* Entry in parent->children list */
42 struct list_head children
;
43 unsigned int depth
; /* level of nesting in serio hierarchy */
45 struct serio_driver
*drv
; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
46 struct mutex drv_mutex
; /* protects serio->drv so attributes can pin driver */
50 struct list_head node
;
52 #define to_serio_port(d) container_of(d, struct serio, dev)
55 const char *description
;
57 const struct serio_device_id
*id_table
;
60 void (*write_wakeup
)(struct serio
*);
61 irqreturn_t (*interrupt
)(struct serio
*, unsigned char, unsigned int);
62 int (*connect
)(struct serio
*, struct serio_driver
*drv
);
63 int (*reconnect
)(struct serio
*);
64 void (*disconnect
)(struct serio
*);
65 void (*cleanup
)(struct serio
*);
67 struct device_driver driver
;
69 #define to_serio_driver(d) container_of(d, struct serio_driver, driver)
71 int serio_open(struct serio
*serio
, struct serio_driver
*drv
);
72 void serio_close(struct serio
*serio
);
73 void serio_rescan(struct serio
*serio
);
74 void serio_reconnect(struct serio
*serio
);
75 irqreturn_t
serio_interrupt(struct serio
*serio
, unsigned char data
, unsigned int flags
);
77 void __serio_register_port(struct serio
*serio
, struct module
*owner
);
79 /* use a define to avoid include chaining to get THIS_MODULE */
80 #define serio_register_port(serio) \
81 __serio_register_port(serio, THIS_MODULE)
83 void serio_unregister_port(struct serio
*serio
);
84 void serio_unregister_child_port(struct serio
*serio
);
86 int __must_check
__serio_register_driver(struct serio_driver
*drv
,
87 struct module
*owner
, const char *mod_name
);
89 /* use a define to avoid include chaining to get THIS_MODULE & friends */
90 #define serio_register_driver(drv) \
91 __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
93 void serio_unregister_driver(struct serio_driver
*drv
);
96 * module_serio_driver() - Helper macro for registering a serio driver
97 * @__serio_driver: serio_driver struct
99 * Helper macro for serio drivers which do not do anything special in
100 * module init/exit. This eliminates a lot of boilerplate. Each module
101 * may only use this macro once, and calling it replaces module_init()
104 #define module_serio_driver(__serio_driver) \
105 module_driver(__serio_driver, serio_register_driver, \
106 serio_unregister_driver)
108 static inline int serio_write(struct serio
*serio
, unsigned char data
)
111 return serio
->write(serio
, data
);
116 static inline void serio_drv_write_wakeup(struct serio
*serio
)
118 if (serio
->drv
&& serio
->drv
->write_wakeup
)
119 serio
->drv
->write_wakeup(serio
);
123 * Use the following functions to manipulate serio's per-port
124 * driver-specific data.
126 static inline void *serio_get_drvdata(struct serio
*serio
)
128 return dev_get_drvdata(&serio
->dev
);
131 static inline void serio_set_drvdata(struct serio
*serio
, void *data
)
133 dev_set_drvdata(&serio
->dev
, data
);
137 * Use the following functions to protect critical sections in
138 * driver code from port's interrupt handler
140 static inline void serio_pause_rx(struct serio
*serio
)
142 spin_lock_irq(&serio
->lock
);
145 static inline void serio_continue_rx(struct serio
*serio
)
147 spin_unlock_irq(&serio
->lock
);
This page took 0.040737 seconds and 5 git commands to generate.