hpsa: allow passthru ioctls to work with bidirectional commands

Treat the the data direction bits as a bit mask allowing both
READ and WRITE at the same time instead of testing for equality
to see if it's a exclusively a READ or a WRITE.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Reviewed-by: Mike Miller <michael.miller@canonical.com>
Reviewed-by: Webb Scales <webb.scales@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Stephen M. Cameron 2014-05-29 10:52:41 -05:00 committed by Christoph Hellwig
parent 84ce1ee5bf
commit 9233fb10f3

View File

@ -4963,7 +4963,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
buff = kmalloc(iocommand.buf_size, GFP_KERNEL); buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
if (buff == NULL) if (buff == NULL)
return -EFAULT; return -EFAULT;
if (iocommand.Request.Type.Direction == XFER_WRITE) { if (iocommand.Request.Type.Direction & XFER_WRITE) {
/* Copy the data into the buffer we created */ /* Copy the data into the buffer we created */
if (copy_from_user(buff, iocommand.buf, if (copy_from_user(buff, iocommand.buf,
iocommand.buf_size)) { iocommand.buf_size)) {
@ -5026,7 +5026,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
rc = -EFAULT; rc = -EFAULT;
goto out; goto out;
} }
if (iocommand.Request.Type.Direction == XFER_READ && if ((iocommand.Request.Type.Direction & XFER_READ) &&
iocommand.buf_size > 0) { iocommand.buf_size > 0) {
/* Copy the data out of the buffer we created */ /* Copy the data out of the buffer we created */
if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) { if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) {
@ -5103,7 +5103,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
status = -ENOMEM; status = -ENOMEM;
goto cleanup1; goto cleanup1;
} }
if (ioc->Request.Type.Direction == XFER_WRITE) { if (ioc->Request.Type.Direction & XFER_WRITE) {
if (copy_from_user(buff[sg_used], data_ptr, sz)) { if (copy_from_user(buff[sg_used], data_ptr, sz)) {
status = -ENOMEM; status = -ENOMEM;
goto cleanup1; goto cleanup1;
@ -5155,7 +5155,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
status = -EFAULT; status = -EFAULT;
goto cleanup0; goto cleanup0;
} }
if (ioc->Request.Type.Direction == XFER_READ && ioc->buf_size > 0) { if ((ioc->Request.Type.Direction & XFER_READ) && ioc->buf_size > 0) {
/* Copy the data out of the buffer we created */ /* Copy the data out of the buffer we created */
BYTE __user *ptr = ioc->buf; BYTE __user *ptr = ioc->buf;
for (i = 0; i < sg_used; i++) { for (i = 0; i < sg_used; i++) {