@@ -1792,17 +1792,19 @@ static void ata_scsi_rbuf_fill(struct ata_device *dev, struct scsi_cmnd *cmd,
1792
1792
unsigned int (* actor )(struct ata_device * dev ,
1793
1793
struct scsi_cmnd * cmd , u8 * rbuf ))
1794
1794
{
1795
- unsigned int rc ;
1796
1795
unsigned long flags ;
1796
+ unsigned int len ;
1797
1797
1798
1798
spin_lock_irqsave (& ata_scsi_rbuf_lock , flags );
1799
1799
1800
1800
memset (ata_scsi_rbuf , 0 , ATA_SCSI_RBUF_SIZE );
1801
- rc = actor (dev , cmd , ata_scsi_rbuf );
1802
- if (rc == 0 ) {
1801
+ len = actor (dev , cmd , ata_scsi_rbuf );
1802
+ if (len ) {
1803
1803
sg_copy_from_buffer (scsi_sglist (cmd ), scsi_sg_count (cmd ),
1804
1804
ata_scsi_rbuf , ATA_SCSI_RBUF_SIZE );
1805
1805
cmd -> result = SAM_STAT_GOOD ;
1806
+ if (scsi_bufflen (cmd ) > len )
1807
+ scsi_set_resid (cmd , scsi_bufflen (cmd ) - len );
1806
1808
}
1807
1809
1808
1810
spin_unlock_irqrestore (& ata_scsi_rbuf_lock , flags );
@@ -1890,7 +1892,11 @@ static unsigned int ata_scsiop_inq_std(struct ata_device *dev,
1890
1892
else
1891
1893
memcpy (rbuf + 58 , versions , sizeof (versions ));
1892
1894
1893
- return 0 ;
1895
+ /*
1896
+ * Include all 8 possible version descriptors, even if not all of
1897
+ * them are popoulated.
1898
+ */
1899
+ return 96 ;
1894
1900
}
1895
1901
1896
1902
/**
@@ -1928,7 +1934,8 @@ static unsigned int ata_scsiop_inq_00(struct ata_device *dev,
1928
1934
num_pages ++ ;
1929
1935
}
1930
1936
rbuf [3 ] = num_pages ; /* number of supported VPD pages */
1931
- return 0 ;
1937
+
1938
+ return get_unaligned_be16 (& rbuf [2 ]) + 4 ;
1932
1939
}
1933
1940
1934
1941
/**
@@ -1955,7 +1962,8 @@ static unsigned int ata_scsiop_inq_80(struct ata_device *dev,
1955
1962
memcpy (rbuf , hdr , sizeof (hdr ));
1956
1963
ata_id_string (dev -> id , (unsigned char * ) & rbuf [4 ],
1957
1964
ATA_ID_SERNO , ATA_ID_SERNO_LEN );
1958
- return 0 ;
1965
+
1966
+ return get_unaligned_be16 (& rbuf [2 ]) + 4 ;
1959
1967
}
1960
1968
1961
1969
/**
@@ -2016,7 +2024,8 @@ static unsigned int ata_scsiop_inq_83(struct ata_device *dev,
2016
2024
num += ATA_ID_WWN_LEN ;
2017
2025
}
2018
2026
rbuf [3 ] = num - 4 ; /* page len (assume less than 256 bytes) */
2019
- return 0 ;
2027
+
2028
+ return get_unaligned_be16 (& rbuf [2 ]) + 4 ;
2020
2029
}
2021
2030
2022
2031
/**
@@ -2053,7 +2062,8 @@ static unsigned int ata_scsiop_inq_89(struct ata_device *dev,
2053
2062
rbuf [56 ] = ATA_CMD_ID_ATA ;
2054
2063
2055
2064
memcpy (& rbuf [60 ], & dev -> id [0 ], 512 );
2056
- return 0 ;
2065
+
2066
+ return get_unaligned_be16 (& rbuf [2 ]) + 4 ;
2057
2067
}
2058
2068
2059
2069
/**
@@ -2104,7 +2114,7 @@ static unsigned int ata_scsiop_inq_b0(struct ata_device *dev,
2104
2114
put_unaligned_be32 (1 , & rbuf [28 ]);
2105
2115
}
2106
2116
2107
- return 0 ;
2117
+ return get_unaligned_be16 ( & rbuf [ 2 ]) + 4 ;
2108
2118
}
2109
2119
2110
2120
/**
@@ -2134,7 +2144,7 @@ static unsigned int ata_scsiop_inq_b1(struct ata_device *dev,
2134
2144
if (zoned )
2135
2145
rbuf [8 ] = (zoned << 4 );
2136
2146
2137
- return 0 ;
2147
+ return get_unaligned_be16 ( & rbuf [ 2 ]) + 4 ;
2138
2148
}
2139
2149
2140
2150
/**
@@ -2157,7 +2167,7 @@ static unsigned int ata_scsiop_inq_b2(struct ata_device *dev,
2157
2167
rbuf [3 ] = 0x4 ;
2158
2168
rbuf [5 ] = 1 << 6 ; /* TPWS */
2159
2169
2160
- return 0 ;
2170
+ return get_unaligned_be16 ( & rbuf [ 2 ]) + 4 ;
2161
2171
}
2162
2172
2163
2173
/**
@@ -2177,7 +2187,7 @@ static unsigned int ata_scsiop_inq_b6(struct ata_device *dev,
2177
2187
{
2178
2188
if (!(dev -> flags & ATA_DFLAG_ZAC )) {
2179
2189
ata_scsi_set_invalid_field (dev , cmd , 2 , 0xff );
2180
- return 1 ;
2190
+ return 0 ;
2181
2191
}
2182
2192
2183
2193
/*
@@ -2195,7 +2205,7 @@ static unsigned int ata_scsiop_inq_b6(struct ata_device *dev,
2195
2205
put_unaligned_be32 (dev -> zac_zones_optimal_nonseq , & rbuf [12 ]);
2196
2206
put_unaligned_be32 (dev -> zac_zones_max_open , & rbuf [16 ]);
2197
2207
2198
- return 0 ;
2208
+ return get_unaligned_be16 ( & rbuf [ 2 ]) + 4 ;
2199
2209
}
2200
2210
2201
2211
/**
@@ -2219,7 +2229,7 @@ static unsigned int ata_scsiop_inq_b9(struct ata_device *dev,
2219
2229
2220
2230
if (!cpr_log ) {
2221
2231
ata_scsi_set_invalid_field (dev , cmd , 2 , 0xff );
2222
- return 1 ;
2232
+ return 0 ;
2223
2233
}
2224
2234
2225
2235
/* SCSI Concurrent Positioning Ranges VPD page: SBC-5 rev 1 or later */
@@ -2233,7 +2243,7 @@ static unsigned int ata_scsiop_inq_b9(struct ata_device *dev,
2233
2243
put_unaligned_be64 (cpr_log -> cpr [i ].num_lbas , & desc [16 ]);
2234
2244
}
2235
2245
2236
- return 0 ;
2246
+ return get_unaligned_be16 ( & rbuf [ 2 ]) + 4 ;
2237
2247
}
2238
2248
2239
2249
/**
@@ -2255,7 +2265,7 @@ static unsigned int ata_scsiop_inquiry(struct ata_device *dev,
2255
2265
/* is CmdDt set? */
2256
2266
if (scsicmd [1 ] & 2 ) {
2257
2267
ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
2258
- return 1 ;
2268
+ return 0 ;
2259
2269
}
2260
2270
2261
2271
/* Is EVPD clear? */
@@ -2283,7 +2293,7 @@ static unsigned int ata_scsiop_inquiry(struct ata_device *dev,
2283
2293
return ata_scsiop_inq_b9 (dev , cmd , rbuf );
2284
2294
default :
2285
2295
ata_scsi_set_invalid_field (dev , cmd , 2 , 0xff );
2286
- return 1 ;
2296
+ return 0 ;
2287
2297
}
2288
2298
}
2289
2299
@@ -2614,24 +2624,27 @@ static unsigned int ata_scsiop_mode_sense(struct ata_device *dev,
2614
2624
rbuf [3 ] = sizeof (sat_blk_desc );
2615
2625
memcpy (rbuf + 4 , sat_blk_desc , sizeof (sat_blk_desc ));
2616
2626
}
2617
- } else {
2618
- put_unaligned_be16 (p - rbuf - 2 , & rbuf [0 ]);
2619
- rbuf [3 ] |= dpofua ;
2620
- if (ebd ) {
2621
- rbuf [7 ] = sizeof (sat_blk_desc );
2622
- memcpy (rbuf + 8 , sat_blk_desc , sizeof (sat_blk_desc ));
2623
- }
2627
+
2628
+ return rbuf [0 ] + 1 ;
2629
+ }
2630
+
2631
+ put_unaligned_be16 (p - rbuf - 2 , & rbuf [0 ]);
2632
+ rbuf [3 ] |= dpofua ;
2633
+ if (ebd ) {
2634
+ rbuf [7 ] = sizeof (sat_blk_desc );
2635
+ memcpy (rbuf + 8 , sat_blk_desc , sizeof (sat_blk_desc ));
2624
2636
}
2625
- return 0 ;
2637
+
2638
+ return get_unaligned_be16 (& rbuf [0 ]) + 2 ;
2626
2639
2627
2640
invalid_fld :
2628
2641
ata_scsi_set_invalid_field (dev , cmd , fp , bp );
2629
- return 1 ;
2642
+ return 0 ;
2630
2643
2631
2644
saving_not_supp :
2632
2645
ata_scsi_set_sense (dev , cmd , ILLEGAL_REQUEST , 0x39 , 0x0 );
2633
2646
/* "Saving parameters not supported" */
2634
- return 1 ;
2647
+ return 0 ;
2635
2648
}
2636
2649
2637
2650
/**
@@ -2674,7 +2687,7 @@ static unsigned int ata_scsiop_read_cap(struct ata_device *dev,
2674
2687
rbuf [6 ] = sector_size >> (8 * 1 );
2675
2688
rbuf [7 ] = sector_size ;
2676
2689
2677
- return 0 ;
2690
+ return 8 ;
2678
2691
}
2679
2692
2680
2693
/*
@@ -2684,7 +2697,7 @@ static unsigned int ata_scsiop_read_cap(struct ata_device *dev,
2684
2697
if (scsicmd [0 ] != SERVICE_ACTION_IN_16 ||
2685
2698
(scsicmd [1 ] & 0x1f ) != SAI_READ_CAPACITY_16 ) {
2686
2699
ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
2687
- return 1 ;
2700
+ return 0 ;
2688
2701
}
2689
2702
2690
2703
/* sector count, 64-bit */
@@ -2719,7 +2732,7 @@ static unsigned int ata_scsiop_read_cap(struct ata_device *dev,
2719
2732
}
2720
2733
}
2721
2734
2722
- return 0 ;
2735
+ return 16 ;
2723
2736
}
2724
2737
2725
2738
/**
@@ -2738,7 +2751,7 @@ static unsigned int ata_scsiop_report_luns(struct ata_device *dev,
2738
2751
{
2739
2752
rbuf [3 ] = 8 ; /* just one lun, LUN 0, size 8 bytes */
2740
2753
2741
- return 0 ;
2754
+ return 16 ;
2742
2755
}
2743
2756
2744
2757
/*
@@ -3463,13 +3476,13 @@ static unsigned int ata_scsiop_maint_in(struct ata_device *dev,
3463
3476
3464
3477
if ((cdb [1 ] & 0x1f ) != MI_REPORT_SUPPORTED_OPERATION_CODES ) {
3465
3478
ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
3466
- return 1 ;
3479
+ return 0 ;
3467
3480
}
3468
3481
3469
3482
if (cdb [2 ] != 1 && cdb [2 ] != 3 ) {
3470
3483
ata_dev_warn (dev , "invalid command format %d\n" , cdb [2 ]);
3471
3484
ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
3472
- return 1 ;
3485
+ return 0 ;
3473
3486
}
3474
3487
3475
3488
switch (cdb [3 ]) {
@@ -3542,7 +3555,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_device *dev,
3542
3555
rbuf [0 ] = rwcdlp ;
3543
3556
rbuf [1 ] = cdlp | supported ;
3544
3557
3545
- return 0 ;
3558
+ return 4 ;
3546
3559
}
3547
3560
3548
3561
/**
0 commit comments