diff options
Diffstat (limited to 'drivers/s390/char/raw3270.c')
-rw-r--r-- | drivers/s390/char/raw3270.c | 611 |
1 files changed, 261 insertions, 350 deletions
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index 9a6c140c5f07..4c9030a5b9f2 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | 30 | ||
31 | static struct class *class3270; | 31 | struct class *class3270; |
32 | 32 | ||
33 | /* The main 3270 data structure. */ | 33 | /* The main 3270 data structure. */ |
34 | struct raw3270 { | 34 | struct raw3270 { |
@@ -37,6 +37,7 @@ struct raw3270 { | |||
37 | int minor; | 37 | int minor; |
38 | 38 | ||
39 | short model, rows, cols; | 39 | short model, rows, cols; |
40 | unsigned int state; | ||
40 | unsigned long flags; | 41 | unsigned long flags; |
41 | 42 | ||
42 | struct list_head req_queue; /* Request queue. */ | 43 | struct list_head req_queue; /* Request queue. */ |
@@ -46,20 +47,26 @@ struct raw3270 { | |||
46 | struct timer_list timer; /* Device timer. */ | 47 | struct timer_list timer; /* Device timer. */ |
47 | 48 | ||
48 | unsigned char *ascebc; /* ascii -> ebcdic table */ | 49 | unsigned char *ascebc; /* ascii -> ebcdic table */ |
49 | struct device *clttydev; /* 3270-class tty device ptr */ | ||
50 | struct device *cltubdev; /* 3270-class tub device ptr */ | ||
51 | 50 | ||
52 | struct raw3270_request init_request; | 51 | struct raw3270_view init_view; |
52 | struct raw3270_request init_reset; | ||
53 | struct raw3270_request init_readpart; | ||
54 | struct raw3270_request init_readmod; | ||
53 | unsigned char init_data[256]; | 55 | unsigned char init_data[256]; |
54 | }; | 56 | }; |
55 | 57 | ||
58 | /* raw3270->state */ | ||
59 | #define RAW3270_STATE_INIT 0 /* Initial state */ | ||
60 | #define RAW3270_STATE_RESET 1 /* Reset command is pending */ | ||
61 | #define RAW3270_STATE_W4ATTN 2 /* Wait for attention interrupt */ | ||
62 | #define RAW3270_STATE_READMOD 3 /* Read partition is pending */ | ||
63 | #define RAW3270_STATE_READY 4 /* Device is usable by views */ | ||
64 | |||
56 | /* raw3270->flags */ | 65 | /* raw3270->flags */ |
57 | #define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */ | 66 | #define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */ |
58 | #define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */ | 67 | #define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */ |
59 | #define RAW3270_FLAGS_ATTN 2 /* Device sent an ATTN interrupt */ | 68 | #define RAW3270_FLAGS_CONSOLE 2 /* Device is the console. */ |
60 | #define RAW3270_FLAGS_READY 4 /* Device is useable by views */ | 69 | #define RAW3270_FLAGS_FROZEN 3 /* set if 3270 is frozen for suspend */ |
61 | #define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */ | ||
62 | #define RAW3270_FLAGS_FROZEN 16 /* set if 3270 is frozen for suspend */ | ||
63 | 70 | ||
64 | /* Semaphore to protect global data of raw3270 (devices, views, etc). */ | 71 | /* Semaphore to protect global data of raw3270 (devices, views, etc). */ |
65 | static DEFINE_MUTEX(raw3270_mutex); | 72 | static DEFINE_MUTEX(raw3270_mutex); |
@@ -97,6 +104,17 @@ static unsigned char raw3270_ebcgraf[64] = { | |||
97 | 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f | 104 | 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f |
98 | }; | 105 | }; |
99 | 106 | ||
107 | static inline int raw3270_state_ready(struct raw3270 *rp) | ||
108 | { | ||
109 | return rp->state == RAW3270_STATE_READY; | ||
110 | } | ||
111 | |||
112 | static inline int raw3270_state_final(struct raw3270 *rp) | ||
113 | { | ||
114 | return rp->state == RAW3270_STATE_INIT || | ||
115 | rp->state == RAW3270_STATE_READY; | ||
116 | } | ||
117 | |||
100 | void | 118 | void |
101 | raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr) | 119 | raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr) |
102 | { | 120 | { |
@@ -214,7 +232,7 @@ raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib) | |||
214 | * Stop running ccw. | 232 | * Stop running ccw. |
215 | */ | 233 | */ |
216 | static int | 234 | static int |
217 | raw3270_halt_io_nolock(struct raw3270 *rp, struct raw3270_request *rq) | 235 | __raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq) |
218 | { | 236 | { |
219 | int retries; | 237 | int retries; |
220 | int rc; | 238 | int rc; |
@@ -233,18 +251,6 @@ raw3270_halt_io_nolock(struct raw3270 *rp, struct raw3270_request *rq) | |||
233 | return rc; | 251 | return rc; |
234 | } | 252 | } |
235 | 253 | ||
236 | static int | ||
237 | raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq) | ||
238 | { | ||
239 | unsigned long flags; | ||
240 | int rc; | ||
241 | |||
242 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
243 | rc = raw3270_halt_io_nolock(rp, rq); | ||
244 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
245 | return rc; | ||
246 | } | ||
247 | |||
248 | /* | 254 | /* |
249 | * Add the request to the request queue, try to start it if the | 255 | * Add the request to the request queue, try to start it if the |
250 | * 3270 device is idle. Return without waiting for end of i/o. | 256 | * 3270 device is idle. Return without waiting for end of i/o. |
@@ -281,8 +287,8 @@ raw3270_start(struct raw3270_view *view, struct raw3270_request *rq) | |||
281 | if (!rp || rp->view != view || | 287 | if (!rp || rp->view != view || |
282 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 288 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
283 | rc = -EACCES; | 289 | rc = -EACCES; |
284 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 290 | else if (!raw3270_state_ready(rp)) |
285 | rc = -ENODEV; | 291 | rc = -EBUSY; |
286 | else | 292 | else |
287 | rc = __raw3270_start(rp, view, rq); | 293 | rc = __raw3270_start(rp, view, rq); |
288 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | 294 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); |
@@ -299,8 +305,8 @@ raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq) | |||
299 | if (!rp || rp->view != view || | 305 | if (!rp || rp->view != view || |
300 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 306 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
301 | rc = -EACCES; | 307 | rc = -EACCES; |
302 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 308 | else if (!raw3270_state_ready(rp)) |
303 | rc = -ENODEV; | 309 | rc = -EBUSY; |
304 | else | 310 | else |
305 | rc = __raw3270_start(rp, view, rq); | 311 | rc = __raw3270_start(rp, view, rq); |
306 | return rc; | 312 | return rc; |
@@ -378,7 +384,7 @@ raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
378 | case RAW3270_IO_STOP: | 384 | case RAW3270_IO_STOP: |
379 | if (!rq) | 385 | if (!rq) |
380 | break; | 386 | break; |
381 | raw3270_halt_io_nolock(rp, rq); | 387 | __raw3270_halt_io(rp, rq); |
382 | rq->rc = -EIO; | 388 | rq->rc = -EIO; |
383 | break; | 389 | break; |
384 | default: | 390 | default: |
@@ -413,9 +419,14 @@ raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
413 | } | 419 | } |
414 | 420 | ||
415 | /* | 421 | /* |
416 | * Size sensing. | 422 | * To determine the size of the 3270 device we need to do: |
423 | * 1) send a 'read partition' data stream to the device | ||
424 | * 2) wait for the attn interrupt that precedes the query reply | ||
425 | * 3) do a read modified to get the query reply | ||
426 | * To make things worse we have to cope with intervention | ||
427 | * required (3270 device switched to 'stand-by') and command | ||
428 | * rejects (old devices that can't do 'read partition'). | ||
417 | */ | 429 | */ |
418 | |||
419 | struct raw3270_ua { /* Query Reply structure for Usable Area */ | 430 | struct raw3270_ua { /* Query Reply structure for Usable Area */ |
420 | struct { /* Usable Area Query Reply Base */ | 431 | struct { /* Usable Area Query Reply Base */ |
421 | short l; /* Length of this structured field */ | 432 | short l; /* Length of this structured field */ |
@@ -451,117 +462,21 @@ struct raw3270_ua { /* Query Reply structure for Usable Area */ | |||
451 | } __attribute__ ((packed)) aua; | 462 | } __attribute__ ((packed)) aua; |
452 | } __attribute__ ((packed)); | 463 | } __attribute__ ((packed)); |
453 | 464 | ||
454 | static struct diag210 raw3270_init_diag210; | ||
455 | static DEFINE_MUTEX(raw3270_init_mutex); | ||
456 | |||
457 | static int | ||
458 | raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq, | ||
459 | struct irb *irb) | ||
460 | { | ||
461 | /* | ||
462 | * Unit-Check Processing: | ||
463 | * Expect Command Reject or Intervention Required. | ||
464 | */ | ||
465 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
466 | /* Request finished abnormally. */ | ||
467 | if (irb->ecw[0] & SNS0_INTERVENTION_REQ) { | ||
468 | set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags); | ||
469 | return RAW3270_IO_BUSY; | ||
470 | } | ||
471 | } | ||
472 | if (rq) { | ||
473 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
474 | if (irb->ecw[0] & SNS0_CMD_REJECT) | ||
475 | rq->rc = -EOPNOTSUPP; | ||
476 | else | ||
477 | rq->rc = -EIO; | ||
478 | } else | ||
479 | /* Request finished normally. Copy residual count. */ | ||
480 | rq->rescnt = irb->scsw.cmd.count; | ||
481 | } | ||
482 | if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { | ||
483 | set_bit(RAW3270_FLAGS_ATTN, &view->dev->flags); | ||
484 | wake_up(&raw3270_wait_queue); | ||
485 | } | ||
486 | return RAW3270_IO_DONE; | ||
487 | } | ||
488 | |||
489 | static struct raw3270_fn raw3270_init_fn = { | ||
490 | .intv = raw3270_init_irq | ||
491 | }; | ||
492 | |||
493 | static struct raw3270_view raw3270_init_view = { | ||
494 | .fn = &raw3270_init_fn | ||
495 | }; | ||
496 | |||
497 | /* | ||
498 | * raw3270_wait/raw3270_wait_interruptible/__raw3270_wakeup | ||
499 | * Wait for end of request. The request must have been started | ||
500 | * with raw3270_start, rc = 0. The device lock may NOT have been | ||
501 | * released between calling raw3270_start and raw3270_wait. | ||
502 | */ | ||
503 | static void | 465 | static void |
504 | raw3270_wake_init(struct raw3270_request *rq, void *data) | 466 | raw3270_size_device_vm(struct raw3270 *rp) |
505 | { | ||
506 | wake_up((wait_queue_head_t *) data); | ||
507 | } | ||
508 | |||
509 | /* | ||
510 | * Special wait function that can cope with console initialization. | ||
511 | */ | ||
512 | static int | ||
513 | raw3270_start_init(struct raw3270 *rp, struct raw3270_view *view, | ||
514 | struct raw3270_request *rq) | ||
515 | { | ||
516 | unsigned long flags; | ||
517 | int rc; | ||
518 | |||
519 | #ifdef CONFIG_TN3270_CONSOLE | ||
520 | if (raw3270_registered == 0) { | ||
521 | spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags); | ||
522 | rq->callback = NULL; | ||
523 | rc = __raw3270_start(rp, view, rq); | ||
524 | if (rc == 0) | ||
525 | while (!raw3270_request_final(rq)) { | ||
526 | wait_cons_dev(); | ||
527 | barrier(); | ||
528 | } | ||
529 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | ||
530 | return rq->rc; | ||
531 | } | ||
532 | #endif | ||
533 | rq->callback = raw3270_wake_init; | ||
534 | rq->callback_data = &raw3270_wait_queue; | ||
535 | spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags); | ||
536 | rc = __raw3270_start(rp, view, rq); | ||
537 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | ||
538 | if (rc) | ||
539 | return rc; | ||
540 | /* Now wait for the completion. */ | ||
541 | rc = wait_event_interruptible(raw3270_wait_queue, | ||
542 | raw3270_request_final(rq)); | ||
543 | if (rc == -ERESTARTSYS) { /* Interrupted by a signal. */ | ||
544 | raw3270_halt_io(view->dev, rq); | ||
545 | /* No wait for the halt to complete. */ | ||
546 | wait_event(raw3270_wait_queue, raw3270_request_final(rq)); | ||
547 | return -ERESTARTSYS; | ||
548 | } | ||
549 | return rq->rc; | ||
550 | } | ||
551 | |||
552 | static int | ||
553 | __raw3270_size_device_vm(struct raw3270 *rp) | ||
554 | { | 467 | { |
555 | int rc, model; | 468 | int rc, model; |
556 | struct ccw_dev_id dev_id; | 469 | struct ccw_dev_id dev_id; |
470 | struct diag210 diag_data; | ||
557 | 471 | ||
558 | ccw_device_get_id(rp->cdev, &dev_id); | 472 | ccw_device_get_id(rp->cdev, &dev_id); |
559 | raw3270_init_diag210.vrdcdvno = dev_id.devno; | 473 | diag_data.vrdcdvno = dev_id.devno; |
560 | raw3270_init_diag210.vrdclen = sizeof(struct diag210); | 474 | diag_data.vrdclen = sizeof(struct diag210); |
561 | rc = diag210(&raw3270_init_diag210); | 475 | rc = diag210(&diag_data); |
562 | if (rc) | 476 | model = diag_data.vrdccrmd; |
563 | return rc; | 477 | /* Use default model 2 if the size could not be detected */ |
564 | model = raw3270_init_diag210.vrdccrmd; | 478 | if (rc || model < 2 || model > 5) |
479 | model = 2; | ||
565 | switch (model) { | 480 | switch (model) { |
566 | case 2: | 481 | case 2: |
567 | rp->model = model; | 482 | rp->model = model; |
@@ -583,77 +498,25 @@ __raw3270_size_device_vm(struct raw3270 *rp) | |||
583 | rp->rows = 27; | 498 | rp->rows = 27; |
584 | rp->cols = 132; | 499 | rp->cols = 132; |
585 | break; | 500 | break; |
586 | default: | ||
587 | rc = -EOPNOTSUPP; | ||
588 | break; | ||
589 | } | 501 | } |
590 | return rc; | ||
591 | } | 502 | } |
592 | 503 | ||
593 | static int | 504 | static void |
594 | __raw3270_size_device(struct raw3270 *rp) | 505 | raw3270_size_device(struct raw3270 *rp) |
595 | { | 506 | { |
596 | static const unsigned char wbuf[] = | ||
597 | { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 }; | ||
598 | struct raw3270_ua *uap; | 507 | struct raw3270_ua *uap; |
599 | int rc; | ||
600 | 508 | ||
601 | /* | ||
602 | * To determine the size of the 3270 device we need to do: | ||
603 | * 1) send a 'read partition' data stream to the device | ||
604 | * 2) wait for the attn interrupt that precedes the query reply | ||
605 | * 3) do a read modified to get the query reply | ||
606 | * To make things worse we have to cope with intervention | ||
607 | * required (3270 device switched to 'stand-by') and command | ||
608 | * rejects (old devices that can't do 'read partition'). | ||
609 | */ | ||
610 | memset(&rp->init_request, 0, sizeof(rp->init_request)); | ||
611 | memset(&rp->init_data, 0, 256); | ||
612 | /* Store 'read partition' data stream to init_data */ | ||
613 | memcpy(&rp->init_data, wbuf, sizeof(wbuf)); | ||
614 | INIT_LIST_HEAD(&rp->init_request.list); | ||
615 | rp->init_request.ccw.cmd_code = TC_WRITESF; | ||
616 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | ||
617 | rp->init_request.ccw.count = sizeof(wbuf); | ||
618 | rp->init_request.ccw.cda = (__u32) __pa(&rp->init_data); | ||
619 | |||
620 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | ||
621 | if (rc) | ||
622 | /* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */ | ||
623 | return rc; | ||
624 | |||
625 | /* Wait for attention interrupt. */ | ||
626 | #ifdef CONFIG_TN3270_CONSOLE | ||
627 | if (raw3270_registered == 0) { | ||
628 | unsigned long flags; | ||
629 | |||
630 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
631 | while (!test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags)) | ||
632 | wait_cons_dev(); | ||
633 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
634 | } else | ||
635 | #endif | ||
636 | rc = wait_event_interruptible(raw3270_wait_queue, | ||
637 | test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags)); | ||
638 | if (rc) | ||
639 | return rc; | ||
640 | |||
641 | /* | ||
642 | * The device accepted the 'read partition' command. Now | ||
643 | * set up a read ccw and issue it. | ||
644 | */ | ||
645 | rp->init_request.ccw.cmd_code = TC_READMOD; | ||
646 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | ||
647 | rp->init_request.ccw.count = sizeof(rp->init_data); | ||
648 | rp->init_request.ccw.cda = (__u32) __pa(rp->init_data); | ||
649 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | ||
650 | if (rc) | ||
651 | return rc; | ||
652 | /* Got a Query Reply */ | 509 | /* Got a Query Reply */ |
653 | uap = (struct raw3270_ua *) (rp->init_data + 1); | 510 | uap = (struct raw3270_ua *) (rp->init_data + 1); |
654 | /* Paranoia check. */ | 511 | /* Paranoia check. */ |
655 | if (rp->init_data[0] != 0x88 || uap->uab.qcode != 0x81) | 512 | if (rp->init_readmod.rc || rp->init_data[0] != 0x88 || |
656 | return -EOPNOTSUPP; | 513 | uap->uab.qcode != 0x81) { |
514 | /* Couldn't detect size. Use default model 2. */ | ||
515 | rp->model = 2; | ||
516 | rp->rows = 24; | ||
517 | rp->cols = 80; | ||
518 | return; | ||
519 | } | ||
657 | /* Copy rows/columns of default Usable Area */ | 520 | /* Copy rows/columns of default Usable Area */ |
658 | rp->rows = uap->uab.h; | 521 | rp->rows = uap->uab.h; |
659 | rp->cols = uap->uab.w; | 522 | rp->cols = uap->uab.w; |
@@ -666,66 +529,131 @@ __raw3270_size_device(struct raw3270 *rp) | |||
666 | rp->rows = uap->aua.hauai; | 529 | rp->rows = uap->aua.hauai; |
667 | rp->cols = uap->aua.wauai; | 530 | rp->cols = uap->aua.wauai; |
668 | } | 531 | } |
669 | return 0; | 532 | /* Try to find a model. */ |
533 | rp->model = 0; | ||
534 | if (rp->rows == 24 && rp->cols == 80) | ||
535 | rp->model = 2; | ||
536 | if (rp->rows == 32 && rp->cols == 80) | ||
537 | rp->model = 3; | ||
538 | if (rp->rows == 43 && rp->cols == 80) | ||
539 | rp->model = 4; | ||
540 | if (rp->rows == 27 && rp->cols == 132) | ||
541 | rp->model = 5; | ||
670 | } | 542 | } |
671 | 543 | ||
672 | static int | 544 | static void |
673 | raw3270_size_device(struct raw3270 *rp) | 545 | raw3270_size_device_done(struct raw3270 *rp) |
674 | { | 546 | { |
675 | int rc; | 547 | struct raw3270_view *view; |
676 | 548 | ||
677 | mutex_lock(&raw3270_init_mutex); | ||
678 | rp->view = &raw3270_init_view; | ||
679 | raw3270_init_view.dev = rp; | ||
680 | if (MACHINE_IS_VM) | ||
681 | rc = __raw3270_size_device_vm(rp); | ||
682 | else | ||
683 | rc = __raw3270_size_device(rp); | ||
684 | raw3270_init_view.dev = NULL; | ||
685 | rp->view = NULL; | 549 | rp->view = NULL; |
686 | mutex_unlock(&raw3270_init_mutex); | 550 | rp->state = RAW3270_STATE_READY; |
687 | if (rc == 0) { /* Found something. */ | 551 | /* Notify views about new size */ |
688 | /* Try to find a model. */ | 552 | list_for_each_entry(view, &rp->view_list, list) |
689 | rp->model = 0; | 553 | if (view->fn->resize) |
690 | if (rp->rows == 24 && rp->cols == 80) | 554 | view->fn->resize(view, rp->model, rp->rows, rp->cols); |
691 | rp->model = 2; | 555 | /* Setup processing done, now activate a view */ |
692 | if (rp->rows == 32 && rp->cols == 80) | 556 | list_for_each_entry(view, &rp->view_list, list) { |
693 | rp->model = 3; | 557 | rp->view = view; |
694 | if (rp->rows == 43 && rp->cols == 80) | 558 | if (view->fn->activate(view) == 0) |
695 | rp->model = 4; | 559 | break; |
696 | if (rp->rows == 27 && rp->cols == 132) | 560 | rp->view = NULL; |
697 | rp->model = 5; | ||
698 | } else { | ||
699 | /* Couldn't detect size. Use default model 2. */ | ||
700 | rp->model = 2; | ||
701 | rp->rows = 24; | ||
702 | rp->cols = 80; | ||
703 | return 0; | ||
704 | } | 561 | } |
705 | return rc; | 562 | } |
563 | |||
564 | static void | ||
565 | raw3270_read_modified_cb(struct raw3270_request *rq, void *data) | ||
566 | { | ||
567 | struct raw3270 *rp = rq->view->dev; | ||
568 | |||
569 | raw3270_size_device(rp); | ||
570 | raw3270_size_device_done(rp); | ||
571 | } | ||
572 | |||
573 | static void | ||
574 | raw3270_read_modified(struct raw3270 *rp) | ||
575 | { | ||
576 | if (rp->state != RAW3270_STATE_W4ATTN) | ||
577 | return; | ||
578 | /* Use 'read modified' to get the result of a read partition. */ | ||
579 | memset(&rp->init_readmod, 0, sizeof(rp->init_readmod)); | ||
580 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | ||
581 | rp->init_readmod.ccw.cmd_code = TC_READMOD; | ||
582 | rp->init_readmod.ccw.flags = CCW_FLAG_SLI; | ||
583 | rp->init_readmod.ccw.count = sizeof(rp->init_data); | ||
584 | rp->init_readmod.ccw.cda = (__u32) __pa(rp->init_data); | ||
585 | rp->init_readmod.callback = raw3270_read_modified_cb; | ||
586 | rp->state = RAW3270_STATE_READMOD; | ||
587 | raw3270_start_irq(&rp->init_view, &rp->init_readmod); | ||
588 | } | ||
589 | |||
590 | static void | ||
591 | raw3270_writesf_readpart(struct raw3270 *rp) | ||
592 | { | ||
593 | static const unsigned char wbuf[] = | ||
594 | { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 }; | ||
595 | |||
596 | /* Store 'read partition' data stream to init_data */ | ||
597 | memset(&rp->init_readpart, 0, sizeof(rp->init_readpart)); | ||
598 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | ||
599 | memcpy(&rp->init_data, wbuf, sizeof(wbuf)); | ||
600 | rp->init_readpart.ccw.cmd_code = TC_WRITESF; | ||
601 | rp->init_readpart.ccw.flags = CCW_FLAG_SLI; | ||
602 | rp->init_readpart.ccw.count = sizeof(wbuf); | ||
603 | rp->init_readpart.ccw.cda = (__u32) __pa(&rp->init_data); | ||
604 | rp->state = RAW3270_STATE_W4ATTN; | ||
605 | raw3270_start_irq(&rp->init_view, &rp->init_readpart); | ||
606 | } | ||
607 | |||
608 | /* | ||
609 | * Device reset | ||
610 | */ | ||
611 | static void | ||
612 | raw3270_reset_device_cb(struct raw3270_request *rq, void *data) | ||
613 | { | ||
614 | struct raw3270 *rp = rq->view->dev; | ||
615 | |||
616 | if (rp->state != RAW3270_STATE_RESET) | ||
617 | return; | ||
618 | if (rq && rq->rc) { | ||
619 | /* Reset command failed. */ | ||
620 | rp->state = RAW3270_STATE_INIT; | ||
621 | } else if (0 && MACHINE_IS_VM) { | ||
622 | raw3270_size_device_vm(rp); | ||
623 | raw3270_size_device_done(rp); | ||
624 | } else | ||
625 | raw3270_writesf_readpart(rp); | ||
706 | } | 626 | } |
707 | 627 | ||
708 | static int | 628 | static int |
709 | raw3270_reset_device(struct raw3270 *rp) | 629 | __raw3270_reset_device(struct raw3270 *rp) |
710 | { | 630 | { |
711 | int rc; | 631 | int rc; |
712 | 632 | ||
713 | mutex_lock(&raw3270_init_mutex); | 633 | /* Store reset data stream to init_data/init_reset */ |
714 | memset(&rp->init_request, 0, sizeof(rp->init_request)); | 634 | memset(&rp->init_reset, 0, sizeof(rp->init_reset)); |
715 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | 635 | memset(&rp->init_data, 0, sizeof(rp->init_data)); |
716 | /* Store reset data stream to init_data/init_request */ | ||
717 | rp->init_data[0] = TW_KR; | 636 | rp->init_data[0] = TW_KR; |
718 | INIT_LIST_HEAD(&rp->init_request.list); | 637 | rp->init_reset.ccw.cmd_code = TC_EWRITEA; |
719 | rp->init_request.ccw.cmd_code = TC_EWRITEA; | 638 | rp->init_reset.ccw.flags = CCW_FLAG_SLI; |
720 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | 639 | rp->init_reset.ccw.count = 1; |
721 | rp->init_request.ccw.count = 1; | 640 | rp->init_reset.ccw.cda = (__u32) __pa(rp->init_data); |
722 | rp->init_request.ccw.cda = (__u32) __pa(rp->init_data); | 641 | rp->init_reset.callback = raw3270_reset_device_cb; |
723 | rp->view = &raw3270_init_view; | 642 | rc = __raw3270_start(rp, &rp->init_view, &rp->init_reset); |
724 | raw3270_init_view.dev = rp; | 643 | if (rc == 0 && rp->state == RAW3270_STATE_INIT) |
725 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | 644 | rp->state = RAW3270_STATE_RESET; |
726 | raw3270_init_view.dev = NULL; | 645 | return rc; |
727 | rp->view = NULL; | 646 | } |
728 | mutex_unlock(&raw3270_init_mutex); | 647 | |
648 | static int | ||
649 | raw3270_reset_device(struct raw3270 *rp) | ||
650 | { | ||
651 | unsigned long flags; | ||
652 | int rc; | ||
653 | |||
654 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
655 | rc = __raw3270_reset_device(rp); | ||
656 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
729 | return rc; | 657 | return rc; |
730 | } | 658 | } |
731 | 659 | ||
@@ -739,13 +667,50 @@ raw3270_reset(struct raw3270_view *view) | |||
739 | if (!rp || rp->view != view || | 667 | if (!rp || rp->view != view || |
740 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 668 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
741 | rc = -EACCES; | 669 | rc = -EACCES; |
742 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 670 | else if (!raw3270_state_ready(rp)) |
743 | rc = -ENODEV; | 671 | rc = -EBUSY; |
744 | else | 672 | else |
745 | rc = raw3270_reset_device(view->dev); | 673 | rc = raw3270_reset_device(view->dev); |
746 | return rc; | 674 | return rc; |
747 | } | 675 | } |
748 | 676 | ||
677 | static int | ||
678 | raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq, | ||
679 | struct irb *irb) | ||
680 | { | ||
681 | struct raw3270 *rp; | ||
682 | |||
683 | /* | ||
684 | * Unit-Check Processing: | ||
685 | * Expect Command Reject or Intervention Required. | ||
686 | */ | ||
687 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
688 | /* Request finished abnormally. */ | ||
689 | if (irb->ecw[0] & SNS0_INTERVENTION_REQ) { | ||
690 | set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags); | ||
691 | return RAW3270_IO_BUSY; | ||
692 | } | ||
693 | } | ||
694 | if (rq) { | ||
695 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
696 | if (irb->ecw[0] & SNS0_CMD_REJECT) | ||
697 | rq->rc = -EOPNOTSUPP; | ||
698 | else | ||
699 | rq->rc = -EIO; | ||
700 | } | ||
701 | } | ||
702 | if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { | ||
703 | /* Queue read modified after attention interrupt */ | ||
704 | rp = view->dev; | ||
705 | raw3270_read_modified(rp); | ||
706 | } | ||
707 | return RAW3270_IO_DONE; | ||
708 | } | ||
709 | |||
710 | static struct raw3270_fn raw3270_init_fn = { | ||
711 | .intv = raw3270_init_irq | ||
712 | }; | ||
713 | |||
749 | /* | 714 | /* |
750 | * Setup new 3270 device. | 715 | * Setup new 3270 device. |
751 | */ | 716 | */ |
@@ -774,6 +739,10 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) | |||
774 | INIT_LIST_HEAD(&rp->req_queue); | 739 | INIT_LIST_HEAD(&rp->req_queue); |
775 | INIT_LIST_HEAD(&rp->view_list); | 740 | INIT_LIST_HEAD(&rp->view_list); |
776 | 741 | ||
742 | rp->init_view.dev = rp; | ||
743 | rp->init_view.fn = &raw3270_init_fn; | ||
744 | rp->view = &rp->init_view; | ||
745 | |||
777 | /* | 746 | /* |
778 | * Add device to list and find the smallest unused minor | 747 | * Add device to list and find the smallest unused minor |
779 | * number for it. Note: there is no device with minor 0, | 748 | * number for it. Note: there is no device with minor 0, |
@@ -812,6 +781,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) | |||
812 | */ | 781 | */ |
813 | struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) | 782 | struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) |
814 | { | 783 | { |
784 | unsigned long flags; | ||
815 | struct raw3270 *rp; | 785 | struct raw3270 *rp; |
816 | char *ascebc; | 786 | char *ascebc; |
817 | int rc; | 787 | int rc; |
@@ -822,16 +792,15 @@ struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) | |||
822 | if (rc) | 792 | if (rc) |
823 | return ERR_PTR(rc); | 793 | return ERR_PTR(rc); |
824 | set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags); | 794 | set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags); |
825 | rc = raw3270_reset_device(rp); | 795 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
826 | if (rc) | 796 | do { |
827 | return ERR_PTR(rc); | 797 | __raw3270_reset_device(rp); |
828 | rc = raw3270_size_device(rp); | 798 | while (!raw3270_state_final(rp)) { |
829 | if (rc) | 799 | wait_cons_dev(); |
830 | return ERR_PTR(rc); | 800 | barrier(); |
831 | rc = raw3270_reset_device(rp); | 801 | } |
832 | if (rc) | 802 | } while (rp->state != RAW3270_STATE_READY); |
833 | return ERR_PTR(rc); | 803 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
834 | set_bit(RAW3270_FLAGS_READY, &rp->flags); | ||
835 | return rp; | 804 | return rp; |
836 | } | 805 | } |
837 | 806 | ||
@@ -893,13 +862,13 @@ raw3270_activate_view(struct raw3270_view *view) | |||
893 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 862 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
894 | if (rp->view == view) | 863 | if (rp->view == view) |
895 | rc = 0; | 864 | rc = 0; |
896 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 865 | else if (!raw3270_state_ready(rp)) |
897 | rc = -ENODEV; | 866 | rc = -EBUSY; |
898 | else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 867 | else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
899 | rc = -EACCES; | 868 | rc = -EACCES; |
900 | else { | 869 | else { |
901 | oldview = NULL; | 870 | oldview = NULL; |
902 | if (rp->view) { | 871 | if (rp->view && rp->view->fn->deactivate) { |
903 | oldview = rp->view; | 872 | oldview = rp->view; |
904 | oldview->fn->deactivate(oldview); | 873 | oldview->fn->deactivate(oldview); |
905 | } | 874 | } |
@@ -944,7 +913,7 @@ raw3270_deactivate_view(struct raw3270_view *view) | |||
944 | list_del_init(&view->list); | 913 | list_del_init(&view->list); |
945 | list_add_tail(&view->list, &rp->view_list); | 914 | list_add_tail(&view->list, &rp->view_list); |
946 | /* Try to activate another view. */ | 915 | /* Try to activate another view. */ |
947 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags) && | 916 | if (raw3270_state_ready(rp) && |
948 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { | 917 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { |
949 | list_for_each_entry(view, &rp->view_list, list) { | 918 | list_for_each_entry(view, &rp->view_list, list) { |
950 | rp->view = view; | 919 | rp->view = view; |
@@ -975,18 +944,16 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) | |||
975 | if (rp->minor != minor) | 944 | if (rp->minor != minor) |
976 | continue; | 945 | continue; |
977 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 946 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
978 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags)) { | 947 | atomic_set(&view->ref_count, 2); |
979 | atomic_set(&view->ref_count, 2); | 948 | view->dev = rp; |
980 | view->dev = rp; | 949 | view->fn = fn; |
981 | view->fn = fn; | 950 | view->model = rp->model; |
982 | view->model = rp->model; | 951 | view->rows = rp->rows; |
983 | view->rows = rp->rows; | 952 | view->cols = rp->cols; |
984 | view->cols = rp->cols; | 953 | view->ascebc = rp->ascebc; |
985 | view->ascebc = rp->ascebc; | 954 | spin_lock_init(&view->lock); |
986 | spin_lock_init(&view->lock); | 955 | list_add(&view->list, &rp->view_list); |
987 | list_add(&view->list, &rp->view_list); | 956 | rc = 0; |
988 | rc = 0; | ||
989 | } | ||
990 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 957 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
991 | break; | 958 | break; |
992 | } | 959 | } |
@@ -1010,14 +977,11 @@ raw3270_find_view(struct raw3270_fn *fn, int minor) | |||
1010 | if (rp->minor != minor) | 977 | if (rp->minor != minor) |
1011 | continue; | 978 | continue; |
1012 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 979 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1013 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags)) { | 980 | list_for_each_entry(tmp, &rp->view_list, list) { |
1014 | view = ERR_PTR(-ENOENT); | 981 | if (tmp->fn == fn) { |
1015 | list_for_each_entry(tmp, &rp->view_list, list) { | 982 | raw3270_get_view(tmp); |
1016 | if (tmp->fn == fn) { | 983 | view = tmp; |
1017 | raw3270_get_view(tmp); | 984 | break; |
1018 | view = tmp; | ||
1019 | break; | ||
1020 | } | ||
1021 | } | 985 | } |
1022 | } | 986 | } |
1023 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 987 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
@@ -1044,7 +1008,7 @@ raw3270_del_view(struct raw3270_view *view) | |||
1044 | rp->view = NULL; | 1008 | rp->view = NULL; |
1045 | } | 1009 | } |
1046 | list_del_init(&view->list); | 1010 | list_del_init(&view->list); |
1047 | if (!rp->view && test_bit(RAW3270_FLAGS_READY, &rp->flags) && | 1011 | if (!rp->view && raw3270_state_ready(rp) && |
1048 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { | 1012 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { |
1049 | /* Try to activate another view. */ | 1013 | /* Try to activate another view. */ |
1050 | list_for_each_entry(nv, &rp->view_list, list) { | 1014 | list_for_each_entry(nv, &rp->view_list, list) { |
@@ -1072,10 +1036,6 @@ raw3270_delete_device(struct raw3270 *rp) | |||
1072 | 1036 | ||
1073 | /* Remove from device chain. */ | 1037 | /* Remove from device chain. */ |
1074 | mutex_lock(&raw3270_mutex); | 1038 | mutex_lock(&raw3270_mutex); |
1075 | if (rp->clttydev && !IS_ERR(rp->clttydev)) | ||
1076 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1077 | if (rp->cltubdev && !IS_ERR(rp->cltubdev)) | ||
1078 | device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, rp->minor)); | ||
1079 | list_del_init(&rp->list); | 1039 | list_del_init(&rp->list); |
1080 | mutex_unlock(&raw3270_mutex); | 1040 | mutex_unlock(&raw3270_mutex); |
1081 | 1041 | ||
@@ -1139,75 +1099,34 @@ static struct attribute_group raw3270_attr_group = { | |||
1139 | 1099 | ||
1140 | static int raw3270_create_attributes(struct raw3270 *rp) | 1100 | static int raw3270_create_attributes(struct raw3270 *rp) |
1141 | { | 1101 | { |
1142 | int rc; | 1102 | return sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); |
1143 | |||
1144 | rc = sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1145 | if (rc) | ||
1146 | goto out; | ||
1147 | |||
1148 | rp->clttydev = device_create(class3270, &rp->cdev->dev, | ||
1149 | MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL, | ||
1150 | "tty%s", dev_name(&rp->cdev->dev)); | ||
1151 | if (IS_ERR(rp->clttydev)) { | ||
1152 | rc = PTR_ERR(rp->clttydev); | ||
1153 | goto out_ttydev; | ||
1154 | } | ||
1155 | |||
1156 | rp->cltubdev = device_create(class3270, &rp->cdev->dev, | ||
1157 | MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL, | ||
1158 | "tub%s", dev_name(&rp->cdev->dev)); | ||
1159 | if (!IS_ERR(rp->cltubdev)) | ||
1160 | goto out; | ||
1161 | |||
1162 | rc = PTR_ERR(rp->cltubdev); | ||
1163 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1164 | |||
1165 | out_ttydev: | ||
1166 | sysfs_remove_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1167 | out: | ||
1168 | return rc; | ||
1169 | } | 1103 | } |
1170 | 1104 | ||
1171 | /* | 1105 | /* |
1172 | * Notifier for device addition/removal | 1106 | * Notifier for device addition/removal |
1173 | */ | 1107 | */ |
1174 | struct raw3270_notifier { | ||
1175 | struct list_head list; | ||
1176 | void (*notifier)(int, int); | ||
1177 | }; | ||
1178 | |||
1179 | static LIST_HEAD(raw3270_notifier); | 1108 | static LIST_HEAD(raw3270_notifier); |
1180 | 1109 | ||
1181 | int raw3270_register_notifier(void (*notifier)(int, int)) | 1110 | int raw3270_register_notifier(struct raw3270_notifier *notifier) |
1182 | { | 1111 | { |
1183 | struct raw3270_notifier *np; | ||
1184 | struct raw3270 *rp; | 1112 | struct raw3270 *rp; |
1185 | 1113 | ||
1186 | np = kmalloc(sizeof(struct raw3270_notifier), GFP_KERNEL); | ||
1187 | if (!np) | ||
1188 | return -ENOMEM; | ||
1189 | np->notifier = notifier; | ||
1190 | mutex_lock(&raw3270_mutex); | 1114 | mutex_lock(&raw3270_mutex); |
1191 | list_add_tail(&np->list, &raw3270_notifier); | 1115 | list_add_tail(¬ifier->list, &raw3270_notifier); |
1192 | list_for_each_entry(rp, &raw3270_devices, list) { | 1116 | list_for_each_entry(rp, &raw3270_devices, list) |
1193 | get_device(&rp->cdev->dev); | 1117 | notifier->create(rp->minor); |
1194 | notifier(rp->minor, 1); | ||
1195 | } | ||
1196 | mutex_unlock(&raw3270_mutex); | 1118 | mutex_unlock(&raw3270_mutex); |
1197 | return 0; | 1119 | return 0; |
1198 | } | 1120 | } |
1199 | 1121 | ||
1200 | void raw3270_unregister_notifier(void (*notifier)(int, int)) | 1122 | void raw3270_unregister_notifier(struct raw3270_notifier *notifier) |
1201 | { | 1123 | { |
1202 | struct raw3270_notifier *np; | 1124 | struct raw3270 *rp; |
1203 | 1125 | ||
1204 | mutex_lock(&raw3270_mutex); | 1126 | mutex_lock(&raw3270_mutex); |
1205 | list_for_each_entry(np, &raw3270_notifier, list) | 1127 | list_for_each_entry(rp, &raw3270_devices, list) |
1206 | if (np->notifier == notifier) { | 1128 | notifier->destroy(rp->minor); |
1207 | list_del(&np->list); | 1129 | list_del(¬ifier->list); |
1208 | kfree(np); | ||
1209 | break; | ||
1210 | } | ||
1211 | mutex_unlock(&raw3270_mutex); | 1130 | mutex_unlock(&raw3270_mutex); |
1212 | } | 1131 | } |
1213 | 1132 | ||
@@ -1217,29 +1136,20 @@ void raw3270_unregister_notifier(void (*notifier)(int, int)) | |||
1217 | static int | 1136 | static int |
1218 | raw3270_set_online (struct ccw_device *cdev) | 1137 | raw3270_set_online (struct ccw_device *cdev) |
1219 | { | 1138 | { |
1220 | struct raw3270 *rp; | ||
1221 | struct raw3270_notifier *np; | 1139 | struct raw3270_notifier *np; |
1140 | struct raw3270 *rp; | ||
1222 | int rc; | 1141 | int rc; |
1223 | 1142 | ||
1224 | rp = raw3270_create_device(cdev); | 1143 | rp = raw3270_create_device(cdev); |
1225 | if (IS_ERR(rp)) | 1144 | if (IS_ERR(rp)) |
1226 | return PTR_ERR(rp); | 1145 | return PTR_ERR(rp); |
1227 | rc = raw3270_reset_device(rp); | ||
1228 | if (rc) | ||
1229 | goto failure; | ||
1230 | rc = raw3270_size_device(rp); | ||
1231 | if (rc) | ||
1232 | goto failure; | ||
1233 | rc = raw3270_reset_device(rp); | ||
1234 | if (rc) | ||
1235 | goto failure; | ||
1236 | rc = raw3270_create_attributes(rp); | 1146 | rc = raw3270_create_attributes(rp); |
1237 | if (rc) | 1147 | if (rc) |
1238 | goto failure; | 1148 | goto failure; |
1239 | set_bit(RAW3270_FLAGS_READY, &rp->flags); | 1149 | raw3270_reset_device(rp); |
1240 | mutex_lock(&raw3270_mutex); | 1150 | mutex_lock(&raw3270_mutex); |
1241 | list_for_each_entry(np, &raw3270_notifier, list) | 1151 | list_for_each_entry(np, &raw3270_notifier, list) |
1242 | np->notifier(rp->minor, 1); | 1152 | np->create(rp->minor); |
1243 | mutex_unlock(&raw3270_mutex); | 1153 | mutex_unlock(&raw3270_mutex); |
1244 | return 0; | 1154 | return 0; |
1245 | 1155 | ||
@@ -1268,14 +1178,14 @@ raw3270_remove (struct ccw_device *cdev) | |||
1268 | */ | 1178 | */ |
1269 | if (rp == NULL) | 1179 | if (rp == NULL) |
1270 | return; | 1180 | return; |
1271 | clear_bit(RAW3270_FLAGS_READY, &rp->flags); | ||
1272 | 1181 | ||
1273 | sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group); | 1182 | sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group); |
1274 | 1183 | ||
1275 | /* Deactivate current view and remove all views. */ | 1184 | /* Deactivate current view and remove all views. */ |
1276 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); | 1185 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
1277 | if (rp->view) { | 1186 | if (rp->view) { |
1278 | rp->view->fn->deactivate(rp->view); | 1187 | if (rp->view->fn->deactivate) |
1188 | rp->view->fn->deactivate(rp->view); | ||
1279 | rp->view = NULL; | 1189 | rp->view = NULL; |
1280 | } | 1190 | } |
1281 | while (!list_empty(&rp->view_list)) { | 1191 | while (!list_empty(&rp->view_list)) { |
@@ -1290,7 +1200,7 @@ raw3270_remove (struct ccw_device *cdev) | |||
1290 | 1200 | ||
1291 | mutex_lock(&raw3270_mutex); | 1201 | mutex_lock(&raw3270_mutex); |
1292 | list_for_each_entry(np, &raw3270_notifier, list) | 1202 | list_for_each_entry(np, &raw3270_notifier, list) |
1293 | np->notifier(rp->minor, 0); | 1203 | np->destroy(rp->minor); |
1294 | mutex_unlock(&raw3270_mutex); | 1204 | mutex_unlock(&raw3270_mutex); |
1295 | 1205 | ||
1296 | /* Reset 3270 device. */ | 1206 | /* Reset 3270 device. */ |
@@ -1324,7 +1234,7 @@ static int raw3270_pm_stop(struct ccw_device *cdev) | |||
1324 | if (!rp) | 1234 | if (!rp) |
1325 | return 0; | 1235 | return 0; |
1326 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 1236 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1327 | if (rp->view) | 1237 | if (rp->view && rp->view->fn->deactivate) |
1328 | rp->view->fn->deactivate(rp->view); | 1238 | rp->view->fn->deactivate(rp->view); |
1329 | if (!test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags)) { | 1239 | if (!test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags)) { |
1330 | /* | 1240 | /* |
@@ -1351,7 +1261,7 @@ static int raw3270_pm_start(struct ccw_device *cdev) | |||
1351 | return 0; | 1261 | return 0; |
1352 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 1262 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1353 | clear_bit(RAW3270_FLAGS_FROZEN, &rp->flags); | 1263 | clear_bit(RAW3270_FLAGS_FROZEN, &rp->flags); |
1354 | if (rp->view) | 1264 | if (rp->view && rp->view->fn->activate) |
1355 | rp->view->fn->activate(rp->view); | 1265 | rp->view->fn->activate(rp->view); |
1356 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 1266 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
1357 | return 0; | 1267 | return 0; |
@@ -1434,6 +1344,7 @@ MODULE_LICENSE("GPL"); | |||
1434 | module_init(raw3270_init); | 1344 | module_init(raw3270_init); |
1435 | module_exit(raw3270_exit); | 1345 | module_exit(raw3270_exit); |
1436 | 1346 | ||
1347 | EXPORT_SYMBOL(class3270); | ||
1437 | EXPORT_SYMBOL(raw3270_request_alloc); | 1348 | EXPORT_SYMBOL(raw3270_request_alloc); |
1438 | EXPORT_SYMBOL(raw3270_request_free); | 1349 | EXPORT_SYMBOL(raw3270_request_free); |
1439 | EXPORT_SYMBOL(raw3270_request_reset); | 1350 | EXPORT_SYMBOL(raw3270_request_reset); |