/* * The console driver */ static void srm_console_write(struct console *co, const char *s, unsigned count) { unsigned long flags; spin_lock_irqsave(&srmcons_callback_lock, flags); srmcons_do_write(NULL, s, count); spin_unlock_irqrestore(&srmcons_callback_lock, flags); }
static int srmcons_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count) { unsigned long flags; if (from_user) { unsigned char tmp[512]; int ret = 0; size_t c; while ((c = count) > 0) { if (c > sizeof(tmp)) c = sizeof(tmp); c -= copy_from_user(tmp, buf, c); if (!c) { printk("%s: EFAULT (count %d)\n", __FUNCTION__, count); return -EFAULT; } spin_lock_irqsave(&srmcons_callback_lock, flags); srmcons_do_write(tty, tmp, c); spin_unlock_irqrestore(&srmcons_callback_lock, flags); buf += c; count -= c; ret += c; } return ret; } spin_lock_irqsave(&srmcons_callback_lock, flags); srmcons_do_write(tty, buf, count); spin_unlock_irqrestore(&srmcons_callback_lock, flags); return count; }
static int srmcons_write(struct tty_struct *tty, const unsigned char *buf, int count) { unsigned long flags; spin_lock_irqsave(&srmcons_callback_lock, flags); srmcons_do_write(tty->port, (const char *) buf, count); spin_unlock_irqrestore(&srmcons_callback_lock, flags); return count; }