Skip to contentSkip to conversation

scsi: sr: simplify the sr_open function

PATCH Applied Enze Li 4 participants 5 messages Mar 27, 2023 – Apr 12, 2023 SCSI

lore
Share & tools
lore

Enze Li

author
#0 lore raw

PATCH 1/1 scsi: sr: simplify the sr_open function

Simplify the sr_open function by removing the goto label as it does only return one error code.

---
 drivers/scsi/sr.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/sr.c +1 -6
index 9e51dcd30bfd..12869e6d4ebd 100644
@@ -590,20 +590,15 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
 {
 	struct scsi_cd *cd = cdi->handle;
 	struct scsi_device *sdev = cd->device;
-	int retval;
 
 	/*
 	 * If the device is in error recovery, wait until it is done.
 	 * If the device is offline, then disallow any access to it.
 	 */
-	retval = -ENXIO;
 	if (!scsi_block_when_processing_errors(sdev))
-		goto error_out;
+		return -ENXIO;
 
 	return 0;
-
-error_out:
-	return retval;	
 }
 
 static void sr_release(struct cdrom_device_info *cdi)
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Enze Li

Simplify the sr_open function by removing the goto label as it does only return one error code.

---
  drivers/scsi/sr.c | 7 +------
  1 file changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/sr.c +0 -1
index 9e51dcd30bfd..12869e6d4ebd 100644
@@ -590,20 +590,15 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
  {
  	struct scsi_cd *cd = cdi->handle;
  	struct scsi_device *sdev = cd->device;
-	int retval;
 
  	/*
  	 * If the device is in error recovery, wait until it is done.
  	 * If the device is offline, then disallow any access to it.
  	 */

drivers/scsi/sr.c static int sr_open(struct cdrom_device_info *cdi, int purpose) · line 602

Quoted 10 lines
drivers/scsi/sr.c +1 -5
-	retval = -ENXIO;
  	if (!scsi_block_when_processing_errors(sdev))
-		goto error_out;
+		return -ENXIO;
 
  	return 0;
-
-error_out:
-	return retval;	
  }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Enze Li
Quoted 8 lines · Enze Li

Simplify the sr_open function by removing the goto label as it does only return one error code.

---
 drivers/scsi/sr.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Looks good to me.

Signature · 4 lines
Best Regards, Benjamin Block        /        Linux on IBM Z Kernel Development
IBM Deutschland Research & Development GmbH    /   https://www.ibm.com/privacy
Vors. Aufs.-R.: Gregor Pillen         /         Geschäftsführung: David Faller
Sitz der Ges.: Böblingen     /    Registergericht: AmtsG Stuttgart, HRB 243294
#3 lore raw
In reply to Enze Li

Enze,

Quoted 2 lines

Simplify the sr_open function by removing the goto label as it does only return one error code.

Applied to 6.4/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering