Revisiting Old APIs
Along with the tty structure changes, a few tty ioctls have been removed, specifically the TIOCMGET, TIOCMBIS, TIOCMBIC and TIOCMSET ioctls. They have been replaced with two new function callbacks, tiocmget and tiocmset, that have been added to the struct tty_operations structure. These functions are defined as:
int (*tiocmget)(struct tty_struct *tty,
struct file *file);
int (*tiocmset)(struct tty_struct *tty,
struct file *file,
unsigned int set,
unsigned int clear);
The tiocmget function is called when the tty core or a user wants to know what the current line settings are for a specific tty port. This works almost exactly like the old TIOCMGET ioctl call did. The line status is defined as the different MSR_* values, but instead of being copied back into user space, as the old ioctl required the driver to do, they merely are returned from the function call. Here's an example of how a tiocmget function could look:
int
tiny_tiocmget(struct tty_struct *tty,
struct file *file)
{
struct tiny_private *tp = tty->private;
unsigned int msr = tp->msr;
unsigned int mcr = tp->mcr;
unsigned int result = 0;
result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0)
/* DTR is set */
| ((mcr & MCR_RTS) ? TIOCM_RTS: 0)
/* RTS is set */
| ((msr & MSR_CTS) ? TIOCM_CTS: 0)
/* CTS is set */
| ((msr & MSR_CD) ? TIOCM_CAR: 0)
/* Carrier detect is set */
| ((msr & MSR_RI) ? TIOCM_RI: 0)
/* Ring Indicator is set */
| ((msr & MSR_DSR) ? TIOCM_DSR: 0);
/* DSR is set */
return result;
The tiocmset function is called when the tty core or a user wants to set or clear any of the different line settings. This single function replaces the TIOCMBIS, TIOCMBIC and TIOCMSET ioctl calls. The set and clear variables in this function are used to tell which line settings to set and which to clear. The same line setting cannot be asked to be cleared and set at the same time, so the order in which variables are processed does not matter. An example of the tiocmset function is:
int
tiny_tiocmset(struct tty_struct *tty,
struct file *file,
unsigned int set, unsigned int clear)
{
struct tiny_private *tp = tty->private;
if (set & TIOCM_RTS)
mcr |= MCR_RTS;
if (set & TIOCM_DTR)
mcr |= MCR_RTS;
if (set & TIOCM_LOOP)
mcr |= MCR_LOOPBACK;
if (clear & TIOCM_RTS)
mcr &= ~MCR_RTS;
if (clear & TIOCM_DTR)
mcr &= ~MCR_RTS;
if (clear & TIOCM_LOOP)
mcr &= ~MCR_LOOPBACK;
/* set the new MCR value in the device */
tp->mcr = mcr;
return 0;
}
The usbserial core also has been affected a bit by these tty core changes. The tiocmget and tiocmset functions have been added to the struct usb_serial_device_type structure. The tty calls to these functions are passed down to the lower usbserial drivers, if the usbserial driver provides those callbacks.
I would like to thank Al Viro, Christoph Hellwig and Russell King for finally starting to work on cleaning up the tty layer to raise it to the proper standards of the rest of the kernel. Their changes have been instrumental in simplifying the tty driver interface, allowing driver authors to focus on the specific hardware implementations and not worry about the kernel interactions as much as before.
Greg Kroah-Hartman currently is the Linux kernel maintainer for a variety of different driver subsystems. He works for IBM, doing Linux kernel-related things, and can be reached at greg@kroah.com.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?




8 hours 20 min ago
12 hours 47 min ago
16 hours 23 min ago
16 hours 55 min ago
19 hours 19 min ago
19 hours 22 min ago
19 hours 23 min ago
23 hours 48 min ago
1 day 1 hour ago
1 day 6 hours ago