include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / ieee1394 / sbp2.c
index a2984a0..4565cb5 100644 (file)
@@ -56,7 +56,6 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
-#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -265,7 +264,7 @@ static struct hpsb_highlevel sbp2_highlevel = {
        .host_reset     = sbp2_host_reset,
 };
 
-const static struct hpsb_address_ops sbp2_ops = {
+static const struct hpsb_address_ops sbp2_ops = {
        .write          = sbp2_handle_status_write
 };
 
@@ -275,7 +274,7 @@ static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *,
 static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64,
                                    size_t, u16);
 
-const static struct hpsb_address_ops sbp2_physdma_ops = {
+static const struct hpsb_address_ops sbp2_physdma_ops = {
        .read           = sbp2_handle_physdma_read,
        .write          = sbp2_handle_physdma_write,
 };
@@ -285,7 +284,7 @@ const static struct hpsb_address_ops sbp2_physdma_ops = {
 /*
  * Interface to driver core and IEEE 1394 core
  */
-static struct ieee1394_device_id sbp2_id_table[] = {
+static const struct ieee1394_device_id sbp2_id_table[] = {
        {
         .match_flags   = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
         .specifier_id  = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
@@ -347,8 +346,8 @@ static struct scsi_host_template sbp2_shost_template = {
        .sdev_attrs              = sbp2_sysfs_sdev_attrs,
 };
 
-/* for match-all entries in sbp2_workarounds_table */
-#define SBP2_ROM_VALUE_WILDCARD 0x1000000
+#define SBP2_ROM_VALUE_WILDCARD ~0         /* match all */
+#define SBP2_ROM_VALUE_MISSING  0xff000000 /* not present in the unit dir. */
 
 /*
  * List of devices with known bugs.
@@ -359,60 +358,69 @@ static struct scsi_host_template sbp2_shost_template = {
  */
 static const struct {
        u32 firmware_revision;
-       u32 model_id;
+       u32 model;
        unsigned workarounds;
 } sbp2_workarounds_table[] = {
        /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
                .firmware_revision      = 0x002800,
-               .model_id               = 0x001010,
+               .model                  = 0x001010,
                .workarounds            = SBP2_WORKAROUND_INQUIRY_36 |
                                          SBP2_WORKAROUND_MODE_SENSE_8 |
                                          SBP2_WORKAROUND_POWER_CONDITION,
        },
        /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
                .firmware_revision      = 0x002800,
-               .model_id               = 0x000000,
-               .workarounds            = SBP2_WORKAROUND_DELAY_INQUIRY |
-                                         SBP2_WORKAROUND_POWER_CONDITION,
+               .model                  = 0x000000,
+               .workarounds            = SBP2_WORKAROUND_POWER_CONDITION,
        },
        /* Initio bridges, actually only needed for some older ones */ {
                .firmware_revision      = 0x000200,
-               .model_id               = SBP2_ROM_VALUE_WILDCARD,
+               .model                  = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_INQUIRY_36,
        },
        /* PL-3507 bridge with Prolific firmware */ {
                .firmware_revision      = 0x012800,
-               .model_id               = SBP2_ROM_VALUE_WILDCARD,
+               .model                  = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_POWER_CONDITION,
        },
        /* Symbios bridge */ {
                .firmware_revision      = 0xa0b800,
-               .model_id               = SBP2_ROM_VALUE_WILDCARD,
+               .model                  = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS,
        },
        /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
                .firmware_revision      = 0x002600,
-               .model_id               = SBP2_ROM_VALUE_WILDCARD,
+               .model                  = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS,
        },
+       /*
+        * iPod 2nd generation: needs 128k max transfer size workaround
+        * iPod 3rd generation: needs fix capacity workaround
+        */
+       {
+               .firmware_revision      = 0x0a2700,
+               .model                  = 0x000000,
+               .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS |
+                                         SBP2_WORKAROUND_FIX_CAPACITY,
+       },
        /* iPod 4th generation */ {
                .firmware_revision      = 0x0a2700,
-               .model_id               = 0x000021,
+               .model                  = 0x000021,
                .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
        },
        /* iPod mini */ {
                .firmware_revision      = 0x0a2700,
-               .model_id               = 0x000022,
+               .model                  = 0x000022,
                .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
        },
        /* iPod mini */ {
                .firmware_revision      = 0x0a2700,
-               .model_id               = 0x000023,
+               .model                  = 0x000023,
                .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
        },
        /* iPod Photo */ {
                .firmware_revision      = 0x0a2700,
-               .model_id               = 0x00007e,
+               .model                  = 0x00007e,
                .workarounds            = SBP2_WORKAROUND_FIX_CAPACITY,
        }
 };
@@ -708,7 +716,7 @@ static int sbp2_remove(struct device *dev)
        struct scsi_device *sdev;
 
        ud = container_of(dev, struct unit_directory, device);
-       lu = ud->device.driver_data;
+       lu = dev_get_drvdata(&ud->device);
        if (!lu)
                return 0;
 
@@ -736,7 +744,7 @@ static int sbp2_remove(struct device *dev)
 
 static int sbp2_update(struct unit_directory *ud)
 {
-       struct sbp2_lu *lu = ud->device.driver_data;
+       struct sbp2_lu *lu = dev_get_drvdata(&ud->device);
 
        if (sbp2_reconnect_device(lu) != 0) {
                /*
@@ -805,7 +813,7 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
        atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
        INIT_WORK(&lu->protocol_work, NULL);
 
-       ud->device.driver_data = lu;
+       dev_set_drvdata(&ud->device, lu);
 
        hi = hpsb_get_hostinfo(&sbp2_highlevel, ud->ne->host);
        if (!hi) {
@@ -870,6 +878,7 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
        }
 
        shost->hostdata[0] = (unsigned long)lu;
+       shost->max_cmd_len = SBP2_MAX_CDB_SIZE;
 
        if (!scsi_add_host(shost, &ud->device)) {
                lu->shost = shost;
@@ -1041,7 +1050,7 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
                hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
                                          lu->status_fifo_addr);
 
-       lu->ud->device.driver_data = NULL;
+       dev_set_drvdata(&lu->ud->device, NULL);
 
        module_put(hi->host->driver->owner);
 no_hi:
@@ -1341,13 +1350,15 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
        struct csr1212_keyval *kv;
        struct csr1212_dentry *dentry;
        u64 management_agent_addr;
-       u32 unit_characteristics, firmware_revision;
+       u32 unit_characteristics, firmware_revision, model;
        unsigned workarounds;
        int i;
 
        management_agent_addr = 0;
        unit_characteristics = 0;
-       firmware_revision = 0;
+       firmware_revision = SBP2_ROM_VALUE_MISSING;
+       model = ud->flags & UNIT_DIRECTORY_MODEL_ID ?
+                               ud->model_id : SBP2_ROM_VALUE_MISSING;
 
        csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
                switch (kv->key.id) {
@@ -1388,9 +1399,9 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
                            sbp2_workarounds_table[i].firmware_revision !=
                            (firmware_revision & 0xffff00))
                                continue;
-                       if (sbp2_workarounds_table[i].model_id !=
+                       if (sbp2_workarounds_table[i].model !=
                            SBP2_ROM_VALUE_WILDCARD &&
-                           sbp2_workarounds_table[i].model_id != ud->model_id)
+                           sbp2_workarounds_table[i].model != model)
                                continue;
                        workarounds |= sbp2_workarounds_table[i].workarounds;
                        break;
@@ -1401,9 +1412,8 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
                          "(firmware_revision 0x%06x, vendor_id 0x%06x,"
                          " model_id 0x%06x)",
                          NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
-                         workarounds, firmware_revision,
-                         ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
-                         ud->model_id);
+                         workarounds, firmware_revision, ud->vendor_id,
+                         model);
 
        /* We would need one SCSI host template for each target to adjust
         * max_sectors on the fly, therefore warn only. */
@@ -2009,7 +2019,7 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
        if (lu->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
                sdev->start_stop_pwr_cond = 1;
        if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
-               blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
+               blk_queue_max_hw_sectors(sdev->request_queue, 128 * 1024 / 512);
 
        blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE);
        return 0;