/*
         * realloc if new shift is calculated, which is caused by setting
-        * up one new default queue depth after calling ->slave_configure
+        * up one new default queue depth after calling ->device_configure
         */
        if (!need_alloc && new_shift != sdev->budget_map.shift)
                need_alloc = need_free = true;
 static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
                blist_flags_t *bflags, int async)
 {
+       const struct scsi_host_template *hostt = sdev->host->hostt;
        struct queue_limits lim;
        int ret;
 
                lim.max_hw_sectors = 512;
        else if (*bflags & BLIST_MAX_1024)
                lim.max_hw_sectors = 1024;
+
+       if (hostt->device_configure)
+               ret = hostt->device_configure(sdev, &lim);
+       else if (hostt->slave_configure)
+               ret = hostt->slave_configure(sdev);
+       if (ret) {
+               queue_limits_cancel_update(sdev->request_queue);
+               /*
+                * If the LLDD reports device not present, don't clutter the
+                * console with failure messages.
+                */
+               if (ret != -ENXIO)
+                       sdev_printk(KERN_ERR, sdev,
+                               "failed to configure device\n");
+               return SCSI_SCAN_NO_RESPONSE;
+       }
+
        ret = queue_limits_commit_update(sdev->request_queue, &lim);
        if (ret) {
                sdev_printk(KERN_ERR, sdev, "failed to apply queue limits.\n");
                return SCSI_SCAN_NO_RESPONSE;
        }
 
-       if (sdev->host->hostt->slave_configure) {
-               ret = sdev->host->hostt->slave_configure(sdev);
-               if (ret) {
-                       /*
-                        * if LLDD reports slave not present, don't clutter
-                        * console with alloc failure messages
-                        */
-                       if (ret != -ENXIO) {
-                               sdev_printk(KERN_ERR, sdev,
-                                       "failed to configure device\n");
-                       }
-                       return SCSI_SCAN_NO_RESPONSE;
-               }
-
-               /*
-                * The queue_depth is often changed in ->slave_configure.
-                * Set up budget map again since memory consumption of
-                * the map depends on actual queue depth.
-                */
+       /*
+        * The queue_depth is often changed in ->device_configure.
+        *
+        * Set up budget map again since memory consumption of the map depends
+        * on actual queue depth.
+        */
+       if (hostt->device_configure || hostt->slave_configure)
                scsi_realloc_sdev_budget_map(sdev, sdev->queue_depth);
-       }
 
        if (sdev->scsi_level >= SCSI_3)
                scsi_attach_vpd(sdev);