~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/serio.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Copyright (C) 1999-2002 Vojtech Pavlik
  4  */
  5 #ifndef _SERIO_H
  6 #define _SERIO_H
  7 
  8 
  9 #include <linux/types.h>
 10 #include <linux/interrupt.h>
 11 #include <linux/list.h>
 12 #include <linux/spinlock.h>
 13 #include <linux/mutex.h>
 14 #include <linux/device.h>
 15 #include <linux/mod_devicetable.h>
 16 #include <uapi/linux/serio.h>
 17 
 18 extern const struct bus_type serio_bus;
 19 
 20 struct serio {
 21         void *port_data;
 22 
 23         char name[32];
 24         char phys[32];
 25         char firmware_id[128];
 26 
 27         bool manual_bind;
 28 
 29         struct serio_device_id id;
 30 
 31         /* Protects critical sections from port's interrupt handler */
 32         spinlock_t lock;
 33 
 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 *);
 39 
 40         struct serio *parent;
 41         /* Entry in parent->children list */
 42         struct list_head child_node;
 43         struct list_head children;
 44         /* Level of nesting in serio hierarchy */
 45         unsigned int depth;
 46 
 47         /*
 48          * serio->drv is accessed from interrupt handlers; when modifying
 49          * caller should acquire serio->drv_mutex and serio->lock.
 50          */
 51         struct serio_driver *drv;
 52         /* Protects serio->drv so attributes can pin current driver */
 53         struct mutex drv_mutex;
 54 
 55         struct device dev;
 56 
 57         struct list_head node;
 58 
 59         /*
 60          * For use by PS/2 layer when several ports share hardware and
 61          * may get indigestion when exposed to concurrent access (i8042).
 62          */
 63         struct mutex *ps2_cmd_mutex;
 64 };
 65 #define to_serio_port(d)        container_of(d, struct serio, dev)
 66 
 67 struct serio_driver {
 68         const char *description;
 69 
 70         const struct serio_device_id *id_table;
 71         bool manual_bind;
 72 
 73         void (*write_wakeup)(struct serio *);
 74         irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
 75         int  (*connect)(struct serio *, struct serio_driver *drv);
 76         int  (*reconnect)(struct serio *);
 77         int  (*fast_reconnect)(struct serio *);
 78         void (*disconnect)(struct serio *);
 79         void (*cleanup)(struct serio *);
 80 
 81         struct device_driver driver;
 82 };
 83 #define to_serio_driver(d)      container_of_const(d, struct serio_driver, driver)
 84 
 85 int serio_open(struct serio *serio, struct serio_driver *drv);
 86 void serio_close(struct serio *serio);
 87 void serio_rescan(struct serio *serio);
 88 void serio_reconnect(struct serio *serio);
 89 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
 90 
 91 void __serio_register_port(struct serio *serio, struct module *owner);
 92 
 93 /* use a define to avoid include chaining to get THIS_MODULE */
 94 #define serio_register_port(serio) \
 95         __serio_register_port(serio, THIS_MODULE)
 96 
 97 void serio_unregister_port(struct serio *serio);
 98 void serio_unregister_child_port(struct serio *serio);
 99 
100 int __must_check __serio_register_driver(struct serio_driver *drv,
101                                 struct module *owner, const char *mod_name);
102 
103 /* use a define to avoid include chaining to get THIS_MODULE & friends */
104 #define serio_register_driver(drv) \
105         __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
106 
107 void serio_unregister_driver(struct serio_driver *drv);
108 
109 /**
110  * module_serio_driver() - Helper macro for registering a serio driver
111  * @__serio_driver: serio_driver struct
112  *
113  * Helper macro for serio drivers which do not do anything special in
114  * module init/exit. This eliminates a lot of boilerplate. Each module
115  * may only use this macro once, and calling it replaces module_init()
116  * and module_exit().
117  */
118 #define module_serio_driver(__serio_driver) \
119         module_driver(__serio_driver, serio_register_driver, \
120                        serio_unregister_driver)
121 
122 static inline int serio_write(struct serio *serio, unsigned char data)
123 {
124         if (serio->write)
125                 return serio->write(serio, data);
126         else
127                 return -1;
128 }
129 
130 static inline void serio_drv_write_wakeup(struct serio *serio)
131 {
132         if (serio->drv && serio->drv->write_wakeup)
133                 serio->drv->write_wakeup(serio);
134 }
135 
136 /*
137  * Use the following functions to manipulate serio's per-port
138  * driver-specific data.
139  */
140 static inline void *serio_get_drvdata(struct serio *serio)
141 {
142         return dev_get_drvdata(&serio->dev);
143 }
144 
145 static inline void serio_set_drvdata(struct serio *serio, void *data)
146 {
147         dev_set_drvdata(&serio->dev, data);
148 }
149 
150 /*
151  * Use the following functions to protect critical sections in
152  * driver code from port's interrupt handler
153  */
154 static inline void serio_pause_rx(struct serio *serio)
155 {
156         spin_lock_irq(&serio->lock);
157 }
158 
159 static inline void serio_continue_rx(struct serio *serio)
160 {
161         spin_unlock_irq(&serio->lock);
162 }
163 
164 #endif
165 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php