diff mbox series

scsi: sr: simplify the sr_open function

Message ID 20230327030237.3407253-1-lienze@kylinos.cn (mailing list archive)
State Accepted
Headers show
Series scsi: sr: simplify the sr_open function | expand

Commit Message

Enze Li March 27, 2023, 3:02 a.m. UTC
Simplify the sr_open function by removing the goto label as it does only
return one error code.

Signed-off-by: Enze Li <lienze@kylinos.cn>
---
 drivers/scsi/sr.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Bart Van Assche March 29, 2023, 8:50 p.m. UTC | #1
On 3/26/23 20:02, Enze Li wrote:
> Simplify the sr_open function by removing the goto label as it does only
> return one error code.
> 
> Signed-off-by: Enze Li <lienze@kylinos.cn>
> ---
>   drivers/scsi/sr.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
> index 9e51dcd30bfd..12869e6d4ebd 100644
> --- a/drivers/scsi/sr.c
> +++ b/drivers/scsi/sr.c
> @@ -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;	
>   }

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Benjamin Block March 30, 2023, 2:46 p.m. UTC | #2
On Mon, Mar 27, 2023 at 11:02:37AM +0800, Enze Li wrote:
> Simplify the sr_open function by removing the goto label as it does only
> return one error code.
> 
> Signed-off-by: Enze Li <lienze@kylinos.cn>
> ---
>  drivers/scsi/sr.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 

Looks good to me.


Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Martin K. Petersen April 3, 2023, 1:37 a.m. UTC | #3
Enze,

> 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!
Martin K. Petersen April 12, 2023, 2:04 a.m. UTC | #4
On Mon, 27 Mar 2023 11:02:37 +0800, Enze Li wrote:

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

Applied to 6.4/scsi-queue, thanks!

[1/1] scsi: sr: simplify the sr_open function
      https://git.kernel.org/mkp/scsi/c/ca62009eff72
diff mbox series

Patch

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 9e51dcd30bfd..12869e6d4ebd 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -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)