@@ -247,7 +247,7 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_
247
247
{
248
248
USBD_MSC_BOT_HandleTypeDef * hmsc = & ((usbd_cdc_msc_hid_state_t * )pdev -> pClassData )-> MSC_BOT_ClassData ;
249
249
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 )
251
251
{
252
252
SCSI_SenseCode (pdev ,
253
253
lun ,
@@ -258,15 +258,17 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_
258
258
else
259
259
{
260
260
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 );
265
266
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 );
270
272
271
273
hmsc -> bot_data_length = 8 ;
272
274
return 0 ;
@@ -516,7 +518,7 @@ static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *para
516
518
}
517
519
518
520
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 ] ;
520
522
521
523
/* cases 4,5 : Hi <> Dn */
522
524
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
596
598
return -1 ; /* error */
597
599
}
598
600
599
- hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size ;
601
+ hmsc -> scsi_blk_len *= hmsc -> scsi_blk_size [ lun ] ;
600
602
601
603
/* cases 3,11,13 : Hn,Ho <> D0 */
602
604
if (hmsc -> cbw .dDataLength != hmsc -> scsi_blk_len )
@@ -670,7 +672,7 @@ static int8_t SCSI_CheckAddressRange (USBD_HandleTypeDef *pdev, uint8_t lun , u
670
672
{
671
673
USBD_MSC_BOT_HandleTypeDef * hmsc = & ((usbd_cdc_msc_hid_state_t * )pdev -> pClassData )-> MSC_BOT_ClassData ;
672
674
673
- if ((blk_offset + blk_nbr ) > hmsc -> scsi_blk_nbr )
675
+ if ((blk_offset + blk_nbr ) > hmsc -> scsi_blk_nbr [ lun ] )
674
676
{
675
677
SCSI_SenseCode (pdev ,
676
678
lun ,
@@ -697,7 +699,7 @@ static int8_t SCSI_ProcessRead (USBD_HandleTypeDef *pdev, uint8_t lun)
697
699
if ( hmsc -> bdev_ops -> Read (lun ,
698
700
hmsc -> bot_data ,
699
701
hmsc -> scsi_blk_addr_in_blks ,
700
- len / hmsc -> scsi_blk_size ) < 0 )
702
+ len / hmsc -> scsi_blk_size [ lun ] ) < 0 )
701
703
{
702
704
703
705
SCSI_SenseCode (pdev ,
@@ -714,7 +716,7 @@ static int8_t SCSI_ProcessRead (USBD_HandleTypeDef *pdev, uint8_t lun)
714
716
len );
715
717
716
718
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 ] ;
718
720
hmsc -> scsi_blk_len -= len ;
719
721
720
722
/* case 6 : Hi = Di */
@@ -744,7 +746,7 @@ static int8_t SCSI_ProcessWrite (USBD_HandleTypeDef *pdev, uint8_t lun)
744
746
if (hmsc -> bdev_ops -> Write (lun ,
745
747
hmsc -> bot_data ,
746
748
hmsc -> scsi_blk_addr_in_blks ,
747
- len / hmsc -> scsi_blk_size ) < 0 )
749
+ len / hmsc -> scsi_blk_size [ lun ] ) < 0 )
748
750
{
749
751
SCSI_SenseCode (pdev ,
750
752
lun ,
@@ -754,7 +756,7 @@ static int8_t SCSI_ProcessWrite (USBD_HandleTypeDef *pdev, uint8_t lun)
754
756
}
755
757
756
758
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 ] ;
758
760
hmsc -> scsi_blk_len -= len ;
759
761
760
762
/* case 12 : Ho = Do */
0 commit comments