1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_TTY_DRIVER_H
3 #define _LINUX_TTY_DRIVER_H
4
5 #include <linux/export.h>
6 #include <linux/fs.h>
7 #include <linux/kref.h>
8 #include <linux/list.h>
9 #include <linux/cdev.h>
10 #include <linux/uaccess.h>
11 #include <linux/termios.h>
12 #include <linux/seq_file.h>
13
14 struct tty_struct;
15 struct tty_driver;
16 struct serial_icounter_struct;
17 struct serial_struct;
18
19 /**
20 * enum tty_driver_flag -- TTY Driver Flags
21 *
22 * These are flags passed to tty_alloc_driver().
23 *
24 * @TTY_DRIVER_INSTALLED:
25 * Whether this driver was succesfully installed. This is a tty internal
26 * flag. Do not touch.
27 *
28 * @TTY_DRIVER_RESET_TERMIOS:
29 * Requests the tty layer to reset the termios setting when the last
30 * process has closed the device. Used for PTYs, in particular.
31 *
32 * @TTY_DRIVER_REAL_RAW:
33 * Indicates that the driver will guarantee not to set any special
34 * character handling flags if this is set for the tty:
35 *
36 * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)``
37 *
38 * That is, if there is no reason for the driver to
39 * send notifications of parity and break characters up to the line
40 * driver, it won't do so. This allows the line driver to optimize for
41 * this case if this flag is set. (Note that there is also a promise, if
42 * the above case is true, not to signal overruns, either.)
43 *
44 * @TTY_DRIVER_DYNAMIC_DEV:
45 * The individual tty devices need to be registered with a call to
46 * tty_register_device() when the device is found in the system and
47 * unregistered with a call to tty_unregister_device() so the devices will
48 * be show up properly in sysfs. If not set, all &tty_driver.num entries
49 * will be created by the tty core in sysfs when tty_register_driver() is
50 * called. This is to be used by drivers that have tty devices that can
51 * appear and disappear while the main tty driver is registered with the
52 * tty core.
53 *
54 * @TTY_DRIVER_DEVPTS_MEM:
55 * Don't use the standard arrays (&tty_driver.ttys and
56 * &tty_driver.termios), instead use dynamic memory keyed through the
57 * devpts filesystem. This is only applicable to the PTY driver.
58 *
59 * @TTY_DRIVER_HARDWARE_BREAK:
60 * Hardware handles break signals. Pass the requested timeout to the
61 * &tty_operations.break_ctl instead of using a simple on/off interface.
62 *
63 * @TTY_DRIVER_DYNAMIC_ALLOC:
64 * Do not allocate structures which are needed per line for this driver
65 * (&tty_driver.ports) as it would waste memory. The driver will take
66 * care. This is only applicable to the PTY driver.
67 *
68 * @TTY_DRIVER_UNNUMBERED_NODE:
69 * Do not create numbered ``/dev`` nodes. For example, create
70 * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a
71 * driver for a single tty device is being allocated.
72 */
73 enum tty_driver_flag {
74 TTY_DRIVER_INSTALLED = BIT(0),
75 TTY_DRIVER_RESET_TERMIOS = BIT(1),
76 TTY_DRIVER_REAL_RAW = BIT(2),
77 TTY_DRIVER_DYNAMIC_DEV = BIT(3),
78 TTY_DRIVER_DEVPTS_MEM = BIT(4),
79 TTY_DRIVER_HARDWARE_BREAK = BIT(5),
80 TTY_DRIVER_DYNAMIC_ALLOC = BIT(6),
81 TTY_DRIVER_UNNUMBERED_NODE = BIT(7),
82 };
83
84 enum tty_driver_type {
85 TTY_DRIVER_TYPE_SYSTEM,
86 TTY_DRIVER_TYPE_CONSOLE,
87 TTY_DRIVER_TYPE_SERIAL,
88 TTY_DRIVER_TYPE_PTY,
89 TTY_DRIVER_TYPE_SCC,
90 TTY_DRIVER_TYPE_SYSCONS,
91 };
92
93 enum tty_driver_subtype {
94 SYSTEM_TYPE_TTY = 1,
95 SYSTEM_TYPE_CONSOLE,
96 SYSTEM_TYPE_SYSCONS,
97 SYSTEM_TYPE_SYSPTMX,
98
99 PTY_TYPE_MASTER = 1,
100 PTY_TYPE_SLAVE,
101
102 SERIAL_TYPE_NORMAL = 1,
103 };
104
105 /**
106 * struct tty_operations -- interface between driver and tty
107 *
108 * @lookup: ``struct tty_struct *()(struct tty_driver *self, struct file *,
109 * int idx)``
110 *
111 * Return the tty device corresponding to @idx, %NULL if there is not
112 * one currently in use and an %ERR_PTR value on error. Called under
113 * %tty_mutex (for now!)
114 *
115 * Optional method. Default behaviour is to use the @self->ttys array.
116 *
117 * @install: ``int ()(struct tty_driver *self, struct tty_struct *tty)``
118 *
119 * Install a new @tty into the @self's internal tables. Used in
120 * conjunction with @lookup and @remove methods.
121 *
122 * Optional method. Default behaviour is to use the @self->ttys array.
123 *
124 * @remove: ``void ()(struct tty_driver *self, struct tty_struct *tty)``
125 *
126 * Remove a closed @tty from the @self's internal tables. Used in
127 * conjunction with @lookup and @remove methods.
128 *
129 * Optional method. Default behaviour is to use the @self->ttys array.
130 *
131 * @open: ``int ()(struct tty_struct *tty, struct file *)``
132 *
133 * This routine is called when a particular @tty device is opened. This
134 * routine is mandatory; if this routine is not filled in, the attempted
135 * open will fail with %ENODEV.
136 *
137 * Required method. Called with tty lock held. May sleep.
138 *
139 * @close: ``void ()(struct tty_struct *tty, struct file *)``
140 *
141 * This routine is called when a particular @tty device is closed. At the
142 * point of return from this call the driver must make no further ldisc
143 * calls of any kind.
144 *
145 * Remark: called even if the corresponding @open() failed.
146 *
147 * Required method. Called with tty lock held. May sleep.
148 *
149 * @shutdown: ``void ()(struct tty_struct *tty)``
150 *
151 * This routine is called under the tty lock when a particular @tty device
152 * is closed for the last time. It executes before the @tty resources
153 * are freed so may execute while another function holds a @tty kref.
154 *
155 * @cleanup: ``void ()(struct tty_struct *tty)``
156 *
157 * This routine is called asynchronously when a particular @tty device
158 * is closed for the last time freeing up the resources. This is
159 * actually the second part of shutdown for routines that might sleep.
160 *
161 * @write: ``ssize_t ()(struct tty_struct *tty, const u8 *buf, size_t count)``
162 *
163 * This routine is called by the kernel to write a series (@count) of
164 * characters (@buf) to the @tty device. The characters may come from
165 * user space or kernel space. This routine will return the
166 * number of characters actually accepted for writing.
167 *
168 * May occur in parallel in special cases. Because this includes panic
169 * paths drivers generally shouldn't try and do clever locking here.
170 *
171 * Optional: Required for writable devices. May not sleep.
172 *
173 * @put_char: ``int ()(struct tty_struct *tty, u8 ch)``
174 *
175 * This routine is called by the kernel to write a single character @ch to
176 * the @tty device. If the kernel uses this routine, it must call the
177 * @flush_chars() routine (if defined) when it is done stuffing characters
178 * into the driver. If there is no room in the queue, the character is
179 * ignored.
180 *
181 * Optional: Kernel will use the @write method if not provided. Do not
182 * call this function directly, call tty_put_char().
183 *
184 * @flush_chars: ``void ()(struct tty_struct *tty)``
185 *
186 * This routine is called by the kernel after it has written a
187 * series of characters to the tty device using @put_char().
188 *
189 * Optional. Do not call this function directly, call
190 * tty_driver_flush_chars().
191 *
192 * @write_room: ``unsigned int ()(struct tty_struct *tty)``
193 *
194 * This routine returns the numbers of characters the @tty driver
195 * will accept for queuing to be written. This number is subject
196 * to change as output buffers get emptied, or if the output flow
197 * control is acted.
198 *
199 * The ldisc is responsible for being intelligent about multi-threading of
200 * write_room/write calls
201 *
202 * Required if @write method is provided else not needed. Do not call this
203 * function directly, call tty_write_room()
204 *
205 * @chars_in_buffer: ``unsigned int ()(struct tty_struct *tty)``
206 *
207 * This routine returns the number of characters in the device private
208 * output queue. Used in tty_wait_until_sent() and for poll()
209 * implementation.
210 *
211 * Optional: if not provided, it is assumed there is no queue on the
212 * device. Do not call this function directly, call tty_chars_in_buffer().
213 *
214 * @ioctl: ``int ()(struct tty_struct *tty, unsigned int cmd,
215 * unsigned long arg)``
216 *
217 * This routine allows the @tty driver to implement device-specific
218 * ioctls. If the ioctl number passed in @cmd is not recognized by the
219 * driver, it should return %ENOIOCTLCMD.
220 *
221 * Optional.
222 *
223 * @compat_ioctl: ``long ()(struct tty_struct *tty, unsigned int cmd,
224 * unsigned long arg)``
225 *
226 * Implement ioctl processing for 32 bit process on 64 bit system.
227 *
228 * Optional.
229 *
230 * @set_termios: ``void ()(struct tty_struct *tty, const struct ktermios *old)``
231 *
232 * This routine allows the @tty driver to be notified when device's
233 * termios settings have changed. New settings are in @tty->termios.
234 * Previous settings are passed in the @old argument.
235 *
236 * The API is defined such that the driver should return the actual modes
237 * selected. This means that the driver is responsible for modifying any
238 * bits in @tty->termios it cannot fulfill to indicate the actual modes
239 * being used.
240 *
241 * Optional. Called under the @tty->termios_rwsem. May sleep.
242 *
243 * @ldisc_ok: ``int ()(struct tty_struct *tty, int ldisc)``
244 *
245 * This routine allows the @tty driver to decide if it can deal
246 * with a particular @ldisc.
247 *
248 * Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
249 *
250 * @set_ldisc: ``void ()(struct tty_struct *tty)``
251 *
252 * This routine allows the @tty driver to be notified when the device's
253 * line discipline is being changed. At the point this is done the
254 * discipline is not yet usable.
255 *
256 * Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
257 *
258 * @throttle: ``void ()(struct tty_struct *tty)``
259 *
260 * This routine notifies the @tty driver that input buffers for the line
261 * discipline are close to full, and it should somehow signal that no more
262 * characters should be sent to the @tty.
263 *
264 * Serialization including with @unthrottle() is the job of the ldisc
265 * layer.
266 *
267 * Optional: Always invoke via tty_throttle_safe(). Called under the
268 * @tty->termios_rwsem.
269 *
270 * @unthrottle: ``void ()(struct tty_struct *tty)``
271 *
272 * This routine notifies the @tty driver that it should signal that
273 * characters can now be sent to the @tty without fear of overrunning the
274 * input buffers of the line disciplines.
275 *
276 * Optional. Always invoke via tty_unthrottle(). Called under the
277 * @tty->termios_rwsem.
278 *
279 * @stop: ``void ()(struct tty_struct *tty)``
280 *
281 * This routine notifies the @tty driver that it should stop outputting
282 * characters to the tty device.
283 *
284 * Called with @tty->flow.lock held. Serialized with @start() method.
285 *
286 * Optional. Always invoke via stop_tty().
287 *
288 * @start: ``void ()(struct tty_struct *tty)``
289 *
290 * This routine notifies the @tty driver that it resumed sending
291 * characters to the @tty device.
292 *
293 * Called with @tty->flow.lock held. Serialized with stop() method.
294 *
295 * Optional. Always invoke via start_tty().
296 *
297 * @hangup: ``void ()(struct tty_struct *tty)``
298 *
299 * This routine notifies the @tty driver that it should hang up the @tty
300 * device.
301 *
302 * Optional. Called with tty lock held.
303 *
304 * @break_ctl: ``int ()(struct tty_struct *tty, int state)``
305 *
306 * This optional routine requests the @tty driver to turn on or off BREAK
307 * status on the RS-232 port. If @state is -1, then the BREAK status
308 * should be turned on; if @state is 0, then BREAK should be turned off.
309 *
310 * If this routine is implemented, the high-level tty driver will handle
311 * the following ioctls: %TCSBRK, %TCSBRKP, %TIOCSBRK, %TIOCCBRK.
312 *
313 * If the driver sets %TTY_DRIVER_HARDWARE_BREAK in tty_alloc_driver(),
314 * then the interface will also be called with actual times and the
315 * hardware is expected to do the delay work itself. 0 and -1 are still
316 * used for on/off.
317 *
318 * Optional: Required for %TCSBRK/%BRKP/etc. handling. May sleep.
319 *
320 * @flush_buffer: ``void ()(struct tty_struct *tty)``
321 *
322 * This routine discards device private output buffer. Invoked on close,
323 * hangup, to implement %TCOFLUSH ioctl and similar.
324 *
325 * Optional: if not provided, it is assumed there is no queue on the
326 * device. Do not call this function directly, call
327 * tty_driver_flush_buffer().
328 *
329 * @wait_until_sent: ``void ()(struct tty_struct *tty, int timeout)``
330 *
331 * This routine waits until the device has written out all of the
332 * characters in its transmitter FIFO. Or until @timeout (in jiffies) is
333 * reached.
334 *
335 * Optional: If not provided, the device is assumed to have no FIFO.
336 * Usually correct to invoke via tty_wait_until_sent(). May sleep.
337 *
338 * @send_xchar: ``void ()(struct tty_struct *tty, u8 ch)``
339 *
340 * This routine is used to send a high-priority XON/XOFF character (@ch)
341 * to the @tty device.
342 *
343 * Optional: If not provided, then the @write method is called under
344 * the @tty->atomic_write_lock to keep it serialized with the ldisc.
345 *
346 * @tiocmget: ``int ()(struct tty_struct *tty)``
347 *
348 * This routine is used to obtain the modem status bits from the @tty
349 * driver.
350 *
351 * Optional: If not provided, then %ENOTTY is returned from the %TIOCMGET
352 * ioctl. Do not call this function directly, call tty_tiocmget().
353 *
354 * @tiocmset: ``int ()(struct tty_struct *tty,
355 * unsigned int set, unsigned int clear)``
356 *
357 * This routine is used to set the modem status bits to the @tty driver.
358 * First, @clear bits should be cleared, then @set bits set.
359 *
360 * Optional: If not provided, then %ENOTTY is returned from the %TIOCMSET
361 * ioctl. Do not call this function directly, call tty_tiocmset().
362 *
363 * @resize: ``int ()(struct tty_struct *tty, struct winsize *ws)``
364 *
365 * Called when a termios request is issued which changes the requested
366 * terminal geometry to @ws.
367 *
368 * Optional: the default action is to update the termios structure
369 * without error. This is usually the correct behaviour. Drivers should
370 * not force errors here if they are not resizable objects (e.g. a serial
371 * line). See tty_do_resize() if you need to wrap the standard method
372 * in your own logic -- the usual case.
373 *
374 * @get_icount: ``int ()(struct tty_struct *tty,
375 * struct serial_icounter *icount)``
376 *
377 * Called when the @tty device receives a %TIOCGICOUNT ioctl. Passed a
378 * kernel structure @icount to complete.
379 *
380 * Optional: called only if provided, otherwise %ENOTTY will be returned.
381 *
382 * @get_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
383 *
384 * Called when the @tty device receives a %TIOCGSERIAL ioctl. Passed a
385 * kernel structure @p (&struct serial_struct) to complete.
386 *
387 * Optional: called only if provided, otherwise %ENOTTY will be returned.
388 * Do not call this function directly, call tty_tiocgserial().
389 *
390 * @set_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
391 *
392 * Called when the @tty device receives a %TIOCSSERIAL ioctl. Passed a
393 * kernel structure @p (&struct serial_struct) to set the values from.
394 *
395 * Optional: called only if provided, otherwise %ENOTTY will be returned.
396 * Do not call this function directly, call tty_tiocsserial().
397 *
398 * @show_fdinfo: ``void ()(struct tty_struct *tty, struct seq_file *m)``
399 *
400 * Called when the @tty device file descriptor receives a fdinfo request
401 * from VFS (to show in /proc/<pid>/fdinfo/). @m should be filled with
402 * information.
403 *
404 * Optional: called only if provided, otherwise nothing is written to @m.
405 * Do not call this function directly, call tty_show_fdinfo().
406 *
407 * @poll_init: ``int ()(struct tty_driver *driver, int line, char *options)``
408 *
409 * kgdboc support (Documentation/process/debugging/kgdb.rst). This routine is
410 * called to initialize the HW for later use by calling @poll_get_char or
411 * @poll_put_char.
412 *
413 * Optional: called only if provided, otherwise skipped as a non-polling
414 * driver.
415 *
416 * @poll_get_char: ``int ()(struct tty_driver *driver, int line)``
417 *
418 * kgdboc support (see @poll_init). @driver should read a character from a
419 * tty identified by @line and return it.
420 *
421 * Optional: called only if @poll_init provided.
422 *
423 * @poll_put_char: ``void ()(struct tty_driver *driver, int line, char ch)``
424 *
425 * kgdboc support (see @poll_init). @driver should write character @ch to
426 * a tty identified by @line.
427 *
428 * Optional: called only if @poll_init provided.
429 *
430 * @proc_show: ``int ()(struct seq_file *m, void *driver)``
431 *
432 * Driver @driver (cast to &struct tty_driver) can show additional info in
433 * /proc/tty/driver/<driver_name>. It is enough to fill in the information
434 * into @m.
435 *
436 * Optional: called only if provided, otherwise no /proc entry created.
437 *
438 * This structure defines the interface between the low-level tty driver and
439 * the tty routines. These routines can be defined. Unless noted otherwise,
440 * they are optional, and can be filled in with a %NULL pointer.
441 */
442 struct tty_operations {
443 struct tty_struct * (*lookup)(struct tty_driver *driver,
444 struct file *filp, int idx);
445 int (*install)(struct tty_driver *driver, struct tty_struct *tty);
446 void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
447 int (*open)(struct tty_struct * tty, struct file * filp);
448 void (*close)(struct tty_struct * tty, struct file * filp);
449 void (*shutdown)(struct tty_struct *tty);
450 void (*cleanup)(struct tty_struct *tty);
451 ssize_t (*write)(struct tty_struct *tty, const u8 *buf, size_t count);
452 int (*put_char)(struct tty_struct *tty, u8 ch);
453 void (*flush_chars)(struct tty_struct *tty);
454 unsigned int (*write_room)(struct tty_struct *tty);
455 unsigned int (*chars_in_buffer)(struct tty_struct *tty);
456 int (*ioctl)(struct tty_struct *tty,
457 unsigned int cmd, unsigned long arg);
458 long (*compat_ioctl)(struct tty_struct *tty,
459 unsigned int cmd, unsigned long arg);
460 void (*set_termios)(struct tty_struct *tty, const struct ktermios *old);
461 void (*throttle)(struct tty_struct * tty);
462 void (*unthrottle)(struct tty_struct * tty);
463 void (*stop)(struct tty_struct *tty);
464 void (*start)(struct tty_struct *tty);
465 void (*hangup)(struct tty_struct *tty);
466 int (*break_ctl)(struct tty_struct *tty, int state);
467 void (*flush_buffer)(struct tty_struct *tty);
468 int (*ldisc_ok)(struct tty_struct *tty, int ldisc);
469 void (*set_ldisc)(struct tty_struct *tty);
470 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
471 void (*send_xchar)(struct tty_struct *tty, u8 ch);
472 int (*tiocmget)(struct tty_struct *tty);
473 int (*tiocmset)(struct tty_struct *tty,
474 unsigned int set, unsigned int clear);
475 int (*resize)(struct tty_struct *tty, struct winsize *ws);
476 int (*get_icount)(struct tty_struct *tty,
477 struct serial_icounter_struct *icount);
478 int (*get_serial)(struct tty_struct *tty, struct serial_struct *p);
479 int (*set_serial)(struct tty_struct *tty, struct serial_struct *p);
480 void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m);
481 #ifdef CONFIG_CONSOLE_POLL
482 int (*poll_init)(struct tty_driver *driver, int line, char *options);
483 int (*poll_get_char)(struct tty_driver *driver, int line);
484 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
485 #endif
486 int (*proc_show)(struct seq_file *m, void *driver);
487 } __randomize_layout;
488
489 /**
490 * struct tty_driver -- driver for TTY devices
491 *
492 * @kref: reference counting. Reaching zero frees all the internals and the
493 * driver.
494 * @cdevs: allocated/registered character /dev devices
495 * @owner: modules owning this driver. Used drivers cannot be rmmod'ed.
496 * Automatically set by tty_alloc_driver().
497 * @driver_name: name of the driver used in /proc/tty
498 * @name: used for constructing /dev node name
499 * @name_base: used as a number base for constructing /dev node name
500 * @major: major /dev device number (zero for autoassignment)
501 * @minor_start: the first minor /dev device number
502 * @num: number of devices allocated
503 * @type: type of tty driver (enum tty_driver_type)
504 * @subtype: subtype of tty driver (enum tty_driver_subtype)
505 * @init_termios: termios to set to each tty initially (e.g. %tty_std_termios)
506 * @flags: tty driver flags (%TTY_DRIVER_)
507 * @proc_entry: proc fs entry, used internally
508 * @other: driver of the linked tty; only used for the PTY driver
509 * @ttys: array of active &struct tty_struct, set by tty_standard_install()
510 * @ports: array of &struct tty_port; can be set during initialization by
511 * tty_port_link_device() and similar
512 * @termios: storage for termios at each TTY close for the next open
513 * @driver_state: pointer to driver's arbitrary data
514 * @ops: driver hooks for TTYs. Set them using tty_set_operations(). Use &struct
515 * tty_port helpers in them as much as possible.
516 * @tty_drivers: used internally to link tty_drivers together
517 *
518 * The usual handling of &struct tty_driver is to allocate it by
519 * tty_alloc_driver(), set up all the necessary members, and register it by
520 * tty_register_driver(). At last, the driver is torn down by calling
521 * tty_unregister_driver() followed by tty_driver_kref_put().
522 *
523 * The fields required to be set before calling tty_register_driver() include
524 * @driver_name, @name, @type, @subtype, @init_termios, and @ops.
525 */
526 struct tty_driver {
527 struct kref kref;
528 struct cdev **cdevs;
529 struct module *owner;
530 const char *driver_name;
531 const char *name;
532 int name_base;
533 int major;
534 int minor_start;
535 unsigned int num;
536 enum tty_driver_type type;
537 enum tty_driver_subtype subtype;
538 struct ktermios init_termios;
539 unsigned long flags;
540 struct proc_dir_entry *proc_entry;
541 struct tty_driver *other;
542
543 /*
544 * Pointer to the tty data structures
545 */
546 struct tty_struct **ttys;
547 struct tty_port **ports;
548 struct ktermios **termios;
549 void *driver_state;
550
551 /*
552 * Driver methods
553 */
554
555 const struct tty_operations *ops;
556 struct list_head tty_drivers;
557 } __randomize_layout;
558
559 extern struct list_head tty_drivers;
560
561 struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
562 unsigned long flags);
563 struct tty_driver *tty_find_polling_driver(char *name, int *line);
564
565 void tty_driver_kref_put(struct tty_driver *driver);
566
567 /**
568 * tty_alloc_driver - allocate tty driver
569 * @lines: count of lines this driver can handle at most
570 * @flags: some of enum tty_driver_flag, will be set in driver->flags
571 *
572 * Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends).
573 */
574 #define tty_alloc_driver(lines, flags) \
575 __tty_alloc_driver(lines, THIS_MODULE, flags)
576
tty_driver_kref_get(struct tty_driver * d)577 static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
578 {
579 kref_get(&d->kref);
580 return d;
581 }
582
tty_set_operations(struct tty_driver * driver,const struct tty_operations * op)583 static inline void tty_set_operations(struct tty_driver *driver,
584 const struct tty_operations *op)
585 {
586 driver->ops = op;
587 }
588
589 int tty_register_driver(struct tty_driver *driver);
590 void tty_unregister_driver(struct tty_driver *driver);
591 struct device *tty_register_device(struct tty_driver *driver, unsigned index,
592 struct device *dev);
593 struct device *tty_register_device_attr(struct tty_driver *driver,
594 unsigned index, struct device *device, void *drvdata,
595 const struct attribute_group **attr_grp);
596 void tty_unregister_device(struct tty_driver *driver, unsigned index);
597
598 #ifdef CONFIG_PROC_FS
599 void proc_tty_register_driver(struct tty_driver *);
600 void proc_tty_unregister_driver(struct tty_driver *);
601 #else
proc_tty_register_driver(struct tty_driver * d)602 static inline void proc_tty_register_driver(struct tty_driver *d) {}
proc_tty_unregister_driver(struct tty_driver * d)603 static inline void proc_tty_unregister_driver(struct tty_driver *d) {}
604 #endif
605
606 #endif /* #ifdef _LINUX_TTY_DRIVER_H */
607