]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/s390/char/tape_3590.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[linux-2.6-omap-h63xx.git] / drivers / s390 / char / tape_3590.c
index 9f244c591eeb320c3533368f84a53595d6c5ae4c..42ce7915fc5d7cc1bce71aaa60c867f12cb16894 100644 (file)
@@ -708,16 +708,22 @@ static void tape_3590_med_state_set(struct tape_device *device,
 
        c_info = &TAPE_3590_CRYPT_INFO(device);
 
-       if (sense->masst == MSENSE_UNASSOCIATED) {
+       DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst);
+       switch (sense->macst) {
+       case 0x04:
+       case 0x05:
+       case 0x06:
                tape_med_state_set(device, MS_UNLOADED);
                TAPE_3590_CRYPT_INFO(device).medium_status = 0;
                return;
-       }
-       if (sense->masst != MSENSE_ASSOCIATED_MOUNT) {
-               PRINT_ERR("Unknown medium state: %x\n", sense->masst);
+       case 0x08:
+       case 0x09:
+               tape_med_state_set(device, MS_LOADED);
+               break;
+       default:
+               tape_med_state_set(device, MS_UNKNOWN);
                return;
        }
-       tape_med_state_set(device, MS_LOADED);
        c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK;
        if (sense->flags & MSENSE_CRYPT_MASK) {
                PRINT_INFO("Medium is encrypted (%04x)\n", sense->flags);
@@ -835,15 +841,17 @@ tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
                /* Probably result of halt ssch */
                return TAPE_IO_PENDING;
        else if (irb->scsw.dstat == 0x85)
-               /* Device Ready -> check medium state */
-               tape_3590_schedule_work(device, TO_MSEN);
-       else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
+               /* Device Ready */
+               DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id);
+       else if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
                tape_3590_schedule_work(device, TO_READ_ATTMSG);
-       else {
+       else {
                DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
                PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
                tape_dump_sense(device, NULL, irb);
        }
+       /* check medium state */
+       tape_3590_schedule_work(device, TO_MSEN);
        return TAPE_IO_SUCCESS;
 }
 
@@ -1487,7 +1495,7 @@ tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
                           device->cdev->dev.bus_id);
                return tape_3590_erp_basic(device, request, irb, -EPERM);
        case 0x8013:
-               PRINT_WARN("(%s): Another host has priviliged access to the "
+               PRINT_WARN("(%s): Another host has privileged access to the "
                           "tape device\n", device->cdev->dev.bus_id);
                PRINT_WARN("(%s): To solve the problem unload the current "
                           "cartridge!\n", device->cdev->dev.bus_id);
@@ -1590,7 +1598,7 @@ tape_3590_setup_device(struct tape_device *device)
        rc = tape_3590_read_dev_chars(device, rdc_data);
        if (rc) {
                DBF_LH(3, "Read device characteristics failed!\n");
-               goto fail_kmalloc;
+               goto fail_rdc_data;
        }
        rc = tape_std_assign(device);
        if (rc)