Driver/tiny_tty/tiny_set_termios()

Last-modified: 2007-09-21 (金) 19:35:39

228 :static void tiny_set_termios(struct tty_struct *tty, struct termios *old_termios)
229 :{
230 : unsigned int cflag;
231 :
232 : cflag = tty->termios->c_cflag;

termios構造体のc_cflagを取得、変更内容はここに入っている。

233 :
234 : /* check that they really want us to change something */
235 : if (old_termios) {

古いフラグと比較して、変更する必要があるかを確認する。

236 : if ((cflag == old_termios->c_cflag) &&
237 : (RELEVANT_IFLAG(tty->termios->c_iflag) ==
238 : RELEVANT_IFLAG(old_termios->c_iflag))) {
239 : printk(KERN_DEBUG " - nothing to change...\n");
240 : return;
241 : }
242 : }
243 :
244 : /* get the byte size */
245 : switch (cflag & CSIZE) {
 CSIZE(データビットの変更)
246 : case CS5:
247 : printk(KERN_DEBUG " - data bits = 5\n");
248 : break;
249 : case CS6:
250 : printk(KERN_DEBUG " - data bits = 6\n");
251 : break;
252 : case CS7:
253 : printk(KERN_DEBUG " - data bits = 7\n");
254 : break;
255 : default:
256 : case CS8:
257 : printk(KERN_DEBUG " - data bits = 8\n");
258 : break;
259 : }
260 :
261 : /* determine the parity */
262 : if (cflag & PARENB)

パリティビットの変更

263 : if (cflag & PARODD)
264 : printk(KERN_DEBUG " - parity = odd\n");
265 : else
266 : printk(KERN_DEBUG " - parity = even\n");
267 : else
268 : printk(KERN_DEBUG " - parity = none\n");
269 :
270 : /* figure out the stop bits requested */
271 : if (cflag & CSTOPB)

ストップビットの変更

272 : printk(KERN_DEBUG " - stop bits = 2\n");
273 : else
274 : printk(KERN_DEBUG " - stop bits = 1\n");
275 :
276 : /* figure out the hardware flow control settings */

フローコントロールの変更

277 : if (cflag & CRTSCTS)
278 : printk(KERN_DEBUG " - RTS/CTS is enabled\n");
279 : else
280 : printk(KERN_DEBUG " - RTS/CTS is disabled\n");
281 :
282 : /* determine software flow control */
283 : /* if we are implementing XON/XOFF, set the start and
284 : * stop character in the device */
285 : if (I_IXOFF(tty) || I_IXON(tty)) {

XON/XOFFの変更

286 : unsigned char stop_char = STOP_CHAR(tty);
287 : unsigned char start_char = START_CHAR(tty);
288 :
289 : /* if we are implementing INBOUND XON/XOFF */
290 : if (I_IXOFF(tty))
291 : printk(KERN_DEBUG " - INBOUND XON/XOFF is enabled, "
292 : "XON = %2x, XOFF = %2x", start_char, stop_char);
293 : else
294 : printk(KERN_DEBUG" - INBOUND XON/XOFF is disabled");
295 :
296 : /* if we are implementing OUTBOUND XON/XOFF */
297 : if (I_IXON(tty))
298 : printk(KERN_DEBUG" - OUTBOUND XON/XOFF is enabled, "
299 : "XON = %2x, XOFF = %2x", start_char, stop_char);
300 : else
301 : printk(KERN_DEBUG" - OUTBOUND XON/XOFF is disabled");
302 : }