* [PATCH 1/3] compat: backport usb_pipe_endpoint()
@ 2011-02-21 22:32 Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 2/3] compat: backport tty_{lock,unlock,locked} Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 3/3] compat: backport tty_set_termios Hauke Mehrtens
0 siblings, 2 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-02-21 22:32 UTC (permalink / raw
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/linux/compat-2.6.35.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h
index c4de169..857a521 100644
--- a/include/linux/compat-2.6.35.h
+++ b/include/linux/compat-2.6.35.h
@@ -7,6 +7,7 @@
#include <linux/etherdevice.h>
#include <net/sock.h>
#include <linux/types.h>
+#include <linux/usb.h>
/* added on linux/kernel.h */
#define USHRT_MAX ((u16)(~0U))
@@ -31,6 +32,14 @@ extern loff_t noop_llseek(struct file *file, loff_t offset, int origin);
#define pm_qos_request(_qos) pm_qos_requirement(_qos)
+static inline struct usb_host_endpoint *
+usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)
+{
+ struct usb_host_endpoint **eps;
+ eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out;
+ return eps[usb_pipeendpoint(pipe)];
+}
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */
#endif /* LINUX_26_35_COMPAT_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] compat: backport tty_{lock,unlock,locked}
2011-02-21 22:32 [PATCH 1/3] compat: backport usb_pipe_endpoint() Hauke Mehrtens
@ 2011-02-21 22:32 ` Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 3/3] compat: backport tty_set_termios Hauke Mehrtens
1 sibling, 0 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-02-21 22:32 UTC (permalink / raw
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/linux/compat-2.6.36.h | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h
index 74d2309..0e3b774 100644
--- a/include/linux/compat-2.6.36.h
+++ b/include/linux/compat-2.6.36.h
@@ -9,6 +9,7 @@
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <linux/pm_qos_params.h>
+#include <linux/smp_lock.h>
#define kparam_block_sysfs_write(a)
#define kparam_unblock_sysfs_write(a)
@@ -101,6 +102,23 @@ int no_printk(const char *s, ...) { return 0; }
#define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0)
#endif
+#define EXTPROC 0200000
+#define TIOCPKT_IOCTL 64
+
+static inline void tty_lock(void) __acquires(kernel_lock)
+{
+#ifdef CONFIG_LOCK_KERNEL
+ /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
+ WARN_ON(kernel_locked());
+#endif
+ lock_kernel();
+}
+static inline void tty_unlock(void) __releases(kernel_lock)
+{
+ unlock_kernel();
+}
+#define tty_locked() (kernel_locked())
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
#endif /* LINUX_26_36_COMPAT_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] compat: backport tty_set_termios
2011-02-21 22:32 [PATCH 1/3] compat: backport usb_pipe_endpoint() Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 2/3] compat: backport tty_{lock,unlock,locked} Hauke Mehrtens
@ 2011-02-21 22:32 ` Hauke Mehrtens
1 sibling, 0 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-02-21 22:32 UTC (permalink / raw
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
This code is copied from the kernel sources.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
compat/Makefile | 1 +
compat/compat-2.6.39.c | 111 +++++++++++++++++++++++++++++++++++++++++
include/linux/compat-2.6.39.h | 7 +++
3 files changed, 119 insertions(+), 0 deletions(-)
create mode 100644 compat/compat-2.6.39.c
diff --git a/compat/Makefile b/compat/Makefile
index 9c042ca..f87b024 100644
--- a/compat/Makefile
+++ b/compat/Makefile
@@ -29,3 +29,4 @@ compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o
compat-$(CONFIG_COMPAT_KERNEL_36) += compat-2.6.36.o
compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o
compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o
+compat-$(CONFIG_COMPAT_KERNEL_39) += compat-2.6.39.o
diff --git a/compat/compat-2.6.39.c b/compat/compat-2.6.39.c
new file mode 100644
index 0000000..c2966f7
--- /dev/null
+++ b/compat/compat-2.6.39.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Compatibility file for Linux wireless for kernels 2.6.39.
+ */
+
+#include <linux/compat.h>
+#include <linux/tty.h>
+
+/*
+ * Termios Helper Methods
+ */
+static void unset_locked_termios(struct ktermios *termios,
+ struct ktermios *old,
+ struct ktermios *locked)
+{
+ int i;
+
+#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z)))
+
+ if (!locked) {
+ printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
+ return;
+ }
+
+ NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag);
+ NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag);
+ NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
+ NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
+ termios->c_line = locked->c_line ? old->c_line : termios->c_line;
+ for (i = 0; i < NCCS; i++)
+ termios->c_cc[i] = locked->c_cc[i] ?
+ old->c_cc[i] : termios->c_cc[i];
+ /* FIXME: What should we do for i/ospeed */
+}
+
+/**
+ * tty_set_termios - update termios values
+ * @tty: tty to update
+ * @new_termios: desired new value
+ *
+ * Perform updates to the termios values set on this terminal. There
+ * is a bit of layering violation here with n_tty in terms of the
+ * internal knowledge of this function.
+ *
+ * Locking: termios_mutex
+ */
+int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
+{
+ struct ktermios old_termios;
+ struct tty_ldisc *ld;
+ unsigned long flags;
+
+ /*
+ * Perform the actual termios internal changes under lock.
+ */
+
+
+ /* FIXME: we need to decide on some locking/ordering semantics
+ for the set_termios notification eventually */
+ mutex_lock(&tty->termios_mutex);
+ old_termios = *tty->termios;
+ *tty->termios = *new_termios;
+ unset_locked_termios(tty->termios, &old_termios, tty->termios_locked);
+
+ /* See if packet mode change of state. */
+ if (tty->link && tty->link->packet) {
+ int extproc = (old_termios.c_lflag & EXTPROC) |
+ (tty->termios->c_lflag & EXTPROC);
+ int old_flow = ((old_termios.c_iflag & IXON) &&
+ (old_termios.c_cc[VSTOP] == '\023') &&
+ (old_termios.c_cc[VSTART] == '\021'));
+ int new_flow = (I_IXON(tty) &&
+ STOP_CHAR(tty) == '\023' &&
+ START_CHAR(tty) == '\021');
+ if ((old_flow != new_flow) || extproc) {
+ spin_lock_irqsave(&tty->ctrl_lock, flags);
+ if (old_flow != new_flow) {
+ tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
+ if (new_flow)
+ tty->ctrl_status |= TIOCPKT_DOSTOP;
+ else
+ tty->ctrl_status |= TIOCPKT_NOSTOP;
+ }
+ if (extproc)
+ tty->ctrl_status |= TIOCPKT_IOCTL;
+ spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+ wake_up_interruptible(&tty->link->read_wait);
+ }
+ }
+
+ if (tty->ops->set_termios)
+ (*tty->ops->set_termios)(tty, &old_termios);
+ else
+ tty_termios_copy_hw(tty->termios, &old_termios);
+
+ ld = tty_ldisc_ref(tty);
+ if (ld != NULL) {
+ if (ld->ops->set_termios)
+ (ld->ops->set_termios)(tty, &old_termios);
+ tty_ldisc_deref(ld);
+ }
+ mutex_unlock(&tty->termios_mutex);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(tty_set_termios);
+
diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h
index c0c98fd..1c7b322 100644
--- a/include/linux/compat-2.6.39.h
+++ b/include/linux/compat-2.6.39.h
@@ -5,6 +5,8 @@
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+#include <linux/tty.h>
+
/*
* This is not part of The 2.6.37 kernel yet but we
* we use it to optimize the backport code we
@@ -22,6 +24,11 @@
#define br_port_exists(dev) (dev->br_port)
#endif
+#define tiocmget(tty) tiocmget(tty, NULL)
+#define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear)
+
+extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
#endif /* LINUX_26_39_COMPAT_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-21 22:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-21 22:32 [PATCH 1/3] compat: backport usb_pipe_endpoint() Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 2/3] compat: backport tty_{lock,unlock,locked} Hauke Mehrtens
2011-02-21 22:32 ` [PATCH 3/3] compat: backport tty_set_termios Hauke Mehrtens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).