aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cdrom/gdrom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cdrom/gdrom.c')
-rw-r--r--drivers/cdrom/gdrom.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 03c71f7698cb..261107d1457c 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -19,6 +19,8 @@
19 * 19 *
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/init.h> 24#include <linux/init.h>
23#include <linux/module.h> 25#include <linux/module.h>
24#include <linux/fs.h> 26#include <linux/fs.h>
@@ -32,6 +34,7 @@
32#include <linux/blkdev.h> 34#include <linux/blkdev.h>
33#include <linux/interrupt.h> 35#include <linux/interrupt.h>
34#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/smp_lock.h>
35#include <linux/wait.h> 38#include <linux/wait.h>
36#include <linux/workqueue.h> 39#include <linux/workqueue.h>
37#include <linux/platform_device.h> 40#include <linux/platform_device.h>
@@ -339,8 +342,7 @@ static int gdrom_get_last_session(struct cdrom_device_info *cd_info,
339 tocuse = 0; 342 tocuse = 0;
340 err = gdrom_readtoc_cmd(gd.toc, 0); 343 err = gdrom_readtoc_cmd(gd.toc, 0);
341 if (err) { 344 if (err) {
342 printk(KERN_INFO "GDROM: Could not get CD " 345 pr_info("Could not get CD table of contents\n");
343 "table of contents\n");
344 return -ENXIO; 346 return -ENXIO;
345 } 347 }
346 } 348 }
@@ -357,8 +359,7 @@ static int gdrom_get_last_session(struct cdrom_device_info *cd_info,
357 } while (track >= fentry); 359 } while (track >= fentry);
358 360
359 if ((track > 100) || (track < get_entry_track(gd.toc->first))) { 361 if ((track > 100) || (track < get_entry_track(gd.toc->first))) {
360 printk(KERN_INFO "GDROM: No data on the last " 362 pr_info("No data on the last session of the CD\n");
361 "session of the CD\n");
362 gdrom_getsense(NULL); 363 gdrom_getsense(NULL);
363 return -ENXIO; 364 return -ENXIO;
364 } 365 }
@@ -451,14 +452,14 @@ static int gdrom_getsense(short *bufstring)
451 goto cleanup_sense; 452 goto cleanup_sense;
452 insw(GDROM_DATA_REG, &sense, sense_command->buflen/2); 453 insw(GDROM_DATA_REG, &sense, sense_command->buflen/2);
453 if (sense[1] & 40) { 454 if (sense[1] & 40) {
454 printk(KERN_INFO "GDROM: Drive not ready - command aborted\n"); 455 pr_info("Drive not ready - command aborted\n");
455 goto cleanup_sense; 456 goto cleanup_sense;
456 } 457 }
457 sense_key = sense[1] & 0x0F; 458 sense_key = sense[1] & 0x0F;
458 if (sense_key < ARRAY_SIZE(sense_texts)) 459 if (sense_key < ARRAY_SIZE(sense_texts))
459 printk(KERN_INFO "GDROM: %s\n", sense_texts[sense_key].text); 460 pr_info("%s\n", sense_texts[sense_key].text);
460 else 461 else
461 printk(KERN_ERR "GDROM: Unknown sense key: %d\n", sense_key); 462 pr_err("Unknown sense key: %d\n", sense_key);
462 if (bufstring) /* return addional sense data */ 463 if (bufstring) /* return addional sense data */
463 memcpy(bufstring, &sense[4], 2); 464 memcpy(bufstring, &sense[4], 2);
464 if (sense_key < 2) 465 if (sense_key < 2)
@@ -492,12 +493,18 @@ static struct cdrom_device_ops gdrom_ops = {
492 493
493static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) 494static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
494{ 495{
495 return cdrom_open(gd.cd_info, bdev, mode); 496 int ret;
497 lock_kernel();
498 ret = cdrom_open(gd.cd_info, bdev, mode);
499 unlock_kernel();
500 return ret;
496} 501}
497 502
498static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) 503static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode)
499{ 504{
505 lock_kernel();
500 cdrom_release(gd.cd_info, mode); 506 cdrom_release(gd.cd_info, mode);
507 unlock_kernel();
501 return 0; 508 return 0;
502} 509}
503 510
@@ -509,7 +516,13 @@ static int gdrom_bdops_mediachanged(struct gendisk *disk)
509static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode, 516static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode,
510 unsigned cmd, unsigned long arg) 517 unsigned cmd, unsigned long arg)
511{ 518{
512 return cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); 519 int ret;
520
521 lock_kernel();
522 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg);
523 unlock_kernel();
524
525 return ret;
513} 526}
514 527
515static const struct block_device_operations gdrom_bdops = { 528static const struct block_device_operations gdrom_bdops = {
@@ -517,7 +530,7 @@ static const struct block_device_operations gdrom_bdops = {
517 .open = gdrom_bdops_open, 530 .open = gdrom_bdops_open,
518 .release = gdrom_bdops_release, 531 .release = gdrom_bdops_release,
519 .media_changed = gdrom_bdops_mediachanged, 532 .media_changed = gdrom_bdops_mediachanged,
520 .locked_ioctl = gdrom_bdops_ioctl, 533 .ioctl = gdrom_bdops_ioctl,
521}; 534};
522 535
523static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id) 536static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id)
@@ -643,14 +656,13 @@ static void gdrom_request(struct request_queue *rq)
643 struct request *req; 656 struct request *req;
644 657
645 while ((req = blk_fetch_request(rq)) != NULL) { 658 while ((req = blk_fetch_request(rq)) != NULL) {
646 if (!blk_fs_request(req)) { 659 if (req->cmd_type != REQ_TYPE_FS) {
647 printk(KERN_DEBUG "GDROM: Non-fs request ignored\n"); 660 printk(KERN_DEBUG "gdrom: Non-fs request ignored\n");
648 __blk_end_request_all(req, -EIO); 661 __blk_end_request_all(req, -EIO);
649 continue; 662 continue;
650 } 663 }
651 if (rq_data_dir(req) != READ) { 664 if (rq_data_dir(req) != READ) {
652 printk(KERN_NOTICE "GDROM: Read only device -"); 665 pr_notice("Read only device - write request ignored\n");
653 printk(" write request ignored\n");
654 __blk_end_request_all(req, -EIO); 666 __blk_end_request_all(req, -EIO);
655 continue; 667 continue;
656 } 668 }
@@ -685,7 +697,7 @@ static int __devinit gdrom_outputversion(void)
685 firmw_ver = kstrndup(id->firmver, 16, GFP_KERNEL); 697 firmw_ver = kstrndup(id->firmver, 16, GFP_KERNEL);
686 if (!firmw_ver) 698 if (!firmw_ver)
687 goto free_manuf_name; 699 goto free_manuf_name;
688 printk(KERN_INFO "GDROM: %s from %s with firmware %s\n", 700 pr_info("%s from %s with firmware %s\n",
689 model_name, manuf_name, firmw_ver); 701 model_name, manuf_name, firmw_ver);
690 err = 0; 702 err = 0;
691 kfree(firmw_ver); 703 kfree(firmw_ver);
@@ -757,7 +769,7 @@ static int __devinit probe_gdrom(struct platform_device *devptr)
757 int err; 769 int err;
758 /* Start the device */ 770 /* Start the device */
759 if (gdrom_execute_diagnostic() != 1) { 771 if (gdrom_execute_diagnostic() != 1) {
760 printk(KERN_WARNING "GDROM: ATA Probe for GDROM failed.\n"); 772 pr_warning("ATA Probe for GDROM failed\n");
761 return -ENODEV; 773 return -ENODEV;
762 } 774 }
763 /* Print out firmware ID */ 775 /* Print out firmware ID */
@@ -767,7 +779,7 @@ static int __devinit probe_gdrom(struct platform_device *devptr)
767 gdrom_major = register_blkdev(0, GDROM_DEV_NAME); 779 gdrom_major = register_blkdev(0, GDROM_DEV_NAME);
768 if (gdrom_major <= 0) 780 if (gdrom_major <= 0)
769 return gdrom_major; 781 return gdrom_major;
770 printk(KERN_INFO "GDROM: Registered with major number %d\n", 782 pr_info("Registered with major number %d\n",
771 gdrom_major); 783 gdrom_major);
772 /* Specify basic properties of drive */ 784 /* Specify basic properties of drive */
773 gd.cd_info = kzalloc(sizeof(struct cdrom_device_info), GFP_KERNEL); 785 gd.cd_info = kzalloc(sizeof(struct cdrom_device_info), GFP_KERNEL);
@@ -818,7 +830,7 @@ probe_fail_no_disk:
818 unregister_blkdev(gdrom_major, GDROM_DEV_NAME); 830 unregister_blkdev(gdrom_major, GDROM_DEV_NAME);
819 gdrom_major = 0; 831 gdrom_major = 0;
820probe_fail_no_mem: 832probe_fail_no_mem:
821 printk(KERN_WARNING "GDROM: Probe failed - error is 0x%X\n", err); 833 pr_warning("Probe failed - error is 0x%X\n", err);
822 return err; 834 return err;
823} 835}
824 836