[SCSI] rework scsi_target allocation
[pandora-kernel.git] / include / scsi / scsi_device.h
index 6c2d80b..f6a9fe0 100644 (file)
@@ -122,9 +122,6 @@ struct scsi_device {
        unsigned tagged_supported:1;    /* Supports SCSI-II tagged queuing */
        unsigned simple_tags:1; /* simple queue tag messages are enabled */
        unsigned ordered_tags:1;/* ordered queue tag messages are enabled */
-       unsigned single_lun:1;  /* Indicates we should only allow I/O to
-                                * one of the luns for the device at a 
-                                * time. */
        unsigned was_reset:1;   /* There was a bus reset on the bus for 
                                 * this device */
        unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
@@ -142,6 +139,7 @@ struct scsi_device {
        unsigned fix_capacity:1;        /* READ_CAPACITY is too high by 1 */
        unsigned guess_capacity:1;      /* READ_CAPACITY might be too high by 1 */
        unsigned retry_hwerror:1;       /* Retry HARDWARE_ERROR */
+       unsigned last_sector_bug:1;     /* Always read last sector in a 1 sector read */
 
        DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
        struct list_head event_list;    /* asserted events */
@@ -158,8 +156,8 @@ struct scsi_device {
 
        int timeout;
 
-       struct device           sdev_gendev;
-       struct class_device     sdev_classdev;
+       struct device           sdev_gendev,
+                               sdev_dev;
 
        struct execute_work     ew; /* used to get process context on put */
 
@@ -169,9 +167,9 @@ struct scsi_device {
 #define        to_scsi_device(d)       \
        container_of(d, struct scsi_device, sdev_gendev)
 #define        class_to_sdev(d)        \
-       container_of(d, struct scsi_device, sdev_classdev)
+       container_of(d, struct scsi_device, sdev_dev)
 #define transport_class_to_sdev(class_dev) \
-       to_scsi_device(class_dev->dev)
+       to_scsi_device(class_dev->parent)
 
 #define sdev_printk(prefix, sdev, fmt, a...)   \
        dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
@@ -183,7 +181,8 @@ struct scsi_device {
        sdev_printk(prefix, (scmd)->device, fmt, ##a)
 
 enum scsi_target_state {
-       STARGET_RUNNING = 1,
+       STARGET_CREATED = 1,
+       STARGET_RUNNING,
        STARGET_DEL,
 };
 
@@ -202,6 +201,9 @@ struct scsi_target {
        unsigned int            id; /* target id ... replace
                                     * scsi_device.id eventually */
        unsigned int            create:1; /* signal that it needs to be added */
+       unsigned int            single_lun:1;   /* Indicates we should only
+                                                * allow I/O to one of the luns
+                                                * for the device at a time. */
        unsigned int            pdt_1f_for_no_lun;      /* PDT = 0x1f */
                                                /* means no lun present */
 
@@ -219,7 +221,7 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
        return to_scsi_target(sdev->sdev_gendev.parent);
 }
 #define transport_class_to_starget(class_dev) \
-       to_scsi_target(class_dev->dev)
+       to_scsi_target(class_dev->parent)
 
 #define starget_printk(prefix, starget, fmt, a...)     \
        dev_printk(prefix, &(starget)->dev, fmt, ##a)
@@ -295,7 +297,7 @@ extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
                            struct scsi_mode_data *data,
                            struct scsi_sense_hdr *);
 extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
-                               int retries);
+                               int retries, struct scsi_sense_hdr *sshdr);
 extern int scsi_device_set_state(struct scsi_device *sdev,
                                 enum scsi_device_state state);
 extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
@@ -386,6 +388,10 @@ static inline int scsi_device_qas(struct scsi_device *sdev)
                return 0;
        return sdev->inquiry[56] & 0x02;
 }
+static inline int scsi_device_enclosure(struct scsi_device *sdev)
+{
+       return sdev->inquiry[6] & (1<<6);
+}
 
 #define MODULE_ALIAS_SCSI_DEVICE(type) \
        MODULE_ALIAS("scsi:t-" __stringify(type) "*")