~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/target/target_core_pscsi.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <linux/blk_types.h>
35
35
#include <linux/slab.h>
36
36
#include <linux/spinlock.h>
37
 
#include <linux/smp_lock.h>
38
37
#include <linux/genhd.h>
39
38
#include <linux/cdrom.h>
40
39
#include <linux/file.h>
42
41
#include <scsi/scsi_device.h>
43
42
#include <scsi/scsi_cmnd.h>
44
43
#include <scsi/scsi_host.h>
45
 
#include <scsi/libsas.h> /* For TASK_ATTR_* */
 
44
#include <scsi/scsi_tcq.h>
46
45
 
47
46
#include <target/target_core_base.h>
48
47
#include <target/target_core_device.h>
442
441
        struct pscsi_dev_virt *pdv,
443
442
        struct se_subsystem_dev *se_dev,
444
443
        struct se_hba *hba)
 
444
        __releases(sh->host_lock)
445
445
{
446
446
        struct se_device *dev;
447
447
        struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
489
489
        struct pscsi_dev_virt *pdv,
490
490
        struct se_subsystem_dev *se_dev,
491
491
        struct se_hba *hba)
 
492
        __releases(sh->host_lock)
492
493
{
493
494
        struct se_device *dev;
494
495
        struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
523
524
        struct pscsi_dev_virt *pdv,
524
525
        struct se_subsystem_dev *se_dev,
525
526
        struct se_hba *hba)
 
527
        __releases(sh->host_lock)
526
528
{
527
529
        struct se_device *dev;
528
530
        struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
556
558
        if (!(pdv)) {
557
559
                printk(KERN_ERR "Unable to locate struct pscsi_dev_virt"
558
560
                                " parameter\n");
559
 
                return NULL;
 
561
                return ERR_PTR(-EINVAL);
560
562
        }
561
563
        /*
562
564
         * If not running in PHV_LLD_SCSI_HOST_NO mode, locate the
566
568
                if (phv->phv_mode == PHV_LLD_SCSI_HOST_NO) {
567
569
                        printk(KERN_ERR "pSCSI: Unable to locate struct"
568
570
                                " Scsi_Host for PHV_LLD_SCSI_HOST_NO\n");
569
 
                        return NULL;
 
571
                        return ERR_PTR(-ENODEV);
570
572
                }
571
573
                /*
572
574
                 * For the newer PHV_VIRUTAL_HOST_ID struct scsi_device
575
577
                if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) {
576
578
                        printk(KERN_ERR "pSCSI: udev_path attribute has not"
577
579
                                " been set before ENABLE=1\n");
578
 
                        return NULL;
 
580
                        return ERR_PTR(-EINVAL);
579
581
                }
580
582
                /*
581
583
                 * If no scsi_host_id= was passed for PHV_VIRUTAL_HOST_ID,
588
590
                                printk(KERN_ERR "pSCSI: Unable to set hba_mode"
589
591
                                        " with active devices\n");
590
592
                                spin_unlock(&hba->device_lock);
591
 
                                return NULL;
 
593
                                return ERR_PTR(-EEXIST);
592
594
                        }
593
595
                        spin_unlock(&hba->device_lock);
594
596
 
595
597
                        if (pscsi_pmode_enable_hba(hba, 1) != 1)
596
 
                                return NULL;
 
598
                                return ERR_PTR(-ENODEV);
597
599
 
598
600
                        legacy_mode_enable = 1;
599
601
                        hba->hba_flags |= HBA_FLAGS_PSCSI_MODE;
603
605
                        if (!(sh)) {
604
606
                                printk(KERN_ERR "pSCSI: Unable to locate"
605
607
                                        " pdv_host_id: %d\n", pdv->pdv_host_id);
606
 
                                return NULL;
 
608
                                return ERR_PTR(-ENODEV);
607
609
                        }
608
610
                }
609
611
        } else {
610
612
                if (phv->phv_mode == PHV_VIRUTAL_HOST_ID) {
611
613
                        printk(KERN_ERR "pSCSI: PHV_VIRUTAL_HOST_ID set while"
612
614
                                " struct Scsi_Host exists\n");
613
 
                        return NULL;
 
615
                        return ERR_PTR(-EEXIST);
614
616
                }
615
617
        }
616
618
 
645
647
                                hba->hba_flags &= ~HBA_FLAGS_PSCSI_MODE;
646
648
                        }
647
649
                        pdv->pdv_sd = NULL;
648
 
                        return NULL;
 
650
                        return ERR_PTR(-ENODEV);
649
651
                }
650
652
                return dev;
651
653
        }
661
663
                hba->hba_flags &= ~HBA_FLAGS_PSCSI_MODE;
662
664
        }
663
665
 
664
 
        return NULL;
 
666
        return ERR_PTR(-ENODEV);
665
667
}
666
668
 
667
669
/*      pscsi_free_device(): (Part of se_subsystem_api_t template)
817
819
                if (!(pt->pscsi_cdb)) {
818
820
                        printk(KERN_ERR "pSCSI: Unable to allocate extended"
819
821
                                        " pt->pscsi_cdb\n");
 
822
                        kfree(pt);
820
823
                        return NULL;
821
824
                }
822
825
        } else
908
911
         * descriptor
909
912
         */
910
913
        blk_execute_rq_nowait(pdv->pdv_sd->request_queue, NULL, pt->pscsi_req,
911
 
                        (task->task_se_cmd->sam_task_attr == TASK_ATTR_HOQ),
 
914
                        (task->task_se_cmd->sam_task_attr == MSG_HEAD_TAG),
912
915
                        pscsi_req_done);
913
916
 
914
917
        return PYX_TRANSPORT_SENT_TO_TRANSPORT;