Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99dff585 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (48 commits)
  serial: 8250_pci: add support for Cronyx Omega PCI multiserial board.
  tty/serial: Fix break handling for PORT_TEGRA
  tty/serial: Add explicit PORT_TEGRA type
  n_tracerouter and n_tracesink ldisc additions.
  Intel PTI implementaiton of MIPI 1149.7.
  Kernel documentation for the PTI feature.
  export kernel call get_task_comm().
  tty: Remove to support serial for S5P6442
  pch_phub: Support new device ML7223
  8250_pci: Add support for the Digi/IBM PCIe 2-port Adapter
  ASoC: Update cx20442 for TTY API change
  pch_uart: Support new device ML7223 IOH
  parport: Use request_muxed_region for IT87 probe and lock
  tty/serial: add support for Xilinx PS UART
  n_gsm: Use print_hex_dump_bytes
  drivers/tty/moxa.c: Put correct tty value
  TTY: tty_io, annotate locking functions
  TTY: serial_core, remove superfluous set_task_state
  TTY: serial_core, remove invalid test
  Char: moxa, fix locking in moxa_write
  ...

Fix up trivial conflicts in drivers/bluetooth/hci_ldisc.c and
drivers/tty/serial/Makefile.

I did the hci_ldisc thing as an evil merge, cleaning things up.
parents bb74e8ca d9a0fbfd
Loading
Loading
Loading
Loading
+99 −0
Original line number Diff line number Diff line
The Intel MID PTI project is HW implemented in Intel Atom
system-on-a-chip designs based on the Parallel Trace
Interface for MIPI P1149.7 cJTAG standard.  The kernel solution
for this platform involves the following files:

./include/linux/pti.h
./drivers/.../n_tracesink.h
./drivers/.../n_tracerouter.c
./drivers/.../n_tracesink.c
./drivers/.../pti.c

pti.c is the driver that enables various debugging features
popular on platforms from certain mobile manufacturers.
n_tracerouter.c and n_tracesink.c allow extra system information to
be collected and routed to the pti driver, such as trace
debugging data from a modem.  Although n_tracerouter
and n_tracesink are a part of the complete PTI solution,
these two line disciplines can work separately from
pti.c and route any data stream from one /dev/tty node
to another /dev/tty node via kernel-space.  This provides
a stable, reliable connection that will not break unless
the user-space application shuts down (plus avoids
kernel->user->kernel context switch overheads of routing
data).

An example debugging usage for this driver system:
   *Hook /dev/ttyPTI0 to syslogd.  Opening this port will also start
    a console device to further capture debugging messages to PTI.
   *Hook /dev/ttyPTI1 to modem debugging data to write to PTI HW.
    This is where n_tracerouter and n_tracesink are used.
   *Hook /dev/pti to a user-level debugging application for writing
    to PTI HW.
   *Use mipi_* Kernel Driver API in other device drivers for
    debugging to PTI by first requesting a PTI write address via
    mipi_request_masterchannel(1).

Below is example pseudo-code on how a 'privileged' application
can hook up n_tracerouter and n_tracesink to any tty on
a system.  'Privileged' means the application has enough
privileges to successfully manipulate the ldisc drivers
but is not just blindly executing as 'root'. Keep in mind
the use of ioctl(,TIOCSETD,) is not specific to the n_tracerouter
and n_tracesink line discpline drivers but is a generic
operation for a program to use a line discpline driver
on a tty port other than the default n_tty.

/////////// To hook up n_tracerouter and n_tracesink /////////

// Note that n_tracerouter depends on n_tracesink.
#include <errno.h>
#define ONE_TTY "/dev/ttyOne"
#define TWO_TTY "/dev/ttyTwo"

// needed global to hand onto ldisc connection
static int g_fd_source = -1;
static int g_fd_sink  = -1;

// these two vars used to grab LDISC values from loaded ldisc drivers
// in OS.  Look at /proc/tty/ldiscs to get the right numbers from
// the ldiscs loaded in the system.
int source_ldisc_num, sink_ldisc_num = -1;
int retval;

g_fd_source = open(ONE_TTY, O_RDWR); // must be R/W
g_fd_sink   = open(TWO_TTY, O_RDWR); // must be R/W

if (g_fd_source <= 0) || (g_fd_sink <= 0) {
   // doubt you'll want to use these exact error lines of code
   printf("Error on open(). errno: %d\n",errno);
   return errno;
}

retval = ioctl(g_fd_sink, TIOCSETD, &sink_ldisc_num);
if (retval < 0) {
   printf("Error on ioctl().  errno: %d\n", errno);
   return errno;
}

retval = ioctl(g_fd_source, TIOCSETD, &source_ldisc_num);
if (retval < 0) {
   printf("Error on ioctl().  errno: %d\n", errno);
   return errno;
}

/////////// To disconnect n_tracerouter and n_tracesink ////////

// First make sure data through the ldiscs has stopped.

// Second, disconnect ldiscs.  This provides a
// little cleaner shutdown on tty stack.
sink_ldisc_num = 0;
source_ldisc_num = 0;
ioctl(g_fd_uart, TIOCSETD, &sink_ldisc_num);
ioctl(g_fd_gadget, TIOCSETD, &source_ldisc_num);

