diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-24 08:41:41 -0400 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-06-24 13:07:53 -0400 |
| commit | 816724e65c72a90a44fbad0ef0b59b186c85fa90 (patch) | |
| tree | 421fa29aedff988e392f92780637553e275d37a0 /drivers/usb/serial/console.c | |
| parent | 70ac4385a13f78bc478f26d317511893741b05bd (diff) | |
| parent | d384ea691fe4ea8c2dd5b9b8d9042eb181776f18 (diff) | |
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
Conflicts:
fs/nfs/inode.c
fs/super.c
Fix conflicts between patch 'NFS: Split fs/nfs/inode.c' and patch
'VFS: Permit filesystem to override root dentry on mount'
Diffstat (limited to 'drivers/usb/serial/console.c')
| -rw-r--r-- | drivers/usb/serial/console.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 8023bb7279b1..f3404e10afb4 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
| @@ -202,7 +202,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun | |||
| 202 | struct usb_serial *serial; | 202 | struct usb_serial *serial; |
| 203 | int retval = -ENODEV; | 203 | int retval = -ENODEV; |
| 204 | 204 | ||
| 205 | if (!port) | 205 | if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) |
| 206 | return; | 206 | return; |
| 207 | serial = port->serial; | 207 | serial = port->serial; |
| 208 | 208 | ||
| @@ -213,17 +213,38 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun | |||
| 213 | 213 | ||
| 214 | if (!port->open_count) { | 214 | if (!port->open_count) { |
| 215 | dbg ("%s - port not opened", __FUNCTION__); | 215 | dbg ("%s - port not opened", __FUNCTION__); |
| 216 | goto exit; | 216 | return; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | /* pass on to the driver specific version of this function if it is available */ | 219 | while (count) { |
| 220 | if (serial->type->write) | 220 | unsigned int i; |
| 221 | retval = serial->type->write(port, buf, count); | 221 | unsigned int lf; |
| 222 | else | 222 | /* search for LF so we can insert CR if necessary */ |
| 223 | retval = usb_serial_generic_write(port, buf, count); | 223 | for (i=0, lf=0 ; i < count ; i++) { |
| 224 | 224 | if (*(buf + i) == 10) { | |
| 225 | exit: | 225 | lf = 1; |
| 226 | dbg("%s - return value (if we had one): %d", __FUNCTION__, retval); | 226 | i++; |
| 227 | break; | ||
| 228 | } | ||
| 229 | } | ||
| 230 | /* pass on to the driver specific version of this function if it is available */ | ||
| 231 | if (serial->type->write) | ||
| 232 | retval = serial->type->write(port, buf, i); | ||
| 233 | else | ||
| 234 | retval = usb_serial_generic_write(port, buf, i); | ||
| 235 | dbg("%s - return value : %d", __FUNCTION__, retval); | ||
| 236 | if (lf) { | ||
| 237 | /* append CR after LF */ | ||
| 238 | unsigned char cr = 13; | ||
| 239 | if (serial->type->write) | ||
| 240 | retval = serial->type->write(port, &cr, 1); | ||
| 241 | else | ||
| 242 | retval = usb_serial_generic_write(port, &cr, 1); | ||
| 243 | dbg("%s - return value : %d", __FUNCTION__, retval); | ||
| 244 | } | ||
| 245 | buf += i; | ||
| 246 | count -= i; | ||
| 247 | } | ||
| 227 | } | 248 | } |
| 228 | 249 | ||
| 229 | static struct console usbcons = { | 250 | static struct console usbcons = { |
| @@ -234,6 +255,14 @@ static struct console usbcons = { | |||
| 234 | .index = -1, | 255 | .index = -1, |
| 235 | }; | 256 | }; |
| 236 | 257 | ||
| 258 | void usb_serial_console_disconnect(struct usb_serial *serial) | ||
| 259 | { | ||
| 260 | if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) { | ||
| 261 | usb_serial_console_exit(); | ||
| 262 | usb_serial_put(serial); | ||
| 263 | } | ||
| 264 | } | ||
| 265 | |||
| 237 | void usb_serial_console_init (int serial_debug, int minor) | 266 | void usb_serial_console_init (int serial_debug, int minor) |
| 238 | { | 267 | { |
| 239 | debug = serial_debug; | 268 | debug = serial_debug; |
| @@ -259,6 +288,11 @@ void usb_serial_console_init (int serial_debug, int minor) | |||
| 259 | 288 | ||
| 260 | void usb_serial_console_exit (void) | 289 | void usb_serial_console_exit (void) |
| 261 | { | 290 | { |
| 262 | unregister_console(&usbcons); | 291 | if (usbcons_info.port) { |
| 292 | unregister_console(&usbcons); | ||
| 293 | if (usbcons_info.port->open_count) | ||
| 294 | usbcons_info.port->open_count--; | ||
| 295 | usbcons_info.port = NULL; | ||
| 296 | } | ||
| 263 | } | 297 | } |
| 264 | 298 | ||
