aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 20:19:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 20:19:08 -0500
commit9b73e76f3cf63379dcf45fcd4f112f5812418d0a (patch)
tree4e6bef87cd0cd6d848fc39a5ae25b981dbbe035b /drivers/scsi/sg.c
parent50d9a126240f9961cfdd063336bbeb91f77a7dce (diff)
parent23c3e290fb9ce38cabc2822b47583fc8702411bf (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits) [SCSI] usbstorage: use last_sector_bug flag universally [SCSI] libsas: abstract STP task status into a function [SCSI] ultrastor: clean up inline asm warnings [SCSI] aic7xxx: fix firmware build [SCSI] aacraid: fib context lock for management ioctls [SCSI] ch: remove forward declarations [SCSI] ch: fix device minor number management bug [SCSI] ch: handle class_device_create failure properly [SCSI] NCR5380: fix section mismatch [SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices [SCSI] IB/iSER: add logical unit reset support [SCSI] don't use __GFP_DMA for sense buffers if not required [SCSI] use dynamically allocated sense buffer [SCSI] scsi.h: add macro for enclosure bit of inquiry data [SCSI] sd: add fix for devices with last sector access problems [SCSI] fix pcmcia compile problem [SCSI] aacraid: add Voodoo Lite class of cards. [SCSI] aacraid: add new driver features flags [SCSI] qla2xxx: Update version number to 8.02.00-k7. [SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command. ...
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f1871ea04045..17216b76efdc 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -602,8 +602,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
602 * but is is possible that the app intended SG_DXFER_TO_DEV, because there 602 * but is is possible that the app intended SG_DXFER_TO_DEV, because there
603 * is a non-zero input_size, so emit a warning. 603 * is a non-zero input_size, so emit a warning.
604 */ 604 */
605 if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) 605 if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
606 if (printk_ratelimit()) 606 static char cmd[TASK_COMM_LEN];
607 if (strcmp(current->comm, cmd) && printk_ratelimit()) {
607 printk(KERN_WARNING 608 printk(KERN_WARNING
608 "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--" 609 "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
609 "guessing data in;\n" KERN_WARNING " " 610 "guessing data in;\n" KERN_WARNING " "
@@ -611,6 +612,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
611 old_hdr.reply_len - (int)SZ_SG_HEADER, 612 old_hdr.reply_len - (int)SZ_SG_HEADER,
612 input_size, (unsigned int) cmnd[0], 613 input_size, (unsigned int) cmnd[0],
613 current->comm); 614 current->comm);
615 strcpy(cmd, current->comm);
616 }
617 }
614 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); 618 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
615 return (k < 0) ? k : count; 619 return (k < 0) ? k : count;
616} 620}
@@ -1418,7 +1422,6 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1418 goto out; 1422 goto out;
1419 } 1423 }
1420 1424
1421 class_set_devdata(cl_dev, sdp);
1422 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1); 1425 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);
1423 if (error) 1426 if (error)
1424 goto cdev_add_err; 1427 goto cdev_add_err;
@@ -1431,11 +1434,14 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1431 MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1434 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
1432 cl_dev->dev, "%s", 1435 cl_dev->dev, "%s",
1433 disk->disk_name); 1436 disk->disk_name);
1434 if (IS_ERR(sg_class_member)) 1437 if (IS_ERR(sg_class_member)) {
1435 printk(KERN_WARNING "sg_add: " 1438 printk(KERN_ERR "sg_add: "
1436 "class_device_create failed\n"); 1439 "class_device_create failed\n");
1440 error = PTR_ERR(sg_class_member);
1441 goto cdev_add_err;
1442 }
1437 class_set_devdata(sg_class_member, sdp); 1443 class_set_devdata(sg_class_member, sdp);
1438 error = sysfs_create_link(&scsidp->sdev_gendev.kobj, 1444 error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
1439 &sg_class_member->kobj, "generic"); 1445 &sg_class_member->kobj, "generic");
1440 if (error) 1446 if (error)
1441 printk(KERN_ERR "sg_add: unable to make symlink " 1447 printk(KERN_ERR "sg_add: unable to make symlink "
@@ -1447,6 +1453,8 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1447 "Attached scsi generic sg%d type %d\n", sdp->index, 1453 "Attached scsi generic sg%d type %d\n", sdp->index,
1448 scsidp->type); 1454 scsidp->type);
1449 1455
1456 class_set_devdata(cl_dev, sdp);
1457
1450 return 0; 1458 return 0;
1451 1459
1452cdev_add_err: 1460cdev_add_err:
@@ -2521,7 +2529,7 @@ sg_idr_max_id(int id, void *p, void *data)
2521static int 2529static int
2522sg_last_dev(void) 2530sg_last_dev(void)
2523{ 2531{
2524 int k = 0; 2532 int k = -1;
2525 unsigned long iflags; 2533 unsigned long iflags;
2526 2534
2527 read_lock_irqsave(&sg_index_lock, iflags); 2535 read_lock_irqsave(&sg_index_lock, iflags);