The WRITE_{6,10,12} are defined numbers, so the branch was always taken.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
drivers/scsi/arcmsr/arcmsr_hba.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
See include/scsi/scsi.h:58-123 for
#define WRITE_6 0x0a
#define WRITE_10 0x2a
#define WRITE_12 0xaa
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 17e3df4..a6e5222 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1171,7 +1171,8 @@ static int arcmsr_build_ccb(struct AdapterControlBlock *acb,
arcmsr_cdb->msgPages = arccdbsize/0x100 + (arccdbsize % 0x100 ? 1 : 0);
if ( arccdbsize > 256)
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE;
- if (pcmd->cmnd[0]|WRITE_6 || pcmd->cmnd[0]|WRITE_10 || pcmd->cmnd[0]|WRITE_12 ){
+ if (pcmd->cmnd[0] & WRITE_6 || pcmd->cmnd[0] & WRITE_10 ||
+ pcmd->cmnd[0] & WRITE_12 ){
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
}
ccb->arc_cdb_size = arccdbsize;
--
You're right, but even this will basically always set the write flag, since some bits will be set the same, even for reads. Eg: #define READ_10 0x28 #define WRITE_10 0x2a That will of course miss other commands which do writes, such as UNMAP and WRITE_32. So we should do it properly: if (pcmd->sc_data_direction == DMA_TO_DEVICE) arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE; -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." --
<http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ae52e7f09ff509df11cd408eabe90132b6be1231;hp=f034260db330bb3ffc815fcb682b1c84aca09591#patch2>
@@ -1034,10 +1075,10 @@ static int arcmsr_build_ccb(struct
AdapterControlBlock *acb,
}
arcmsr_cdb->sgcount = (uint8_t)cdb_sgcount;
arcmsr_cdb->DataLength = scsi_bufflen(pcmd);
+ arcmsr_cdb->msgPages = arccdbsize/0x100 + (arccdbsize % 0x100 ? 1 : 0);
if ( arccdbsize > 256)
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE;
- }
- if (pcmd->sc_data_direction == DMA_TO_DEVICE ) {
+ if (pcmd->cmnd[0]|WRITE_6 || pcmd->cmnd[0] | WRITE_10 ||
pcmd->cmnd[0]|WRITE_12) {
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
ccb->ccb_flags |= CCB_FLAG_WRITE;
}
Until June 2010 it was that way...
--
So it was. Nick, why did you make this change? Your commit message is less than informative, partly because you're making such huge changes in a single commit. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." --
Make sure no other command which does a write, such as UNMAP and WRITE_32, is missed.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
drivers/scsi/arcmsr/arcmsr_hba.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
If you agree this is the right fix, please ack.
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 17e3df4..a5acedc 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1171,7 +1171,7 @@ static int arcmsr_build_ccb(struct AdapterControlBlock *acb,
arcmsr_cdb->msgPages = arccdbsize/0x100 + (arccdbsize % 0x100 ? 1 : 0);
if ( arccdbsize > 256)
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE;
- if (pcmd->cmnd[0]|WRITE_6 || pcmd->cmnd[0]|WRITE_10 || pcmd->cmnd[0]|WRITE_12 ){
+ if (pcmd->sc_data_direction == DMA_TO_DEVICE)
arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE;
}
ccb->arc_cdb_size = arccdbsize;
--
Hi Roel, Thanks for your reminding. I agree with you. This patch is absolutely correct. -----Original Message----- From: roel kluin [mailto:roel.kluin@gmail.com] Sent: Sunday, January 02, 2011 2:40 AM To: Matthew Wilcox; just.for.lkml@googlemail.com Cc: nick.cheng@areca.com.tw; Andrew Morton; LKML; James.Bottomley@suse.de; linux-scsi@vger.kernel.org Subject: Re: [PATCH] [SCSI] arcmsr: &/| confusion in arcmsr_build_ccb() Make sure no other command which does a write, such as UNMAP and WRITE_32, is missed. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> --- drivers/scsi/arcmsr/arcmsr_hba.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) If you agree this is the right fix, please ack. diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 17e3df4..a5acedc 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -1171,7 +1171,7 @@ static int arcmsr_build_ccb(struct AdapterControlBlock *acb, arcmsr_cdb->msgPages = arccdbsize/0x100 + (arccdbsize % 0x100 ? 1 : 0); if ( arccdbsize > 256) arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE; - if (pcmd->cmnd[0]|WRITE_6 || pcmd->cmnd[0]|WRITE_10 || pcmd->cmnd[0]|WRITE_12 ){ + if (pcmd->sc_data_direction == DMA_TO_DEVICE) arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE; } ccb->arc_cdb_size = arccdbsize; --
Compile checking patches you send in next time would be most welcome: CC [M] drivers/scsi/arcmsr/arcmsr_hba.o drivers/scsi/arcmsr/arcmsr_hba.c:1177:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token drivers/scsi/arcmsr/arcmsr_hba.c:1178:2: error: expected identifier or ‘(’ before ‘return’ drivers/scsi/arcmsr/arcmsr_hba.c:1179:1: error: expected identifier or ‘(’ before ‘}’ token drivers/scsi/arcmsr/arcmsr_hba.c: In function ‘arcmsr_build_ccb’: drivers/scsi/arcmsr/arcmsr_hba.c:1176:2: warning: control reaches end of non-void function James --
I'm not sure, if the compiler will optimize this anyway, but would it
look better this way:
if (pcmd->cmnd[0] & (WRITE_6 | WRITE_10 | WRITE_12)){
And that would open the question what really was meant, as that will
be equal to:
if (pcmd->cmnd[0] & WRITE_12){
(if you look at the constants, you can skip WRITE_6 and _10 as there
--
