All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()
       [not found] <20160712132823.1765-1-me>
@ 2016-07-12 13:28 ` tom.ty89
  2016-07-12 13:33   ` Sergei Shtylyov
  2016-07-12 14:53   ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: tom.ty89 @ 2016-07-12 13:28 UTC (permalink / raw)
  To: tj, sergei.shtylyov; +Cc: linux-ide, linux-scsi, Tom Yan

From: Tom Yan <tom.ty89@gmail.com>

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

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66f..6f7c626 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
 static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
 {
 	modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
-	if (changeable || ata_id_wcache_enabled(id))
-		buf[2] |= (1 << 2);	/* write cache enable */
-	if (!changeable && !ata_id_rahead_enabled(id))
-		buf[12] |= (1 << 5);	/* disable read ahead */
+	if (changeable) {
+		buf[2] |= 1 << 2; /* ata_mselect_caching() */
+	}
+	else {
+		buf[2] |= ata_id_wcache_enabled(id) << 2;	/* write cache enable */
+		buf[12] |= !ata_id_rahead_enabled(id) << 5;	/* disable read ahead */
+	}
 	return sizeof(def_cache_mpage);
 }
 
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()
  2016-07-12 13:28 ` [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching() tom.ty89
@ 2016-07-12 13:33   ` Sergei Shtylyov
  2016-07-12 14:53   ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2016-07-12 13:33 UTC (permalink / raw)
  To: tom.ty89, tj; +Cc: linux-ide, linux-scsi

Hello.

On 7/12/2016 4:28 PM, tom.ty89@gmail.com wrote:

> From: Tom Yan <tom.ty89@gmail.com>
>
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..6f7c626 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
>  static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
>  {
>  	modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
> -	if (changeable || ata_id_wcache_enabled(id))
> -		buf[2] |= (1 << 2);	/* write cache enable */
> -	if (!changeable && !ata_id_rahead_enabled(id))
> -		buf[12] |= (1 << 5);	/* disable read ahead */
> +	if (changeable) {
> +		buf[2] |= 1 << 2; /* ata_mselect_caching() */
> +	}
> +	else {

    CodingStyle: } else {

> +		buf[2] |= ata_id_wcache_enabled(id) << 2;	/* write cache enable */
> +		buf[12] |= !ata_id_rahead_enabled(id) << 5;	/* disable read ahead */
> +	}
>  	return sizeof(def_cache_mpage);
>  }
>

MBR, Sergei


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()
  2016-07-12 13:28 ` [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching() tom.ty89
  2016-07-12 13:33   ` Sergei Shtylyov
@ 2016-07-12 14:53   ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2016-07-12 14:53 UTC (permalink / raw)
  To: tom.ty89; +Cc: sergei.shtylyov, linux-ide, linux-scsi

On Tue, Jul 12, 2016 at 09:28:23PM +0800, tom.ty89@gmail.com wrote:
> From: Tom Yan <tom.ty89@gmail.com>
> 
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index bfec66f..6f7c626 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
>  static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
>  {
>  	modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
> -	if (changeable || ata_id_wcache_enabled(id))
> -		buf[2] |= (1 << 2);	/* write cache enable */
> -	if (!changeable && !ata_id_rahead_enabled(id))
> -		buf[12] |= (1 << 5);	/* disable read ahead */
> +	if (changeable) {
> +		buf[2] |= 1 << 2; /* ata_mselect_caching() */
> +	}
> +	else {
> +		buf[2] |= ata_id_wcache_enabled(id) << 2;	/* write cache enable */
> +		buf[12] |= !ata_id_rahead_enabled(id) << 5;	/* disable read ahead */
> +	}

Again, why is this better?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-12 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20160712132823.1765-1-me>
2016-07-12 13:28 ` [PATCH v2 2/2] libata-scsi: better style in ata_msense_caching() tom.ty89
2016-07-12 13:33   ` Sergei Shtylyov
2016-07-12 14:53   ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.