diff mbox

[v4] libata-scsi: minor cleanup in ata_mselect_*()

Message ID 578e979d.d40c620a.f5800.0924@mx.google.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Tom Yan July 19, 2016, 9:11 p.m. UTC
From: Tom Yan <tom.ty89@gmail.com>

1. Removed a repeated bit masking in ata_mselect_control()
2. Moved `wce`/`d_sense` assignment below the page validity checks
3. Added/Removed empty lines where appropriate

Signed-off-by: Tom Yan <tom.ty89@gmail.com>

Comments

Tom Yan July 19, 2016, 11:03 p.m. UTC | #1
Wrongly marked this as a "v4". It's actually a "v1".

On 20 July 2016 at 05:11,  <tom.ty89@gmail.com> wrote:
> From: Tom Yan <tom.ty89@gmail.com>
>
> 1. Removed a repeated bit masking in ata_mselect_control()
> 2. Moved `wce`/`d_sense` assignment below the page validity checks
> 3. Added/Removed empty lines where appropriate
>
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index b00521b..06afe63 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3604,7 +3604,6 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
>          * The first two bytes of def_cache_mpage are a header, so offsets
>          * in mpage are off by 2 compared to buf.  Same for len.
>          */
> -
>         if (len != CACHE_MPAGE_LEN - 2) {
>                 if (len < CACHE_MPAGE_LEN - 2)
>                         *fp = len;
> @@ -3613,8 +3612,6 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
>                 return -EINVAL;
>         }
>
> -       wce = buf[0] & (1 << 2);
> -
>         /*
>          * Check that read-only bits are not modified.
>          */
> @@ -3628,6 +3625,8 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
>                 }
>         }
>
> +       wce = buf[0] & (1 << 2);
> +
>         tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
>         tf->protocol = ATA_PROT_NODATA;
>         tf->nsect = 0;
> @@ -3660,7 +3659,6 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
>          * The first two bytes of def_control_mpage are a header, so offsets
>          * in mpage are off by 2 compared to buf.  Same for len.
>          */
> -
>         if (len != CONTROL_MPAGE_LEN - 2) {
>                 if (len < CONTROL_MPAGE_LEN - 2)
>                         *fp = len;
> @@ -3669,8 +3667,6 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
>                 return -EINVAL;
>         }
>
> -       d_sense = buf[0] & (1 << 2);
> -
>         /*
>          * Check that read-only bits are not modified.
>          */
> @@ -3683,7 +3679,10 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
>                         return -EINVAL;
>                 }
>         }
> -       if (d_sense & (1 << 2))
> +
> +       d_sense = buf[0] & (1 << 2);
> +
> +       if (d_sense)
>                 dev->flags |= ATA_DFLAG_D_SENSE;
>         else
>                 dev->flags &= ~ATA_DFLAG_D_SENSE;
> --
> 2.9.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo July 20, 2016, 3:22 p.m. UTC | #2
On Wed, Jul 20, 2016 at 05:11:50AM +0800, tom.ty89@gmail.com wrote:
> From: Tom Yan <tom.ty89@gmail.com>
> 
> 1. Removed a repeated bit masking in ata_mselect_control()
> 2. Moved `wce`/`d_sense` assignment below the page validity checks
> 3. Added/Removed empty lines where appropriate
> 
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>

Applied to libata/for-4.8.

Thanks.
diff mbox

Patch

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b00521b..06afe63 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3604,7 +3604,6 @@  static int ata_mselect_caching(struct ata_queued_cmd *qc,
 	 * The first two bytes of def_cache_mpage are a header, so offsets
 	 * in mpage are off by 2 compared to buf.  Same for len.
 	 */
-
 	if (len != CACHE_MPAGE_LEN - 2) {
 		if (len < CACHE_MPAGE_LEN - 2)
 			*fp = len;
@@ -3613,8 +3612,6 @@  static int ata_mselect_caching(struct ata_queued_cmd *qc,
 		return -EINVAL;
 	}
 
-	wce = buf[0] & (1 << 2);
-
 	/*
 	 * Check that read-only bits are not modified.
 	 */
@@ -3628,6 +3625,8 @@  static int ata_mselect_caching(struct ata_queued_cmd *qc,
 		}
 	}
 
+	wce = buf[0] & (1 << 2);
+
 	tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
 	tf->protocol = ATA_PROT_NODATA;
 	tf->nsect = 0;
@@ -3660,7 +3659,6 @@  static int ata_mselect_control(struct ata_queued_cmd *qc,
 	 * The first two bytes of def_control_mpage are a header, so offsets
 	 * in mpage are off by 2 compared to buf.  Same for len.
 	 */
-
 	if (len != CONTROL_MPAGE_LEN - 2) {
 		if (len < CONTROL_MPAGE_LEN - 2)
 			*fp = len;
@@ -3669,8 +3667,6 @@  static int ata_mselect_control(struct ata_queued_cmd *qc,
 		return -EINVAL;
 	}
 
-	d_sense = buf[0] & (1 << 2);
-
 	/*
 	 * Check that read-only bits are not modified.
 	 */
@@ -3683,7 +3679,10 @@  static int ata_mselect_control(struct ata_queued_cmd *qc,
 			return -EINVAL;
 		}
 	}
-	if (d_sense & (1 << 2))
+
+	d_sense = buf[0] & (1 << 2);
+
+	if (d_sense)
 		dev->flags |= ATA_DFLAG_D_SENSE;
 	else
 		dev->flags &= ~ATA_DFLAG_D_SENSE;