]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/block/cciss.c
Merge phase #3 (IOMMU) of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
[linux-2.6-omap-h63xx.git] / drivers / block / cciss.c
index 08255644e80ab0bfdde460ef8520544f6626dfe7..1e1f9153000c27638e854142017fc61f6b49a094 100644 (file)
@@ -1533,15 +1533,18 @@ mem_msg:
  * where new drives will be added.  If the index to be returned is greater
  * than the highest_lun index for the controller then highest_lun is set
  * to this new index.  If there are no available indexes then -1 is returned.
+ * "controller_node" is used to know if this is a real logical drive, or just
+ * the controller node, which determines if this counts towards highest_lun.
  */
-static int cciss_find_free_drive_index(int ctlr)
+static int cciss_find_free_drive_index(int ctlr, int controller_node)
 {
        int i;
 
        for (i = 0; i < CISS_MAX_LUN; i++) {
                if (hba[ctlr]->drv[i].raid_level == -1) {
                        if (i > hba[ctlr]->highest_lun)
-                               hba[ctlr]->highest_lun = i;
+                               if (!controller_node)
+                                       hba[ctlr]->highest_lun = i;
                        return i;
                }
        }
@@ -1557,11 +1560,11 @@ static int cciss_find_free_drive_index(int ctlr)
  * a means to talk to the controller in case no logical
  * drives have yet been configured.
  */
-static int cciss_add_gendisk(ctlr_info_t *h, __u32 lunid)
+static int cciss_add_gendisk(ctlr_info_t *h, __u32 lunid, int controller_node)
 {
        int drv_index;
 
-       drv_index = cciss_find_free_drive_index(h->ctlr);
+       drv_index = cciss_find_free_drive_index(h->ctlr, controller_node);
        if (drv_index == -1)
                return -1;
        /*Check if the gendisk needs to be allocated */
@@ -1598,7 +1601,7 @@ static void cciss_add_controller_node(ctlr_info_t *h)
        if (h->gendisk[0] != NULL) /* already did this? Then bail. */
                return;
 
-       drv_index = cciss_add_gendisk(h, 0);
+       drv_index = cciss_add_gendisk(h, 0, 1);
        if (drv_index == -1) {
                printk(KERN_WARNING "cciss%d: could not "
                        "add disk 0.\n", h->ctlr);
@@ -1732,7 +1735,7 @@ static int rebuild_lun_table(ctlr_info_t *h, int first_time)
 
                /* check if the drive was found already in the array */
                if (!drv_found) {
-                       drv_index = cciss_add_gendisk(h, lunid);
+                       drv_index = cciss_add_gendisk(h, lunid, 0);
                        if (drv_index == -1)
                                goto freeret;
                }
@@ -3457,8 +3460,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
               hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
 
        hba[i]->cmd_pool_bits =
-           kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
-                     1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
+           kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
+                       * sizeof(unsigned long), GFP_KERNEL);
        hba[i]->cmd_pool = (CommandList_struct *)
            pci_alloc_consistent(hba[i]->pdev,
                    hba[i]->nr_cmds * sizeof(CommandList_struct),
@@ -3490,8 +3493,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
        /* command and error info recs zeroed out before
           they are used */
        memset(hba[i]->cmd_pool_bits, 0,
-              ((hba[i]->nr_cmds + BITS_PER_LONG -
-                1) / BITS_PER_LONG) * sizeof(unsigned long));
+              DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
+                       * sizeof(unsigned long));
 
        hba[i]->num_luns = 0;
        hba[i]->highest_lun = -1;
@@ -3611,7 +3614,9 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
                }
        }
 
+#ifdef CONFIG_CISS_SCSI_TAPE
        cciss_unregister_scsi(i);       /* unhook from SCSI subsystem */
+#endif
 
        cciss_shutdown(pdev);