// Three, program closes connection, and cleanup:
close(g_fd_uart);
close(g_fd_gadget);
g_fd_uart = g_fd_gadget = NULL;
+11 −8
Original line number Diff line number Diff line
@@ -355,26 +355,29 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
 *             flags        pointer to flags for data
 *             count        count of received data in bytes
 *     
 * Return Value:    None
 * Return Value:    Number of bytes received
 */
static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
static unsigned int hci_uart_tty_receive(struct tty_struct *tty,
		const u8 *data, char *flags, int count)
{
	int ret;
	struct hci_uart *hu = (void *)tty->disc_data;
	int received;

	if (!hu || tty != hu->tty)
		return;
		return -ENODEV;

	if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
		return;
		return -EINVAL;

	spin_lock(&hu->rx_lock);
	ret = hu->proto->recv(hu, (void *) data, count);
	if (ret > 0)
		hu->hdev->stat.byte_rx += count;
	received = hu->proto->recv(hu, (void *) data, count);
	if (received > 0)
		hu->hdev->stat.byte_rx += received;
	spin_unlock(&hu->rx_lock);

	tty_unthrottle(tty);

	return received;
}

static int hci_uart_register_dev(struct hci_uart *hu)
+8 −2
Original line number Diff line number Diff line
@@ -120,17 +120,21 @@ static void serport_ldisc_close(struct tty_struct *tty)
 * 'interrupt' routine.
 */

static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
static unsigned int serport_ldisc_receive(struct tty_struct *tty,
		const unsigned char *cp, char *fp, int count)
{
	struct serport *serport = (struct serport*) tty->disc_data;
	unsigned long flags;
	unsigned int ch_flags;
	int ret = 0;
	int i;

	spin_lock_irqsave(&serport->lock, flags);

	if (!test_bit(SERPORT_ACTIVE, &serport->flags))
	if (!test_bit(SERPORT_ACTIVE, &serport->flags)) {
		ret = -EINVAL;
		goto out;
	}

	for (i = 0; i < count; i++) {
		switch (fp[i]) {
@@ -152,6 +156,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c

out:
	spin_unlock_irqrestore(&serport->lock, flags);

	return ret == 0 ? count : ret;
}

/*
+5 −3
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
 *	cflags	buffer containing error flags for received characters (ignored)
 *	count	number of received characters
 */
static void
static unsigned int
gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
		    char *cflags, int count)
{
@@ -683,12 +683,12 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
	struct inbuf_t *inbuf;

	if (!cs)
		return;
		return -ENODEV;
	inbuf = cs->inbuf;
	if (!inbuf) {
		dev_err(cs->dev, "%s: no inbuf\n", __func__);
		cs_put(cs);
		return;
		return -EINVAL;
	}

	tail = inbuf->tail;
@@ -725,6 +725,8 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
	gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
	gigaset_schedule_event(cs);
	cs_put(cs);

	return count;
}

/*
+20 −5
Original line number Diff line number Diff line
@@ -144,6 +144,19 @@ config PHANTOM
	  If you choose to build module, its name will be phantom. If unsure,
	  say N here.

config INTEL_MID_PTI
	tristate "Parallel Trace Interface for MIPI P1149.7 cJTAG standard"
	default n
	help
	  The PTI (Parallel Trace Interface) driver directs
	  trace data routed from various parts in the system out
	  through an Intel Penwell PTI port and out of the mobile
	  device for analysis with a debugging tool (Lauterbach or Fido).

	  You should select this driver if the target kernel is meant for
	  an Intel Atom (non-netbook) mobile device containing a MIPI
	  P1149.7 standard implementation.

config SGI_IOC4
	tristate "SGI IOC4 Base IO support"
	depends on PCI
@@ -459,7 +472,7 @@ config BMP085
	  module will be called bmp085.

config PCH_PHUB
	tristate "PCH Packet Hub of Intel Topcliff / OKI SEMICONDUCTOR ML7213"
	tristate "Intel EG20T PCH / OKI SEMICONDUCTOR IOH(ML7213/ML7223) PHUB"
	depends on PCI
	help
	  This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of
@@ -467,10 +480,12 @@ config PCH_PHUB
	  processor. The Topcliff has MAC address and Option ROM data in SROM.
	  This driver can access MAC address and Option ROM data in SROM.

	  This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is
	  for IVI(In-Vehicle Infotainment) use.
	  ML7213 is companion chip for Intel Atom E6xx series.
	  ML7213 is completely compatible for Intel EG20T PCH.
	  This driver also can be used for OKI SEMICONDUCTOR IOH(Input/
	  Output Hub), ML7213 and ML7223.
	  ML7213 IOH is for IVI(In-Vehicle Infotainment) use and ML7223 IOH is
	  for MP(Media Phone) use.
	  ML7213/ML7223 is companion chip for Intel Atom E6xx series.
	  ML7213/ML7223 is completely compatible for Intel EG20T PCH.

	  To compile this driver as a module, choose M here: the module will
	  be called pch_phub.
Loading