aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_sysfs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-05 16:30:44 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-05 16:30:44 -0400
commit4f7a307dc6e4d8bfeb56f7cf7231b08cb845687c (patch)
tree3bf90522c87fcb32373cb2a5ff25b1ead33405f5 /drivers/scsi/scsi_sysfs.c
parentfabb5c4e4a474ff0f7d6c1d3466a1b79bbce5f49 (diff)
parent7297824581755593535fc97d2c8b6c47e2dc2db6 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (87 commits) [SCSI] fusion: fix domain validation loops [SCSI] qla2xxx: fix regression on sparc64 [SCSI] modalias for scsi devices [SCSI] sg: cap reserved_size values at max_sectors [SCSI] BusLogic: stop using check_region [SCSI] tgt: fix rdma transfer bugs [SCSI] aacraid: fix aacraid not finding device [SCSI] aacraid: Correct SMC products in aacraid.txt [SCSI] scsi_error.c: Add EH Start Unit retry [SCSI] aacraid: [Fastboot] Panics for AACRAID driver during 'insmod' for kexec test. [SCSI] ipr: Driver version to 2.3.2 [SCSI] ipr: Faster sg list fetch [SCSI] ipr: Return better qc_issue errors [SCSI] ipr: Disrupt device error [SCSI] ipr: Improve async error logging level control [SCSI] ipr: PCI unblock config access fix [SCSI] ipr: Fix for oops following SATA request sense [SCSI] ipr: Log error for SAS dual path switch [SCSI] ipr: Enable logging of debug error data for all devices [SCSI] ipr: Add new PCI-E IDs to device table ...
Diffstat (limited to 'drivers/scsi/scsi_sysfs.c')
-rw-r--r--drivers/scsi/scsi_sysfs.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 939de0de18bc..67a38a1409ba 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -276,8 +276,22 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
276 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 276 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
277} 277}
278 278
279static int scsi_bus_uevent(struct device *dev, char **envp, int num_envp,
280 char *buffer, int buffer_size)
281{
282 struct scsi_device *sdev = to_scsi_device(dev);
283 int i = 0;
284 int length = 0;
285
286 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
287 "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
288 envp[i] = NULL;
289 return 0;
290}
291
279static int scsi_bus_suspend(struct device * dev, pm_message_t state) 292static int scsi_bus_suspend(struct device * dev, pm_message_t state)
280{ 293{
294 struct device_driver *drv = dev->driver;
281 struct scsi_device *sdev = to_scsi_device(dev); 295 struct scsi_device *sdev = to_scsi_device(dev);
282 struct scsi_host_template *sht = sdev->host->hostt; 296 struct scsi_host_template *sht = sdev->host->hostt;
283 int err; 297 int err;
@@ -286,28 +300,51 @@ static int scsi_bus_suspend(struct device * dev, pm_message_t state)
286 if (err) 300 if (err)
287 return err; 301 return err;
288 302
289 if (sht->suspend) 303 /* call HLD suspend first */
304 if (drv && drv->suspend) {
305 err = drv->suspend(dev, state);
306 if (err)
307 return err;
308 }
309
310 /* then, call host suspend */
311 if (sht->suspend) {
290 err = sht->suspend(sdev, state); 312 err = sht->suspend(sdev, state);
313 if (err) {
314 if (drv && drv->resume)
315 drv->resume(dev);
316 return err;
317 }
318 }
291 319
292 return err; 320 return 0;
293} 321}
294 322
295static int scsi_bus_resume(struct device * dev) 323static int scsi_bus_resume(struct device * dev)
296{ 324{
325 struct device_driver *drv = dev->driver;
297 struct scsi_device *sdev = to_scsi_device(dev); 326 struct scsi_device *sdev = to_scsi_device(dev);
298 struct scsi_host_template *sht = sdev->host->hostt; 327 struct scsi_host_template *sht = sdev->host->hostt;
299 int err = 0; 328 int err = 0, err2 = 0;
300 329
330 /* call host resume first */
301 if (sht->resume) 331 if (sht->resume)
302 err = sht->resume(sdev); 332 err = sht->resume(sdev);
303 333
334 /* then, call HLD resume */
335 if (drv && drv->resume)
336 err2 = drv->resume(dev);
337
304 scsi_device_resume(sdev); 338 scsi_device_resume(sdev);
305 return err; 339
340 /* favor LLD failure */
341 return err ? err : err2;;
306} 342}
307 343
308struct bus_type scsi_bus_type = { 344struct bus_type scsi_bus_type = {
309 .name = "scsi", 345 .name = "scsi",
310 .match = scsi_bus_match, 346 .match = scsi_bus_match,
347 .uevent = scsi_bus_uevent,
311 .suspend = scsi_bus_suspend, 348 .suspend = scsi_bus_suspend,
312 .resume = scsi_bus_resume, 349 .resume = scsi_bus_resume,
313}; 350};
@@ -547,6 +584,14 @@ show_sdev_iostat(iorequest_cnt);
547show_sdev_iostat(iodone_cnt); 584show_sdev_iostat(iodone_cnt);
548show_sdev_iostat(ioerr_cnt); 585show_sdev_iostat(ioerr_cnt);
549 586
587static ssize_t
588sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
589{
590 struct scsi_device *sdev;
591 sdev = to_scsi_device(dev);
592 return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
593}
594static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
550 595
551/* Default template for device attributes. May NOT be modified */ 596/* Default template for device attributes. May NOT be modified */
552static struct device_attribute *scsi_sysfs_sdev_attrs[] = { 597static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
@@ -566,6 +611,7 @@ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
566 &dev_attr_iorequest_cnt, 611 &dev_attr_iorequest_cnt,
567 &dev_attr_iodone_cnt, 612 &dev_attr_iodone_cnt,
568 &dev_attr_ioerr_cnt, 613 &dev_attr_ioerr_cnt,
614 &dev_attr_modalias,
569 NULL 615 NULL
570}; 616};
571 617