Revision 2c20ae11

b/hw/ide/atapi.c
695 695
    int action, code;
696 696
    int max_len;
697 697

  
698
    if (buf[0] == GPCMD_MODE_SENSE_10) {
699
        max_len = ube16_to_cpu(buf + 7);
700
    } else {
701
        max_len = buf[4];
702
    }
703

  
698
    max_len = ube16_to_cpu(buf + 7);
704 699
    action = buf[2] >> 6;
705 700
    code = buf[2] & 0x3f;
706 701

  
......
708 703
    case 0: /* current values */
709 704
        switch(code) {
710 705
        case MODE_PAGE_R_W_ERROR: /* error recovery */
711
            cpu_to_ube16(&buf[0], 16 + 6);
706
            cpu_to_ube16(&buf[0], 16 - 2);
712 707
            buf[2] = 0x70;
713 708
            buf[3] = 0;
714 709
            buf[4] = 0;
......
727 722
            ide_atapi_cmd_reply(s, 16, max_len);
728 723
            break;
729 724
        case MODE_PAGE_AUDIO_CTL:
730
            cpu_to_ube16(&buf[0], 24 + 6);
725
            cpu_to_ube16(&buf[0], 24 - 2);
731 726
            buf[2] = 0x70;
732 727
            buf[3] = 0;
733 728
            buf[4] = 0;
......
746 741
            ide_atapi_cmd_reply(s, 24, max_len);
747 742
            break;
748 743
        case MODE_PAGE_CAPABILITIES:
749
            cpu_to_ube16(&buf[0], 28 + 6);
744
            cpu_to_ube16(&buf[0], 30 - 2);
750 745
            buf[2] = 0x70;
751 746
            buf[3] = 0;
752 747
            buf[4] = 0;
......
755 750
            buf[7] = 0;
756 751

  
757 752
            buf[8] = MODE_PAGE_CAPABILITIES;
758
            buf[9] = 28 - 10;
753
            buf[9] = 30 - 10;
759 754
            buf[10] = 0x3b; /* read CDR/CDRW/DVDROM/DVDR/DVDRAM */
760 755
            buf[11] = 0x00;
761 756

  
......
777 772
            buf[25] = 0;
778 773
            buf[26] = 0;
779 774
            buf[27] = 0;
780
            ide_atapi_cmd_reply(s, 28, max_len);
775
            buf[28] = 0;
776
            buf[29] = 0;
777
            ide_atapi_cmd_reply(s, 30, max_len);
781 778
            break;
782 779
        default:
783 780
            goto error_cmd;
......
1043 1040
    [ 0x00 ] = { cmd_test_unit_ready,               CHECK_READY },
1044 1041
    [ 0x03 ] = { cmd_request_sense,                 ALLOW_UA },
1045 1042
    [ 0x12 ] = { cmd_inquiry,                       ALLOW_UA },
1046
    [ 0x1a ] = { cmd_mode_sense, /* (6) */          0 },
1047 1043
    [ 0x1b ] = { cmd_start_stop_unit,               0 }, /* [1] */
1048 1044
    [ 0x1e ] = { cmd_prevent_allow_medium_removal,  0 },
1049 1045
    [ 0x25 ] = { cmd_read_cdvd_capacity,            CHECK_READY },

Also available in: Unified diff