rwsem generic spinlock: use IRQ save/restore spinlocks
[safe/jmp/linux-2.6] / drivers / scsi / libsas / sas_host_smp.c
index 89952ed..04ad8dd 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/scatterlist.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include "sas_internal.h"
 
@@ -137,21 +138,21 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
        int error = -EINVAL;
 
        /* eight is the minimum size for request and response frames */
-       if (req->data_len < 8 || rsp->data_len < 8)
+       if (blk_rq_bytes(req) < 8 || blk_rq_bytes(rsp) < 8)
                goto out;
 
-       if (bio_offset(req->bio) + req->data_len > PAGE_SIZE ||
-           bio_offset(rsp->bio) + rsp->data_len > PAGE_SIZE) {
+       if (bio_offset(req->bio) + blk_rq_bytes(req) > PAGE_SIZE ||
+           bio_offset(rsp->bio) + blk_rq_bytes(rsp) > PAGE_SIZE) {
                shost_printk(KERN_ERR, shost,
                        "SMP request/response frame crosses page boundary");
                goto out;
        }
 
-       req_data = kzalloc(req->data_len, GFP_KERNEL);
+       req_data = kzalloc(blk_rq_bytes(req), GFP_KERNEL);
 
        /* make sure frame can always be built ... we copy
         * back only the requested length */
-       resp_data = kzalloc(max(rsp->data_len, 128U), GFP_KERNEL);
+       resp_data = kzalloc(max(blk_rq_bytes(rsp), 128U), GFP_KERNEL);
 
        if (!req_data || !resp_data) {
                error = -ENOMEM;
@@ -160,7 +161,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
 
        local_irq_disable();
        buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio);
-       memcpy(req_data, buf, req->data_len);
+       memcpy(req_data, buf, blk_rq_bytes(req));
        kunmap_atomic(buf - bio_offset(req->bio), KM_USER0);
        local_irq_enable();
 
@@ -176,9 +177,6 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
        resp_data[1] = req_data[1];
        resp_data[2] = SMP_RESP_FUNC_UNK;
 
-       req->resid_len = req->data_len;
-       rsp->resid_len = rsp->data_len;
-
        switch (req_data[1]) {
        case SMP_REPORT_GENERAL:
                req->resid_len -= 8;
@@ -264,7 +262,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
 
        local_irq_disable();
        buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio);
-       memcpy(buf, resp_data, rsp->data_len);
+       memcpy(buf, resp_data, blk_rq_bytes(rsp));
        flush_kernel_dcache_page(bio_page(rsp->bio));
        kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
        local_irq_enable();