diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2012-01-19 15:00:53 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-02-19 09:08:55 -0500 |
commit | b705690d8d16f7081be3637c0bda2a681f02ecf4 (patch) | |
tree | 1c0562d1541ec8fa13030ea0585321c089252b98 /drivers/scsi/hpsa.c | |
parent | d66ae08bad182e9a87859e120e61cfd51e402ed8 (diff) |
[SCSI] hpsa: combine hpsa_scsi_detect and hpsa_register_scsi
hpsa_register_scsi just calls hpsa_scsi_detect. Move
the guts of hpsa_scsi_detect into hpsa_register_scsi and
get rid of hpsa_scsi_detect.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r-- | drivers/scsi/hpsa.c | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index f4dc212ad49b..68df3da78782 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -1257,46 +1257,6 @@ static void complete_scsi_command(struct CommandList *cp) | |||
1257 | cmd_free(h, cp); | 1257 | cmd_free(h, cp); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | static int hpsa_scsi_detect(struct ctlr_info *h) | ||
1261 | { | ||
1262 | struct Scsi_Host *sh; | ||
1263 | int error; | ||
1264 | |||
1265 | sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h)); | ||
1266 | if (sh == NULL) | ||
1267 | goto fail; | ||
1268 | |||
1269 | sh->io_port = 0; | ||
1270 | sh->n_io_port = 0; | ||
1271 | sh->this_id = -1; | ||
1272 | sh->max_channel = 3; | ||
1273 | sh->max_cmd_len = MAX_COMMAND_SIZE; | ||
1274 | sh->max_lun = HPSA_MAX_LUN; | ||
1275 | sh->max_id = HPSA_MAX_LUN; | ||
1276 | sh->can_queue = h->nr_cmds; | ||
1277 | sh->cmd_per_lun = h->nr_cmds; | ||
1278 | sh->sg_tablesize = h->maxsgentries; | ||
1279 | h->scsi_host = sh; | ||
1280 | sh->hostdata[0] = (unsigned long) h; | ||
1281 | sh->irq = h->intr[h->intr_mode]; | ||
1282 | sh->unique_id = sh->irq; | ||
1283 | error = scsi_add_host(sh, &h->pdev->dev); | ||
1284 | if (error) | ||
1285 | goto fail_host_put; | ||
1286 | scsi_scan_host(sh); | ||
1287 | return 0; | ||
1288 | |||
1289 | fail_host_put: | ||
1290 | dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_add_host" | ||
1291 | " failed for controller %d\n", h->ctlr); | ||
1292 | scsi_host_put(sh); | ||
1293 | return error; | ||
1294 | fail: | ||
1295 | dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_host_alloc" | ||
1296 | " failed for controller %d\n", h->ctlr); | ||
1297 | return -ENOMEM; | ||
1298 | } | ||
1299 | |||
1300 | static void hpsa_pci_unmap(struct pci_dev *pdev, | 1260 | static void hpsa_pci_unmap(struct pci_dev *pdev, |
1301 | struct CommandList *c, int sg_used, int data_direction) | 1261 | struct CommandList *c, int sg_used, int data_direction) |
1302 | { | 1262 | { |
@@ -2228,13 +2188,42 @@ static void hpsa_unregister_scsi(struct ctlr_info *h) | |||
2228 | 2188 | ||
2229 | static int hpsa_register_scsi(struct ctlr_info *h) | 2189 | static int hpsa_register_scsi(struct ctlr_info *h) |
2230 | { | 2190 | { |
2231 | int rc; | 2191 | struct Scsi_Host *sh; |
2192 | int error; | ||
2232 | 2193 | ||
2233 | rc = hpsa_scsi_detect(h); | 2194 | sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h)); |
2234 | if (rc != 0) | 2195 | if (sh == NULL) |
2235 | dev_err(&h->pdev->dev, "hpsa_register_scsi: failed" | 2196 | goto fail; |
2236 | " hpsa_scsi_detect(), rc is %d\n", rc); | 2197 | |
2237 | return rc; | 2198 | sh->io_port = 0; |
2199 | sh->n_io_port = 0; | ||
2200 | sh->this_id = -1; | ||
2201 | sh->max_channel = 3; | ||
2202 | sh->max_cmd_len = MAX_COMMAND_SIZE; | ||
2203 | sh->max_lun = HPSA_MAX_LUN; | ||
2204 | sh->max_id = HPSA_MAX_LUN; | ||
2205 | sh->can_queue = h->nr_cmds; | ||
2206 | sh->cmd_per_lun = h->nr_cmds; | ||
2207 | sh->sg_tablesize = h->maxsgentries; | ||
2208 | h->scsi_host = sh; | ||
2209 | sh->hostdata[0] = (unsigned long) h; | ||
2210 | sh->irq = h->intr[h->intr_mode]; | ||
2211 | sh->unique_id = sh->irq; | ||
2212 | error = scsi_add_host(sh, &h->pdev->dev); | ||
2213 | if (error) | ||
2214 | goto fail_host_put; | ||
2215 | scsi_scan_host(sh); | ||
2216 | return 0; | ||
2217 | |||
2218 | fail_host_put: | ||
2219 | dev_err(&h->pdev->dev, "%s: scsi_add_host" | ||
2220 | " failed for controller %d\n", __func__, h->ctlr); | ||
2221 | scsi_host_put(sh); | ||
2222 | return error; | ||
2223 | fail: | ||
2224 | dev_err(&h->pdev->dev, "%s: scsi_host_alloc" | ||
2225 | " failed for controller %d\n", __func__, h->ctlr); | ||
2226 | return -ENOMEM; | ||
2238 | } | 2227 | } |
2239 | 2228 | ||
2240 | static int wait_for_device_to_become_ready(struct ctlr_info *h, | 2229 | static int wait_for_device_to_become_ready(struct ctlr_info *h, |