@@ -247,7 +247,7 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_
247247{
248248 USBD_MSC_BOT_HandleTypeDef * hmsc = & ((usbd_cdc_msc_hid_state_t * )pdev -> pClassData )-> MSC_BOT_ClassData ;
249249
250- if (hmsc -> bdev_ops -> GetCapacity (lun , & hmsc -> scsi_blk_nbr , & hmsc -> scsi_blk_size ) != 0 )
250+ if (hmsc -> bdev_ops -> GetCapacity (lun , & hmsc -> scsi_blk_nbr [ lun ] , & hmsc -> scsi_blk_size [ lun ] ) != 0 )
251251 {
252252 SCSI_SenseCode (pdev ,
253253 lun ,
@@ -258,15 +258,17 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_
258258 else
259259 {
260260
261- hmsc -> bot_data [0 ] = (uint8_t )((hmsc -> scsi_blk_nbr - 1 ) >> 24 );
262- hmsc -> bot_data [1 ] = (uint8_t )((hmsc -> scsi_blk_nbr - 1 ) >> 16 );
263- hmsc -> bot_data [2 ] = (uint8_t )((hmsc -> scsi_blk_nbr - 1 ) >> 8 );
264- hmsc -> bot_data [3 ] = (uint8_t )(hmsc -> scsi_blk_nbr - 1 );
261+ uint32_t blk_nbr = hmsc -> scsi_blk_nbr [lun ];
262+ hmsc -> bot_data [0 ] = (uint8_t )((blk_nbr - 1 ) >> 24 );
263+ hmsc -> bot_data [1 ] = (uint8_t )((blk_nbr - 1 ) >> 16 );
264+ hmsc -> bot_data [2 ] = (uint8_t )((blk_nbr - 1 ) >> 8 );
265+ hmsc -> bot_data [3 ] = (uint8_t )(blk_nbr - 1 );
265266
266- hmsc -> bot_data [4 ] = (uint8_t )(hmsc -> scsi_blk_size >> 24 );
267- hmsc -> bot_data [5 ] = (uint8_t )(hmsc -> scsi_blk_size >> 16 );
268- hmsc -> bot_data [6 ] = (uint8_t )(hmsc -> scsi_blk_size >> 8 );
269- hmsc -> bot_data [7 ] = (uint8_t )(hmsc -> scsi_blk_size );
267+ uint32_t blk_size = hmsc -> scsi_blk_size [lun ];
268+ hmsc -> bot_data [4 ] = (uint8_t )(blk_size >> 24 );
269+ hmsc -> bot_data [5 ] = (uint8_t )(blk_size >> 16 );
270+ hmsc -> bot_data [6 ] = (uint8_t )(blk_size >> 8 );
271+ hmsc -> bot_data [7 ] = (uint8_t )(blk_size );
270272
271273 hmsc -> bot_data_length = 8 ;
272274 return 0 ;
@@ -516,7 +518,7 @@ static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *para
516518 }
517519
518520 hmsc -> bot_state = USBD_BOT_DATA_IN ;
519- hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size ;
521+ hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size [ lun ] ;
520522
521523 /* cases 4,5 : Hi <> Dn */
522524 if (hmsc -> cbw .dDataLength != hmsc -> scsi_blk_len )
@@ -596,7 +598,7 @@ static int8_t SCSI_Write10 (USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *pa
596598 return -1 ; /* error */
597599 }
598600
599- hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size ;
601+ hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size [ lun ] ;
600602
601603 /* cases 3,11,13 : Hn,Ho <> D0 */
602604 if (hmsc -> cbw .dDataLength != hmsc -> scsi_blk_len )
@@ -670,7 +672,7 @@ static int8_t SCSI_CheckAddressRange (USBD_HandleTypeDef *pdev, uint8_t lun , u
670672{
671673 USBD_MSC_BOT_HandleTypeDef * hmsc = & ((usbd_cdc_msc_hid_state_t * )pdev -> pClassData )-> MSC_BOT_ClassData ;
672674
673- if ((blk_offset + blk_nbr ) > hmsc -> scsi_blk_nbr )
675+ if ((blk_offset + blk_nbr ) > hmsc -> scsi_blk_nbr [ lun ] )
674676 {
675677 SCSI_SenseCode (pdev ,
676678 lun ,
@@ -697,7 +699,7 @@ static int8_t SCSI_ProcessRead (USBD_HandleTypeDef *pdev, uint8_t lun)
697699 if ( hmsc -> bdev_ops -> Read (lun ,
698700 hmsc -> bot_data ,
699701 hmsc -> scsi_blk_addr_in_blks ,
700- len / hmsc -> scsi_blk_size ) < 0 )
702+ len / hmsc -> scsi_blk_size [ lun ] ) < 0 )
701703 {
702704
703705 SCSI_SenseCode (pdev ,
@@ -714,7 +716,7 @@ static int8_t SCSI_ProcessRead (USBD_HandleTypeDef *pdev, uint8_t lun)
714716 len );
715717
716718
717- hmsc -> scsi_blk_addr_in_blks += len / hmsc -> scsi_blk_size ;
719+ hmsc -> scsi_blk_addr_in_blks += len / hmsc -> scsi_blk_size [ lun ] ;
718720 hmsc -> scsi_blk_len -= len ;
719721
720722 /* case 6 : Hi = Di */
@@ -744,7 +746,7 @@ static int8_t SCSI_ProcessWrite (USBD_HandleTypeDef *pdev, uint8_t lun)
744746 if (hmsc -> bdev_ops -> Write (lun ,
745747 hmsc -> bot_data ,
746748 hmsc -> scsi_blk_addr_in_blks ,
747- len / hmsc -> scsi_blk_size ) < 0 )
749+ len / hmsc -> scsi_blk_size [ lun ] ) < 0 )
748750 {
749751 SCSI_SenseCode (pdev ,
750752 lun ,
@@ -754,7 +756,7 @@ static int8_t SCSI_ProcessWrite (USBD_HandleTypeDef *pdev, uint8_t lun)
754756 }
755757
756758
757- hmsc -> scsi_blk_addr_in_blks += len / hmsc -> scsi_blk_size ;
759+ hmsc -> scsi_blk_addr_in_blks += len / hmsc -> scsi_blk_size [ lun ] ;
758760 hmsc -> scsi_blk_len -= len ;
759761
760762 /* case 12 : Ho = Do */
0 commit comments