Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 315299 Details for
Bug 445211
[RFE] DTR/DSR flow control
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
[1/2] backport termiox support
tty-add_termiox.patch (text/plain), 7.67 KB, created by
Aristeu Rozanski
on 2008-08-28 21:17:15 UTC
(
hide
)
Description:
[1/2] backport termiox support
Filename:
MIME Type:
Creator:
Aristeu Rozanski
Created:
2008-08-28 21:17:15 UTC
Size:
7.67 KB
patch
obsolete
>https://bugzilla.redhat.com/show_bug.cgi?id=445211 > >This is a preparation patch for adding support for DTR/DSR serial flow control. >Since this is the interface that is going to be upstream (TC{G,S}ETX* ioctls), >this is a backport of the interface without breaking the kabi (we can't just >add {s,g}et_termiox() to tty_struct). > >Tested locally with serial console and a Point of Sale Printer (as many >probably heard) > >Original upstream commit (in linux-next now): > >From f810b01cbdf82d7627c000dd5945a236d5c496a1 Mon Sep 17 00:00:00 2001 >From: Alan Cox <alan@redhat.com> >Date: Sat, 23 Aug 2008 20:22:35 +1000 >Subject: [PATCH] tty-add-termiox > >We need a way to describe the various additional modes and flow control >features that random weird hardware shows up and software such as wine >wants to emulate as Windows supports them. > >TCGETX/TCSETX and the termiox ioctl are a SYS5 extension that we might as >well adopt. This patches adds the structures and the basic ioctl interfaces >when the TCGETX etc defines are added for an architecture. Drivers wishing >to use this stuff need to add new methods. > >Signed-off-by: Alan Cox <alan@redhat.com> >--- > drivers/char/tty_ioctl.c | 130 ++++++++++++++++++++++++++++++++++++++++++++ > include/asm-i386/ioctls.h | 5 + > include/asm-x86_64/ioctls.h | 5 + > include/linux/termios.h | 15 +++++ > include/linux/tty_driver.h | 6 ++ > 5 files changed, 161 insertions(+) > >--- tree.orig/include/asm-x86_64/ioctls.h 2006-09-19 23:42:06.000000000 -0400 >+++ tree/include/asm-x86_64/ioctls.h 2008-08-27 16:03:05.000000000 -0400 >@@ -49,6 +49,11 @@ > #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ > #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ > >+#define TCGETX 0x5432 /* SYS5 TCGETX compatibility */ >+#define TCSETX 0x5433 >+#define TCSETXF 0x5434 >+#define TCSETXW 0x5435 >+ > #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ > #define FIOCLEX 0x5451 > #define FIOASYNC 0x5452 >--- tree.orig/include/asm-i386/ioctls.h 2006-09-19 23:42:06.000000000 -0400 >+++ tree/include/asm-i386/ioctls.h 2008-08-27 16:03:35.000000000 -0400 >@@ -50,6 +50,11 @@ > #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ > #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ > >+#define TCGETX 0x5432 /* SYS5 TCGETX compatibility */ >+#define TCSETX 0x5433 >+#define TCSETXF 0x5434 >+#define TCSETXW 0x5435 >+ > #define FIONCLEX 0x5450 > #define FIOCLEX 0x5451 > #define FIOASYNC 0x5452 >--- tree.orig/include/linux/termios.h 2008-08-27 15:56:32.000000000 -0400 >+++ tree/include/linux/termios.h 2008-08-27 18:43:02.000000000 -0400 >@@ -4,4 +4,19 @@ > #include <linux/types.h> > #include <asm/termios.h> > >+#define NFF 5 >+ >+struct termiox >+{ >+ __u16 x_hflag; >+ __u16 x_cflag; >+ __u16 x_rflag[NFF]; >+ __u16 x_sflag; >+}; >+ >+#define RTSXOFF 0x0001 /* RTS flow control on input */ >+#define CTSXON 0x0002 /* CTS flow control on output */ >+#define DTRXOFF 0x0004 /* DTR flow control on input */ >+#define DSRXON 0x0008 /* DCD flow control on output */ >+ > #endif >--- tree.orig/drivers/char/tty_ioctl.c 2008-06-18 15:32:54.000000000 -0400 >+++ tree/drivers/char/tty_ioctl.c 2008-08-27 22:26:13.000000000 -0400 >@@ -418,6 +418,126 @@ static int set_ltchars(struct tty_struct > } > #endif > >+/* >+ * kabi: we can't add set_termiox() to tty_operations, so each tty driver that >+ * supports it need to add itself to the list >+ */ >+#define MAX_TTY_TERMIOX_HANDLERS 5 >+static struct { >+ struct tty_driver *driver; >+ void (*get_termiox)(struct tty_struct *, struct termiox *); >+ int (*set_termiox)(struct tty_struct *, struct termiox *); >+} tty_termiox_handlers[MAX_TTY_TERMIOX_HANDLERS]; >+static spinlock_t tty_termiox_handlers_lock = SPIN_LOCK_UNLOCKED; >+ >+int tty_register_termiox_handler(struct tty_driver *driver, >+ void (*get_termiox)(struct tty_struct *, struct termiox *), >+ int (*set_termiox)(struct tty_struct *, struct termiox *)) >+{ >+ int i; >+ >+ spin_lock(&tty_termiox_handlers_lock); >+ for (i = 0; i < MAX_TTY_TERMIOX_HANDLERS; i++) >+ if (tty_termiox_handlers[i].driver == NULL) { >+ tty_termiox_handlers[i].driver = driver; >+ tty_termiox_handlers[i].get_termiox = get_termiox; >+ tty_termiox_handlers[i].set_termiox = set_termiox; >+ spin_unlock(&tty_termiox_handlers_lock); >+ return 0; >+ } >+ return 1; >+ spin_unlock(&tty_termiox_handlers_lock); >+} >+EXPORT_SYMBOL(tty_register_termiox_handler); >+ >+void tty_unregister_termiox_handler(struct tty_driver *driver) >+{ >+ int i; >+ >+ spin_lock(&tty_termiox_handlers_lock); >+ for (i = 0; i < MAX_TTY_TERMIOX_HANDLERS; i++) >+ if (tty_termiox_handlers[i].driver == driver) >+ tty_termiox_handlers[i].driver = NULL; >+ spin_unlock(&tty_termiox_handlers_lock); >+} >+EXPORT_SYMBOL(tty_unregister_termiox_handler); >+ >+/* must be called with the lock held */ >+static int tty_find_termiox_handler(struct tty_driver *driver) >+{ >+ int i; >+ >+ for (i = 0; i < MAX_TTY_TERMIOX_HANDLERS; i++) >+ if (tty_termiox_handlers[i].driver == driver) >+ break; >+ >+ return i; >+} >+ >+static int get_termiox(struct tty_struct *tty, void __user *arg) >+{ >+ struct termiox tx; >+ int i; >+ >+ spin_lock(&tty_termiox_handlers_lock); >+ i = tty_find_termiox_handler(tty->driver); >+ spin_unlock(&tty_termiox_handlers_lock); >+ >+ if (i != MAX_TTY_TERMIOX_HANDLERS) { >+ memset(&tx, 0, sizeof(tx)); >+ tty_termiox_handlers[i].get_termiox(tty, &tx); >+ if (copy_to_user(arg, &tx, sizeof(struct termiox))) >+ return -EFAULT; >+ } else >+ return -EINVAL; >+ return 0; >+} >+ >+/** >+ * set_termiox - set termiox fields if possible >+ * @tty: terminal >+ * @arg: termiox structure from user >+ * @opt: option flags for ioctl type >+ * >+ * Implement the device calling points for the SYS5 termiox ioctl >+ * interface in Linux >+ */ >+ >+static int set_termiox(struct tty_struct *tty, void __user *arg, int opt) >+{ >+ struct termiox tnew; >+ struct tty_ldisc *ld; >+ int ret, i; >+ >+ if (copy_from_user(&tnew, arg, sizeof(struct termiox))) >+ return -EFAULT; >+ >+ ld = tty_ldisc_ref(tty); >+ if (ld != NULL) { >+ if ((opt & TERMIOS_FLUSH) && ld->flush_buffer) >+ ld->flush_buffer(tty); >+ tty_ldisc_deref(ld); >+ } >+ if (opt & TERMIOS_WAIT) { >+ tty_wait_until_sent(tty, 0); >+ if (signal_pending(current)) >+ return -EINTR; >+ } >+ >+ mutex_lock(&tty->termios_mutex); >+ spin_lock(&tty_termiox_handlers_lock); >+ i = tty_find_termiox_handler(tty->driver); >+ spin_unlock(&tty_termiox_handlers_lock); >+ >+ if (i != MAX_TTY_TERMIOX_HANDLERS) >+ ret = tty_termiox_handlers[i].set_termiox(tty, &tnew); >+ else >+ ret = -EINVAL; >+ mutex_unlock(&tty->termios_mutex); >+ >+ return ret; >+} >+ > /** > * send_prio_char - send priority character > * >@@ -592,6 +712,16 @@ int n_tty_ioctl(struct tty_struct * tty, > tty->packet = 0; > return 0; > } >+ >+ case TCGETX: >+ return get_termiox(tty, p); >+ case TCSETX: >+ return set_termiox(tty, p, 0); >+ case TCSETXW: >+ return set_termiox(tty, p, TERMIOS_WAIT); >+ case TCSETXF: >+ return set_termiox(tty, p, TERMIOS_FLUSH); >+ > case TIOCGSOFTCAR: > return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)arg); > case TIOCSSOFTCAR: >--- tree.orig/include/linux/tty_driver.h 2006-09-19 23:42:06.000000000 -0400 >+++ tree/include/linux/tty_driver.h 2008-08-27 22:27:58.000000000 -0400 >@@ -221,6 +221,12 @@ struct tty_driver *alloc_tty_driver(int > void put_tty_driver(struct tty_driver *driver); > void tty_set_operations(struct tty_driver *driver, struct tty_operations *op); > >+/* usage of upstream TC{G,S}ETX */ >+int tty_register_termiox_handler(struct tty_driver *driver, >+ void (*get_termiox)(struct tty_struct *, struct termiox *), >+ int (*set_termiox)(struct tty_struct *, struct termiox *)); >+void tty_unregister_termiox_handler(struct tty_driver *driver); >+ > /* tty driver magic number */ > #define TTY_DRIVER_MAGIC 0x5402 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 445211
:
308359
|
308360
|
309219
|
309849
| 315299 |
315300
|
315301