aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hosts.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/hosts.c')
-rw-r--r--drivers/scsi/hosts.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index c264a8c5f01e..3690360d7a79 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -199,9 +199,13 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
199 if (!shost->can_queue) { 199 if (!shost->can_queue) {
200 printk(KERN_ERR "%s: can_queue = 0 no longer supported\n", 200 printk(KERN_ERR "%s: can_queue = 0 no longer supported\n",
201 sht->name); 201 sht->name);
202 goto out; 202 goto fail;
203 } 203 }
204 204
205 error = scsi_setup_command_freelist(shost);
206 if (error)
207 goto fail;
208
205 if (!shost->shost_gendev.parent) 209 if (!shost->shost_gendev.parent)
206 shost->shost_gendev.parent = dev ? dev : &platform_bus; 210 shost->shost_gendev.parent = dev ? dev : &platform_bus;
207 211
@@ -255,6 +259,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
255 out_del_gendev: 259 out_del_gendev:
256 device_del(&shost->shost_gendev); 260 device_del(&shost->shost_gendev);
257 out: 261 out:
262 scsi_destroy_command_freelist(shost);
263 fail:
258 return error; 264 return error;
259} 265}
260EXPORT_SYMBOL(scsi_add_host); 266EXPORT_SYMBOL(scsi_add_host);
@@ -284,6 +290,11 @@ static void scsi_host_dev_release(struct device *dev)
284 kfree(shost); 290 kfree(shost);
285} 291}
286 292
293struct device_type scsi_host_type = {
294 .name = "scsi_host",
295 .release = scsi_host_dev_release,
296};
297
287/** 298/**
288 * scsi_host_alloc - register a scsi host adapter instance. 299 * scsi_host_alloc - register a scsi host adapter instance.
289 * @sht: pointer to scsi host template 300 * @sht: pointer to scsi host template
@@ -376,33 +387,31 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
376 else 387 else
377 shost->dma_boundary = 0xffffffff; 388 shost->dma_boundary = 0xffffffff;
378 389
379 rval = scsi_setup_command_freelist(shost);
380 if (rval)
381 goto fail_kfree;
382
383 device_initialize(&shost->shost_gendev); 390 device_initialize(&shost->shost_gendev);
384 snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d", 391 snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d",
385 shost->host_no); 392 shost->host_no);
386 shost->shost_gendev.release = scsi_host_dev_release; 393#ifndef CONFIG_SYSFS_DEPRECATED
394 shost->shost_gendev.bus = &scsi_bus_type;
395#endif
396 shost->shost_gendev.type = &scsi_host_type;
387 397
388 device_initialize(&shost->shost_dev); 398 device_initialize(&shost->shost_dev);
389 shost->shost_dev.parent = &shost->shost_gendev; 399 shost->shost_dev.parent = &shost->shost_gendev;
390 shost->shost_dev.class = &shost_class; 400 shost->shost_dev.class = &shost_class;
391 snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d", 401 snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d",
392 shost->host_no); 402 shost->host_no);
403 shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
393 404
394 shost->ehandler = kthread_run(scsi_error_handler, shost, 405 shost->ehandler = kthread_run(scsi_error_handler, shost,
395 "scsi_eh_%d", shost->host_no); 406 "scsi_eh_%d", shost->host_no);
396 if (IS_ERR(shost->ehandler)) { 407 if (IS_ERR(shost->ehandler)) {
397 rval = PTR_ERR(shost->ehandler); 408 rval = PTR_ERR(shost->ehandler);
398 goto fail_destroy_freelist; 409 goto fail_kfree;
399 } 410 }
400 411
401 scsi_proc_hostdir_add(shost->hostt); 412 scsi_proc_hostdir_add(shost->hostt);
402 return shost; 413 return shost;
403 414
404 fail_destroy_freelist:
405 scsi_destroy_command_freelist(shost);
406 fail_kfree: 415 fail_kfree:
407 kfree(shost); 416 kfree(shost);
408 return NULL; 417 return NULL;
@@ -496,7 +505,7 @@ void scsi_exit_hosts(void)
496 505
497int scsi_is_host_device(const struct device *dev) 506int scsi_is_host_device(const struct device *dev)
498{ 507{
499 return dev->release == scsi_host_dev_release; 508 return dev->type == &scsi_host_type;
500} 509}
501EXPORT_SYMBOL(scsi_is_host_device); 510EXPORT_SYMBOL(scsi_is_host_device);
502 511