linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation
@ 2012-02-24  1:22 Roland Dreier
  2012-02-25  1:12 ` Nicholas A. Bellinger
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Dreier @ 2012-02-24  1:22 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi, target-devel

From: Roland Dreier <roland@purestorage.com>

The old code did (MSB << 8) & 0xff, which always evaluates to 0.  Just use
get_unaligned_be16() so we don't have to worry about whether our open-coded
version is correct or not.

Signed-off-by: Roland Dreier <roland@purestorage.com>
---
 drivers/target/target_core_alua.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 01a2691..c7746a3 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -30,6 +30,7 @@
 #include <linux/export.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
+#include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
@@ -267,8 +268,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
 		 * changed.
 		 */
 		if (primary) {
-			tg_pt_id = ((ptr[2] << 8) & 0xff);
-			tg_pt_id |= (ptr[3] & 0xff);
+			tg_pt_id = get_unaligned_be16(ptr + 2);
 			/*
 			 * Locate the matching target port group ID from
 			 * the global tg_pt_gp list
@@ -312,8 +312,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
 			 * the Target Port in question for the the incoming
 			 * SET_TARGET_PORT_GROUPS op.
 			 */
-			rtpi = ((ptr[2] << 8) & 0xff);
-			rtpi |= (ptr[3] & 0xff);
+			rtpi = get_unaligned_be16(ptr + 2);
 			/*
 			 * Locate the matching relative target port identifer
 			 * for the struct se_device storage object.
-- 
1.7.9

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

* Re: [PATCH] target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation
  2012-02-24  1:22 [PATCH] target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation Roland Dreier
@ 2012-02-25  1:12 ` Nicholas A. Bellinger
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2012-02-25  1:12 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-scsi, target-devel

On Thu, 2012-02-23 at 17:22 -0800, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
> 
> The old code did (MSB << 8) & 0xff, which always evaluates to 0.  Just use
> get_unaligned_be16() so we don't have to worry about whether our open-coded
> version is correct or not.
> 
> Signed-off-by: Roland Dreier <roland@purestorage.com>
> ---
>  drivers/target/target_core_alua.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
> index 01a2691..c7746a3 100644
> --- a/drivers/target/target_core_alua.c
> +++ b/drivers/target/target_core_alua.c
> @@ -30,6 +30,7 @@
>  #include <linux/export.h>
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_cmnd.h>
> +#include <asm/unaligned.h>
>  
>  #include <target/target_core_base.h>
>  #include <target/target_core_backend.h>
> @@ -267,8 +268,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
>  		 * changed.
>  		 */
>  		if (primary) {
> -			tg_pt_id = ((ptr[2] << 8) & 0xff);
> -			tg_pt_id |= (ptr[3] & 0xff);
> +			tg_pt_id = get_unaligned_be16(ptr + 2);
>  			/*
>  			 * Locate the matching target port group ID from
>  			 * the global tg_pt_gp list
> @@ -312,8 +312,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
>  			 * the Target Port in question for the the incoming
>  			 * SET_TARGET_PORT_GROUPS op.
>  			 */
> -			rtpi = ((ptr[2] << 8) & 0xff);
> -			rtpi |= (ptr[3] & 0xff);
> +			rtpi = get_unaligned_be16(ptr + 2);
>  			/*
>  			 * Locate the matching relative target port identifer
>  			 * for the struct se_device storage object.

Applied.  Thanks Roland!

--nab


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

end of thread, other threads:[~2012-02-25  1:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24  1:22 [PATCH] target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation Roland Dreier
2012-02-25  1:12 ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).