aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2008-03-18 09:32:28 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-22 16:16:29 -0400
commitb0ed43360fdca227048d88a08290365cb681c1a8 (patch)
treec4bec4f311c2d73159df6fe35986442968aae8c9
parentcb6b7f40630f94126233194847a86bf5501fb63c (diff)
[SCSI] add scsi_host and scsi_target to scsi_bus
This patch implements scsi_host and scsi_target device types and adds both to the scsi_bus. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/hosts.c12
-rw-r--r--drivers/scsi/scsi_proc.c7
-rw-r--r--drivers/scsi/scsi_scan.c12
-rw-r--r--drivers/scsi/scsi_sysfs.c29
4 files changed, 50 insertions, 10 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index c264a8c5f01e..63bed62f270e 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -284,6 +284,11 @@ static void scsi_host_dev_release(struct device *dev)
284 kfree(shost); 284 kfree(shost);
285} 285}
286 286
287struct device_type scsi_host_type = {
288 .name = "scsi_host",
289 .release = scsi_host_dev_release,
290};
291
287/** 292/**
288 * scsi_host_alloc - register a scsi host adapter instance. 293 * scsi_host_alloc - register a scsi host adapter instance.
289 * @sht: pointer to scsi host template 294 * @sht: pointer to scsi host template
@@ -383,7 +388,10 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
383 device_initialize(&shost->shost_gendev); 388 device_initialize(&shost->shost_gendev);
384 snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d", 389 snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d",
385 shost->host_no); 390 shost->host_no);
386 shost->shost_gendev.release = scsi_host_dev_release; 391#ifndef CONFIG_SYSFS_DEPRECATED
392 shost->shost_gendev.bus = &scsi_bus_type;
393#endif
394 shost->shost_gendev.type = &scsi_host_type;
387 395
388 device_initialize(&shost->shost_dev); 396 device_initialize(&shost->shost_dev);
389 shost->shost_dev.parent = &shost->shost_gendev; 397 shost->shost_dev.parent = &shost->shost_gendev;
@@ -496,7 +504,7 @@ void scsi_exit_hosts(void)
496 504
497int scsi_is_host_device(const struct device *dev) 505int scsi_is_host_device(const struct device *dev)
498{ 506{
499 return dev->release == scsi_host_dev_release; 507 return dev->type == &scsi_host_type;
500} 508}
501EXPORT_SYMBOL(scsi_is_host_device); 509EXPORT_SYMBOL(scsi_is_host_device);
502 510
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index ed395154a5b1..3a1c99d5c775 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -190,10 +190,14 @@ void scsi_proc_host_rm(struct Scsi_Host *shost)
190 */ 190 */
191static int proc_print_scsidevice(struct device *dev, void *data) 191static int proc_print_scsidevice(struct device *dev, void *data)
192{ 192{
193 struct scsi_device *sdev = to_scsi_device(dev); 193 struct scsi_device *sdev;
194 struct seq_file *s = data; 194 struct seq_file *s = data;
195 int i; 195 int i;
196 196
197 if (!scsi_is_sdev_device(dev))
198 goto out;
199
200 sdev = to_scsi_device(dev);
197 seq_printf(s, 201 seq_printf(s,
198 "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n Vendor: ", 202 "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n Vendor: ",
199 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); 203 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
@@ -230,6 +234,7 @@ static int proc_print_scsidevice(struct device *dev, void *data)
230 else 234 else
231 seq_printf(s, "\n"); 235 seq_printf(s, "\n");
232 236
237out:
233 return 0; 238 return 0;
234} 239}
235 240
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index e67c14e31bab..e1644b270cdc 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -331,9 +331,14 @@ static void scsi_target_dev_release(struct device *dev)
331 put_device(parent); 331 put_device(parent);
332} 332}
333 333
334struct device_type scsi_target_type = {
335 .name = "scsi_target",
336 .release = scsi_target_dev_release,
337};
338
334int scsi_is_target_device(const struct device *dev) 339int scsi_is_target_device(const struct device *dev)
335{ 340{
336 return dev->release == scsi_target_dev_release; 341 return dev->type == &scsi_target_type;
337} 342}
338EXPORT_SYMBOL(scsi_is_target_device); 343EXPORT_SYMBOL(scsi_is_target_device);
339 344
@@ -391,9 +396,12 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
391 device_initialize(dev); 396 device_initialize(dev);
392 starget->reap_ref = 1; 397 starget->reap_ref = 1;
393 dev->parent = get_device(parent); 398 dev->parent = get_device(parent);
394 dev->release = scsi_target_dev_release;
395 sprintf(dev->bus_id, "target%d:%d:%d", 399 sprintf(dev->bus_id, "target%d:%d:%d",
396 shost->host_no, channel, id); 400 shost->host_no, channel, id);
401#ifndef CONFIG_SYSFS_DEPRECATED
402 dev->bus = &scsi_bus_type;
403#endif
404 dev->type = &scsi_target_type;
397 starget->id = id; 405 starget->id = id;
398 starget->channel = channel; 406 starget->channel = channel;
399 INIT_LIST_HEAD(&starget->siblings); 407 INIT_LIST_HEAD(&starget->siblings);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 67bb20ed45d2..fbd7f9ed1251 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -21,6 +21,8 @@
21#include "scsi_priv.h" 21#include "scsi_priv.h"
22#include "scsi_logging.h" 22#include "scsi_logging.h"
23 23
24static struct device_type scsi_dev_type;
25
24static const struct { 26static const struct {
25 enum scsi_device_state value; 27 enum scsi_device_state value;
26 char *name; 28 char *name;
@@ -335,7 +337,12 @@ static struct class sdev_class = {
335/* all probing is done in the individual ->probe routines */ 337/* all probing is done in the individual ->probe routines */
336static int scsi_bus_match(struct device *dev, struct device_driver *gendrv) 338static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
337{ 339{
338 struct scsi_device *sdp = to_scsi_device(dev); 340 struct scsi_device *sdp;
341
342 if (dev->type != &scsi_dev_type)
343 return 0;
344
345 sdp = to_scsi_device(dev);
339 if (sdp->no_uld_attach) 346 if (sdp->no_uld_attach)
340 return 0; 347 return 0;
341 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 348 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
@@ -351,10 +358,16 @@ static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
351 358
352static int scsi_bus_suspend(struct device * dev, pm_message_t state) 359static int scsi_bus_suspend(struct device * dev, pm_message_t state)
353{ 360{
354 struct device_driver *drv = dev->driver; 361 struct device_driver *drv;
355 struct scsi_device *sdev = to_scsi_device(dev); 362 struct scsi_device *sdev;
356 int err; 363 int err;
357 364
365 if (dev->type != &scsi_dev_type)
366 return 0;
367
368 drv = dev->driver;
369 sdev = to_scsi_device(dev);
370
358 err = scsi_device_quiesce(sdev); 371 err = scsi_device_quiesce(sdev);
359 if (err) 372 if (err)
360 return err; 373 return err;
@@ -370,10 +383,16 @@ static int scsi_bus_suspend(struct device * dev, pm_message_t state)
370 383
371static int scsi_bus_resume(struct device * dev) 384static int scsi_bus_resume(struct device * dev)
372{ 385{
373 struct device_driver *drv = dev->driver; 386 struct device_driver *drv;
374 struct scsi_device *sdev = to_scsi_device(dev); 387 struct scsi_device *sdev;
375 int err = 0; 388 int err = 0;
376 389
390 if (dev->type != &scsi_dev_type)
391 return 0;
392
393 drv = dev->driver;
394 sdev = to_scsi_device(dev);
395
377 if (drv && drv->resume) 396 if (drv && drv->resume)
378 err = drv->resume(dev); 397 err = drv->resume(dev);
379 398