@@ -111,7 +111,7 @@ static struct lock_class_key sr_bio_compl_lkclass;
111
111
static int sr_open (struct cdrom_device_info * , int );
112
112
static void sr_release (struct cdrom_device_info * );
113
113
114
- static void get_sectorsize (struct scsi_cd * );
114
+ static int get_sectorsize (struct scsi_cd * );
115
115
static int get_capabilities (struct scsi_cd * );
116
116
117
117
static unsigned int sr_check_events (struct cdrom_device_info * cdi ,
@@ -473,15 +473,15 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
473
473
return BLK_STS_IOERR ;
474
474
}
475
475
476
- static void sr_revalidate_disk (struct scsi_cd * cd )
476
+ static int sr_revalidate_disk (struct scsi_cd * cd )
477
477
{
478
478
struct scsi_sense_hdr sshdr ;
479
479
480
480
/* if the unit is not ready, nothing more to do */
481
481
if (scsi_test_unit_ready (cd -> device , SR_TIMEOUT , MAX_RETRIES , & sshdr ))
482
- return ;
482
+ return 0 ;
483
483
sr_cd_check (& cd -> cdi );
484
- get_sectorsize (cd );
484
+ return get_sectorsize (cd );
485
485
}
486
486
487
487
static int sr_block_open (struct gendisk * disk , blk_mode_t mode )
@@ -494,13 +494,16 @@ static int sr_block_open(struct gendisk *disk, blk_mode_t mode)
494
494
return - ENXIO ;
495
495
496
496
scsi_autopm_get_device (sdev );
497
- if (disk_check_media_change (disk ))
498
- sr_revalidate_disk (cd );
497
+ if (disk_check_media_change (disk )) {
498
+ ret = sr_revalidate_disk (cd );
499
+ if (ret )
500
+ goto out ;
501
+ }
499
502
500
503
mutex_lock (& cd -> lock );
501
504
ret = cdrom_open (& cd -> cdi , mode );
502
505
mutex_unlock (& cd -> lock );
503
-
506
+ out :
504
507
scsi_autopm_put_device (sdev );
505
508
if (ret )
506
509
scsi_device_put (cd -> device );
@@ -685,7 +688,9 @@ static int sr_probe(struct device *dev)
685
688
blk_pm_runtime_init (sdev -> request_queue , dev );
686
689
687
690
dev_set_drvdata (dev , cd );
688
- sr_revalidate_disk (cd );
691
+ error = sr_revalidate_disk (cd );
692
+ if (error )
693
+ goto unregister_cdrom ;
689
694
690
695
error = device_add_disk (& sdev -> sdev_gendev , disk , NULL );
691
696
if (error )
@@ -714,13 +719,14 @@ static int sr_probe(struct device *dev)
714
719
}
715
720
716
721
717
- static void get_sectorsize (struct scsi_cd * cd )
722
+ static int get_sectorsize (struct scsi_cd * cd )
718
723
{
724
+ struct request_queue * q = cd -> device -> request_queue ;
719
725
static const u8 cmd [10 ] = { READ_CAPACITY };
720
726
unsigned char buffer [8 ] = { };
721
- int the_result ;
727
+ struct queue_limits lim ;
728
+ int err ;
722
729
int sector_size ;
723
- struct request_queue * queue ;
724
730
struct scsi_failure failure_defs [] = {
725
731
{
726
732
.result = SCMD_FAILURE_RESULT_ANY ,
@@ -736,10 +742,10 @@ static void get_sectorsize(struct scsi_cd *cd)
736
742
};
737
743
738
744
/* Do the command and wait.. */
739
- the_result = scsi_execute_cmd (cd -> device , cmd , REQ_OP_DRV_IN , buffer ,
745
+ err = scsi_execute_cmd (cd -> device , cmd , REQ_OP_DRV_IN , buffer ,
740
746
sizeof (buffer ), SR_TIMEOUT , MAX_RETRIES ,
741
747
& exec_args );
742
- if (the_result ) {
748
+ if (err ) {
743
749
cd -> capacity = 0x1fffff ;
744
750
sector_size = 2048 ; /* A guess, just in case */
745
751
} else {
@@ -789,10 +795,12 @@ static void get_sectorsize(struct scsi_cd *cd)
789
795
set_capacity (cd -> disk , cd -> capacity );
790
796
}
791
797
792
- queue = cd -> device -> request_queue ;
793
- blk_queue_logical_block_size (queue , sector_size );
794
-
795
- return ;
798
+ lim = queue_limits_start_update (q );
799
+ lim .logical_block_size = sector_size ;
800
+ blk_mq_freeze_queue (q );
801
+ err = queue_limits_commit_update (q , & lim );
802
+ blk_mq_unfreeze_queue (q );
803
+ return err ;
796
804
}
797
805
798
806
static int get_capabilities (struct scsi_cd * cd )
0 commit comments