diff options
Diffstat (limited to 'drivers')
51 files changed, 1245 insertions, 1107 deletions
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c index 8660779fb288..bdb60663f2ef 100644 --- a/drivers/base/power/suspend.c +++ b/drivers/base/power/suspend.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/vt_kern.h> | ||
11 | #include <linux/device.h> | 12 | #include <linux/device.h> |
12 | #include "../base.h" | 13 | #include "../base.h" |
13 | #include "power.h" | 14 | #include "power.h" |
@@ -62,7 +63,6 @@ int suspend_device(struct device * dev, pm_message_t state) | |||
62 | return error; | 63 | return error; |
63 | } | 64 | } |
64 | 65 | ||
65 | |||
66 | /** | 66 | /** |
67 | * device_suspend - Save state and stop all devices in system. | 67 | * device_suspend - Save state and stop all devices in system. |
68 | * @state: Power state to put each device in. | 68 | * @state: Power state to put each device in. |
@@ -82,6 +82,9 @@ int device_suspend(pm_message_t state) | |||
82 | { | 82 | { |
83 | int error = 0; | 83 | int error = 0; |
84 | 84 | ||
85 | if (!is_console_suspend_safe()) | ||
86 | return -EINVAL; | ||
87 | |||
85 | down(&dpm_sem); | 88 | down(&dpm_sem); |
86 | down(&dpm_list_sem); | 89 | down(&dpm_list_sem); |
87 | while (!list_empty(&dpm_active) && error == 0) { | 90 | while (!list_empty(&dpm_active) && error == 0) { |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index cf39cf9aac25..e29b8926f80e 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -3268,8 +3268,8 @@ clean2: | |||
3268 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 3268 | unregister_blkdev(hba[i]->major, hba[i]->devname); |
3269 | clean1: | 3269 | clean1: |
3270 | release_io_mem(hba[i]); | 3270 | release_io_mem(hba[i]); |
3271 | free_hba(i); | ||
3272 | hba[i]->busy_initializing = 0; | 3271 | hba[i]->busy_initializing = 0; |
3272 | free_hba(i); | ||
3273 | return(-1); | 3273 | return(-1); |
3274 | } | 3274 | } |
3275 | 3275 | ||
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index d23b54332d7e..fb2d0be7cdeb 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -179,6 +179,7 @@ static int print_unex = 1; | |||
179 | #include <linux/devfs_fs_kernel.h> | 179 | #include <linux/devfs_fs_kernel.h> |
180 | #include <linux/platform_device.h> | 180 | #include <linux/platform_device.h> |
181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ | 181 | #include <linux/buffer_head.h> /* for invalidate_buffers() */ |
182 | #include <linux/mutex.h> | ||
182 | 183 | ||
183 | /* | 184 | /* |
184 | * PS/2 floppies have much slower step rates than regular floppies. | 185 | * PS/2 floppies have much slower step rates than regular floppies. |
@@ -413,7 +414,7 @@ static struct floppy_write_errors write_errors[N_DRIVE]; | |||
413 | static struct timer_list motor_off_timer[N_DRIVE]; | 414 | static struct timer_list motor_off_timer[N_DRIVE]; |
414 | static struct gendisk *disks[N_DRIVE]; | 415 | static struct gendisk *disks[N_DRIVE]; |
415 | static struct block_device *opened_bdev[N_DRIVE]; | 416 | static struct block_device *opened_bdev[N_DRIVE]; |
416 | static DECLARE_MUTEX(open_lock); | 417 | static DEFINE_MUTEX(open_lock); |
417 | static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; | 418 | static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; |
418 | 419 | ||
419 | /* | 420 | /* |
@@ -3333,7 +3334,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3333 | if (type) { | 3334 | if (type) { |
3334 | if (!capable(CAP_SYS_ADMIN)) | 3335 | if (!capable(CAP_SYS_ADMIN)) |
3335 | return -EPERM; | 3336 | return -EPERM; |
3336 | down(&open_lock); | 3337 | mutex_lock(&open_lock); |
3337 | LOCK_FDC(drive, 1); | 3338 | LOCK_FDC(drive, 1); |
3338 | floppy_type[type] = *g; | 3339 | floppy_type[type] = *g; |
3339 | floppy_type[type].name = "user format"; | 3340 | floppy_type[type].name = "user format"; |
@@ -3347,7 +3348,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3347 | continue; | 3348 | continue; |
3348 | __invalidate_device(bdev); | 3349 | __invalidate_device(bdev); |
3349 | } | 3350 | } |
3350 | up(&open_lock); | 3351 | mutex_unlock(&open_lock); |
3351 | } else { | 3352 | } else { |
3352 | int oldStretch; | 3353 | int oldStretch; |
3353 | LOCK_FDC(drive, 1); | 3354 | LOCK_FDC(drive, 1); |
@@ -3674,7 +3675,7 @@ static int floppy_release(struct inode *inode, struct file *filp) | |||
3674 | { | 3675 | { |
3675 | int drive = (long)inode->i_bdev->bd_disk->private_data; | 3676 | int drive = (long)inode->i_bdev->bd_disk->private_data; |
3676 | 3677 | ||
3677 | down(&open_lock); | 3678 | mutex_lock(&open_lock); |
3678 | if (UDRS->fd_ref < 0) | 3679 | if (UDRS->fd_ref < 0) |
3679 | UDRS->fd_ref = 0; | 3680 | UDRS->fd_ref = 0; |
3680 | else if (!UDRS->fd_ref--) { | 3681 | else if (!UDRS->fd_ref--) { |
@@ -3684,7 +3685,7 @@ static int floppy_release(struct inode *inode, struct file *filp) | |||
3684 | if (!UDRS->fd_ref) | 3685 | if (!UDRS->fd_ref) |
3685 | opened_bdev[drive] = NULL; | 3686 | opened_bdev[drive] = NULL; |
3686 | floppy_release_irq_and_dma(); | 3687 | floppy_release_irq_and_dma(); |
3687 | up(&open_lock); | 3688 | mutex_unlock(&open_lock); |
3688 | return 0; | 3689 | return 0; |
3689 | } | 3690 | } |
3690 | 3691 | ||
@@ -3702,7 +3703,7 @@ static int floppy_open(struct inode *inode, struct file *filp) | |||
3702 | char *tmp; | 3703 | char *tmp; |
3703 | 3704 | ||
3704 | filp->private_data = (void *)0; | 3705 | filp->private_data = (void *)0; |
3705 | down(&open_lock); | 3706 | mutex_lock(&open_lock); |
3706 | old_dev = UDRS->fd_device; | 3707 | old_dev = UDRS->fd_device; |
3707 | if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) | 3708 | if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) |
3708 | goto out2; | 3709 | goto out2; |
@@ -3785,7 +3786,7 @@ static int floppy_open(struct inode *inode, struct file *filp) | |||
3785 | if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) | 3786 | if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) |
3786 | goto out; | 3787 | goto out; |
3787 | } | 3788 | } |
3788 | up(&open_lock); | 3789 | mutex_unlock(&open_lock); |
3789 | return 0; | 3790 | return 0; |
3790 | out: | 3791 | out: |
3791 | if (UDRS->fd_ref < 0) | 3792 | if (UDRS->fd_ref < 0) |
@@ -3796,7 +3797,7 @@ out: | |||
3796 | opened_bdev[drive] = NULL; | 3797 | opened_bdev[drive] = NULL; |
3797 | floppy_release_irq_and_dma(); | 3798 | floppy_release_irq_and_dma(); |
3798 | out2: | 3799 | out2: |
3799 | up(&open_lock); | 3800 | mutex_unlock(&open_lock); |
3800 | return res; | 3801 | return res; |
3801 | } | 3802 | } |
3802 | 3803 | ||
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 0010704739e3..74bf0255e98f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1144,7 +1144,7 @@ static int lo_ioctl(struct inode * inode, struct file * file, | |||
1144 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1144 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1145 | int err; | 1145 | int err; |
1146 | 1146 | ||
1147 | down(&lo->lo_ctl_mutex); | 1147 | mutex_lock(&lo->lo_ctl_mutex); |
1148 | switch (cmd) { | 1148 | switch (cmd) { |
1149 | case LOOP_SET_FD: | 1149 | case LOOP_SET_FD: |
1150 | err = loop_set_fd(lo, file, inode->i_bdev, arg); | 1150 | err = loop_set_fd(lo, file, inode->i_bdev, arg); |
@@ -1170,7 +1170,7 @@ static int lo_ioctl(struct inode * inode, struct file * file, | |||
1170 | default: | 1170 | default: |
1171 | err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; | 1171 | err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; |
1172 | } | 1172 | } |
1173 | up(&lo->lo_ctl_mutex); | 1173 | mutex_unlock(&lo->lo_ctl_mutex); |
1174 | return err; | 1174 | return err; |
1175 | } | 1175 | } |
1176 | 1176 | ||
@@ -1178,9 +1178,9 @@ static int lo_open(struct inode *inode, struct file *file) | |||
1178 | { | 1178 | { |
1179 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1179 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1180 | 1180 | ||
1181 | down(&lo->lo_ctl_mutex); | 1181 | mutex_lock(&lo->lo_ctl_mutex); |
1182 | lo->lo_refcnt++; | 1182 | lo->lo_refcnt++; |
1183 | up(&lo->lo_ctl_mutex); | 1183 | mutex_unlock(&lo->lo_ctl_mutex); |
1184 | 1184 | ||
1185 | return 0; | 1185 | return 0; |
1186 | } | 1186 | } |
@@ -1189,9 +1189,9 @@ static int lo_release(struct inode *inode, struct file *file) | |||
1189 | { | 1189 | { |
1190 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1190 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; |
1191 | 1191 | ||
1192 | down(&lo->lo_ctl_mutex); | 1192 | mutex_lock(&lo->lo_ctl_mutex); |
1193 | --lo->lo_refcnt; | 1193 | --lo->lo_refcnt; |
1194 | up(&lo->lo_ctl_mutex); | 1194 | mutex_unlock(&lo->lo_ctl_mutex); |
1195 | 1195 | ||
1196 | return 0; | 1196 | return 0; |
1197 | } | 1197 | } |
@@ -1233,12 +1233,12 @@ int loop_unregister_transfer(int number) | |||
1233 | xfer_funcs[n] = NULL; | 1233 | xfer_funcs[n] = NULL; |
1234 | 1234 | ||
1235 | for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { | 1235 | for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { |
1236 | down(&lo->lo_ctl_mutex); | 1236 | mutex_lock(&lo->lo_ctl_mutex); |
1237 | 1237 | ||
1238 | if (lo->lo_encryption == xfer) | 1238 | if (lo->lo_encryption == xfer) |
1239 | loop_release_xfer(lo); | 1239 | loop_release_xfer(lo); |
1240 | 1240 | ||
1241 | up(&lo->lo_ctl_mutex); | 1241 | mutex_unlock(&lo->lo_ctl_mutex); |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | return 0; | 1244 | return 0; |
@@ -1285,7 +1285,7 @@ static int __init loop_init(void) | |||
1285 | lo->lo_queue = blk_alloc_queue(GFP_KERNEL); | 1285 | lo->lo_queue = blk_alloc_queue(GFP_KERNEL); |
1286 | if (!lo->lo_queue) | 1286 | if (!lo->lo_queue) |
1287 | goto out_mem4; | 1287 | goto out_mem4; |
1288 | init_MUTEX(&lo->lo_ctl_mutex); | 1288 | mutex_init(&lo->lo_ctl_mutex); |
1289 | init_completion(&lo->lo_done); | 1289 | init_completion(&lo->lo_done); |
1290 | init_completion(&lo->lo_bh_done); | 1290 | init_completion(&lo->lo_bh_done); |
1291 | lo->lo_number = i; | 1291 | lo->lo_number = i; |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 6997d8e6bfb5..a9bde30dadad 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q) | |||
459 | req->errors = 0; | 459 | req->errors = 0; |
460 | spin_unlock_irq(q->queue_lock); | 460 | spin_unlock_irq(q->queue_lock); |
461 | 461 | ||
462 | down(&lo->tx_lock); | 462 | mutex_lock(&lo->tx_lock); |
463 | if (unlikely(!lo->sock)) { | 463 | if (unlikely(!lo->sock)) { |
464 | up(&lo->tx_lock); | 464 | mutex_unlock(&lo->tx_lock); |
465 | printk(KERN_ERR "%s: Attempted send on closed socket\n", | 465 | printk(KERN_ERR "%s: Attempted send on closed socket\n", |
466 | lo->disk->disk_name); | 466 | lo->disk->disk_name); |
467 | req->errors++; | 467 | req->errors++; |
@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q) | |||
484 | } | 484 | } |
485 | 485 | ||
486 | lo->active_req = NULL; | 486 | lo->active_req = NULL; |
487 | up(&lo->tx_lock); | 487 | mutex_unlock(&lo->tx_lock); |
488 | wake_up_all(&lo->active_wq); | 488 | wake_up_all(&lo->active_wq); |
489 | 489 | ||
490 | spin_lock_irq(q->queue_lock); | 490 | spin_lock_irq(q->queue_lock); |
@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
534 | 534 | ||
535 | case NBD_CLEAR_SOCK: | 535 | case NBD_CLEAR_SOCK: |
536 | error = 0; | 536 | error = 0; |
537 | down(&lo->tx_lock); | 537 | mutex_lock(&lo->tx_lock); |
538 | lo->sock = NULL; | 538 | lo->sock = NULL; |
539 | up(&lo->tx_lock); | 539 | mutex_unlock(&lo->tx_lock); |
540 | file = lo->file; | 540 | file = lo->file; |
541 | lo->file = NULL; | 541 | lo->file = NULL; |
542 | nbd_clear_que(lo); | 542 | nbd_clear_que(lo); |
@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
590 | * FIXME: This code is duplicated from sys_shutdown, but | 590 | * FIXME: This code is duplicated from sys_shutdown, but |
591 | * there should be a more generic interface rather than | 591 | * there should be a more generic interface rather than |
592 | * calling socket ops directly here */ | 592 | * calling socket ops directly here */ |
593 | down(&lo->tx_lock); | 593 | mutex_lock(&lo->tx_lock); |
594 | if (lo->sock) { | 594 | if (lo->sock) { |
595 | printk(KERN_WARNING "%s: shutting down socket\n", | 595 | printk(KERN_WARNING "%s: shutting down socket\n", |
596 | lo->disk->disk_name); | 596 | lo->disk->disk_name); |
@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
598 | SEND_SHUTDOWN|RCV_SHUTDOWN); | 598 | SEND_SHUTDOWN|RCV_SHUTDOWN); |
599 | lo->sock = NULL; | 599 | lo->sock = NULL; |
600 | } | 600 | } |
601 | up(&lo->tx_lock); | 601 | mutex_unlock(&lo->tx_lock); |
602 | file = lo->file; | 602 | file = lo->file; |
603 | lo->file = NULL; | 603 | lo->file = NULL; |
604 | nbd_clear_que(lo); | 604 | nbd_clear_que(lo); |
@@ -683,7 +683,7 @@ static int __init nbd_init(void) | |||
683 | nbd_dev[i].flags = 0; | 683 | nbd_dev[i].flags = 0; |
684 | spin_lock_init(&nbd_dev[i].queue_lock); | 684 | spin_lock_init(&nbd_dev[i].queue_lock); |
685 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); | 685 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); |
686 | init_MUTEX(&nbd_dev[i].tx_lock); | 686 | mutex_init(&nbd_dev[i].tx_lock); |
687 | init_waitqueue_head(&nbd_dev[i].active_wq); | 687 | init_waitqueue_head(&nbd_dev[i].active_wq); |
688 | nbd_dev[i].blksize = 1024; | 688 | nbd_dev[i].blksize = 1024; |
689 | nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ | 689 | nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 476a5b553f34..1d261f985f31 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/seq_file.h> | 56 | #include <linux/seq_file.h> |
57 | #include <linux/miscdevice.h> | 57 | #include <linux/miscdevice.h> |
58 | #include <linux/suspend.h> | 58 | #include <linux/suspend.h> |
59 | #include <linux/mutex.h> | ||
59 | #include <scsi/scsi_cmnd.h> | 60 | #include <scsi/scsi_cmnd.h> |
60 | #include <scsi/scsi_ioctl.h> | 61 | #include <scsi/scsi_ioctl.h> |
61 | #include <scsi/scsi.h> | 62 | #include <scsi/scsi.h> |
@@ -81,7 +82,7 @@ | |||
81 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; | 82 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; |
82 | static struct proc_dir_entry *pkt_proc; | 83 | static struct proc_dir_entry *pkt_proc; |
83 | static int pkt_major; | 84 | static int pkt_major; |
84 | static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ | 85 | static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */ |
85 | static mempool_t *psd_pool; | 86 | static mempool_t *psd_pool; |
86 | 87 | ||
87 | 88 | ||
@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2018 | 2019 | ||
2019 | VPRINTK("pktcdvd: entering open\n"); | 2020 | VPRINTK("pktcdvd: entering open\n"); |
2020 | 2021 | ||
2021 | down(&ctl_mutex); | 2022 | mutex_lock(&ctl_mutex); |
2022 | pd = pkt_find_dev_from_minor(iminor(inode)); | 2023 | pd = pkt_find_dev_from_minor(iminor(inode)); |
2023 | if (!pd) { | 2024 | if (!pd) { |
2024 | ret = -ENODEV; | 2025 | ret = -ENODEV; |
@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2044 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); | 2045 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); |
2045 | } | 2046 | } |
2046 | 2047 | ||
2047 | up(&ctl_mutex); | 2048 | mutex_unlock(&ctl_mutex); |
2048 | return 0; | 2049 | return 0; |
2049 | 2050 | ||
2050 | out_dec: | 2051 | out_dec: |
2051 | pd->refcnt--; | 2052 | pd->refcnt--; |
2052 | out: | 2053 | out: |
2053 | VPRINTK("pktcdvd: failed open (%d)\n", ret); | 2054 | VPRINTK("pktcdvd: failed open (%d)\n", ret); |
2054 | up(&ctl_mutex); | 2055 | mutex_unlock(&ctl_mutex); |
2055 | return ret; | 2056 | return ret; |
2056 | } | 2057 | } |
2057 | 2058 | ||
@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file) | |||
2060 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; | 2061 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; |
2061 | int ret = 0; | 2062 | int ret = 0; |
2062 | 2063 | ||
2063 | down(&ctl_mutex); | 2064 | mutex_lock(&ctl_mutex); |
2064 | pd->refcnt--; | 2065 | pd->refcnt--; |
2065 | BUG_ON(pd->refcnt < 0); | 2066 | BUG_ON(pd->refcnt < 0); |
2066 | if (pd->refcnt == 0) { | 2067 | if (pd->refcnt == 0) { |
2067 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); | 2068 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); |
2068 | pkt_release_dev(pd, flush); | 2069 | pkt_release_dev(pd, flush); |
2069 | } | 2070 | } |
2070 | up(&ctl_mutex); | 2071 | mutex_unlock(&ctl_mutex); |
2071 | return ret; | 2072 | return ret; |
2072 | } | 2073 | } |
2073 | 2074 | ||
@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm | |||
2596 | case PKT_CTRL_CMD_SETUP: | 2597 | case PKT_CTRL_CMD_SETUP: |
2597 | if (!capable(CAP_SYS_ADMIN)) | 2598 | if (!capable(CAP_SYS_ADMIN)) |
2598 | return -EPERM; | 2599 | return -EPERM; |
2599 | down(&ctl_mutex); | 2600 | mutex_lock(&ctl_mutex); |
2600 | ret = pkt_setup_dev(&ctrl_cmd); | 2601 | ret = pkt_setup_dev(&ctrl_cmd); |
2601 | up(&ctl_mutex); | 2602 | mutex_unlock(&ctl_mutex); |
2602 | break; | 2603 | break; |
2603 | case PKT_CTRL_CMD_TEARDOWN: | 2604 | case PKT_CTRL_CMD_TEARDOWN: |
2604 | if (!capable(CAP_SYS_ADMIN)) | 2605 | if (!capable(CAP_SYS_ADMIN)) |
2605 | return -EPERM; | 2606 | return -EPERM; |
2606 | down(&ctl_mutex); | 2607 | mutex_lock(&ctl_mutex); |
2607 | ret = pkt_remove_dev(&ctrl_cmd); | 2608 | ret = pkt_remove_dev(&ctrl_cmd); |
2608 | up(&ctl_mutex); | 2609 | mutex_unlock(&ctl_mutex); |
2609 | break; | 2610 | break; |
2610 | case PKT_CTRL_CMD_STATUS: | 2611 | case PKT_CTRL_CMD_STATUS: |
2611 | down(&ctl_mutex); | 2612 | mutex_lock(&ctl_mutex); |
2612 | pkt_get_status(&ctrl_cmd); | 2613 | pkt_get_status(&ctrl_cmd); |
2613 | up(&ctl_mutex); | 2614 | mutex_unlock(&ctl_mutex); |
2614 | break; | 2615 | break; |
2615 | default: | 2616 | default: |
2616 | return -ENOTTY; | 2617 | return -ENOTTY; |
@@ -2656,7 +2657,7 @@ static int __init pkt_init(void) | |||
2656 | goto out; | 2657 | goto out; |
2657 | } | 2658 | } |
2658 | 2659 | ||
2659 | init_MUTEX(&ctl_mutex); | 2660 | mutex_init(&ctl_mutex); |
2660 | 2661 | ||
2661 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); | 2662 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); |
2662 | 2663 | ||
diff --git a/drivers/block/rd.c b/drivers/block/rd.c index ffd6abd6d5a0..1c54f46d3f70 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c | |||
@@ -310,12 +310,12 @@ static int rd_ioctl(struct inode *inode, struct file *file, | |||
310 | * cache | 310 | * cache |
311 | */ | 311 | */ |
312 | error = -EBUSY; | 312 | error = -EBUSY; |
313 | down(&bdev->bd_sem); | 313 | mutex_lock(&bdev->bd_mutex); |
314 | if (bdev->bd_openers <= 2) { | 314 | if (bdev->bd_openers <= 2) { |
315 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); | 315 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); |
316 | error = 0; | 316 | error = 0; |
317 | } | 317 | } |
318 | up(&bdev->bd_sem); | 318 | mutex_unlock(&bdev->bd_mutex); |
319 | return error; | 319 | return error; |
320 | } | 320 | } |
321 | 321 | ||
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 879bbc26ce96..a59876a0bfa1 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -407,7 +407,6 @@ int register_cdrom(struct cdrom_device_info *cdi) | |||
407 | ENSURE(get_mcn, CDC_MCN); | 407 | ENSURE(get_mcn, CDC_MCN); |
408 | ENSURE(reset, CDC_RESET); | 408 | ENSURE(reset, CDC_RESET); |
409 | ENSURE(audio_ioctl, CDC_PLAY_AUDIO); | 409 | ENSURE(audio_ioctl, CDC_PLAY_AUDIO); |
410 | ENSURE(dev_ioctl, CDC_IOCTLS); | ||
411 | ENSURE(generic_packet, CDC_GENERIC_PACKET); | 410 | ENSURE(generic_packet, CDC_GENERIC_PACKET); |
412 | cdi->mc_flags = 0; | 411 | cdi->mc_flags = 0; |
413 | cdo->n_minors = 0; | 412 | cdo->n_minors = 0; |
@@ -2196,395 +2195,586 @@ retry: | |||
2196 | return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); | 2195 | return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); |
2197 | } | 2196 | } |
2198 | 2197 | ||
2199 | /* Just about every imaginable ioctl is supported in the Uniform layer | 2198 | static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi, |
2200 | * these days. ATAPI / SCSI specific code now mainly resides in | 2199 | void __user *argp) |
2201 | * mmc_ioct(). | ||
2202 | */ | ||
2203 | int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | ||
2204 | struct inode *ip, unsigned int cmd, unsigned long arg) | ||
2205 | { | 2200 | { |
2206 | struct cdrom_device_ops *cdo = cdi->ops; | 2201 | struct cdrom_multisession ms_info; |
2202 | u8 requested_format; | ||
2207 | int ret; | 2203 | int ret; |
2208 | 2204 | ||
2209 | /* Try the generic SCSI command ioctl's first.. */ | 2205 | cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n"); |
2210 | ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, (void __user *)arg); | 2206 | |
2211 | if (ret != -ENOTTY) | 2207 | if (!(cdi->ops->capability & CDC_MULTI_SESSION)) |
2208 | return -ENOSYS; | ||
2209 | |||
2210 | if (copy_from_user(&ms_info, argp, sizeof(ms_info))) | ||
2211 | return -EFAULT; | ||
2212 | |||
2213 | requested_format = ms_info.addr_format; | ||
2214 | if (requested_format != CDROM_MSF && requested_format != CDROM_LBA) | ||
2215 | return -EINVAL; | ||
2216 | ms_info.addr_format = CDROM_LBA; | ||
2217 | |||
2218 | ret = cdi->ops->get_last_session(cdi, &ms_info); | ||
2219 | if (ret) | ||
2212 | return ret; | 2220 | return ret; |
2213 | 2221 | ||
2214 | /* the first few commands do not deal with audio drive_info, but | 2222 | sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format); |
2215 | only with routines in cdrom device operations. */ | 2223 | |
2216 | switch (cmd) { | 2224 | if (copy_to_user(argp, &ms_info, sizeof(ms_info))) |
2217 | case CDROMMULTISESSION: { | 2225 | return -EFAULT; |
2218 | struct cdrom_multisession ms_info; | 2226 | |
2219 | u_char requested_format; | 2227 | cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n"); |
2220 | cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n"); | 2228 | return 0; |
2221 | if (!(cdo->capability & CDC_MULTI_SESSION)) | 2229 | } |
2222 | return -ENOSYS; | 2230 | |
2223 | IOCTL_IN(arg, struct cdrom_multisession, ms_info); | 2231 | static int cdrom_ioctl_eject(struct cdrom_device_info *cdi) |
2224 | requested_format = ms_info.addr_format; | 2232 | { |
2225 | if (!((requested_format == CDROM_MSF) || | 2233 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n"); |
2226 | (requested_format == CDROM_LBA))) | 2234 | |
2227 | return -EINVAL; | 2235 | if (!CDROM_CAN(CDC_OPEN_TRAY)) |
2228 | ms_info.addr_format = CDROM_LBA; | 2236 | return -ENOSYS; |
2229 | if ((ret=cdo->get_last_session(cdi, &ms_info))) | 2237 | if (cdi->use_count != 1 || keeplocked) |
2238 | return -EBUSY; | ||
2239 | if (CDROM_CAN(CDC_LOCK)) { | ||
2240 | int ret = cdi->ops->lock_door(cdi, 0); | ||
2241 | if (ret) | ||
2230 | return ret; | 2242 | return ret; |
2231 | sanitize_format(&ms_info.addr, &ms_info.addr_format, | 2243 | } |
2232 | requested_format); | ||
2233 | IOCTL_OUT(arg, struct cdrom_multisession, ms_info); | ||
2234 | cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n"); | ||
2235 | return 0; | ||
2236 | } | ||
2237 | 2244 | ||
2238 | case CDROMEJECT: { | 2245 | return cdi->ops->tray_move(cdi, 1); |
2239 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n"); | 2246 | } |
2240 | if (!CDROM_CAN(CDC_OPEN_TRAY)) | ||
2241 | return -ENOSYS; | ||
2242 | if (cdi->use_count != 1 || keeplocked) | ||
2243 | return -EBUSY; | ||
2244 | if (CDROM_CAN(CDC_LOCK)) | ||
2245 | if ((ret=cdo->lock_door(cdi, 0))) | ||
2246 | return ret; | ||
2247 | 2247 | ||
2248 | return cdo->tray_move(cdi, 1); | 2248 | static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi) |
2249 | } | 2249 | { |
2250 | cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n"); | ||
2250 | 2251 | ||
2251 | case CDROMCLOSETRAY: { | 2252 | if (!CDROM_CAN(CDC_CLOSE_TRAY)) |
2252 | cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n"); | 2253 | return -ENOSYS; |
2253 | if (!CDROM_CAN(CDC_CLOSE_TRAY)) | 2254 | return cdi->ops->tray_move(cdi, 0); |
2254 | return -ENOSYS; | 2255 | } |
2255 | return cdo->tray_move(cdi, 0); | ||
2256 | } | ||
2257 | 2256 | ||
2258 | case CDROMEJECT_SW: { | 2257 | static int cdrom_ioctl_eject_sw(struct cdrom_device_info *cdi, |
2259 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n"); | 2258 | unsigned long arg) |
2260 | if (!CDROM_CAN(CDC_OPEN_TRAY)) | 2259 | { |
2261 | return -ENOSYS; | 2260 | cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n"); |
2262 | if (keeplocked) | ||
2263 | return -EBUSY; | ||
2264 | cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); | ||
2265 | if (arg) | ||
2266 | cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT; | ||
2267 | return 0; | ||
2268 | } | ||
2269 | 2261 | ||
2270 | case CDROM_MEDIA_CHANGED: { | 2262 | if (!CDROM_CAN(CDC_OPEN_TRAY)) |
2271 | struct cdrom_changer_info *info; | 2263 | return -ENOSYS; |
2272 | int changed; | 2264 | if (keeplocked) |
2265 | return -EBUSY; | ||
2273 | 2266 | ||
2274 | cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n"); | 2267 | cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); |
2275 | if (!CDROM_CAN(CDC_MEDIA_CHANGED)) | 2268 | if (arg) |
2276 | return -ENOSYS; | 2269 | cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT; |
2270 | return 0; | ||
2271 | } | ||
2277 | 2272 | ||
2278 | /* cannot select disc or select current disc */ | 2273 | static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, |
2279 | if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) | 2274 | unsigned long arg) |
2280 | return media_changed(cdi, 1); | 2275 | { |
2276 | struct cdrom_changer_info *info; | ||
2277 | int ret; | ||
2281 | 2278 | ||
2282 | if ((unsigned int)arg >= cdi->capacity) | 2279 | cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n"); |
2283 | return -EINVAL; | ||
2284 | 2280 | ||
2285 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 2281 | if (!CDROM_CAN(CDC_MEDIA_CHANGED)) |
2286 | if (!info) | 2282 | return -ENOSYS; |
2287 | return -ENOMEM; | ||
2288 | 2283 | ||
2289 | if ((ret = cdrom_read_mech_status(cdi, info))) { | 2284 | /* cannot select disc or select current disc */ |
2290 | kfree(info); | 2285 | if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) |
2291 | return ret; | 2286 | return media_changed(cdi, 1); |
2292 | } | ||
2293 | 2287 | ||
2294 | changed = info->slots[arg].change; | 2288 | if ((unsigned int)arg >= cdi->capacity) |
2295 | kfree(info); | 2289 | return -EINVAL; |
2296 | return changed; | ||
2297 | } | ||
2298 | 2290 | ||
2299 | case CDROM_SET_OPTIONS: { | 2291 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
2300 | cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n"); | 2292 | if (!info) |
2301 | /* options need to be in sync with capability. too late for | 2293 | return -ENOMEM; |
2302 | that, so we have to check each one separately... */ | ||
2303 | switch (arg) { | ||
2304 | case CDO_USE_FFLAGS: | ||
2305 | case CDO_CHECK_TYPE: | ||
2306 | break; | ||
2307 | case CDO_LOCK: | ||
2308 | if (!CDROM_CAN(CDC_LOCK)) | ||
2309 | return -ENOSYS; | ||
2310 | break; | ||
2311 | case 0: | ||
2312 | return cdi->options; | ||
2313 | /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */ | ||
2314 | default: | ||
2315 | if (!CDROM_CAN(arg)) | ||
2316 | return -ENOSYS; | ||
2317 | } | ||
2318 | cdi->options |= (int) arg; | ||
2319 | return cdi->options; | ||
2320 | } | ||
2321 | 2294 | ||
2322 | case CDROM_CLEAR_OPTIONS: { | 2295 | ret = cdrom_read_mech_status(cdi, info); |
2323 | cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n"); | 2296 | if (!ret) |
2324 | cdi->options &= ~(int) arg; | 2297 | ret = info->slots[arg].change; |
2325 | return cdi->options; | 2298 | kfree(info); |
2326 | } | 2299 | return ret; |
2300 | } | ||
2327 | 2301 | ||
2328 | case CDROM_SELECT_SPEED: { | 2302 | static int cdrom_ioctl_set_options(struct cdrom_device_info *cdi, |
2329 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); | 2303 | unsigned long arg) |
2330 | if (!CDROM_CAN(CDC_SELECT_SPEED)) | 2304 | { |
2331 | return -ENOSYS; | 2305 | cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n"); |
2332 | return cdo->select_speed(cdi, arg); | ||
2333 | } | ||
2334 | 2306 | ||
2335 | case CDROM_SELECT_DISC: { | 2307 | /* |
2336 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n"); | 2308 | * Options need to be in sync with capability. |
2337 | if (!CDROM_CAN(CDC_SELECT_DISC)) | 2309 | * Too late for that, so we have to check each one separately. |
2310 | */ | ||
2311 | switch (arg) { | ||
2312 | case CDO_USE_FFLAGS: | ||
2313 | case CDO_CHECK_TYPE: | ||
2314 | break; | ||
2315 | case CDO_LOCK: | ||
2316 | if (!CDROM_CAN(CDC_LOCK)) | ||
2317 | return -ENOSYS; | ||
2318 | break; | ||
2319 | case 0: | ||
2320 | return cdi->options; | ||
2321 | /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */ | ||
2322 | default: | ||
2323 | if (!CDROM_CAN(arg)) | ||
2338 | return -ENOSYS; | 2324 | return -ENOSYS; |
2325 | } | ||
2326 | cdi->options |= (int) arg; | ||
2327 | return cdi->options; | ||
2328 | } | ||
2339 | 2329 | ||
2340 | if ((arg != CDSL_CURRENT) && (arg != CDSL_NONE)) | 2330 | static int cdrom_ioctl_clear_options(struct cdrom_device_info *cdi, |
2341 | if ((int)arg >= cdi->capacity) | 2331 | unsigned long arg) |
2342 | return -EINVAL; | 2332 | { |
2343 | 2333 | cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n"); | |
2344 | /* cdo->select_disc is a hook to allow a driver-specific | ||
2345 | * way of seleting disc. However, since there is no | ||
2346 | * equiv hook for cdrom_slot_status this may not | ||
2347 | * actually be useful... | ||
2348 | */ | ||
2349 | if (cdo->select_disc != NULL) | ||
2350 | return cdo->select_disc(cdi, arg); | ||
2351 | |||
2352 | /* no driver specific select_disc(), call our own */ | ||
2353 | cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n"); | ||
2354 | return cdrom_select_disc(cdi, arg); | ||
2355 | } | ||
2356 | 2334 | ||
2357 | case CDROMRESET: { | 2335 | cdi->options &= ~(int) arg; |
2358 | if (!capable(CAP_SYS_ADMIN)) | 2336 | return cdi->options; |
2359 | return -EACCES; | 2337 | } |
2360 | cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n"); | ||
2361 | if (!CDROM_CAN(CDC_RESET)) | ||
2362 | return -ENOSYS; | ||
2363 | invalidate_bdev(ip->i_bdev, 0); | ||
2364 | return cdo->reset(cdi); | ||
2365 | } | ||
2366 | 2338 | ||
2367 | case CDROM_LOCKDOOR: { | 2339 | static int cdrom_ioctl_select_speed(struct cdrom_device_info *cdi, |
2368 | cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl"); | 2340 | unsigned long arg) |
2369 | if (!CDROM_CAN(CDC_LOCK)) | 2341 | { |
2370 | return -EDRIVE_CANT_DO_THIS; | 2342 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); |
2371 | keeplocked = arg ? 1 : 0; | ||
2372 | /* don't unlock the door on multiple opens,but allow root | ||
2373 | * to do so */ | ||
2374 | if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN)) | ||
2375 | return -EBUSY; | ||
2376 | return cdo->lock_door(cdi, arg); | ||
2377 | } | ||
2378 | 2343 | ||
2379 | case CDROM_DEBUG: { | 2344 | if (!CDROM_CAN(CDC_SELECT_SPEED)) |
2380 | if (!capable(CAP_SYS_ADMIN)) | 2345 | return -ENOSYS; |
2381 | return -EACCES; | 2346 | return cdi->ops->select_speed(cdi, arg); |
2382 | cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis"); | 2347 | } |
2383 | debug = arg ? 1 : 0; | ||
2384 | return debug; | ||
2385 | } | ||
2386 | 2348 | ||
2387 | case CDROM_GET_CAPABILITY: { | 2349 | static int cdrom_ioctl_select_disc(struct cdrom_device_info *cdi, |
2388 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n"); | 2350 | unsigned long arg) |
2389 | return (cdo->capability & ~cdi->mask); | 2351 | { |
2390 | } | 2352 | cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n"); |
2353 | |||
2354 | if (!CDROM_CAN(CDC_SELECT_DISC)) | ||
2355 | return -ENOSYS; | ||
2356 | |||
2357 | if (arg != CDSL_CURRENT && arg != CDSL_NONE) { | ||
2358 | if ((int)arg >= cdi->capacity) | ||
2359 | return -EINVAL; | ||
2360 | } | ||
2361 | |||
2362 | /* | ||
2363 | * ->select_disc is a hook to allow a driver-specific way of | ||
2364 | * seleting disc. However, since there is no equivalent hook for | ||
2365 | * cdrom_slot_status this may not actually be useful... | ||
2366 | */ | ||
2367 | if (cdi->ops->select_disc) | ||
2368 | return cdi->ops->select_disc(cdi, arg); | ||
2369 | |||
2370 | cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n"); | ||
2371 | return cdrom_select_disc(cdi, arg); | ||
2372 | } | ||
2373 | |||
2374 | static int cdrom_ioctl_reset(struct cdrom_device_info *cdi, | ||
2375 | struct block_device *bdev) | ||
2376 | { | ||
2377 | cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n"); | ||
2378 | |||
2379 | if (!capable(CAP_SYS_ADMIN)) | ||
2380 | return -EACCES; | ||
2381 | if (!CDROM_CAN(CDC_RESET)) | ||
2382 | return -ENOSYS; | ||
2383 | invalidate_bdev(bdev, 0); | ||
2384 | return cdi->ops->reset(cdi); | ||
2385 | } | ||
2386 | |||
2387 | static int cdrom_ioctl_lock_door(struct cdrom_device_info *cdi, | ||
2388 | unsigned long arg) | ||
2389 | { | ||
2390 | cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl"); | ||
2391 | |||
2392 | if (!CDROM_CAN(CDC_LOCK)) | ||
2393 | return -EDRIVE_CANT_DO_THIS; | ||
2394 | |||
2395 | keeplocked = arg ? 1 : 0; | ||
2396 | |||
2397 | /* | ||
2398 | * Don't unlock the door on multiple opens by default, but allow | ||
2399 | * root to do so. | ||
2400 | */ | ||
2401 | if (cdi->use_count != 1 && !arg && !capable(CAP_SYS_ADMIN)) | ||
2402 | return -EBUSY; | ||
2403 | return cdi->ops->lock_door(cdi, arg); | ||
2404 | } | ||
2405 | |||
2406 | static int cdrom_ioctl_debug(struct cdrom_device_info *cdi, | ||
2407 | unsigned long arg) | ||
2408 | { | ||
2409 | cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis"); | ||
2410 | |||
2411 | if (!capable(CAP_SYS_ADMIN)) | ||
2412 | return -EACCES; | ||
2413 | debug = arg ? 1 : 0; | ||
2414 | return debug; | ||
2415 | } | ||
2391 | 2416 | ||
2392 | /* The following function is implemented, although very few audio | 2417 | static int cdrom_ioctl_get_capability(struct cdrom_device_info *cdi) |
2418 | { | ||
2419 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n"); | ||
2420 | return (cdi->ops->capability & ~cdi->mask); | ||
2421 | } | ||
2422 | |||
2423 | /* | ||
2424 | * The following function is implemented, although very few audio | ||
2393 | * discs give Universal Product Code information, which should just be | 2425 | * discs give Universal Product Code information, which should just be |
2394 | * the Medium Catalog Number on the box. Note, that the way the code | 2426 | * the Medium Catalog Number on the box. Note, that the way the code |
2395 | * is written on the CD is /not/ uniform across all discs! | 2427 | * is written on the CD is /not/ uniform across all discs! |
2396 | */ | 2428 | */ |
2397 | case CDROM_GET_MCN: { | 2429 | static int cdrom_ioctl_get_mcn(struct cdrom_device_info *cdi, |
2398 | struct cdrom_mcn mcn; | 2430 | void __user *argp) |
2399 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n"); | 2431 | { |
2400 | if (!(cdo->capability & CDC_MCN)) | 2432 | struct cdrom_mcn mcn; |
2401 | return -ENOSYS; | 2433 | int ret; |
2402 | if ((ret=cdo->get_mcn(cdi, &mcn))) | ||
2403 | return ret; | ||
2404 | IOCTL_OUT(arg, struct cdrom_mcn, mcn); | ||
2405 | cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n"); | ||
2406 | return 0; | ||
2407 | } | ||
2408 | 2434 | ||
2409 | case CDROM_DRIVE_STATUS: { | 2435 | cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n"); |
2410 | cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n"); | ||
2411 | if (!(cdo->capability & CDC_DRIVE_STATUS)) | ||
2412 | return -ENOSYS; | ||
2413 | if (!CDROM_CAN(CDC_SELECT_DISC)) | ||
2414 | return cdo->drive_status(cdi, CDSL_CURRENT); | ||
2415 | if ((arg == CDSL_CURRENT) || (arg == CDSL_NONE)) | ||
2416 | return cdo->drive_status(cdi, CDSL_CURRENT); | ||
2417 | if (((int)arg >= cdi->capacity)) | ||
2418 | return -EINVAL; | ||
2419 | return cdrom_slot_status(cdi, arg); | ||
2420 | } | ||
2421 | 2436 | ||
2422 | /* Ok, this is where problems start. The current interface for the | 2437 | if (!(cdi->ops->capability & CDC_MCN)) |
2423 | CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption | 2438 | return -ENOSYS; |
2424 | that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, | 2439 | ret = cdi->ops->get_mcn(cdi, &mcn); |
2425 | while this is often the case, it is also very common for CDs to | 2440 | if (ret) |
2426 | have some tracks with data, and some tracks with audio. Just | 2441 | return ret; |
2427 | because I feel like it, I declare the following to be the best | ||
2428 | way to cope. If the CD has ANY data tracks on it, it will be | ||
2429 | returned as a data CD. If it has any XA tracks, I will return | ||
2430 | it as that. Now I could simplify this interface by combining these | ||
2431 | returns with the above, but this more clearly demonstrates | ||
2432 | the problem with the current interface. Too bad this wasn't | ||
2433 | designed to use bitmasks... -Erik | ||
2434 | |||
2435 | Well, now we have the option CDS_MIXED: a mixed-type CD. | ||
2436 | User level programmers might feel the ioctl is not very useful. | ||
2437 | ---david | ||
2438 | */ | ||
2439 | case CDROM_DISC_STATUS: { | ||
2440 | tracktype tracks; | ||
2441 | cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n"); | ||
2442 | cdrom_count_tracks(cdi, &tracks); | ||
2443 | if (tracks.error) | ||
2444 | return(tracks.error); | ||
2445 | |||
2446 | /* Policy mode on */ | ||
2447 | if (tracks.audio > 0) { | ||
2448 | if (tracks.data==0 && tracks.cdi==0 && tracks.xa==0) | ||
2449 | return CDS_AUDIO; | ||
2450 | else | ||
2451 | return CDS_MIXED; | ||
2452 | } | ||
2453 | if (tracks.cdi > 0) return CDS_XA_2_2; | ||
2454 | if (tracks.xa > 0) return CDS_XA_2_1; | ||
2455 | if (tracks.data > 0) return CDS_DATA_1; | ||
2456 | /* Policy mode off */ | ||
2457 | 2442 | ||
2458 | cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n"); | 2443 | if (copy_to_user(argp, &mcn, sizeof(mcn))) |
2459 | return CDS_NO_INFO; | 2444 | return -EFAULT; |
2460 | } | 2445 | cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n"); |
2446 | return 0; | ||
2447 | } | ||
2461 | 2448 | ||
2462 | case CDROM_CHANGER_NSLOTS: { | 2449 | static int cdrom_ioctl_drive_status(struct cdrom_device_info *cdi, |
2463 | cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n"); | 2450 | unsigned long arg) |
2464 | return cdi->capacity; | 2451 | { |
2465 | } | 2452 | cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n"); |
2453 | |||
2454 | if (!(cdi->ops->capability & CDC_DRIVE_STATUS)) | ||
2455 | return -ENOSYS; | ||
2456 | if (!CDROM_CAN(CDC_SELECT_DISC) || | ||
2457 | (arg == CDSL_CURRENT || arg == CDSL_NONE)) | ||
2458 | return cdi->ops->drive_status(cdi, CDSL_CURRENT); | ||
2459 | if (((int)arg >= cdi->capacity)) | ||
2460 | return -EINVAL; | ||
2461 | return cdrom_slot_status(cdi, arg); | ||
2462 | } | ||
2463 | |||
2464 | /* | ||
2465 | * Ok, this is where problems start. The current interface for the | ||
2466 | * CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption that | ||
2467 | * CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, while this | ||
2468 | * is often the case, it is also very common for CDs to have some tracks | ||
2469 | * with data, and some tracks with audio. Just because I feel like it, | ||
2470 | * I declare the following to be the best way to cope. If the CD has ANY | ||
2471 | * data tracks on it, it will be returned as a data CD. If it has any XA | ||
2472 | * tracks, I will return it as that. Now I could simplify this interface | ||
2473 | * by combining these returns with the above, but this more clearly | ||
2474 | * demonstrates the problem with the current interface. Too bad this | ||
2475 | * wasn't designed to use bitmasks... -Erik | ||
2476 | * | ||
2477 | * Well, now we have the option CDS_MIXED: a mixed-type CD. | ||
2478 | * User level programmers might feel the ioctl is not very useful. | ||
2479 | * ---david | ||
2480 | */ | ||
2481 | static int cdrom_ioctl_disc_status(struct cdrom_device_info *cdi) | ||
2482 | { | ||
2483 | tracktype tracks; | ||
2484 | |||
2485 | cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n"); | ||
2486 | |||
2487 | cdrom_count_tracks(cdi, &tracks); | ||
2488 | if (tracks.error) | ||
2489 | return tracks.error; | ||
2490 | |||
2491 | /* Policy mode on */ | ||
2492 | if (tracks.audio > 0) { | ||
2493 | if (!tracks.data && !tracks.cdi && !tracks.xa) | ||
2494 | return CDS_AUDIO; | ||
2495 | else | ||
2496 | return CDS_MIXED; | ||
2466 | } | 2497 | } |
2467 | 2498 | ||
2468 | /* use the ioctls that are implemented through the generic_packet() | 2499 | if (tracks.cdi > 0) |
2469 | interface. this may look at bit funny, but if -ENOTTY is | 2500 | return CDS_XA_2_2; |
2470 | returned that particular ioctl is not implemented and we | 2501 | if (tracks.xa > 0) |
2471 | let it go through the device specific ones. */ | 2502 | return CDS_XA_2_1; |
2503 | if (tracks.data > 0) | ||
2504 | return CDS_DATA_1; | ||
2505 | /* Policy mode off */ | ||
2506 | |||
2507 | cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n"); | ||
2508 | return CDS_NO_INFO; | ||
2509 | } | ||
2510 | |||
2511 | static int cdrom_ioctl_changer_nslots(struct cdrom_device_info *cdi) | ||
2512 | { | ||
2513 | cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n"); | ||
2514 | return cdi->capacity; | ||
2515 | } | ||
2516 | |||
2517 | static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi, | ||
2518 | void __user *argp) | ||
2519 | { | ||
2520 | struct cdrom_subchnl q; | ||
2521 | u8 requested, back; | ||
2522 | int ret; | ||
2523 | |||
2524 | /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/ | ||
2525 | |||
2526 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2527 | return -ENOSYS; | ||
2528 | if (copy_from_user(&q, argp, sizeof(q))) | ||
2529 | return -EFAULT; | ||
2530 | |||
2531 | requested = q.cdsc_format; | ||
2532 | if (requested != CDROM_MSF && requested != CDROM_LBA) | ||
2533 | return -EINVAL; | ||
2534 | q.cdsc_format = CDROM_MSF; | ||
2535 | |||
2536 | ret = cdi->ops->audio_ioctl(cdi, CDROMSUBCHNL, &q); | ||
2537 | if (ret) | ||
2538 | return ret; | ||
2539 | |||
2540 | back = q.cdsc_format; /* local copy */ | ||
2541 | sanitize_format(&q.cdsc_absaddr, &back, requested); | ||
2542 | sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested); | ||
2543 | |||
2544 | if (copy_to_user(argp, &q, sizeof(q))) | ||
2545 | return -EFAULT; | ||
2546 | /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */ | ||
2547 | return 0; | ||
2548 | } | ||
2549 | |||
2550 | static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi, | ||
2551 | void __user *argp) | ||
2552 | { | ||
2553 | struct cdrom_tochdr header; | ||
2554 | int ret; | ||
2555 | |||
2556 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */ | ||
2557 | |||
2558 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2559 | return -ENOSYS; | ||
2560 | if (copy_from_user(&header, argp, sizeof(header))) | ||
2561 | return -EFAULT; | ||
2562 | |||
2563 | ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header); | ||
2564 | if (ret) | ||
2565 | return ret; | ||
2566 | |||
2567 | if (copy_to_user(argp, &header, sizeof(header))) | ||
2568 | return -EFAULT; | ||
2569 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */ | ||
2570 | return 0; | ||
2571 | } | ||
2572 | |||
2573 | static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi, | ||
2574 | void __user *argp) | ||
2575 | { | ||
2576 | struct cdrom_tocentry entry; | ||
2577 | u8 requested_format; | ||
2578 | int ret; | ||
2579 | |||
2580 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */ | ||
2581 | |||
2582 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2583 | return -ENOSYS; | ||
2584 | if (copy_from_user(&entry, argp, sizeof(entry))) | ||
2585 | return -EFAULT; | ||
2586 | |||
2587 | requested_format = entry.cdte_format; | ||
2588 | if (requested_format != CDROM_MSF && requested_format != CDROM_LBA) | ||
2589 | return -EINVAL; | ||
2590 | /* make interface to low-level uniform */ | ||
2591 | entry.cdte_format = CDROM_MSF; | ||
2592 | ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry); | ||
2593 | if (ret) | ||
2594 | return ret; | ||
2595 | sanitize_format(&entry.cdte_addr, &entry.cdte_format, requested_format); | ||
2596 | |||
2597 | if (copy_to_user(argp, &entry, sizeof(entry))) | ||
2598 | return -EFAULT; | ||
2599 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */ | ||
2600 | return 0; | ||
2601 | } | ||
2602 | |||
2603 | static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi, | ||
2604 | void __user *argp) | ||
2605 | { | ||
2606 | struct cdrom_msf msf; | ||
2607 | |||
2608 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n"); | ||
2609 | |||
2610 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2611 | return -ENOSYS; | ||
2612 | if (copy_from_user(&msf, argp, sizeof(msf))) | ||
2613 | return -EFAULT; | ||
2614 | return cdi->ops->audio_ioctl(cdi, CDROMPLAYMSF, &msf); | ||
2615 | } | ||
2616 | |||
2617 | static int cdrom_ioctl_play_trkind(struct cdrom_device_info *cdi, | ||
2618 | void __user *argp) | ||
2619 | { | ||
2620 | struct cdrom_ti ti; | ||
2621 | int ret; | ||
2622 | |||
2623 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n"); | ||
2624 | |||
2625 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2626 | return -ENOSYS; | ||
2627 | if (copy_from_user(&ti, argp, sizeof(ti))) | ||
2628 | return -EFAULT; | ||
2629 | |||
2630 | ret = check_for_audio_disc(cdi, cdi->ops); | ||
2631 | if (ret) | ||
2632 | return ret; | ||
2633 | return cdi->ops->audio_ioctl(cdi, CDROMPLAYTRKIND, &ti); | ||
2634 | } | ||
2635 | static int cdrom_ioctl_volctrl(struct cdrom_device_info *cdi, | ||
2636 | void __user *argp) | ||
2637 | { | ||
2638 | struct cdrom_volctrl volume; | ||
2639 | |||
2640 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n"); | ||
2641 | |||
2642 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2643 | return -ENOSYS; | ||
2644 | if (copy_from_user(&volume, argp, sizeof(volume))) | ||
2645 | return -EFAULT; | ||
2646 | return cdi->ops->audio_ioctl(cdi, CDROMVOLCTRL, &volume); | ||
2647 | } | ||
2648 | |||
2649 | static int cdrom_ioctl_volread(struct cdrom_device_info *cdi, | ||
2650 | void __user *argp) | ||
2651 | { | ||
2652 | struct cdrom_volctrl volume; | ||
2653 | int ret; | ||
2654 | |||
2655 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n"); | ||
2656 | |||
2657 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2658 | return -ENOSYS; | ||
2659 | |||
2660 | ret = cdi->ops->audio_ioctl(cdi, CDROMVOLREAD, &volume); | ||
2661 | if (ret) | ||
2662 | return ret; | ||
2663 | |||
2664 | if (copy_to_user(argp, &volume, sizeof(volume))) | ||
2665 | return -EFAULT; | ||
2666 | return 0; | ||
2667 | } | ||
2668 | |||
2669 | static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi, | ||
2670 | unsigned int cmd) | ||
2671 | { | ||
2672 | int ret; | ||
2673 | |||
2674 | cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n"); | ||
2675 | |||
2676 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2677 | return -ENOSYS; | ||
2678 | ret = check_for_audio_disc(cdi, cdi->ops); | ||
2679 | if (ret) | ||
2680 | return ret; | ||
2681 | return cdi->ops->audio_ioctl(cdi, cmd, NULL); | ||
2682 | } | ||
2683 | |||
2684 | /* | ||
2685 | * Just about every imaginable ioctl is supported in the Uniform layer | ||
2686 | * these days. | ||
2687 | * ATAPI / SCSI specific code now mainly resides in mmc_ioctl(). | ||
2688 | */ | ||
2689 | int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | ||
2690 | struct inode *ip, unsigned int cmd, unsigned long arg) | ||
2691 | { | ||
2692 | void __user *argp = (void __user *)arg; | ||
2693 | int ret; | ||
2694 | |||
2695 | /* | ||
2696 | * Try the generic SCSI command ioctl's first. | ||
2697 | */ | ||
2698 | ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp); | ||
2699 | if (ret != -ENOTTY) | ||
2700 | return ret; | ||
2701 | |||
2702 | switch (cmd) { | ||
2703 | case CDROMMULTISESSION: | ||
2704 | return cdrom_ioctl_multisession(cdi, argp); | ||
2705 | case CDROMEJECT: | ||
2706 | return cdrom_ioctl_eject(cdi); | ||
2707 | case CDROMCLOSETRAY: | ||
2708 | return cdrom_ioctl_closetray(cdi); | ||
2709 | case CDROMEJECT_SW: | ||
2710 | return cdrom_ioctl_eject_sw(cdi, arg); | ||
2711 | case CDROM_MEDIA_CHANGED: | ||
2712 | return cdrom_ioctl_media_changed(cdi, arg); | ||
2713 | case CDROM_SET_OPTIONS: | ||
2714 | return cdrom_ioctl_set_options(cdi, arg); | ||
2715 | case CDROM_CLEAR_OPTIONS: | ||
2716 | return cdrom_ioctl_clear_options(cdi, arg); | ||
2717 | case CDROM_SELECT_SPEED: | ||
2718 | return cdrom_ioctl_select_speed(cdi, arg); | ||
2719 | case CDROM_SELECT_DISC: | ||
2720 | return cdrom_ioctl_select_disc(cdi, arg); | ||
2721 | case CDROMRESET: | ||
2722 | return cdrom_ioctl_reset(cdi, ip->i_bdev); | ||
2723 | case CDROM_LOCKDOOR: | ||
2724 | return cdrom_ioctl_lock_door(cdi, arg); | ||
2725 | case CDROM_DEBUG: | ||
2726 | return cdrom_ioctl_debug(cdi, arg); | ||
2727 | case CDROM_GET_CAPABILITY: | ||
2728 | return cdrom_ioctl_get_capability(cdi); | ||
2729 | case CDROM_GET_MCN: | ||
2730 | return cdrom_ioctl_get_mcn(cdi, argp); | ||
2731 | case CDROM_DRIVE_STATUS: | ||
2732 | return cdrom_ioctl_drive_status(cdi, arg); | ||
2733 | case CDROM_DISC_STATUS: | ||
2734 | return cdrom_ioctl_disc_status(cdi); | ||
2735 | case CDROM_CHANGER_NSLOTS: | ||
2736 | return cdrom_ioctl_changer_nslots(cdi); | ||
2737 | } | ||
2738 | |||
2739 | /* | ||
2740 | * Use the ioctls that are implemented through the generic_packet() | ||
2741 | * interface. this may look at bit funny, but if -ENOTTY is | ||
2742 | * returned that particular ioctl is not implemented and we | ||
2743 | * let it go through the device specific ones. | ||
2744 | */ | ||
2472 | if (CDROM_CAN(CDC_GENERIC_PACKET)) { | 2745 | if (CDROM_CAN(CDC_GENERIC_PACKET)) { |
2473 | ret = mmc_ioctl(cdi, cmd, arg); | 2746 | ret = mmc_ioctl(cdi, cmd, arg); |
2474 | if (ret != -ENOTTY) { | 2747 | if (ret != -ENOTTY) |
2475 | return ret; | 2748 | return ret; |
2476 | } | ||
2477 | } | 2749 | } |
2478 | 2750 | ||
2479 | /* note: most of the cdinfo() calls are commented out here, | 2751 | /* |
2480 | because they fill up the sys log when CD players poll | 2752 | * Note: most of the cdinfo() calls are commented out here, |
2481 | the drive. */ | 2753 | * because they fill up the sys log when CD players poll |
2754 | * the drive. | ||
2755 | */ | ||
2482 | switch (cmd) { | 2756 | switch (cmd) { |
2483 | case CDROMSUBCHNL: { | 2757 | case CDROMSUBCHNL: |
2484 | struct cdrom_subchnl q; | 2758 | return cdrom_ioctl_get_subchnl(cdi, argp); |
2485 | u_char requested, back; | 2759 | case CDROMREADTOCHDR: |
2486 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | 2760 | return cdrom_ioctl_read_tochdr(cdi, argp); |
2487 | return -ENOSYS; | 2761 | case CDROMREADTOCENTRY: |
2488 | /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/ | 2762 | return cdrom_ioctl_read_tocentry(cdi, argp); |
2489 | IOCTL_IN(arg, struct cdrom_subchnl, q); | 2763 | case CDROMPLAYMSF: |
2490 | requested = q.cdsc_format; | 2764 | return cdrom_ioctl_play_msf(cdi, argp); |
2491 | if (!((requested == CDROM_MSF) || | 2765 | case CDROMPLAYTRKIND: |
2492 | (requested == CDROM_LBA))) | 2766 | return cdrom_ioctl_play_trkind(cdi, argp); |
2493 | return -EINVAL; | 2767 | case CDROMVOLCTRL: |
2494 | q.cdsc_format = CDROM_MSF; | 2768 | return cdrom_ioctl_volctrl(cdi, argp); |
2495 | if ((ret=cdo->audio_ioctl(cdi, cmd, &q))) | 2769 | case CDROMVOLREAD: |
2496 | return ret; | 2770 | return cdrom_ioctl_volread(cdi, argp); |
2497 | back = q.cdsc_format; /* local copy */ | ||
2498 | sanitize_format(&q.cdsc_absaddr, &back, requested); | ||
2499 | sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested); | ||
2500 | IOCTL_OUT(arg, struct cdrom_subchnl, q); | ||
2501 | /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */ | ||
2502 | return 0; | ||
2503 | } | ||
2504 | case CDROMREADTOCHDR: { | ||
2505 | struct cdrom_tochdr header; | ||
2506 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2507 | return -ENOSYS; | ||
2508 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */ | ||
2509 | IOCTL_IN(arg, struct cdrom_tochdr, header); | ||
2510 | if ((ret=cdo->audio_ioctl(cdi, cmd, &header))) | ||
2511 | return ret; | ||
2512 | IOCTL_OUT(arg, struct cdrom_tochdr, header); | ||
2513 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */ | ||
2514 | return 0; | ||
2515 | } | ||
2516 | case CDROMREADTOCENTRY: { | ||
2517 | struct cdrom_tocentry entry; | ||
2518 | u_char requested_format; | ||
2519 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2520 | return -ENOSYS; | ||
2521 | /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */ | ||
2522 | IOCTL_IN(arg, struct cdrom_tocentry, entry); | ||
2523 | requested_format = entry.cdte_format; | ||
2524 | if (!((requested_format == CDROM_MSF) || | ||
2525 | (requested_format == CDROM_LBA))) | ||
2526 | return -EINVAL; | ||
2527 | /* make interface to low-level uniform */ | ||
2528 | entry.cdte_format = CDROM_MSF; | ||
2529 | if ((ret=cdo->audio_ioctl(cdi, cmd, &entry))) | ||
2530 | return ret; | ||
2531 | sanitize_format(&entry.cdte_addr, | ||
2532 | &entry.cdte_format, requested_format); | ||
2533 | IOCTL_OUT(arg, struct cdrom_tocentry, entry); | ||
2534 | /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */ | ||
2535 | return 0; | ||
2536 | } | ||
2537 | case CDROMPLAYMSF: { | ||
2538 | struct cdrom_msf msf; | ||
2539 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2540 | return -ENOSYS; | ||
2541 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n"); | ||
2542 | IOCTL_IN(arg, struct cdrom_msf, msf); | ||
2543 | return cdo->audio_ioctl(cdi, cmd, &msf); | ||
2544 | } | ||
2545 | case CDROMPLAYTRKIND: { | ||
2546 | struct cdrom_ti ti; | ||
2547 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2548 | return -ENOSYS; | ||
2549 | cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n"); | ||
2550 | IOCTL_IN(arg, struct cdrom_ti, ti); | ||
2551 | CHECKAUDIO; | ||
2552 | return cdo->audio_ioctl(cdi, cmd, &ti); | ||
2553 | } | ||
2554 | case CDROMVOLCTRL: { | ||
2555 | struct cdrom_volctrl volume; | ||
2556 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2557 | return -ENOSYS; | ||
2558 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n"); | ||
2559 | IOCTL_IN(arg, struct cdrom_volctrl, volume); | ||
2560 | return cdo->audio_ioctl(cdi, cmd, &volume); | ||
2561 | } | ||
2562 | case CDROMVOLREAD: { | ||
2563 | struct cdrom_volctrl volume; | ||
2564 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | ||
2565 | return -ENOSYS; | ||
2566 | cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n"); | ||
2567 | if ((ret=cdo->audio_ioctl(cdi, cmd, &volume))) | ||
2568 | return ret; | ||
2569 | IOCTL_OUT(arg, struct cdrom_volctrl, volume); | ||
2570 | return 0; | ||
2571 | } | ||
2572 | case CDROMSTART: | 2771 | case CDROMSTART: |
2573 | case CDROMSTOP: | 2772 | case CDROMSTOP: |
2574 | case CDROMPAUSE: | 2773 | case CDROMPAUSE: |
2575 | case CDROMRESUME: { | 2774 | case CDROMRESUME: |
2576 | if (!CDROM_CAN(CDC_PLAY_AUDIO)) | 2775 | return cdrom_ioctl_audioctl(cdi, cmd); |
2577 | return -ENOSYS; | 2776 | } |
2578 | cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n"); | ||
2579 | CHECKAUDIO; | ||
2580 | return cdo->audio_ioctl(cdi, cmd, NULL); | ||
2581 | } | ||
2582 | } /* switch */ | ||
2583 | 2777 | ||
2584 | /* do the device specific ioctls */ | ||
2585 | if (CDROM_CAN(CDC_IOCTLS)) | ||
2586 | return cdo->dev_ioctl(cdi, cmd, arg); | ||
2587 | |||
2588 | return -ENOSYS; | 2778 | return -ENOSYS; |
2589 | } | 2779 | } |
2590 | 2780 | ||
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c index 378e88d20757..72ffd64e8b1e 100644 --- a/drivers/cdrom/cdu31a.c +++ b/drivers/cdrom/cdu31a.c | |||
@@ -2668,7 +2668,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi, | |||
2668 | return retval; | 2668 | return retval; |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | static int scd_dev_ioctl(struct cdrom_device_info *cdi, | 2671 | static int scd_read_audio(struct cdrom_device_info *cdi, |
2672 | unsigned int cmd, unsigned long arg) | 2672 | unsigned int cmd, unsigned long arg) |
2673 | { | 2673 | { |
2674 | void __user *argp = (void __user *)arg; | 2674 | void __user *argp = (void __user *)arg; |
@@ -2894,11 +2894,10 @@ static struct cdrom_device_ops scd_dops = { | |||
2894 | .get_mcn = scd_get_mcn, | 2894 | .get_mcn = scd_get_mcn, |
2895 | .reset = scd_reset, | 2895 | .reset = scd_reset, |
2896 | .audio_ioctl = scd_audio_ioctl, | 2896 | .audio_ioctl = scd_audio_ioctl, |
2897 | .dev_ioctl = scd_dev_ioctl, | ||
2898 | .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | | 2897 | .capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK | |
2899 | CDC_SELECT_SPEED | CDC_MULTI_SESSION | | 2898 | CDC_SELECT_SPEED | CDC_MULTI_SESSION | |
2900 | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | | 2899 | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | |
2901 | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS, | 2900 | CDC_RESET | CDC_DRIVE_STATUS, |
2902 | .n_minors = 1, | 2901 | .n_minors = 1, |
2903 | }; | 2902 | }; |
2904 | 2903 | ||
@@ -2936,6 +2935,9 @@ static int scd_block_ioctl(struct inode *inode, struct file *file, | |||
2936 | case CDROMCLOSETRAY: | 2935 | case CDROMCLOSETRAY: |
2937 | retval = scd_tray_move(&scd_info, 0); | 2936 | retval = scd_tray_move(&scd_info, 0); |
2938 | break; | 2937 | break; |
2938 | case CDROMREADAUDIO: | ||
2939 | retval = scd_read_audio(&scd_info, CDROMREADAUDIO, arg); | ||
2940 | break; | ||
2939 | default: | 2941 | default: |
2940 | retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); | 2942 | retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg); |
2941 | } | 2943 | } |
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c index ce127f7ec0f6..fad27a87ce35 100644 --- a/drivers/cdrom/cm206.c +++ b/drivers/cdrom/cm206.c | |||
@@ -1157,32 +1157,6 @@ static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | |||
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | /* Ioctl. These ioctls are specific to the cm206 driver. I have made | ||
1161 | some driver statistics accessible through ioctl calls. | ||
1162 | */ | ||
1163 | |||
1164 | static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, | ||
1165 | unsigned long arg) | ||
1166 | { | ||
1167 | switch (cmd) { | ||
1168 | #ifdef STATISTICS | ||
1169 | case CM206CTL_GET_STAT: | ||
1170 | if (arg >= NR_STATS) | ||
1171 | return -EINVAL; | ||
1172 | else | ||
1173 | return cd->stats[arg]; | ||
1174 | case CM206CTL_GET_LAST_STAT: | ||
1175 | if (arg >= NR_STATS) | ||
1176 | return -EINVAL; | ||
1177 | else | ||
1178 | return cd->last_stat[arg]; | ||
1179 | #endif | ||
1180 | default: | ||
1181 | debug(("Unknown ioctl call 0x%x\n", cmd)); | ||
1182 | return -EINVAL; | ||
1183 | } | ||
1184 | } | ||
1185 | |||
1186 | static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) | 1160 | static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) |
1187 | { | 1161 | { |
1188 | if (cd != NULL) { | 1162 | if (cd != NULL) { |
@@ -1321,11 +1295,10 @@ static struct cdrom_device_ops cm206_dops = { | |||
1321 | .get_mcn = cm206_get_upc, | 1295 | .get_mcn = cm206_get_upc, |
1322 | .reset = cm206_reset, | 1296 | .reset = cm206_reset, |
1323 | .audio_ioctl = cm206_audio_ioctl, | 1297 | .audio_ioctl = cm206_audio_ioctl, |
1324 | .dev_ioctl = cm206_ioctl, | ||
1325 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 1298 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
1326 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | | 1299 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | |
1327 | CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | | 1300 | CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED | |
1328 | CDC_IOCTLS | CDC_DRIVE_STATUS, | 1301 | CDC_DRIVE_STATUS, |
1329 | .n_minors = 1, | 1302 | .n_minors = 1, |
1330 | }; | 1303 | }; |
1331 | 1304 | ||
@@ -1350,6 +1323,21 @@ static int cm206_block_release(struct inode *inode, struct file *file) | |||
1350 | static int cm206_block_ioctl(struct inode *inode, struct file *file, | 1323 | static int cm206_block_ioctl(struct inode *inode, struct file *file, |
1351 | unsigned cmd, unsigned long arg) | 1324 | unsigned cmd, unsigned long arg) |
1352 | { | 1325 | { |
1326 | switch (cmd) { | ||
1327 | #ifdef STATISTICS | ||
1328 | case CM206CTL_GET_STAT: | ||
1329 | if (arg >= NR_STATS) | ||
1330 | return -EINVAL; | ||
1331 | return cd->stats[arg]; | ||
1332 | case CM206CTL_GET_LAST_STAT: | ||
1333 | if (arg >= NR_STATS) | ||
1334 | return -EINVAL; | ||
1335 | return cd->last_stat[arg]; | ||
1336 | #endif | ||
1337 | default: | ||
1338 | break; | ||
1339 | } | ||
1340 | |||
1353 | return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); | 1341 | return cdrom_ioctl(file, &cm206_info, inode, cmd, arg); |
1354 | } | 1342 | } |
1355 | 1343 | ||
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c index 466e9c2974bd..4760f515f591 100644 --- a/drivers/cdrom/sbpcd.c +++ b/drivers/cdrom/sbpcd.c | |||
@@ -4160,332 +4160,6 @@ static int sbpcd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_mu | |||
4160 | return 0; | 4160 | return 0; |
4161 | } | 4161 | } |
4162 | 4162 | ||
4163 | /*==========================================================================*/ | ||
4164 | /*==========================================================================*/ | ||
4165 | /* | ||
4166 | * ioctl support | ||
4167 | */ | ||
4168 | static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd, | ||
4169 | u_long arg) | ||
4170 | { | ||
4171 | struct sbpcd_drive *p = cdi->handle; | ||
4172 | int i; | ||
4173 | |||
4174 | msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg); | ||
4175 | if (p->drv_id==-1) { | ||
4176 | msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name); | ||
4177 | return (-ENXIO); /* no such drive */ | ||
4178 | } | ||
4179 | down(&ioctl_read_sem); | ||
4180 | if (p != current_drive) | ||
4181 | switch_drive(p); | ||
4182 | |||
4183 | msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd); | ||
4184 | switch (cmd) /* Sun-compatible */ | ||
4185 | { | ||
4186 | case DDIOCSDBG: /* DDI Debug */ | ||
4187 | if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM); | ||
4188 | i=sbpcd_dbg_ioctl(arg,1); | ||
4189 | RETURN_UP(i); | ||
4190 | case CDROMRESET: /* hard reset the drive */ | ||
4191 | msg(DBG_IOC,"ioctl: CDROMRESET entered.\n"); | ||
4192 | i=DriveReset(); | ||
4193 | current_drive->audio_state=0; | ||
4194 | RETURN_UP(i); | ||
4195 | |||
4196 | case CDROMREADMODE1: | ||
4197 | msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n"); | ||
4198 | #ifdef SAFE_MIXED | ||
4199 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4200 | #endif /* SAFE_MIXED */ | ||
4201 | cc_ModeSelect(CD_FRAMESIZE); | ||
4202 | cc_ModeSense(); | ||
4203 | current_drive->mode=READ_M1; | ||
4204 | RETURN_UP(0); | ||
4205 | |||
4206 | case CDROMREADMODE2: /* not usable at the moment */ | ||
4207 | msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n"); | ||
4208 | #ifdef SAFE_MIXED | ||
4209 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4210 | #endif /* SAFE_MIXED */ | ||
4211 | cc_ModeSelect(CD_FRAMESIZE_RAW1); | ||
4212 | cc_ModeSense(); | ||
4213 | current_drive->mode=READ_M2; | ||
4214 | RETURN_UP(0); | ||
4215 | |||
4216 | case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ | ||
4217 | msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); | ||
4218 | if (current_drive->sbp_audsiz>0) | ||
4219 | vfree(current_drive->aud_buf); | ||
4220 | current_drive->aud_buf=NULL; | ||
4221 | current_drive->sbp_audsiz=arg; | ||
4222 | |||
4223 | if (current_drive->sbp_audsiz>16) | ||
4224 | { | ||
4225 | current_drive->sbp_audsiz = 0; | ||
4226 | RETURN_UP(current_drive->sbp_audsiz); | ||
4227 | } | ||
4228 | |||
4229 | if (current_drive->sbp_audsiz>0) | ||
4230 | { | ||
4231 | current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW); | ||
4232 | if (current_drive->aud_buf==NULL) | ||
4233 | { | ||
4234 | msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz); | ||
4235 | current_drive->sbp_audsiz=0; | ||
4236 | } | ||
4237 | else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz); | ||
4238 | } | ||
4239 | RETURN_UP(current_drive->sbp_audsiz); | ||
4240 | |||
4241 | case CDROMREADAUDIO: | ||
4242 | { /* start of CDROMREADAUDIO */ | ||
4243 | int i=0, j=0, frame, block=0; | ||
4244 | u_int try=0; | ||
4245 | u_long timeout; | ||
4246 | u_char *p; | ||
4247 | u_int data_tries = 0; | ||
4248 | u_int data_waits = 0; | ||
4249 | u_int data_retrying = 0; | ||
4250 | int status_tries; | ||
4251 | int error_flag; | ||
4252 | |||
4253 | msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n"); | ||
4254 | if (fam0_drive) RETURN_UP(-EINVAL); | ||
4255 | if (famL_drive) RETURN_UP(-EINVAL); | ||
4256 | if (famV_drive) RETURN_UP(-EINVAL); | ||
4257 | if (famT_drive) RETURN_UP(-EINVAL); | ||
4258 | #ifdef SAFE_MIXED | ||
4259 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
4260 | #endif /* SAFE_MIXED */ | ||
4261 | if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL); | ||
4262 | if (copy_from_user(&read_audio, (void __user *)arg, | ||
4263 | sizeof(struct cdrom_read_audio))) | ||
4264 | RETURN_UP(-EFAULT); | ||
4265 | if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL); | ||
4266 | if (!access_ok(VERIFY_WRITE, read_audio.buf, | ||
4267 | read_audio.nframes*CD_FRAMESIZE_RAW)) | ||
4268 | RETURN_UP(-EFAULT); | ||
4269 | |||
4270 | if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */ | ||
4271 | block=msf2lba(&read_audio.addr.msf.minute); | ||
4272 | else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */ | ||
4273 | block=read_audio.addr.lba; | ||
4274 | else RETURN_UP(-EINVAL); | ||
4275 | #if 000 | ||
4276 | i=cc_SetSpeed(speed_150,0,0); | ||
4277 | if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i); | ||
4278 | #endif | ||
4279 | msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n", | ||
4280 | block, blk2msf(block)); | ||
4281 | msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n"); | ||
4282 | #if OLD_BUSY | ||
4283 | while (busy_data) sbp_sleep(HZ/10); /* wait a bit */ | ||
4284 | busy_audio=1; | ||
4285 | #endif /* OLD_BUSY */ | ||
4286 | error_flag=0; | ||
4287 | for (data_tries=5; data_tries>0; data_tries--) | ||
4288 | { | ||
4289 | msg(DBG_AUD,"data_tries=%d ...\n", data_tries); | ||
4290 | current_drive->mode=READ_AU; | ||
4291 | cc_ModeSelect(CD_FRAMESIZE_RAW); | ||
4292 | cc_ModeSense(); | ||
4293 | for (status_tries=3; status_tries > 0; status_tries--) | ||
4294 | { | ||
4295 | flags_cmd_out |= f_respo3; | ||
4296 | cc_ReadStatus(); | ||
4297 | if (sbp_status() != 0) break; | ||
4298 | if (st_check) cc_ReadError(); | ||
4299 | sbp_sleep(1); /* wait a bit, try again */ | ||
4300 | } | ||
4301 | if (status_tries == 0) | ||
4302 | { | ||
4303 | msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__); | ||
4304 | continue; | ||
4305 | } | ||
4306 | msg(DBG_AUD,"read_audio: sbp_status: ok.\n"); | ||
4307 | |||
4308 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | ||
4309 | if (fam0L_drive) | ||
4310 | { | ||
4311 | flags_cmd_out |= f_lopsta | f_getsta | f_bit1; | ||
4312 | cmd_type=READ_M2; | ||
4313 | drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */ | ||
4314 | drvcmd[1]=(block>>16)&0x000000ff; | ||
4315 | drvcmd[2]=(block>>8)&0x000000ff; | ||
4316 | drvcmd[3]=block&0x000000ff; | ||
4317 | drvcmd[4]=0; | ||
4318 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
4319 | drvcmd[6]=0; | ||
4320 | } | ||
4321 | else if (fam1_drive) | ||
4322 | { | ||
4323 | drvcmd[0]=CMD1_READ; /* "read frames", new drives */ | ||
4324 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
4325 | drvcmd[4]=0; | ||
4326 | drvcmd[5]=0; | ||
4327 | drvcmd[6]=read_audio.nframes; /* # of frames */ | ||
4328 | } | ||
4329 | else if (fam2_drive) | ||
4330 | { | ||
4331 | drvcmd[0]=CMD2_READ_XA2; | ||
4332 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
4333 | drvcmd[4]=0; | ||
4334 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
4335 | drvcmd[6]=0x11; /* raw mode */ | ||
4336 | } | ||
4337 | else if (famT_drive) /* CD-55A: not tested yet */ | ||
4338 | { | ||
4339 | } | ||
4340 | msg(DBG_AUD,"read_audio: before giving \"read\" command.\n"); | ||
4341 | flags_cmd_out=f_putcmd; | ||
4342 | response_count=0; | ||
4343 | i=cmd_out(); | ||
4344 | if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i); | ||
4345 | sbp_sleep(0); | ||
4346 | msg(DBG_AUD,"read_audio: after giving \"read\" command.\n"); | ||
4347 | for (frame=1;frame<2 && !error_flag; frame++) | ||
4348 | { | ||
4349 | try=maxtim_data; | ||
4350 | for (timeout=jiffies+9*HZ; ; ) | ||
4351 | { | ||
4352 | for ( ; try!=0;try--) | ||
4353 | { | ||
4354 | j=inb(CDi_status); | ||
4355 | if (!(j&s_not_data_ready)) break; | ||
4356 | if (!(j&s_not_result_ready)) break; | ||
4357 | if (fam0L_drive) if (j&s_attention) break; | ||
4358 | } | ||
4359 | if (try != 0 || time_after_eq(jiffies, timeout)) break; | ||
4360 | if (data_retrying == 0) data_waits++; | ||
4361 | data_retrying = 1; | ||
4362 | sbp_sleep(1); | ||
4363 | try = 1; | ||
4364 | } | ||
4365 | if (try==0) | ||
4366 | { | ||
4367 | msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n"); | ||
4368 | error_flag++; | ||
4369 | break; | ||
4370 | } | ||
4371 | msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n"); | ||
4372 | if (j&s_not_data_ready) | ||
4373 | { | ||
4374 | msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n"); | ||
4375 | error_flag++; | ||
4376 | break; | ||
4377 | } | ||
4378 | msg(DBG_AUD,"read_audio: before reading data.\n"); | ||
4379 | error_flag=0; | ||
4380 | p = current_drive->aud_buf; | ||
4381 | if (sbpro_type==1) OUT(CDo_sel_i_d,1); | ||
4382 | if (do_16bit) | ||
4383 | { | ||
4384 | u_short *p2 = (u_short *) p; | ||
4385 | |||
4386 | for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
4387 | { | ||
4388 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
4389 | |||
4390 | /* get one sample */ | ||
4391 | *p2++ = inw_p(CDi_data); | ||
4392 | *p2++ = inw_p(CDi_data); | ||
4393 | } | ||
4394 | } else { | ||
4395 | for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
4396 | { | ||
4397 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
4398 | |||
4399 | /* get one sample */ | ||
4400 | *p++ = inb_p(CDi_data); | ||
4401 | *p++ = inb_p(CDi_data); | ||
4402 | *p++ = inb_p(CDi_data); | ||
4403 | *p++ = inb_p(CDi_data); | ||
4404 | } | ||
4405 | } | ||
4406 | if (sbpro_type==1) OUT(CDo_sel_i_d,0); | ||
4407 | data_retrying = 0; | ||
4408 | } | ||
4409 | msg(DBG_AUD,"read_audio: after reading data.\n"); | ||
4410 | if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */ | ||
4411 | { | ||
4412 | msg(DBG_AUD,"read_audio: read aborted by drive\n"); | ||
4413 | #if 0000 | ||
4414 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
4415 | #else | ||
4416 | i=cc_ReadError(); | ||
4417 | #endif | ||
4418 | continue; | ||
4419 | } | ||
4420 | if (fam0L_drive) | ||
4421 | { | ||
4422 | i=maxtim_data; | ||
4423 | for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--) | ||
4424 | { | ||
4425 | for ( ;i!=0;i--) | ||
4426 | { | ||
4427 | j=inb(CDi_status); | ||
4428 | if (!(j&s_not_data_ready)) break; | ||
4429 | if (!(j&s_not_result_ready)) break; | ||
4430 | if (j&s_attention) break; | ||
4431 | } | ||
4432 | if (i != 0 || time_after_eq(jiffies, timeout)) break; | ||
4433 | sbp_sleep(0); | ||
4434 | i = 1; | ||
4435 | } | ||
4436 | if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ"); | ||
4437 | if (!(j&s_attention)) | ||
4438 | { | ||
4439 | msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n"); | ||
4440 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
4441 | continue; | ||
4442 | } | ||
4443 | } | ||
4444 | do | ||
4445 | { | ||
4446 | if (fam0L_drive) cc_ReadStatus(); | ||
4447 | i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */ | ||
4448 | if (i<0) { msg(DBG_AUD, | ||
4449 | "read_audio: cc_ReadStatus error after read: %02X\n", | ||
4450 | current_drive->status_bits); | ||
4451 | continue; /* FIXME */ | ||
4452 | } | ||
4453 | } | ||
4454 | while ((fam0L_drive)&&(!st_check)&&(!(i&p_success))); | ||
4455 | if (st_check) | ||
4456 | { | ||
4457 | i=cc_ReadError(); | ||
4458 | msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i); | ||
4459 | continue; | ||
4460 | } | ||
4461 | if (copy_to_user(read_audio.buf, | ||
4462 | current_drive->aud_buf, | ||
4463 | read_audio.nframes * CD_FRAMESIZE_RAW)) | ||
4464 | RETURN_UP(-EFAULT); | ||
4465 | msg(DBG_AUD,"read_audio: copy_to_user done.\n"); | ||
4466 | break; | ||
4467 | } | ||
4468 | cc_ModeSelect(CD_FRAMESIZE); | ||
4469 | cc_ModeSense(); | ||
4470 | current_drive->mode=READ_M1; | ||
4471 | #if OLD_BUSY | ||
4472 | busy_audio=0; | ||
4473 | #endif /* OLD_BUSY */ | ||
4474 | if (data_tries == 0) | ||
4475 | { | ||
4476 | msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__); | ||
4477 | RETURN_UP(-EIO); | ||
4478 | } | ||
4479 | msg(DBG_AUD,"read_audio: successful return.\n"); | ||
4480 | RETURN_UP(0); | ||
4481 | } /* end of CDROMREADAUDIO */ | ||
4482 | |||
4483 | default: | ||
4484 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | ||
4485 | RETURN_UP(-EINVAL); | ||
4486 | } /* end switch(cmd) */ | ||
4487 | } | ||
4488 | |||
4489 | static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | 4163 | static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, |
4490 | void * arg) | 4164 | void * arg) |
4491 | { | 4165 | { |
@@ -4530,7 +4204,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4530 | default: | 4204 | default: |
4531 | RETURN_UP(-EINVAL); | 4205 | RETURN_UP(-EINVAL); |
4532 | } | 4206 | } |
4533 | 4207 | ||
4534 | case CDROMRESUME: /* resume paused audio play */ | 4208 | case CDROMRESUME: /* resume paused audio play */ |
4535 | msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n"); | 4209 | msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n"); |
4536 | /* resume playing audio tracks when a previous PLAY AUDIO call has */ | 4210 | /* resume playing audio tracks when a previous PLAY AUDIO call has */ |
@@ -4544,12 +4218,12 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4544 | if (i<0) RETURN_UP(-EIO); | 4218 | if (i<0) RETURN_UP(-EIO); |
4545 | current_drive->audio_state=audio_playing; | 4219 | current_drive->audio_state=audio_playing; |
4546 | RETURN_UP(0); | 4220 | RETURN_UP(0); |
4547 | 4221 | ||
4548 | case CDROMPLAYMSF: | 4222 | case CDROMPLAYMSF: |
4549 | msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n"); | 4223 | msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n"); |
4550 | #ifdef SAFE_MIXED | 4224 | #ifdef SAFE_MIXED |
4551 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | 4225 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); |
4552 | #endif /* SAFE_MIXED */ | 4226 | #endif /* SAFE_MIXED */ |
4553 | if (current_drive->audio_state==audio_playing) | 4227 | if (current_drive->audio_state==audio_playing) |
4554 | { | 4228 | { |
4555 | i=cc_Pause_Resume(1); | 4229 | i=cc_Pause_Resume(1); |
@@ -4584,7 +4258,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4584 | msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n"); | 4258 | msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n"); |
4585 | #ifdef SAFE_MIXED | 4259 | #ifdef SAFE_MIXED |
4586 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | 4260 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); |
4587 | #endif /* SAFE_MIXED */ | 4261 | #endif /* SAFE_MIXED */ |
4588 | if (current_drive->audio_state==audio_playing) | 4262 | if (current_drive->audio_state==audio_playing) |
4589 | { | 4263 | { |
4590 | msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n"); | 4264 | msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n"); |
@@ -4654,13 +4328,13 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4654 | cc_DriveReset(); | 4328 | cc_DriveReset(); |
4655 | #endif | 4329 | #endif |
4656 | RETURN_UP(i); | 4330 | RETURN_UP(i); |
4657 | 4331 | ||
4658 | case CDROMSTART: /* Spin up the drive */ | 4332 | case CDROMSTART: /* Spin up the drive */ |
4659 | msg(DBG_IOC,"ioctl: CDROMSTART entered.\n"); | 4333 | msg(DBG_IOC,"ioctl: CDROMSTART entered.\n"); |
4660 | cc_SpinUp(); | 4334 | cc_SpinUp(); |
4661 | current_drive->audio_state=0; | 4335 | current_drive->audio_state=0; |
4662 | RETURN_UP(0); | 4336 | RETURN_UP(0); |
4663 | 4337 | ||
4664 | case CDROMVOLCTRL: /* Volume control */ | 4338 | case CDROMVOLCTRL: /* Volume control */ |
4665 | msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n"); | 4339 | msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n"); |
4666 | memcpy(&volctrl,(char *) arg,sizeof(volctrl)); | 4340 | memcpy(&volctrl,(char *) arg,sizeof(volctrl)); |
@@ -4670,7 +4344,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4670 | current_drive->vol_ctrl1=volctrl.channel1; | 4344 | current_drive->vol_ctrl1=volctrl.channel1; |
4671 | i=cc_SetVolume(); | 4345 | i=cc_SetVolume(); |
4672 | RETURN_UP(0); | 4346 | RETURN_UP(0); |
4673 | 4347 | ||
4674 | case CDROMVOLREAD: /* read Volume settings from drive */ | 4348 | case CDROMVOLREAD: /* read Volume settings from drive */ |
4675 | msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n"); | 4349 | msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n"); |
4676 | st=cc_GetVolume(); | 4350 | st=cc_GetVolume(); |
@@ -4694,7 +4368,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4694 | if (i<0) { | 4368 | if (i<0) { |
4695 | j=cc_ReadError(); /* clear out error status from drive */ | 4369 | j=cc_ReadError(); /* clear out error status from drive */ |
4696 | current_drive->audio_state=CDROM_AUDIO_NO_STATUS; | 4370 | current_drive->audio_state=CDROM_AUDIO_NO_STATUS; |
4697 | /* get and set the disk state here, | 4371 | /* get and set the disk state here, |
4698 | probably not the right place, but who cares! | 4372 | probably not the right place, but who cares! |
4699 | It makes it work properly! --AJK */ | 4373 | It makes it work properly! --AJK */ |
4700 | if (current_drive->CD_changed==0xFF) { | 4374 | if (current_drive->CD_changed==0xFF) { |
@@ -4715,8 +4389,8 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4715 | } | 4389 | } |
4716 | } | 4390 | } |
4717 | memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl)); | 4391 | memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl)); |
4718 | /* | 4392 | /* |
4719 | This virtual crap is very bogus! | 4393 | This virtual crap is very bogus! |
4720 | It doesn't detect when the cd is done playing audio! | 4394 | It doesn't detect when the cd is done playing audio! |
4721 | Lets do this right with proper hardware register reading! | 4395 | Lets do this right with proper hardware register reading! |
4722 | */ | 4396 | */ |
@@ -4775,7 +4449,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4775 | SC.cdsc_trk,SC.cdsc_ind, | 4449 | SC.cdsc_trk,SC.cdsc_ind, |
4776 | SC.cdsc_absaddr,SC.cdsc_reladdr); | 4450 | SC.cdsc_absaddr,SC.cdsc_reladdr); |
4777 | RETURN_UP(0); | 4451 | RETURN_UP(0); |
4778 | 4452 | ||
4779 | default: | 4453 | default: |
4780 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | 4454 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); |
4781 | RETURN_UP(-EINVAL); | 4455 | RETURN_UP(-EINVAL); |
@@ -4788,7 +4462,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, | |||
4788 | static void sbp_transfer(struct request *req) | 4462 | static void sbp_transfer(struct request *req) |
4789 | { | 4463 | { |
4790 | long offs; | 4464 | long offs; |
4791 | 4465 | ||
4792 | while ( (req->nr_sectors > 0) && | 4466 | while ( (req->nr_sectors > 0) && |
4793 | (req->sector/4 >= current_drive->sbp_first_frame) && | 4467 | (req->sector/4 >= current_drive->sbp_first_frame) && |
4794 | (req->sector/4 <= current_drive->sbp_last_frame) ) | 4468 | (req->sector/4 <= current_drive->sbp_last_frame) ) |
@@ -4807,11 +4481,11 @@ static void sbp_transfer(struct request *req) | |||
4807 | * | 4481 | * |
4808 | * This is a kludge so we don't need to modify end_request. | 4482 | * This is a kludge so we don't need to modify end_request. |
4809 | * We put the req we take out after INIT_REQUEST in the requests list, | 4483 | * We put the req we take out after INIT_REQUEST in the requests list, |
4810 | * so that end_request will discard it. | 4484 | * so that end_request will discard it. |
4811 | * | 4485 | * |
4812 | * The bug could be present in other block devices, perhaps we | 4486 | * The bug could be present in other block devices, perhaps we |
4813 | * should modify INIT_REQUEST and end_request instead, and | 4487 | * should modify INIT_REQUEST and end_request instead, and |
4814 | * change every block device.. | 4488 | * change every block device.. |
4815 | * | 4489 | * |
4816 | * Could be a race here?? Could e.g. a timer interrupt schedule() us? | 4490 | * Could be a race here?? Could e.g. a timer interrupt schedule() us? |
4817 | * If so, we should copy end_request here, and do it right.. (or | 4491 | * If so, we should copy end_request here, and do it right.. (or |
@@ -4883,19 +4557,19 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4883 | while (busy_audio) sbp_sleep(HZ); /* wait a bit */ | 4557 | while (busy_audio) sbp_sleep(HZ); /* wait a bit */ |
4884 | busy_data=1; | 4558 | busy_data=1; |
4885 | #endif /* OLD_BUSY */ | 4559 | #endif /* OLD_BUSY */ |
4886 | 4560 | ||
4887 | if (p->audio_state==audio_playing) goto err_done; | 4561 | if (p->audio_state==audio_playing) goto err_done; |
4888 | if (p != current_drive) | 4562 | if (p != current_drive) |
4889 | switch_drive(p); | 4563 | switch_drive(p); |
4890 | 4564 | ||
4891 | block = req->sector; /* always numbered as 512-byte-pieces */ | 4565 | block = req->sector; /* always numbered as 512-byte-pieces */ |
4892 | nsect = req->nr_sectors; /* always counted as 512-byte-pieces */ | 4566 | nsect = req->nr_sectors; /* always counted as 512-byte-pieces */ |
4893 | 4567 | ||
4894 | msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect); | 4568 | msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect); |
4895 | #if 0 | 4569 | #if 0 |
4896 | msg(DBG_MUL,"read LBA %d\n", block/4); | 4570 | msg(DBG_MUL,"read LBA %d\n", block/4); |
4897 | #endif | 4571 | #endif |
4898 | 4572 | ||
4899 | sbp_transfer(req); | 4573 | sbp_transfer(req); |
4900 | /* if we satisfied the request from the buffer, we're done. */ | 4574 | /* if we satisfied the request from the buffer, we're done. */ |
4901 | if (req->nr_sectors == 0) | 4575 | if (req->nr_sectors == 0) |
@@ -4914,10 +4588,10 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4914 | i=prepare(0,0); /* at moment not really a hassle check, but ... */ | 4588 | i=prepare(0,0); /* at moment not really a hassle check, but ... */ |
4915 | if (i!=0) | 4589 | if (i!=0) |
4916 | msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i); | 4590 | msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i); |
4917 | #endif /* FUTURE */ | 4591 | #endif /* FUTURE */ |
4918 | 4592 | ||
4919 | if (!st_spinning) cc_SpinUp(); | 4593 | if (!st_spinning) cc_SpinUp(); |
4920 | 4594 | ||
4921 | for (data_tries=n_retries; data_tries > 0; data_tries--) | 4595 | for (data_tries=n_retries; data_tries > 0; data_tries--) |
4922 | { | 4596 | { |
4923 | for (status_tries=3; status_tries > 0; status_tries--) | 4597 | for (status_tries=3; status_tries > 0; status_tries--) |
@@ -4940,7 +4614,7 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4940 | { | 4614 | { |
4941 | #ifdef SAFE_MIXED | 4615 | #ifdef SAFE_MIXED |
4942 | current_drive->has_data=2; /* is really a data disk */ | 4616 | current_drive->has_data=2; /* is really a data disk */ |
4943 | #endif /* SAFE_MIXED */ | 4617 | #endif /* SAFE_MIXED */ |
4944 | #ifdef DEBUG_GTL | 4618 | #ifdef DEBUG_GTL |
4945 | printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n", | 4619 | printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n", |
4946 | xnr, req, req->sector, req->nr_sectors, jiffies); | 4620 | xnr, req, req->sector, req->nr_sectors, jiffies); |
@@ -4951,7 +4625,7 @@ static void do_sbpcd_request(request_queue_t * q) | |||
4951 | goto request_loop; | 4625 | goto request_loop; |
4952 | } | 4626 | } |
4953 | } | 4627 | } |
4954 | 4628 | ||
4955 | err_done: | 4629 | err_done: |
4956 | #if OLD_BUSY | 4630 | #if OLD_BUSY |
4957 | busy_data=0; | 4631 | busy_data=0; |
@@ -4976,7 +4650,7 @@ static void sbp_read_cmd(struct request *req) | |||
4976 | 4650 | ||
4977 | int i; | 4651 | int i; |
4978 | int block; | 4652 | int block; |
4979 | 4653 | ||
4980 | current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */ | 4654 | current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */ |
4981 | current_drive->sbp_current = 0; | 4655 | current_drive->sbp_current = 0; |
4982 | block=req->sector/4; | 4656 | block=req->sector/4; |
@@ -4993,7 +4667,7 @@ static void sbp_read_cmd(struct request *req) | |||
4993 | current_drive->sbp_read_frames=1; | 4667 | current_drive->sbp_read_frames=1; |
4994 | } | 4668 | } |
4995 | } | 4669 | } |
4996 | 4670 | ||
4997 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | 4671 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; |
4998 | clr_cmdbuf(); | 4672 | clr_cmdbuf(); |
4999 | if (famV_drive) | 4673 | if (famV_drive) |
@@ -5092,7 +4766,7 @@ static int sbp_data(struct request *req) | |||
5092 | int success; | 4766 | int success; |
5093 | int wait; | 4767 | int wait; |
5094 | int duration; | 4768 | int duration; |
5095 | 4769 | ||
5096 | error_flag=0; | 4770 | error_flag=0; |
5097 | success=0; | 4771 | success=0; |
5098 | #if LONG_TIMING | 4772 | #if LONG_TIMING |
@@ -5105,12 +4779,12 @@ static int sbp_data(struct request *req) | |||
5105 | for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++) | 4779 | for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++) |
5106 | { | 4780 | { |
5107 | SBPCD_CLI; | 4781 | SBPCD_CLI; |
5108 | 4782 | ||
5109 | del_timer(&data_timer); | 4783 | del_timer(&data_timer); |
5110 | data_timer.expires=jiffies+max_latency; | 4784 | data_timer.expires=jiffies+max_latency; |
5111 | timed_out_data=0; | 4785 | timed_out_data=0; |
5112 | add_timer(&data_timer); | 4786 | add_timer(&data_timer); |
5113 | while (!timed_out_data) | 4787 | while (!timed_out_data) |
5114 | { | 4788 | { |
5115 | if (current_drive->f_multisession) try=maxtim_data*4; | 4789 | if (current_drive->f_multisession) try=maxtim_data*4; |
5116 | else try=maxtim_data; | 4790 | else try=maxtim_data; |
@@ -5207,9 +4881,9 @@ static int sbp_data(struct request *req) | |||
5207 | else | 4881 | else |
5208 | { | 4882 | { |
5209 | sbp_sleep(1); | 4883 | sbp_sleep(1); |
5210 | OUT(CDo_sel_i_d,0); | 4884 | OUT(CDo_sel_i_d,0); |
5211 | i=inb(CDi_status); | 4885 | i=inb(CDi_status); |
5212 | } | 4886 | } |
5213 | if (!(i&s_not_data_ready)) | 4887 | if (!(i&s_not_data_ready)) |
5214 | { | 4888 | { |
5215 | OUT(CDo_sel_i_d,1); | 4889 | OUT(CDo_sel_i_d,1); |
@@ -5311,7 +4985,7 @@ static int sbp_data(struct request *req) | |||
5311 | } | 4985 | } |
5312 | SBPCD_STI; | 4986 | SBPCD_STI; |
5313 | } | 4987 | } |
5314 | 4988 | ||
5315 | #if 0 | 4989 | #if 0 |
5316 | if (!success) | 4990 | if (!success) |
5317 | #endif | 4991 | #endif |
@@ -5370,7 +5044,326 @@ static int sbpcd_block_ioctl(struct inode *inode, struct file *file, | |||
5370 | unsigned cmd, unsigned long arg) | 5044 | unsigned cmd, unsigned long arg) |
5371 | { | 5045 | { |
5372 | struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data; | 5046 | struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data; |
5373 | return cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg); | 5047 | struct cdrom_device_info *cdi = p->sbpcd_infop; |
5048 | int ret, i; | ||
5049 | |||
5050 | ret = cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg); | ||
5051 | if (ret != -ENOSYS) | ||
5052 | return ret; | ||
5053 | |||
5054 | msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg); | ||
5055 | if (p->drv_id==-1) { | ||
5056 | msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name); | ||
5057 | return (-ENXIO); /* no such drive */ | ||
5058 | } | ||
5059 | down(&ioctl_read_sem); | ||
5060 | if (p != current_drive) | ||
5061 | switch_drive(p); | ||
5062 | |||
5063 | msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd); | ||
5064 | switch (cmd) /* Sun-compatible */ | ||
5065 | { | ||
5066 | case DDIOCSDBG: /* DDI Debug */ | ||
5067 | if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM); | ||
5068 | i=sbpcd_dbg_ioctl(arg,1); | ||
5069 | RETURN_UP(i); | ||
5070 | case CDROMRESET: /* hard reset the drive */ | ||
5071 | msg(DBG_IOC,"ioctl: CDROMRESET entered.\n"); | ||
5072 | i=DriveReset(); | ||
5073 | current_drive->audio_state=0; | ||
5074 | RETURN_UP(i); | ||
5075 | |||
5076 | case CDROMREADMODE1: | ||
5077 | msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n"); | ||
5078 | #ifdef SAFE_MIXED | ||
5079 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5080 | #endif /* SAFE_MIXED */ | ||
5081 | cc_ModeSelect(CD_FRAMESIZE); | ||
5082 | cc_ModeSense(); | ||
5083 | current_drive->mode=READ_M1; | ||
5084 | RETURN_UP(0); | ||
5085 | |||
5086 | case CDROMREADMODE2: /* not usable at the moment */ | ||
5087 | msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n"); | ||
5088 | #ifdef SAFE_MIXED | ||
5089 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5090 | #endif /* SAFE_MIXED */ | ||
5091 | cc_ModeSelect(CD_FRAMESIZE_RAW1); | ||
5092 | cc_ModeSense(); | ||
5093 | current_drive->mode=READ_M2; | ||
5094 | RETURN_UP(0); | ||
5095 | |||
5096 | case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ | ||
5097 | msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); | ||
5098 | if (current_drive->sbp_audsiz>0) | ||
5099 | vfree(current_drive->aud_buf); | ||
5100 | current_drive->aud_buf=NULL; | ||
5101 | current_drive->sbp_audsiz=arg; | ||
5102 | |||
5103 | if (current_drive->sbp_audsiz>16) | ||
5104 | { | ||
5105 | current_drive->sbp_audsiz = 0; | ||
5106 | RETURN_UP(current_drive->sbp_audsiz); | ||
5107 | } | ||
5108 | |||
5109 | if (current_drive->sbp_audsiz>0) | ||
5110 | { | ||
5111 | current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW); | ||
5112 | if (current_drive->aud_buf==NULL) | ||
5113 | { | ||
5114 | msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz); | ||
5115 | current_drive->sbp_audsiz=0; | ||
5116 | } | ||
5117 | else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz); | ||
5118 | } | ||
5119 | RETURN_UP(current_drive->sbp_audsiz); | ||
5120 | |||
5121 | case CDROMREADAUDIO: | ||
5122 | { /* start of CDROMREADAUDIO */ | ||
5123 | int i=0, j=0, frame, block=0; | ||
5124 | u_int try=0; | ||
5125 | u_long timeout; | ||
5126 | u_char *p; | ||
5127 | u_int data_tries = 0; | ||
5128 | u_int data_waits = 0; | ||
5129 | u_int data_retrying = 0; | ||
5130 | int status_tries; | ||
5131 | int error_flag; | ||
5132 | |||
5133 | msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n"); | ||
5134 | if (fam0_drive) RETURN_UP(-EINVAL); | ||
5135 | if (famL_drive) RETURN_UP(-EINVAL); | ||
5136 | if (famV_drive) RETURN_UP(-EINVAL); | ||
5137 | if (famT_drive) RETURN_UP(-EINVAL); | ||
5138 | #ifdef SAFE_MIXED | ||
5139 | if (current_drive->has_data>1) RETURN_UP(-EBUSY); | ||
5140 | #endif /* SAFE_MIXED */ | ||
5141 | if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL); | ||
5142 | if (copy_from_user(&read_audio, (void __user *)arg, | ||
5143 | sizeof(struct cdrom_read_audio))) | ||
5144 | RETURN_UP(-EFAULT); | ||
5145 | if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL); | ||
5146 | if (!access_ok(VERIFY_WRITE, read_audio.buf, | ||
5147 | read_audio.nframes*CD_FRAMESIZE_RAW)) | ||
5148 | RETURN_UP(-EFAULT); | ||
5149 | |||
5150 | if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */ | ||
5151 | block=msf2lba(&read_audio.addr.msf.minute); | ||
5152 | else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */ | ||
5153 | block=read_audio.addr.lba; | ||
5154 | else RETURN_UP(-EINVAL); | ||
5155 | #if 000 | ||
5156 | i=cc_SetSpeed(speed_150,0,0); | ||
5157 | if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i); | ||
5158 | #endif | ||
5159 | msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n", | ||
5160 | block, blk2msf(block)); | ||
5161 | msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n"); | ||
5162 | #if OLD_BUSY | ||
5163 | while (busy_data) sbp_sleep(HZ/10); /* wait a bit */ | ||
5164 | busy_audio=1; | ||
5165 | #endif /* OLD_BUSY */ | ||
5166 | error_flag=0; | ||
5167 | for (data_tries=5; data_tries>0; data_tries--) | ||
5168 | { | ||
5169 | msg(DBG_AUD,"data_tries=%d ...\n", data_tries); | ||
5170 | current_drive->mode=READ_AU; | ||
5171 | cc_ModeSelect(CD_FRAMESIZE_RAW); | ||
5172 | cc_ModeSense(); | ||
5173 | for (status_tries=3; status_tries > 0; status_tries--) | ||
5174 | { | ||
5175 | flags_cmd_out |= f_respo3; | ||
5176 | cc_ReadStatus(); | ||
5177 | if (sbp_status() != 0) break; | ||
5178 | if (st_check) cc_ReadError(); | ||
5179 | sbp_sleep(1); /* wait a bit, try again */ | ||
5180 | } | ||
5181 | if (status_tries == 0) | ||
5182 | { | ||
5183 | msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__); | ||
5184 | continue; | ||
5185 | } | ||
5186 | msg(DBG_AUD,"read_audio: sbp_status: ok.\n"); | ||
5187 | |||
5188 | flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check; | ||
5189 | if (fam0L_drive) | ||
5190 | { | ||
5191 | flags_cmd_out |= f_lopsta | f_getsta | f_bit1; | ||
5192 | cmd_type=READ_M2; | ||
5193 | drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */ | ||
5194 | drvcmd[1]=(block>>16)&0x000000ff; | ||
5195 | drvcmd[2]=(block>>8)&0x000000ff; | ||
5196 | drvcmd[3]=block&0x000000ff; | ||
5197 | drvcmd[4]=0; | ||
5198 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
5199 | drvcmd[6]=0; | ||
5200 | } | ||
5201 | else if (fam1_drive) | ||
5202 | { | ||
5203 | drvcmd[0]=CMD1_READ; /* "read frames", new drives */ | ||
5204 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
5205 | drvcmd[4]=0; | ||
5206 | drvcmd[5]=0; | ||
5207 | drvcmd[6]=read_audio.nframes; /* # of frames */ | ||
5208 | } | ||
5209 | else if (fam2_drive) | ||
5210 | { | ||
5211 | drvcmd[0]=CMD2_READ_XA2; | ||
5212 | lba2msf(block,&drvcmd[1]); /* msf-bin format required */ | ||
5213 | drvcmd[4]=0; | ||
5214 | drvcmd[5]=read_audio.nframes; /* # of frames */ | ||
5215 | drvcmd[6]=0x11; /* raw mode */ | ||
5216 | } | ||
5217 | else if (famT_drive) /* CD-55A: not tested yet */ | ||
5218 | { | ||
5219 | } | ||
5220 | msg(DBG_AUD,"read_audio: before giving \"read\" command.\n"); | ||
5221 | flags_cmd_out=f_putcmd; | ||
5222 | response_count=0; | ||
5223 | i=cmd_out(); | ||
5224 | if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i); | ||
5225 | sbp_sleep(0); | ||
5226 | msg(DBG_AUD,"read_audio: after giving \"read\" command.\n"); | ||
5227 | for (frame=1;frame<2 && !error_flag; frame++) | ||
5228 | { | ||
5229 | try=maxtim_data; | ||
5230 | for (timeout=jiffies+9*HZ; ; ) | ||
5231 | { | ||
5232 | for ( ; try!=0;try--) | ||
5233 | { | ||
5234 | j=inb(CDi_status); | ||
5235 | if (!(j&s_not_data_ready)) break; | ||
5236 | if (!(j&s_not_result_ready)) break; | ||
5237 | if (fam0L_drive) if (j&s_attention) break; | ||
5238 | } | ||
5239 | if (try != 0 || time_after_eq(jiffies, timeout)) break; | ||
5240 | if (data_retrying == 0) data_waits++; | ||
5241 | data_retrying = 1; | ||
5242 | sbp_sleep(1); | ||
5243 | try = 1; | ||
5244 | } | ||
5245 | if (try==0) | ||
5246 | { | ||
5247 | msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n"); | ||
5248 | error_flag++; | ||
5249 | break; | ||
5250 | } | ||
5251 | msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n"); | ||
5252 | if (j&s_not_data_ready) | ||
5253 | { | ||
5254 | msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n"); | ||
5255 | error_flag++; | ||
5256 | break; | ||
5257 | } | ||
5258 | msg(DBG_AUD,"read_audio: before reading data.\n"); | ||
5259 | error_flag=0; | ||
5260 | p = current_drive->aud_buf; | ||
5261 | if (sbpro_type==1) OUT(CDo_sel_i_d,1); | ||
5262 | if (do_16bit) | ||
5263 | { | ||
5264 | u_short *p2 = (u_short *) p; | ||
5265 | |||
5266 | for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
5267 | { | ||
5268 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
5269 | |||
5270 | /* get one sample */ | ||
5271 | *p2++ = inw_p(CDi_data); | ||
5272 | *p2++ = inw_p(CDi_data); | ||
5273 | } | ||
5274 | } else { | ||
5275 | for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;) | ||
5276 | { | ||
5277 | if ((inb_p(CDi_status)&s_not_data_ready)) continue; | ||
5278 | |||
5279 | /* get one sample */ | ||
5280 | *p++ = inb_p(CDi_data); | ||
5281 | *p++ = inb_p(CDi_data); | ||
5282 | *p++ = inb_p(CDi_data); | ||
5283 | *p++ = inb_p(CDi_data); | ||
5284 | } | ||
5285 | } | ||
5286 | if (sbpro_type==1) OUT(CDo_sel_i_d,0); | ||
5287 | data_retrying = 0; | ||
5288 | } | ||
5289 | msg(DBG_AUD,"read_audio: after reading data.\n"); | ||
5290 | if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */ | ||
5291 | { | ||
5292 | msg(DBG_AUD,"read_audio: read aborted by drive\n"); | ||
5293 | #if 0000 | ||
5294 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
5295 | #else | ||
5296 | i=cc_ReadError(); | ||
5297 | #endif | ||
5298 | continue; | ||
5299 | } | ||
5300 | if (fam0L_drive) | ||
5301 | { | ||
5302 | i=maxtim_data; | ||
5303 | for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--) | ||
5304 | { | ||
5305 | for ( ;i!=0;i--) | ||
5306 | { | ||
5307 | j=inb(CDi_status); | ||
5308 | if (!(j&s_not_data_ready)) break; | ||
5309 | if (!(j&s_not_result_ready)) break; | ||
5310 | if (j&s_attention) break; | ||
5311 | } | ||
5312 | if (i != 0 || time_after_eq(jiffies, timeout)) break; | ||
5313 | sbp_sleep(0); | ||
5314 | i = 1; | ||
5315 | } | ||
5316 | if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ"); | ||
5317 | if (!(j&s_attention)) | ||
5318 | { | ||
5319 | msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n"); | ||
5320 | i=cc_DriveReset(); /* ugly fix to prevent a hang */ | ||
5321 | continue; | ||
5322 | } | ||
5323 | } | ||
5324 | do | ||
5325 | { | ||
5326 | if (fam0L_drive) cc_ReadStatus(); | ||
5327 | i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */ | ||
5328 | if (i<0) { msg(DBG_AUD, | ||
5329 | "read_audio: cc_ReadStatus error after read: %02X\n", | ||
5330 | current_drive->status_bits); | ||
5331 | continue; /* FIXME */ | ||
5332 | } | ||
5333 | } | ||
5334 | while ((fam0L_drive)&&(!st_check)&&(!(i&p_success))); | ||
5335 | if (st_check) | ||
5336 | { | ||
5337 | i=cc_ReadError(); | ||
5338 | msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i); | ||
5339 | continue; | ||
5340 | } | ||
5341 | if (copy_to_user(read_audio.buf, | ||
5342 | current_drive->aud_buf, | ||
5343 | read_audio.nframes * CD_FRAMESIZE_RAW)) | ||
5344 | RETURN_UP(-EFAULT); | ||
5345 | msg(DBG_AUD,"read_audio: copy_to_user done.\n"); | ||
5346 | break; | ||
5347 | } | ||
5348 | cc_ModeSelect(CD_FRAMESIZE); | ||
5349 | cc_ModeSense(); | ||
5350 | current_drive->mode=READ_M1; | ||
5351 | #if OLD_BUSY | ||
5352 | busy_audio=0; | ||
5353 | #endif /* OLD_BUSY */ | ||
5354 | if (data_tries == 0) | ||
5355 | { | ||
5356 | msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__); | ||
5357 | RETURN_UP(-EIO); | ||
5358 | } | ||
5359 | msg(DBG_AUD,"read_audio: successful return.\n"); | ||
5360 | RETURN_UP(0); | ||
5361 | } /* end of CDROMREADAUDIO */ | ||
5362 | |||
5363 | default: | ||
5364 | msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd); | ||
5365 | RETURN_UP(-EINVAL); | ||
5366 | } /* end switch(cmd) */ | ||
5374 | } | 5367 | } |
5375 | 5368 | ||
5376 | static int sbpcd_block_media_changed(struct gendisk *disk) | 5369 | static int sbpcd_block_media_changed(struct gendisk *disk) |
@@ -5478,10 +5471,9 @@ static struct cdrom_device_ops sbpcd_dops = { | |||
5478 | .get_mcn = sbpcd_get_mcn, | 5471 | .get_mcn = sbpcd_get_mcn, |
5479 | .reset = sbpcd_reset, | 5472 | .reset = sbpcd_reset, |
5480 | .audio_ioctl = sbpcd_audio_ioctl, | 5473 | .audio_ioctl = sbpcd_audio_ioctl, |
5481 | .dev_ioctl = sbpcd_dev_ioctl, | ||
5482 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 5474 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
5483 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | | 5475 | CDC_MULTI_SESSION | CDC_MEDIA_CHANGED | |
5484 | CDC_MCN | CDC_PLAY_AUDIO | CDC_IOCTLS, | 5476 | CDC_MCN | CDC_PLAY_AUDIO, |
5485 | .n_minors = 1, | 5477 | .n_minors = 1, |
5486 | }; | 5478 | }; |
5487 | 5479 | ||
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index e27617259552..c0f817ba7adb 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -627,7 +627,7 @@ static struct cdrom_device_ops viocd_dops = { | |||
627 | .media_changed = viocd_media_changed, | 627 | .media_changed = viocd_media_changed, |
628 | .lock_door = viocd_lock_door, | 628 | .lock_door = viocd_lock_door, |
629 | .generic_packet = viocd_packet, | 629 | .generic_packet = viocd_packet, |
630 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM | 630 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM |
631 | }; | 631 | }; |
632 | 632 | ||
633 | static int __init find_capability(const char *type) | 633 | static int __init find_capability(const char *type) |
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 7ac365b5d9ec..6602b3156df5 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -46,8 +46,6 @@ | |||
46 | 46 | ||
47 | /* Sanity checks */ | 47 | /* Sanity checks */ |
48 | 48 | ||
49 | #define SERIAL_INLINE | ||
50 | |||
51 | #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) | 49 | #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) |
52 | #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ | 50 | #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ |
53 | tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) | 51 | tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) |
@@ -95,10 +93,6 @@ static char *serial_version = "4.30"; | |||
95 | #include <asm/amigahw.h> | 93 | #include <asm/amigahw.h> |
96 | #include <asm/amigaints.h> | 94 | #include <asm/amigaints.h> |
97 | 95 | ||
98 | #ifdef SERIAL_INLINE | ||
99 | #define _INLINE_ inline | ||
100 | #endif | ||
101 | |||
102 | #define custom amiga_custom | 96 | #define custom amiga_custom |
103 | static char *serial_name = "Amiga-builtin serial driver"; | 97 | static char *serial_name = "Amiga-builtin serial driver"; |
104 | 98 | ||
@@ -253,14 +247,14 @@ static void rs_start(struct tty_struct *tty) | |||
253 | * This routine is used by the interrupt handler to schedule | 247 | * This routine is used by the interrupt handler to schedule |
254 | * processing in the software interrupt portion of the driver. | 248 | * processing in the software interrupt portion of the driver. |
255 | */ | 249 | */ |
256 | static _INLINE_ void rs_sched_event(struct async_struct *info, | 250 | static void rs_sched_event(struct async_struct *info, |
257 | int event) | 251 | int event) |
258 | { | 252 | { |
259 | info->event |= 1 << event; | 253 | info->event |= 1 << event; |
260 | tasklet_schedule(&info->tlet); | 254 | tasklet_schedule(&info->tlet); |
261 | } | 255 | } |
262 | 256 | ||
263 | static _INLINE_ void receive_chars(struct async_struct *info) | 257 | static void receive_chars(struct async_struct *info) |
264 | { | 258 | { |
265 | int status; | 259 | int status; |
266 | int serdatr; | 260 | int serdatr; |
@@ -349,7 +343,7 @@ out: | |||
349 | return; | 343 | return; |
350 | } | 344 | } |
351 | 345 | ||
352 | static _INLINE_ void transmit_chars(struct async_struct *info) | 346 | static void transmit_chars(struct async_struct *info) |
353 | { | 347 | { |
354 | custom.intreq = IF_TBE; | 348 | custom.intreq = IF_TBE; |
355 | mb(); | 349 | mb(); |
@@ -389,7 +383,7 @@ static _INLINE_ void transmit_chars(struct async_struct *info) | |||
389 | } | 383 | } |
390 | } | 384 | } |
391 | 385 | ||
392 | static _INLINE_ void check_modem_status(struct async_struct *info) | 386 | static void check_modem_status(struct async_struct *info) |
393 | { | 387 | { |
394 | unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); | 388 | unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); |
395 | unsigned char dstatus; | 389 | unsigned char dstatus; |
@@ -1959,7 +1953,7 @@ done: | |||
1959 | * number, and identifies which options were configured into this | 1953 | * number, and identifies which options were configured into this |
1960 | * driver. | 1954 | * driver. |
1961 | */ | 1955 | */ |
1962 | static _INLINE_ void show_serial_version(void) | 1956 | static void show_serial_version(void) |
1963 | { | 1957 | { |
1964 | printk(KERN_INFO "%s version %s\n", serial_name, serial_version); | 1958 | printk(KERN_INFO "%s version %s\n", serial_name, serial_version); |
1965 | } | 1959 | } |
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c index e38a5f0e07bb..5e59c0b42731 100644 --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c | |||
@@ -48,8 +48,8 @@ static int gs_debug; | |||
48 | #define NEW_WRITE_LOCKING 1 | 48 | #define NEW_WRITE_LOCKING 1 |
49 | #if NEW_WRITE_LOCKING | 49 | #if NEW_WRITE_LOCKING |
50 | #define DECL /* Nothing */ | 50 | #define DECL /* Nothing */ |
51 | #define LOCKIT down (& port->port_write_sem); | 51 | #define LOCKIT mutex_lock(& port->port_write_mutex); |
52 | #define RELEASEIT up (&port->port_write_sem); | 52 | #define RELEASEIT mutex_unlock(&port->port_write_mutex); |
53 | #else | 53 | #else |
54 | #define DECL unsigned long flags; | 54 | #define DECL unsigned long flags; |
55 | #define LOCKIT save_flags (flags);cli () | 55 | #define LOCKIT save_flags (flags);cli () |
@@ -124,14 +124,14 @@ int gs_write(struct tty_struct * tty, | |||
124 | /* get exclusive "write" access to this port (problem 3) */ | 124 | /* get exclusive "write" access to this port (problem 3) */ |
125 | /* This is not a spinlock because we can have a disk access (page | 125 | /* This is not a spinlock because we can have a disk access (page |
126 | fault) in copy_from_user */ | 126 | fault) in copy_from_user */ |
127 | down (& port->port_write_sem); | 127 | mutex_lock(& port->port_write_mutex); |
128 | 128 | ||
129 | while (1) { | 129 | while (1) { |
130 | 130 | ||
131 | c = count; | 131 | c = count; |
132 | 132 | ||
133 | /* This is safe because we "OWN" the "head". Noone else can | 133 | /* This is safe because we "OWN" the "head". Noone else can |
134 | change the "head": we own the port_write_sem. */ | 134 | change the "head": we own the port_write_mutex. */ |
135 | /* Don't overrun the end of the buffer */ | 135 | /* Don't overrun the end of the buffer */ |
136 | t = SERIAL_XMIT_SIZE - port->xmit_head; | 136 | t = SERIAL_XMIT_SIZE - port->xmit_head; |
137 | if (t < c) c = t; | 137 | if (t < c) c = t; |
@@ -153,7 +153,7 @@ int gs_write(struct tty_struct * tty, | |||
153 | count -= c; | 153 | count -= c; |
154 | total += c; | 154 | total += c; |
155 | } | 155 | } |
156 | up (& port->port_write_sem); | 156 | mutex_unlock(& port->port_write_mutex); |
157 | 157 | ||
158 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", | 158 | gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", |
159 | (port->flags & GS_TX_INTEN)?"enabled": "disabled"); | 159 | (port->flags & GS_TX_INTEN)?"enabled": "disabled"); |
@@ -214,7 +214,7 @@ int gs_write(struct tty_struct * tty, | |||
214 | c = count; | 214 | c = count; |
215 | 215 | ||
216 | /* This is safe because we "OWN" the "head". Noone else can | 216 | /* This is safe because we "OWN" the "head". Noone else can |
217 | change the "head": we own the port_write_sem. */ | 217 | change the "head": we own the port_write_mutex. */ |
218 | /* Don't overrun the end of the buffer */ | 218 | /* Don't overrun the end of the buffer */ |
219 | t = SERIAL_XMIT_SIZE - port->xmit_head; | 219 | t = SERIAL_XMIT_SIZE - port->xmit_head; |
220 | if (t < c) c = t; | 220 | if (t < c) c = t; |
@@ -888,7 +888,7 @@ int gs_init_port(struct gs_port *port) | |||
888 | spin_lock_irqsave (&port->driver_lock, flags); | 888 | spin_lock_irqsave (&port->driver_lock, flags); |
889 | if (port->tty) | 889 | if (port->tty) |
890 | clear_bit(TTY_IO_ERROR, &port->tty->flags); | 890 | clear_bit(TTY_IO_ERROR, &port->tty->flags); |
891 | init_MUTEX(&port->port_write_sem); | 891 | mutex_init(&port->port_write_mutex); |
892 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; | 892 | port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; |
893 | spin_unlock_irqrestore(&port->driver_lock, flags); | 893 | spin_unlock_irqrestore(&port->driver_lock, flags); |
894 | gs_set_termios(port->tty, NULL); | 894 | gs_set_termios(port->tty, NULL); |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 28c5a3193b81..ede128356af2 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -181,7 +181,6 @@ static struct tty_driver *stli_serial; | |||
181 | * is already swapping a shared buffer won't make things any worse. | 181 | * is already swapping a shared buffer won't make things any worse. |
182 | */ | 182 | */ |
183 | static char *stli_tmpwritebuf; | 183 | static char *stli_tmpwritebuf; |
184 | static DECLARE_MUTEX(stli_tmpwritesem); | ||
185 | 184 | ||
186 | #define STLI_TXBUFSIZE 4096 | 185 | #define STLI_TXBUFSIZE 4096 |
187 | 186 | ||
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index ccad7ae94541..ede365d05387 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty) | |||
132 | * We test the TTY_THROTTLED bit first so that it always | 132 | * We test the TTY_THROTTLED bit first so that it always |
133 | * indicates the current state. The decision about whether | 133 | * indicates the current state. The decision about whether |
134 | * it is worth allowing more input has been taken by the caller. | 134 | * it is worth allowing more input has been taken by the caller. |
135 | * Can sleep, may be called under the atomic_read semaphore but | 135 | * Can sleep, may be called under the atomic_read_lock mutex but |
136 | * this is not guaranteed. | 136 | * this is not guaranteed. |
137 | */ | 137 | */ |
138 | 138 | ||
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) | |||
1132 | * buffer, and once to drain the space from the (physical) beginning of | 1132 | * buffer, and once to drain the space from the (physical) beginning of |
1133 | * the buffer to head pointer. | 1133 | * the buffer to head pointer. |
1134 | * | 1134 | * |
1135 | * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set | 1135 | * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set |
1136 | * | 1136 | * |
1137 | */ | 1137 | */ |
1138 | 1138 | ||
@@ -1262,11 +1262,11 @@ do_it_again: | |||
1262 | * Internal serialization of reads. | 1262 | * Internal serialization of reads. |
1263 | */ | 1263 | */ |
1264 | if (file->f_flags & O_NONBLOCK) { | 1264 | if (file->f_flags & O_NONBLOCK) { |
1265 | if (down_trylock(&tty->atomic_read)) | 1265 | if (!mutex_trylock(&tty->atomic_read_lock)) |
1266 | return -EAGAIN; | 1266 | return -EAGAIN; |
1267 | } | 1267 | } |
1268 | else { | 1268 | else { |
1269 | if (down_interruptible(&tty->atomic_read)) | 1269 | if (mutex_lock_interruptible(&tty->atomic_read_lock)) |
1270 | return -ERESTARTSYS; | 1270 | return -ERESTARTSYS; |
1271 | } | 1271 | } |
1272 | 1272 | ||
@@ -1393,7 +1393,7 @@ do_it_again: | |||
1393 | timeout = time; | 1393 | timeout = time; |
1394 | } | 1394 | } |
1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); | 1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); |
1396 | up(&tty->atomic_read); | 1396 | mutex_unlock(&tty->atomic_read_lock); |
1397 | remove_wait_queue(&tty->read_wait, &wait); | 1397 | remove_wait_queue(&tty->read_wait, &wait); |
1398 | 1398 | ||
1399 | if (!waitqueue_active(&tty->read_wait)) | 1399 | if (!waitqueue_active(&tty->read_wait)) |
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index ca41d62b1d9d..8865387d3448 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/rwsem.h> | 27 | #include <linux/rwsem.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/smp_lock.h> | 29 | #include <linux/smp_lock.h> |
30 | #include <linux/mutex.h> | ||
30 | 31 | ||
31 | #include <asm/hardware/dec21285.h> | 32 | #include <asm/hardware/dec21285.h> |
32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
@@ -56,7 +57,7 @@ static int gbWriteEnable; | |||
56 | static int gbWriteBase64Enable; | 57 | static int gbWriteBase64Enable; |
57 | static volatile unsigned char *FLASH_BASE; | 58 | static volatile unsigned char *FLASH_BASE; |
58 | static int gbFlashSize = KFLASH_SIZE; | 59 | static int gbFlashSize = KFLASH_SIZE; |
59 | static DECLARE_MUTEX(nwflash_sem); | 60 | static DEFINE_MUTEX(nwflash_mutex); |
60 | 61 | ||
61 | extern spinlock_t gpio_lock; | 62 | extern spinlock_t gpio_lock; |
62 | 63 | ||
@@ -140,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | |||
140 | /* | 141 | /* |
141 | * We now lock against reads and writes. --rmk | 142 | * We now lock against reads and writes. --rmk |
142 | */ | 143 | */ |
143 | if (down_interruptible(&nwflash_sem)) | 144 | if (mutex_lock_interruptible(&nwflash_mutex)) |
144 | return -ERESTARTSYS; | 145 | return -ERESTARTSYS; |
145 | 146 | ||
146 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); | 147 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); |
@@ -149,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | |||
149 | *ppos += count; | 150 | *ppos += count; |
150 | } else | 151 | } else |
151 | ret = -EFAULT; | 152 | ret = -EFAULT; |
152 | up(&nwflash_sem); | 153 | mutex_unlock(&nwflash_mutex); |
153 | } | 154 | } |
154 | return ret; | 155 | return ret; |
155 | } | 156 | } |
@@ -188,7 +189,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
188 | /* | 189 | /* |
189 | * We now lock against reads and writes. --rmk | 190 | * We now lock against reads and writes. --rmk |
190 | */ | 191 | */ |
191 | if (down_interruptible(&nwflash_sem)) | 192 | if (mutex_lock_interruptible(&nwflash_mutex)) |
192 | return -ERESTARTSYS; | 193 | return -ERESTARTSYS; |
193 | 194 | ||
194 | written = 0; | 195 | written = 0; |
@@ -277,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
277 | */ | 278 | */ |
278 | leds_event(led_release); | 279 | leds_event(led_release); |
279 | 280 | ||
280 | up(&nwflash_sem); | 281 | mutex_unlock(&nwflash_mutex); |
281 | 282 | ||
282 | return written; | 283 | return written; |
283 | } | 284 | } |
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 30e4cbe16bb0..15a7b4086524 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/uio.h> | 19 | #include <linux/uio.h> |
20 | #include <linux/cdev.h> | 20 | #include <linux/cdev.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/mutex.h> | ||
22 | 23 | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
@@ -29,7 +30,7 @@ struct raw_device_data { | |||
29 | 30 | ||
30 | static struct class *raw_class; | 31 | static struct class *raw_class; |
31 | static struct raw_device_data raw_devices[MAX_RAW_MINORS]; | 32 | static struct raw_device_data raw_devices[MAX_RAW_MINORS]; |
32 | static DECLARE_MUTEX(raw_mutex); | 33 | static DEFINE_MUTEX(raw_mutex); |
33 | static struct file_operations raw_ctl_fops; /* forward declaration */ | 34 | static struct file_operations raw_ctl_fops; /* forward declaration */ |
34 | 35 | ||
35 | /* | 36 | /* |
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
53 | return 0; | 54 | return 0; |
54 | } | 55 | } |
55 | 56 | ||
56 | down(&raw_mutex); | 57 | mutex_lock(&raw_mutex); |
57 | 58 | ||
58 | /* | 59 | /* |
59 | * All we need to do on open is check that the device is bound. | 60 | * All we need to do on open is check that the device is bound. |
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
78 | filp->f_dentry->d_inode->i_mapping = | 79 | filp->f_dentry->d_inode->i_mapping = |
79 | bdev->bd_inode->i_mapping; | 80 | bdev->bd_inode->i_mapping; |
80 | filp->private_data = bdev; | 81 | filp->private_data = bdev; |
81 | up(&raw_mutex); | 82 | mutex_unlock(&raw_mutex); |
82 | return 0; | 83 | return 0; |
83 | 84 | ||
84 | out2: | 85 | out2: |
@@ -86,7 +87,7 @@ out2: | |||
86 | out1: | 87 | out1: |
87 | blkdev_put(bdev); | 88 | blkdev_put(bdev); |
88 | out: | 89 | out: |
89 | up(&raw_mutex); | 90 | mutex_unlock(&raw_mutex); |
90 | return err; | 91 | return err; |
91 | } | 92 | } |
92 | 93 | ||
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp) | |||
99 | const int minor= iminor(inode); | 100 | const int minor= iminor(inode); |
100 | struct block_device *bdev; | 101 | struct block_device *bdev; |
101 | 102 | ||
102 | down(&raw_mutex); | 103 | mutex_lock(&raw_mutex); |
103 | bdev = raw_devices[minor].binding; | 104 | bdev = raw_devices[minor].binding; |
104 | if (--raw_devices[minor].inuse == 0) { | 105 | if (--raw_devices[minor].inuse == 0) { |
105 | /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ | 106 | /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ |
106 | inode->i_mapping = &inode->i_data; | 107 | inode->i_mapping = &inode->i_data; |
107 | inode->i_mapping->backing_dev_info = &default_backing_dev_info; | 108 | inode->i_mapping->backing_dev_info = &default_backing_dev_info; |
108 | } | 109 | } |
109 | up(&raw_mutex); | 110 | mutex_unlock(&raw_mutex); |
110 | 111 | ||
111 | bd_release(bdev); | 112 | bd_release(bdev); |
112 | blkdev_put(bdev); | 113 | blkdev_put(bdev); |
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
187 | goto out; | 188 | goto out; |
188 | } | 189 | } |
189 | 190 | ||
190 | down(&raw_mutex); | 191 | mutex_lock(&raw_mutex); |
191 | if (rawdev->inuse) { | 192 | if (rawdev->inuse) { |
192 | up(&raw_mutex); | 193 | mutex_unlock(&raw_mutex); |
193 | err = -EBUSY; | 194 | err = -EBUSY; |
194 | goto out; | 195 | goto out; |
195 | } | 196 | } |
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
211 | bind_device(&rq); | 212 | bind_device(&rq); |
212 | } | 213 | } |
213 | } | 214 | } |
214 | up(&raw_mutex); | 215 | mutex_unlock(&raw_mutex); |
215 | } else { | 216 | } else { |
216 | struct block_device *bdev; | 217 | struct block_device *bdev; |
217 | 218 | ||
218 | down(&raw_mutex); | 219 | mutex_lock(&raw_mutex); |
219 | bdev = rawdev->binding; | 220 | bdev = rawdev->binding; |
220 | if (bdev) { | 221 | if (bdev) { |
221 | rq.block_major = MAJOR(bdev->bd_dev); | 222 | rq.block_major = MAJOR(bdev->bd_dev); |
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp, | |||
223 | } else { | 224 | } else { |
224 | rq.block_major = rq.block_minor = 0; | 225 | rq.block_major = rq.block_minor = 0; |
225 | } | 226 | } |
226 | up(&raw_mutex); | 227 | mutex_unlock(&raw_mutex); |
227 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { | 228 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { |
228 | err = -EFAULT; | 229 | err = -EFAULT; |
229 | goto out; | 230 | goto out; |
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index fee68cc895f8..510bd3e0e88b 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c | |||
@@ -97,7 +97,7 @@ | |||
97 | #include <asm/amigahw.h> | 97 | #include <asm/amigahw.h> |
98 | #include <linux/zorro.h> | 98 | #include <linux/zorro.h> |
99 | #include <asm/irq.h> | 99 | #include <asm/irq.h> |
100 | #include <asm/semaphore.h> | 100 | #include <linux/mutex.h> |
101 | 101 | ||
102 | #include <linux/delay.h> | 102 | #include <linux/delay.h> |
103 | 103 | ||
@@ -654,7 +654,7 @@ static void a2232_init_portstructs(void) | |||
654 | port->gs.closing_wait = 30 * HZ; | 654 | port->gs.closing_wait = 30 * HZ; |
655 | port->gs.rd = &a2232_real_driver; | 655 | port->gs.rd = &a2232_real_driver; |
656 | #ifdef NEW_WRITE_LOCKING | 656 | #ifdef NEW_WRITE_LOCKING |
657 | init_MUTEX(&(port->gs.port_write_sem)); | 657 | init_MUTEX(&(port->gs.port_write_mutex)); |
658 | #endif | 658 | #endif |
659 | init_waitqueue_head(&port->gs.open_wait); | 659 | init_waitqueue_head(&port->gs.open_wait); |
660 | init_waitqueue_head(&port->gs.close_wait); | 660 | init_waitqueue_head(&port->gs.close_wait); |
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 0e7d216e7eb0..b543821d8cb4 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * License. See the file "COPYING" in the main directory of this archive | 5 | * License. See the file "COPYING" in the main directory of this archive |
6 | * for more details. | 6 | * for more details. |
7 | * | 7 | * |
8 | * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved. | 8 | * Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | /* | 11 | /* |
@@ -77,7 +77,7 @@ scdrv_open(struct inode *inode, struct file *file) | |||
77 | scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); | 77 | scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); |
78 | 78 | ||
79 | /* allocate memory for subchannel data */ | 79 | /* allocate memory for subchannel data */ |
80 | sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); | 80 | sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); |
81 | if (sd == NULL) { | 81 | if (sd == NULL) { |
82 | printk("%s: couldn't allocate subchannel data\n", | 82 | printk("%s: couldn't allocate subchannel data\n", |
83 | __FUNCTION__); | 83 | __FUNCTION__); |
@@ -85,7 +85,6 @@ scdrv_open(struct inode *inode, struct file *file) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /* initialize subch_data_s fields */ | 87 | /* initialize subch_data_s fields */ |
88 | memset(sd, 0, sizeof (struct subch_data_s)); | ||
89 | sd->sd_nasid = scd->scd_nasid; | 88 | sd->sd_nasid = scd->scd_nasid; |
90 | sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); | 89 | sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); |
91 | 90 | ||
@@ -394,7 +393,7 @@ scdrv_init(void) | |||
394 | sprintf(devnamep, "#%d", geo_slab(geoid)); | 393 | sprintf(devnamep, "#%d", geo_slab(geoid)); |
395 | 394 | ||
396 | /* allocate sysctl device data */ | 395 | /* allocate sysctl device data */ |
397 | scd = kmalloc(sizeof (struct sysctl_data_s), | 396 | scd = kzalloc(sizeof (struct sysctl_data_s), |
398 | GFP_KERNEL); | 397 | GFP_KERNEL); |
399 | if (!scd) { | 398 | if (!scd) { |
400 | printk("%s: failed to allocate device info" | 399 | printk("%s: failed to allocate device info" |
@@ -402,7 +401,6 @@ scdrv_init(void) | |||
402 | SYSCTL_BASENAME, devname); | 401 | SYSCTL_BASENAME, devname); |
403 | continue; | 402 | continue; |
404 | } | 403 | } |
405 | memset(scd, 0, sizeof (struct sysctl_data_s)); | ||
406 | 404 | ||
407 | /* initialize sysctl device data fields */ | 405 | /* initialize sysctl device data fields */ |
408 | scd->scd_nasid = cnodeid_to_nasid(cnode); | 406 | scd->scd_nasid = cnodeid_to_nasid(cnode); |
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c index a4fa507eed9e..e234d50e142a 100644 --- a/drivers/char/snsc_event.c +++ b/drivers/char/snsc_event.c | |||
@@ -287,7 +287,7 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
287 | { | 287 | { |
288 | int rv; | 288 | int rv; |
289 | 289 | ||
290 | event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); | 290 | event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); |
291 | if (event_sd == NULL) { | 291 | if (event_sd == NULL) { |
292 | printk(KERN_WARNING "%s: couldn't allocate subchannel info" | 292 | printk(KERN_WARNING "%s: couldn't allocate subchannel info" |
293 | " for event monitoring\n", __FUNCTION__); | 293 | " for event monitoring\n", __FUNCTION__); |
@@ -295,7 +295,6 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | /* initialize subch_data_s fields */ | 297 | /* initialize subch_data_s fields */ |
298 | memset(event_sd, 0, sizeof (struct subch_data_s)); | ||
299 | event_sd->sd_nasid = scd->scd_nasid; | 298 | event_sd->sd_nasid = scd->scd_nasid; |
300 | spin_lock_init(&event_sd->sd_rlock); | 299 | spin_lock_init(&event_sd->sd_rlock); |
301 | 300 | ||
@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd) | |||
321 | return; | 320 | return; |
322 | } | 321 | } |
323 | } | 322 | } |
324 | |||
325 | |||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index bdaab6992109..3f5d6077f39c 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -148,7 +148,6 @@ static struct tty_driver *stl_serial; | |||
148 | * is already swapping a shared buffer won't make things any worse. | 148 | * is already swapping a shared buffer won't make things any worse. |
149 | */ | 149 | */ |
150 | static char *stl_tmpwritebuf; | 150 | static char *stl_tmpwritebuf; |
151 | static DECLARE_MUTEX(stl_tmpwritesem); | ||
152 | 151 | ||
153 | /* | 152 | /* |
154 | * Define a local default termios struct. All ports will be created | 153 | * Define a local default termios struct. All ports will be created |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index a6b4f02bdceb..3b4747230270 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -2318,7 +2318,7 @@ static int sx_init_portstructs (int nboards, int nports) | |||
2318 | port->board = board; | 2318 | port->board = board; |
2319 | port->gs.rd = &sx_real_driver; | 2319 | port->gs.rd = &sx_real_driver; |
2320 | #ifdef NEW_WRITE_LOCKING | 2320 | #ifdef NEW_WRITE_LOCKING |
2321 | port->gs.port_write_sem = MUTEX; | 2321 | port->gs.port_write_mutex = MUTEX; |
2322 | #endif | 2322 | #endif |
2323 | port->gs.driver_lock = SPIN_LOCK_UNLOCKED; | 2323 | port->gs.driver_lock = SPIN_LOCK_UNLOCKED; |
2324 | /* | 2324 | /* |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 53d3d066554e..76592ee1fb38 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */ | |||
130 | 130 | ||
131 | /* Semaphore to protect creating and releasing a tty. This is shared with | 131 | /* Semaphore to protect creating and releasing a tty. This is shared with |
132 | vt.c for deeply disgusting hack reasons */ | 132 | vt.c for deeply disgusting hack reasons */ |
133 | DECLARE_MUTEX(tty_sem); | 133 | DEFINE_MUTEX(tty_mutex); |
134 | 134 | ||
135 | #ifdef CONFIG_UNIX98_PTYS | 135 | #ifdef CONFIG_UNIX98_PTYS |
136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ | 136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ |
@@ -1188,11 +1188,11 @@ void disassociate_ctty(int on_exit) | |||
1188 | 1188 | ||
1189 | lock_kernel(); | 1189 | lock_kernel(); |
1190 | 1190 | ||
1191 | down(&tty_sem); | 1191 | mutex_lock(&tty_mutex); |
1192 | tty = current->signal->tty; | 1192 | tty = current->signal->tty; |
1193 | if (tty) { | 1193 | if (tty) { |
1194 | tty_pgrp = tty->pgrp; | 1194 | tty_pgrp = tty->pgrp; |
1195 | up(&tty_sem); | 1195 | mutex_unlock(&tty_mutex); |
1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) | 1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) |
1197 | tty_vhangup(tty); | 1197 | tty_vhangup(tty); |
1198 | } else { | 1198 | } else { |
@@ -1200,7 +1200,7 @@ void disassociate_ctty(int on_exit) | |||
1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); | 1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); |
1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); | 1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); |
1202 | } | 1202 | } |
1203 | up(&tty_sem); | 1203 | mutex_unlock(&tty_mutex); |
1204 | unlock_kernel(); | 1204 | unlock_kernel(); |
1205 | return; | 1205 | return; |
1206 | } | 1206 | } |
@@ -1211,7 +1211,7 @@ void disassociate_ctty(int on_exit) | |||
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | /* Must lock changes to tty_old_pgrp */ | 1213 | /* Must lock changes to tty_old_pgrp */ |
1214 | down(&tty_sem); | 1214 | mutex_lock(&tty_mutex); |
1215 | current->signal->tty_old_pgrp = 0; | 1215 | current->signal->tty_old_pgrp = 0; |
1216 | tty->session = 0; | 1216 | tty->session = 0; |
1217 | tty->pgrp = -1; | 1217 | tty->pgrp = -1; |
@@ -1222,7 +1222,7 @@ void disassociate_ctty(int on_exit) | |||
1222 | p->signal->tty = NULL; | 1222 | p->signal->tty = NULL; |
1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); | 1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); |
1224 | read_unlock(&tasklist_lock); | 1224 | read_unlock(&tasklist_lock); |
1225 | up(&tty_sem); | 1225 | mutex_unlock(&tty_mutex); |
1226 | unlock_kernel(); | 1226 | unlock_kernel(); |
1227 | } | 1227 | } |
1228 | 1228 | ||
@@ -1306,7 +1306,7 @@ static inline ssize_t do_tty_write( | |||
1306 | ssize_t ret = 0, written = 0; | 1306 | ssize_t ret = 0, written = 0; |
1307 | unsigned int chunk; | 1307 | unsigned int chunk; |
1308 | 1308 | ||
1309 | if (down_interruptible(&tty->atomic_write)) { | 1309 | if (mutex_lock_interruptible(&tty->atomic_write_lock)) { |
1310 | return -ERESTARTSYS; | 1310 | return -ERESTARTSYS; |
1311 | } | 1311 | } |
1312 | 1312 | ||
@@ -1329,7 +1329,7 @@ static inline ssize_t do_tty_write( | |||
1329 | if (count < chunk) | 1329 | if (count < chunk) |
1330 | chunk = count; | 1330 | chunk = count; |
1331 | 1331 | ||
1332 | /* write_buf/write_cnt is protected by the atomic_write semaphore */ | 1332 | /* write_buf/write_cnt is protected by the atomic_write_lock mutex */ |
1333 | if (tty->write_cnt < chunk) { | 1333 | if (tty->write_cnt < chunk) { |
1334 | unsigned char *buf; | 1334 | unsigned char *buf; |
1335 | 1335 | ||
@@ -1338,7 +1338,7 @@ static inline ssize_t do_tty_write( | |||
1338 | 1338 | ||
1339 | buf = kmalloc(chunk, GFP_KERNEL); | 1339 | buf = kmalloc(chunk, GFP_KERNEL); |
1340 | if (!buf) { | 1340 | if (!buf) { |
1341 | up(&tty->atomic_write); | 1341 | mutex_unlock(&tty->atomic_write_lock); |
1342 | return -ENOMEM; | 1342 | return -ENOMEM; |
1343 | } | 1343 | } |
1344 | kfree(tty->write_buf); | 1344 | kfree(tty->write_buf); |
@@ -1374,7 +1374,7 @@ static inline ssize_t do_tty_write( | |||
1374 | inode->i_mtime = current_fs_time(inode->i_sb); | 1374 | inode->i_mtime = current_fs_time(inode->i_sb); |
1375 | ret = written; | 1375 | ret = written; |
1376 | } | 1376 | } |
1377 | up(&tty->atomic_write); | 1377 | mutex_unlock(&tty->atomic_write_lock); |
1378 | return ret; | 1378 | return ret; |
1379 | } | 1379 | } |
1380 | 1380 | ||
@@ -1442,8 +1442,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p) | |||
1442 | 1442 | ||
1443 | /* | 1443 | /* |
1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a | 1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a |
1445 | * failed open. The new code protects the open with a semaphore, so it's | 1445 | * failed open. The new code protects the open with a mutex, so it's |
1446 | * really quite straightforward. The semaphore locking can probably be | 1446 | * really quite straightforward. The mutex locking can probably be |
1447 | * relaxed for the (most common) case of reopening a tty. | 1447 | * relaxed for the (most common) case of reopening a tty. |
1448 | */ | 1448 | */ |
1449 | static int init_dev(struct tty_driver *driver, int idx, | 1449 | static int init_dev(struct tty_driver *driver, int idx, |
@@ -1640,7 +1640,7 @@ fast_track: | |||
1640 | success: | 1640 | success: |
1641 | *ret_tty = tty; | 1641 | *ret_tty = tty; |
1642 | 1642 | ||
1643 | /* All paths come through here to release the semaphore */ | 1643 | /* All paths come through here to release the mutex */ |
1644 | end_init: | 1644 | end_init: |
1645 | return retval; | 1645 | return retval; |
1646 | 1646 | ||
@@ -1837,7 +1837,7 @@ static void release_dev(struct file * filp) | |||
1837 | /* Guard against races with tty->count changes elsewhere and | 1837 | /* Guard against races with tty->count changes elsewhere and |
1838 | opens on /dev/tty */ | 1838 | opens on /dev/tty */ |
1839 | 1839 | ||
1840 | down(&tty_sem); | 1840 | mutex_lock(&tty_mutex); |
1841 | tty_closing = tty->count <= 1; | 1841 | tty_closing = tty->count <= 1; |
1842 | o_tty_closing = o_tty && | 1842 | o_tty_closing = o_tty && |
1843 | (o_tty->count <= (pty_master ? 1 : 0)); | 1843 | (o_tty->count <= (pty_master ? 1 : 0)); |
@@ -1868,7 +1868,7 @@ static void release_dev(struct file * filp) | |||
1868 | 1868 | ||
1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " | 1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " |
1870 | "active!\n", tty_name(tty, buf)); | 1870 | "active!\n", tty_name(tty, buf)); |
1871 | up(&tty_sem); | 1871 | mutex_unlock(&tty_mutex); |
1872 | schedule(); | 1872 | schedule(); |
1873 | } | 1873 | } |
1874 | 1874 | ||
@@ -1934,7 +1934,7 @@ static void release_dev(struct file * filp) | |||
1934 | read_unlock(&tasklist_lock); | 1934 | read_unlock(&tasklist_lock); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | up(&tty_sem); | 1937 | mutex_unlock(&tty_mutex); |
1938 | 1938 | ||
1939 | /* check whether both sides are closing ... */ | 1939 | /* check whether both sides are closing ... */ |
1940 | if (!tty_closing || (o_tty && !o_tty_closing)) | 1940 | if (!tty_closing || (o_tty && !o_tty_closing)) |
@@ -2040,11 +2040,11 @@ retry_open: | |||
2040 | index = -1; | 2040 | index = -1; |
2041 | retval = 0; | 2041 | retval = 0; |
2042 | 2042 | ||
2043 | down(&tty_sem); | 2043 | mutex_lock(&tty_mutex); |
2044 | 2044 | ||
2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { | 2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { |
2046 | if (!current->signal->tty) { | 2046 | if (!current->signal->tty) { |
2047 | up(&tty_sem); | 2047 | mutex_unlock(&tty_mutex); |
2048 | return -ENXIO; | 2048 | return -ENXIO; |
2049 | } | 2049 | } |
2050 | driver = current->signal->tty->driver; | 2050 | driver = current->signal->tty->driver; |
@@ -2070,18 +2070,18 @@ retry_open: | |||
2070 | noctty = 1; | 2070 | noctty = 1; |
2071 | goto got_driver; | 2071 | goto got_driver; |
2072 | } | 2072 | } |
2073 | up(&tty_sem); | 2073 | mutex_unlock(&tty_mutex); |
2074 | return -ENODEV; | 2074 | return -ENODEV; |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | driver = get_tty_driver(device, &index); | 2077 | driver = get_tty_driver(device, &index); |
2078 | if (!driver) { | 2078 | if (!driver) { |
2079 | up(&tty_sem); | 2079 | mutex_unlock(&tty_mutex); |
2080 | return -ENODEV; | 2080 | return -ENODEV; |
2081 | } | 2081 | } |
2082 | got_driver: | 2082 | got_driver: |
2083 | retval = init_dev(driver, index, &tty); | 2083 | retval = init_dev(driver, index, &tty); |
2084 | up(&tty_sem); | 2084 | mutex_unlock(&tty_mutex); |
2085 | if (retval) | 2085 | if (retval) |
2086 | return retval; | 2086 | return retval; |
2087 | 2087 | ||
@@ -2167,9 +2167,9 @@ static int ptmx_open(struct inode * inode, struct file * filp) | |||
2167 | } | 2167 | } |
2168 | up(&allocated_ptys_lock); | 2168 | up(&allocated_ptys_lock); |
2169 | 2169 | ||
2170 | down(&tty_sem); | 2170 | mutex_lock(&tty_mutex); |
2171 | retval = init_dev(ptm_driver, index, &tty); | 2171 | retval = init_dev(ptm_driver, index, &tty); |
2172 | up(&tty_sem); | 2172 | mutex_unlock(&tty_mutex); |
2173 | 2173 | ||
2174 | if (retval) | 2174 | if (retval) |
2175 | goto out; | 2175 | goto out; |
@@ -2915,8 +2915,8 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
2915 | init_waitqueue_head(&tty->write_wait); | 2915 | init_waitqueue_head(&tty->write_wait); |
2916 | init_waitqueue_head(&tty->read_wait); | 2916 | init_waitqueue_head(&tty->read_wait); |
2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); | 2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); |
2918 | sema_init(&tty->atomic_read, 1); | 2918 | mutex_init(&tty->atomic_read_lock); |
2919 | sema_init(&tty->atomic_write, 1); | 2919 | mutex_init(&tty->atomic_write_lock); |
2920 | spin_lock_init(&tty->read_lock); | 2920 | spin_lock_init(&tty->read_lock); |
2921 | INIT_LIST_HEAD(&tty->tty_files); | 2921 | INIT_LIST_HEAD(&tty->tty_files); |
2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); | 2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); |
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index d9325281e482..fd00822ac145 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c | |||
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void) | |||
184 | port->gs.closing_wait = 30 * HZ; | 184 | port->gs.closing_wait = 30 * HZ; |
185 | port->gs.rd = &scc_real_driver; | 185 | port->gs.rd = &scc_real_driver; |
186 | #ifdef NEW_WRITE_LOCKING | 186 | #ifdef NEW_WRITE_LOCKING |
187 | port->gs.port_write_sem = MUTEX; | 187 | port->gs.port_write_mutex = MUTEX; |
188 | #endif | 188 | #endif |
189 | init_waitqueue_head(&port->gs.open_wait); | 189 | init_waitqueue_head(&port->gs.open_wait); |
190 | init_waitqueue_head(&port->gs.close_wait); | 190 | init_waitqueue_head(&port->gs.close_wait); |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 0900d1dbee59..ca4844c527da 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | /* | 2491 | /* |
2492 | * We take tty_sem in here to prevent another thread from coming in via init_dev | 2492 | * We take tty_mutex in here to prevent another thread from coming in via init_dev |
2493 | * and taking a ref against the tty while we're in the process of forgetting | 2493 | * and taking a ref against the tty while we're in the process of forgetting |
2494 | * about it and cleaning things up. | 2494 | * about it and cleaning things up. |
2495 | * | 2495 | * |
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2497 | */ | 2497 | */ |
2498 | static void con_close(struct tty_struct *tty, struct file *filp) | 2498 | static void con_close(struct tty_struct *tty, struct file *filp) |
2499 | { | 2499 | { |
2500 | down(&tty_sem); | 2500 | mutex_lock(&tty_mutex); |
2501 | acquire_console_sem(); | 2501 | acquire_console_sem(); |
2502 | if (tty && tty->count == 1) { | 2502 | if (tty && tty->count == 1) { |
2503 | struct vc_data *vc = tty->driver_data; | 2503 | struct vc_data *vc = tty->driver_data; |
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp) | |||
2507 | tty->driver_data = NULL; | 2507 | tty->driver_data = NULL; |
2508 | release_console_sem(); | 2508 | release_console_sem(); |
2509 | vcs_remove_devfs(tty); | 2509 | vcs_remove_devfs(tty); |
2510 | up(&tty_sem); | 2510 | mutex_unlock(&tty_mutex); |
2511 | /* | 2511 | /* |
2512 | * tty_sem is released, but we still hold BKL, so there is | 2512 | * tty_mutex is released, but we still hold BKL, so there is |
2513 | * still exclusion against init_dev() | 2513 | * still exclusion against init_dev() |
2514 | */ | 2514 | */ |
2515 | return; | 2515 | return; |
2516 | } | 2516 | } |
2517 | release_console_sem(); | 2517 | release_console_sem(); |
2518 | up(&tty_sem); | 2518 | mutex_unlock(&tty_mutex); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | static void vc_init(struct vc_data *vc, unsigned int rows, | 2521 | static void vc_init(struct vc_data *vc, unsigned int rows, |
@@ -2869,9 +2869,9 @@ void unblank_screen(void) | |||
2869 | } | 2869 | } |
2870 | 2870 | ||
2871 | /* | 2871 | /* |
2872 | * We defer the timer blanking to work queue so it can take the console semaphore | 2872 | * We defer the timer blanking to work queue so it can take the console mutex |
2873 | * (console operations can still happen at irq time, but only from printk which | 2873 | * (console operations can still happen at irq time, but only from printk which |
2874 | * has the console semaphore. Not perfect yet, but better than no locking | 2874 | * has the console mutex. Not perfect yet, but better than no locking |
2875 | */ | 2875 | */ |
2876 | static void blank_screen_t(unsigned long dummy) | 2876 | static void blank_screen_t(unsigned long dummy) |
2877 | { | 2877 | { |
@@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) | |||
3234 | } | 3234 | } |
3235 | } | 3235 | } |
3236 | 3236 | ||
3237 | int is_console_suspend_safe(void) | ||
3238 | { | ||
3239 | /* It is unsafe to suspend devices while X has control of the | ||
3240 | * hardware. Make sure we are running on a kernel-controlled console. | ||
3241 | */ | ||
3242 | return vc_cons[fg_console].d->vc_mode == KD_TEXT; | ||
3243 | } | ||
3244 | |||
3237 | /* | 3245 | /* |
3238 | * Visible symbols for modules | 3246 | * Visible symbols for modules |
3239 | */ | 3247 | */ |
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 1533f56baa42..2700c5c45b8a 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/completion.h> | 42 | #include <linux/completion.h> |
43 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
44 | #include <linux/usb.h> | 44 | #include <linux/usb.h> |
45 | #include <linux/mutex.h> | ||
45 | 46 | ||
46 | 47 | ||
47 | #ifdef CONFIG_USB_DEBUG | 48 | #ifdef CONFIG_USB_DEBUG |
@@ -143,7 +144,7 @@ struct usb_pcwd_private { | |||
143 | static struct usb_pcwd_private *usb_pcwd_device; | 144 | static struct usb_pcwd_private *usb_pcwd_device; |
144 | 145 | ||
145 | /* prevent races between open() and disconnect() */ | 146 | /* prevent races between open() and disconnect() */ |
146 | static DECLARE_MUTEX (disconnect_sem); | 147 | static DEFINE_MUTEX(disconnect_mutex); |
147 | 148 | ||
148 | /* local function prototypes */ | 149 | /* local function prototypes */ |
149 | static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); | 150 | static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); |
@@ -723,7 +724,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
723 | struct usb_pcwd_private *usb_pcwd; | 724 | struct usb_pcwd_private *usb_pcwd; |
724 | 725 | ||
725 | /* prevent races with open() */ | 726 | /* prevent races with open() */ |
726 | down (&disconnect_sem); | 727 | mutex_lock(&disconnect_mutex); |
727 | 728 | ||
728 | usb_pcwd = usb_get_intfdata (interface); | 729 | usb_pcwd = usb_get_intfdata (interface); |
729 | usb_set_intfdata (interface, NULL); | 730 | usb_set_intfdata (interface, NULL); |
@@ -749,7 +750,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) | |||
749 | 750 | ||
750 | cards_found--; | 751 | cards_found--; |
751 | 752 | ||
752 | up (&disconnect_sem); | 753 | mutex_unlock(&disconnect_mutex); |
753 | 754 | ||
754 | printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); | 755 | printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); |
755 | } | 756 | } |
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index d7125f4d9113..35897079a78d 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/netlink.h> | 26 | #include <linux/netlink.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/connector.h> | 28 | #include <linux/connector.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #include <net/sock.h> | 31 | #include <net/sock.h> |
31 | 32 | ||
@@ -41,7 +42,7 @@ module_param(cn_val, uint, 0); | |||
41 | MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); | 42 | MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); |
42 | MODULE_PARM_DESC(cn_val, "Connector's main device val."); | 43 | MODULE_PARM_DESC(cn_val, "Connector's main device val."); |
43 | 44 | ||
44 | static DECLARE_MUTEX(notify_lock); | 45 | static DEFINE_MUTEX(notify_lock); |
45 | static LIST_HEAD(notify_list); | 46 | static LIST_HEAD(notify_list); |
46 | 47 | ||
47 | static struct cn_dev cdev; | 48 | static struct cn_dev cdev; |
@@ -260,7 +261,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event) | |||
260 | { | 261 | { |
261 | struct cn_ctl_entry *ent; | 262 | struct cn_ctl_entry *ent; |
262 | 263 | ||
263 | down(¬ify_lock); | 264 | mutex_lock(¬ify_lock); |
264 | list_for_each_entry(ent, ¬ify_list, notify_entry) { | 265 | list_for_each_entry(ent, ¬ify_list, notify_entry) { |
265 | int i; | 266 | int i; |
266 | struct cn_notify_req *req; | 267 | struct cn_notify_req *req; |
@@ -293,7 +294,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event) | |||
293 | cn_netlink_send(&m, ctl->group, GFP_KERNEL); | 294 | cn_netlink_send(&m, ctl->group, GFP_KERNEL); |
294 | } | 295 | } |
295 | } | 296 | } |
296 | up(¬ify_lock); | 297 | mutex_unlock(¬ify_lock); |
297 | } | 298 | } |
298 | 299 | ||
299 | /* | 300 | /* |
@@ -407,14 +408,14 @@ static void cn_callback(void *data) | |||
407 | if (ctl->group == 0) { | 408 | if (ctl->group == 0) { |
408 | struct cn_ctl_entry *n; | 409 | struct cn_ctl_entry *n; |
409 | 410 | ||
410 | down(¬ify_lock); | 411 | mutex_lock(¬ify_lock); |
411 | list_for_each_entry_safe(ent, n, ¬ify_list, notify_entry) { | 412 | list_for_each_entry_safe(ent, n, ¬ify_list, notify_entry) { |
412 | if (cn_ctl_msg_equals(ent->msg, ctl)) { | 413 | if (cn_ctl_msg_equals(ent->msg, ctl)) { |
413 | list_del(&ent->notify_entry); | 414 | list_del(&ent->notify_entry); |
414 | kfree(ent); | 415 | kfree(ent); |
415 | } | 416 | } |
416 | } | 417 | } |
417 | up(¬ify_lock); | 418 | mutex_unlock(¬ify_lock); |
418 | 419 | ||
419 | return; | 420 | return; |
420 | } | 421 | } |
@@ -429,9 +430,9 @@ static void cn_callback(void *data) | |||
429 | 430 | ||
430 | memcpy(ent->msg, ctl, size - sizeof(*ent)); | 431 | memcpy(ent->msg, ctl, size - sizeof(*ent)); |
431 | 432 | ||
432 | down(¬ify_lock); | 433 | mutex_lock(¬ify_lock); |
433 | list_add(&ent->notify_entry, ¬ify_list); | 434 | list_add(&ent->notify_entry, ¬ify_list); |
434 | up(¬ify_lock); | 435 | mutex_unlock(¬ify_lock); |
435 | } | 436 | } |
436 | 437 | ||
437 | static int __init cn_init(void) | 438 | static int __init cn_init(void) |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 3a4e5c5b4e1f..d6543fc4a923 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <linux/types.h> | 35 | #include <linux/types.h> |
36 | #include <linux/mutex.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/semaphore.h> | 38 | #include <asm/semaphore.h> |
38 | 39 | ||
@@ -48,7 +49,7 @@ static u8 *smi_data_buf; | |||
48 | static dma_addr_t smi_data_buf_handle; | 49 | static dma_addr_t smi_data_buf_handle; |
49 | static unsigned long smi_data_buf_size; | 50 | static unsigned long smi_data_buf_size; |
50 | static u32 smi_data_buf_phys_addr; | 51 | static u32 smi_data_buf_phys_addr; |
51 | static DECLARE_MUTEX(smi_data_lock); | 52 | static DEFINE_MUTEX(smi_data_lock); |
52 | 53 | ||
53 | static unsigned int host_control_action; | 54 | static unsigned int host_control_action; |
54 | static unsigned int host_control_smi_type; | 55 | static unsigned int host_control_smi_type; |
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev, | |||
139 | buf_size = simple_strtoul(buf, NULL, 10); | 140 | buf_size = simple_strtoul(buf, NULL, 10); |
140 | 141 | ||
141 | /* make sure SMI data buffer is at least buf_size */ | 142 | /* make sure SMI data buffer is at least buf_size */ |
142 | down(&smi_data_lock); | 143 | mutex_lock(&smi_data_lock); |
143 | ret = smi_data_buf_realloc(buf_size); | 144 | ret = smi_data_buf_realloc(buf_size); |
144 | up(&smi_data_lock); | 145 | mutex_unlock(&smi_data_lock); |
145 | if (ret) | 146 | if (ret) |
146 | return ret; | 147 | return ret; |
147 | 148 | ||
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos, | |||
154 | size_t max_read; | 155 | size_t max_read; |
155 | ssize_t ret; | 156 | ssize_t ret; |
156 | 157 | ||
157 | down(&smi_data_lock); | 158 | mutex_lock(&smi_data_lock); |
158 | 159 | ||
159 | if (pos >= smi_data_buf_size) { | 160 | if (pos >= smi_data_buf_size) { |
160 | ret = 0; | 161 | ret = 0; |
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos, | |||
165 | ret = min(max_read, count); | 166 | ret = min(max_read, count); |
166 | memcpy(buf, smi_data_buf + pos, ret); | 167 | memcpy(buf, smi_data_buf + pos, ret); |
167 | out: | 168 | out: |
168 | up(&smi_data_lock); | 169 | mutex_unlock(&smi_data_lock); |
169 | return ret; | 170 | return ret; |
170 | } | 171 | } |
171 | 172 | ||
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos, | |||
174 | { | 175 | { |
175 | ssize_t ret; | 176 | ssize_t ret; |
176 | 177 | ||
177 | down(&smi_data_lock); | 178 | mutex_lock(&smi_data_lock); |
178 | 179 | ||
179 | ret = smi_data_buf_realloc(pos + count); | 180 | ret = smi_data_buf_realloc(pos + count); |
180 | if (ret) | 181 | if (ret) |
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos, | |||
183 | memcpy(smi_data_buf + pos, buf, count); | 184 | memcpy(smi_data_buf + pos, buf, count); |
184 | ret = count; | 185 | ret = count; |
185 | out: | 186 | out: |
186 | up(&smi_data_lock); | 187 | mutex_unlock(&smi_data_lock); |
187 | return ret; | 188 | return ret; |
188 | } | 189 | } |
189 | 190 | ||
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev, | |||
201 | ssize_t ret; | 202 | ssize_t ret; |
202 | 203 | ||
203 | /* make sure buffer is available for host control command */ | 204 | /* make sure buffer is available for host control command */ |
204 | down(&smi_data_lock); | 205 | mutex_lock(&smi_data_lock); |
205 | ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); | 206 | ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); |
206 | up(&smi_data_lock); | 207 | mutex_unlock(&smi_data_lock); |
207 | if (ret) | 208 | if (ret) |
208 | return ret; | 209 | return ret; |
209 | 210 | ||
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev, | |||
302 | unsigned long val = simple_strtoul(buf, NULL, 10); | 303 | unsigned long val = simple_strtoul(buf, NULL, 10); |
303 | ssize_t ret; | 304 | ssize_t ret; |
304 | 305 | ||
305 | down(&smi_data_lock); | 306 | mutex_lock(&smi_data_lock); |
306 | 307 | ||
307 | if (smi_data_buf_size < sizeof(struct smi_cmd)) { | 308 | if (smi_data_buf_size < sizeof(struct smi_cmd)) { |
308 | ret = -ENODEV; | 309 | ret = -ENODEV; |
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev, | |||
334 | } | 335 | } |
335 | 336 | ||
336 | out: | 337 | out: |
337 | up(&smi_data_lock); | 338 | mutex_unlock(&smi_data_lock); |
338 | return ret; | 339 | return ret; |
339 | } | 340 | } |
340 | 341 | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 3325660f7248..c7671e188017 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -313,6 +313,7 @@ | |||
313 | #include <linux/cdrom.h> | 313 | #include <linux/cdrom.h> |
314 | #include <linux/ide.h> | 314 | #include <linux/ide.h> |
315 | #include <linux/completion.h> | 315 | #include <linux/completion.h> |
316 | #include <linux/mutex.h> | ||
316 | 317 | ||
317 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 318 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ |
318 | 319 | ||
@@ -324,7 +325,7 @@ | |||
324 | 325 | ||
325 | #include "ide-cd.h" | 326 | #include "ide-cd.h" |
326 | 327 | ||
327 | static DECLARE_MUTEX(idecd_ref_sem); | 328 | static DEFINE_MUTEX(idecd_ref_mutex); |
328 | 329 | ||
329 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) | 330 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) |
330 | 331 | ||
@@ -335,11 +336,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
335 | { | 336 | { |
336 | struct cdrom_info *cd = NULL; | 337 | struct cdrom_info *cd = NULL; |
337 | 338 | ||
338 | down(&idecd_ref_sem); | 339 | mutex_lock(&idecd_ref_mutex); |
339 | cd = ide_cd_g(disk); | 340 | cd = ide_cd_g(disk); |
340 | if (cd) | 341 | if (cd) |
341 | kref_get(&cd->kref); | 342 | kref_get(&cd->kref); |
342 | up(&idecd_ref_sem); | 343 | mutex_unlock(&idecd_ref_mutex); |
343 | return cd; | 344 | return cd; |
344 | } | 345 | } |
345 | 346 | ||
@@ -347,9 +348,9 @@ static void ide_cd_release(struct kref *); | |||
347 | 348 | ||
348 | static void ide_cd_put(struct cdrom_info *cd) | 349 | static void ide_cd_put(struct cdrom_info *cd) |
349 | { | 350 | { |
350 | down(&idecd_ref_sem); | 351 | mutex_lock(&idecd_ref_mutex); |
351 | kref_put(&cd->kref, ide_cd_release); | 352 | kref_put(&cd->kref, ide_cd_release); |
352 | up(&idecd_ref_sem); | 353 | mutex_unlock(&idecd_ref_mutex); |
353 | } | 354 | } |
354 | 355 | ||
355 | /**************************************************************************** | 356 | /**************************************************************************** |
@@ -2471,52 +2472,6 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
2471 | } | 2472 | } |
2472 | 2473 | ||
2473 | static | 2474 | static |
2474 | int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, | ||
2475 | unsigned int cmd, unsigned long arg) | ||
2476 | { | ||
2477 | struct packet_command cgc; | ||
2478 | char buffer[16]; | ||
2479 | int stat; | ||
2480 | |||
2481 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
2482 | |||
2483 | /* These will be moved into the Uniform layer shortly... */ | ||
2484 | switch (cmd) { | ||
2485 | case CDROMSETSPINDOWN: { | ||
2486 | char spindown; | ||
2487 | |||
2488 | if (copy_from_user(&spindown, (void __user *) arg, sizeof(char))) | ||
2489 | return -EFAULT; | ||
2490 | |||
2491 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2492 | return stat; | ||
2493 | |||
2494 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
2495 | |||
2496 | return cdrom_mode_select(cdi, &cgc); | ||
2497 | } | ||
2498 | |||
2499 | case CDROMGETSPINDOWN: { | ||
2500 | char spindown; | ||
2501 | |||
2502 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2503 | return stat; | ||
2504 | |||
2505 | spindown = buffer[11] & 0x0f; | ||
2506 | |||
2507 | if (copy_to_user((void __user *) arg, &spindown, sizeof (char))) | ||
2508 | return -EFAULT; | ||
2509 | |||
2510 | return 0; | ||
2511 | } | ||
2512 | |||
2513 | default: | ||
2514 | return -EINVAL; | ||
2515 | } | ||
2516 | |||
2517 | } | ||
2518 | |||
2519 | static | ||
2520 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, | 2475 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, |
2521 | unsigned int cmd, void *arg) | 2476 | unsigned int cmd, void *arg) |
2522 | 2477 | ||
@@ -2852,12 +2807,11 @@ static struct cdrom_device_ops ide_cdrom_dops = { | |||
2852 | .get_mcn = ide_cdrom_get_mcn, | 2807 | .get_mcn = ide_cdrom_get_mcn, |
2853 | .reset = ide_cdrom_reset, | 2808 | .reset = ide_cdrom_reset, |
2854 | .audio_ioctl = ide_cdrom_audio_ioctl, | 2809 | .audio_ioctl = ide_cdrom_audio_ioctl, |
2855 | .dev_ioctl = ide_cdrom_dev_ioctl, | ||
2856 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 2810 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
2857 | CDC_SELECT_SPEED | CDC_SELECT_DISC | | 2811 | CDC_SELECT_SPEED | CDC_SELECT_DISC | |
2858 | CDC_MULTI_SESSION | CDC_MCN | | 2812 | CDC_MULTI_SESSION | CDC_MCN | |
2859 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | | 2813 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | |
2860 | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R | | 2814 | CDC_DRIVE_STATUS | CDC_CD_R | |
2861 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | | 2815 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | |
2862 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | | 2816 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | |
2863 | CDC_MRW_W | CDC_RAM, | 2817 | CDC_MRW_W | CDC_RAM, |
@@ -3367,6 +3321,45 @@ static int idecd_release(struct inode * inode, struct file * file) | |||
3367 | return 0; | 3321 | return 0; |
3368 | } | 3322 | } |
3369 | 3323 | ||
3324 | static int idecd_set_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3325 | { | ||
3326 | struct packet_command cgc; | ||
3327 | char buffer[16]; | ||
3328 | int stat; | ||
3329 | char spindown; | ||
3330 | |||
3331 | if (copy_from_user(&spindown, (void __user *)arg, sizeof(char))) | ||
3332 | return -EFAULT; | ||
3333 | |||
3334 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3335 | |||
3336 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3337 | if (stat) | ||
3338 | return stat; | ||
3339 | |||
3340 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
3341 | return cdrom_mode_select(cdi, &cgc); | ||
3342 | } | ||
3343 | |||
3344 | static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3345 | { | ||
3346 | struct packet_command cgc; | ||
3347 | char buffer[16]; | ||
3348 | int stat; | ||
3349 | char spindown; | ||
3350 | |||
3351 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3352 | |||
3353 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3354 | if (stat) | ||
3355 | return stat; | ||
3356 | |||
3357 | spindown = buffer[11] & 0x0f; | ||
3358 | if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) | ||
3359 | return -EFAULT; | ||
3360 | return 0; | ||
3361 | } | ||
3362 | |||
3370 | static int idecd_ioctl (struct inode *inode, struct file *file, | 3363 | static int idecd_ioctl (struct inode *inode, struct file *file, |
3371 | unsigned int cmd, unsigned long arg) | 3364 | unsigned int cmd, unsigned long arg) |
3372 | { | 3365 | { |
@@ -3374,7 +3367,16 @@ static int idecd_ioctl (struct inode *inode, struct file *file, | |||
3374 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); | 3367 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); |
3375 | int err; | 3368 | int err; |
3376 | 3369 | ||
3377 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | 3370 | switch (cmd) { |
3371 | case CDROMSETSPINDOWN: | ||
3372 | return idecd_set_spindown(&info->devinfo, arg); | ||
3373 | case CDROMGETSPINDOWN: | ||
3374 | return idecd_get_spindown(&info->devinfo, arg); | ||
3375 | default: | ||
3376 | break; | ||
3377 | } | ||
3378 | |||
3379 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | ||
3378 | if (err == -EINVAL) | 3380 | if (err == -EINVAL) |
3379 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); | 3381 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); |
3380 | 3382 | ||
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 09086b8b6486..e238b7da824b 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/genhd.h> | 60 | #include <linux/genhd.h> |
61 | #include <linux/slab.h> | 61 | #include <linux/slab.h> |
62 | #include <linux/delay.h> | 62 | #include <linux/delay.h> |
63 | #include <linux/mutex.h> | ||
63 | 64 | ||
64 | #define _IDE_DISK | 65 | #define _IDE_DISK |
65 | 66 | ||
@@ -78,7 +79,7 @@ struct ide_disk_obj { | |||
78 | struct kref kref; | 79 | struct kref kref; |
79 | }; | 80 | }; |
80 | 81 | ||
81 | static DECLARE_MUTEX(idedisk_ref_sem); | 82 | static DEFINE_MUTEX(idedisk_ref_mutex); |
82 | 83 | ||
83 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) | 84 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) |
84 | 85 | ||
@@ -89,11 +90,11 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | |||
89 | { | 90 | { |
90 | struct ide_disk_obj *idkp = NULL; | 91 | struct ide_disk_obj *idkp = NULL; |
91 | 92 | ||
92 | down(&idedisk_ref_sem); | 93 | mutex_lock(&idedisk_ref_mutex); |
93 | idkp = ide_disk_g(disk); | 94 | idkp = ide_disk_g(disk); |
94 | if (idkp) | 95 | if (idkp) |
95 | kref_get(&idkp->kref); | 96 | kref_get(&idkp->kref); |
96 | up(&idedisk_ref_sem); | 97 | mutex_unlock(&idedisk_ref_mutex); |
97 | return idkp; | 98 | return idkp; |
98 | } | 99 | } |
99 | 100 | ||
@@ -101,9 +102,9 @@ static void ide_disk_release(struct kref *); | |||
101 | 102 | ||
102 | static void ide_disk_put(struct ide_disk_obj *idkp) | 103 | static void ide_disk_put(struct ide_disk_obj *idkp) |
103 | { | 104 | { |
104 | down(&idedisk_ref_sem); | 105 | mutex_lock(&idedisk_ref_mutex); |
105 | kref_put(&idkp->kref, ide_disk_release); | 106 | kref_put(&idkp->kref, ide_disk_release); |
106 | up(&idedisk_ref_sem); | 107 | mutex_unlock(&idedisk_ref_mutex); |
107 | } | 108 | } |
108 | 109 | ||
109 | /* | 110 | /* |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 1f8db9ac05d1..a53e3ce4a142 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/cdrom.h> | 98 | #include <linux/cdrom.h> |
99 | #include <linux/ide.h> | 99 | #include <linux/ide.h> |
100 | #include <linux/bitops.h> | 100 | #include <linux/bitops.h> |
101 | #include <linux/mutex.h> | ||
101 | 102 | ||
102 | #include <asm/byteorder.h> | 103 | #include <asm/byteorder.h> |
103 | #include <asm/irq.h> | 104 | #include <asm/irq.h> |
@@ -517,7 +518,7 @@ typedef struct { | |||
517 | u8 reserved[4]; | 518 | u8 reserved[4]; |
518 | } idefloppy_mode_parameter_header_t; | 519 | } idefloppy_mode_parameter_header_t; |
519 | 520 | ||
520 | static DECLARE_MUTEX(idefloppy_ref_sem); | 521 | static DEFINE_MUTEX(idefloppy_ref_mutex); |
521 | 522 | ||
522 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) | 523 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) |
523 | 524 | ||
@@ -528,11 +529,11 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | |||
528 | { | 529 | { |
529 | struct ide_floppy_obj *floppy = NULL; | 530 | struct ide_floppy_obj *floppy = NULL; |
530 | 531 | ||
531 | down(&idefloppy_ref_sem); | 532 | mutex_lock(&idefloppy_ref_mutex); |
532 | floppy = ide_floppy_g(disk); | 533 | floppy = ide_floppy_g(disk); |
533 | if (floppy) | 534 | if (floppy) |
534 | kref_get(&floppy->kref); | 535 | kref_get(&floppy->kref); |
535 | up(&idefloppy_ref_sem); | 536 | mutex_unlock(&idefloppy_ref_mutex); |
536 | return floppy; | 537 | return floppy; |
537 | } | 538 | } |
538 | 539 | ||
@@ -540,9 +541,9 @@ static void ide_floppy_release(struct kref *); | |||
540 | 541 | ||
541 | static void ide_floppy_put(struct ide_floppy_obj *floppy) | 542 | static void ide_floppy_put(struct ide_floppy_obj *floppy) |
542 | { | 543 | { |
543 | down(&idefloppy_ref_sem); | 544 | mutex_lock(&idefloppy_ref_mutex); |
544 | kref_put(&floppy->kref, ide_floppy_release); | 545 | kref_put(&floppy->kref, ide_floppy_release); |
545 | up(&idefloppy_ref_sem); | 546 | mutex_unlock(&idefloppy_ref_mutex); |
546 | } | 547 | } |
547 | 548 | ||
548 | /* | 549 | /* |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 0101d0def7c5..ebc59064b475 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -443,6 +443,7 @@ | |||
443 | #include <linux/smp_lock.h> | 443 | #include <linux/smp_lock.h> |
444 | #include <linux/completion.h> | 444 | #include <linux/completion.h> |
445 | #include <linux/bitops.h> | 445 | #include <linux/bitops.h> |
446 | #include <linux/mutex.h> | ||
446 | 447 | ||
447 | #include <asm/byteorder.h> | 448 | #include <asm/byteorder.h> |
448 | #include <asm/irq.h> | 449 | #include <asm/irq.h> |
@@ -1011,7 +1012,7 @@ typedef struct ide_tape_obj { | |||
1011 | int debug_level; | 1012 | int debug_level; |
1012 | } idetape_tape_t; | 1013 | } idetape_tape_t; |
1013 | 1014 | ||
1014 | static DECLARE_MUTEX(idetape_ref_sem); | 1015 | static DEFINE_MUTEX(idetape_ref_mutex); |
1015 | 1016 | ||
1016 | static struct class *idetape_sysfs_class; | 1017 | static struct class *idetape_sysfs_class; |
1017 | 1018 | ||
@@ -1024,11 +1025,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
1024 | { | 1025 | { |
1025 | struct ide_tape_obj *tape = NULL; | 1026 | struct ide_tape_obj *tape = NULL; |
1026 | 1027 | ||
1027 | down(&idetape_ref_sem); | 1028 | mutex_lock(&idetape_ref_mutex); |
1028 | tape = ide_tape_g(disk); | 1029 | tape = ide_tape_g(disk); |
1029 | if (tape) | 1030 | if (tape) |
1030 | kref_get(&tape->kref); | 1031 | kref_get(&tape->kref); |
1031 | up(&idetape_ref_sem); | 1032 | mutex_unlock(&idetape_ref_mutex); |
1032 | return tape; | 1033 | return tape; |
1033 | } | 1034 | } |
1034 | 1035 | ||
@@ -1036,9 +1037,9 @@ static void ide_tape_release(struct kref *); | |||
1036 | 1037 | ||
1037 | static void ide_tape_put(struct ide_tape_obj *tape) | 1038 | static void ide_tape_put(struct ide_tape_obj *tape) |
1038 | { | 1039 | { |
1039 | down(&idetape_ref_sem); | 1040 | mutex_lock(&idetape_ref_mutex); |
1040 | kref_put(&tape->kref, ide_tape_release); | 1041 | kref_put(&tape->kref, ide_tape_release); |
1041 | up(&idetape_ref_sem); | 1042 | mutex_unlock(&idetape_ref_mutex); |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | /* | 1045 | /* |
@@ -1290,11 +1291,11 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
1290 | { | 1291 | { |
1291 | struct ide_tape_obj *tape = NULL; | 1292 | struct ide_tape_obj *tape = NULL; |
1292 | 1293 | ||
1293 | down(&idetape_ref_sem); | 1294 | mutex_lock(&idetape_ref_mutex); |
1294 | tape = idetape_devs[i]; | 1295 | tape = idetape_devs[i]; |
1295 | if (tape) | 1296 | if (tape) |
1296 | kref_get(&tape->kref); | 1297 | kref_get(&tape->kref); |
1297 | up(&idetape_ref_sem); | 1298 | mutex_unlock(&idetape_ref_mutex); |
1298 | return tape; | 1299 | return tape; |
1299 | } | 1300 | } |
1300 | 1301 | ||
@@ -4870,11 +4871,11 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
4870 | 4871 | ||
4871 | drive->driver_data = tape; | 4872 | drive->driver_data = tape; |
4872 | 4873 | ||
4873 | down(&idetape_ref_sem); | 4874 | mutex_lock(&idetape_ref_mutex); |
4874 | for (minor = 0; idetape_devs[minor]; minor++) | 4875 | for (minor = 0; idetape_devs[minor]; minor++) |
4875 | ; | 4876 | ; |
4876 | idetape_devs[minor] = tape; | 4877 | idetape_devs[minor] = tape; |
4877 | up(&idetape_ref_sem); | 4878 | mutex_unlock(&idetape_ref_mutex); |
4878 | 4879 | ||
4879 | idetape_setup(drive, tape, minor); | 4880 | idetape_setup(drive, tape, minor); |
4880 | 4881 | ||
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index feec40cf5900..8c4fcb9027b3 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #ifdef CONFIG_AVMB1_COMPAT | 32 | #ifdef CONFIG_AVMB1_COMPAT |
33 | #include <linux/b1lli.h> | 33 | #include <linux/b1lli.h> |
34 | #endif | 34 | #endif |
35 | #include <linux/mutex.h> | ||
35 | 36 | ||
36 | static char *revision = "$Revision: 1.1.2.8 $"; | 37 | static char *revision = "$Revision: 1.1.2.8 $"; |
37 | 38 | ||
@@ -66,7 +67,7 @@ LIST_HEAD(capi_drivers); | |||
66 | DEFINE_RWLOCK(capi_drivers_list_lock); | 67 | DEFINE_RWLOCK(capi_drivers_list_lock); |
67 | 68 | ||
68 | static DEFINE_RWLOCK(application_lock); | 69 | static DEFINE_RWLOCK(application_lock); |
69 | static DECLARE_MUTEX(controller_sem); | 70 | static DEFINE_MUTEX(controller_mutex); |
70 | 71 | ||
71 | struct capi20_appl *capi_applications[CAPI_MAXAPPL]; | 72 | struct capi20_appl *capi_applications[CAPI_MAXAPPL]; |
72 | struct capi_ctr *capi_cards[CAPI_MAXCONTR]; | 73 | struct capi_ctr *capi_cards[CAPI_MAXCONTR]; |
@@ -395,20 +396,20 @@ attach_capi_ctr(struct capi_ctr *card) | |||
395 | { | 396 | { |
396 | int i; | 397 | int i; |
397 | 398 | ||
398 | down(&controller_sem); | 399 | mutex_lock(&controller_mutex); |
399 | 400 | ||
400 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 401 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
401 | if (capi_cards[i] == NULL) | 402 | if (capi_cards[i] == NULL) |
402 | break; | 403 | break; |
403 | } | 404 | } |
404 | if (i == CAPI_MAXCONTR) { | 405 | if (i == CAPI_MAXCONTR) { |
405 | up(&controller_sem); | 406 | mutex_unlock(&controller_mutex); |
406 | printk(KERN_ERR "kcapi: out of controller slots\n"); | 407 | printk(KERN_ERR "kcapi: out of controller slots\n"); |
407 | return -EBUSY; | 408 | return -EBUSY; |
408 | } | 409 | } |
409 | capi_cards[i] = card; | 410 | capi_cards[i] = card; |
410 | 411 | ||
411 | up(&controller_sem); | 412 | mutex_unlock(&controller_mutex); |
412 | 413 | ||
413 | card->nrecvctlpkt = 0; | 414 | card->nrecvctlpkt = 0; |
414 | card->nrecvdatapkt = 0; | 415 | card->nrecvdatapkt = 0; |
@@ -531,13 +532,13 @@ u16 capi20_register(struct capi20_appl *ap) | |||
531 | 532 | ||
532 | write_unlock_irqrestore(&application_lock, flags); | 533 | write_unlock_irqrestore(&application_lock, flags); |
533 | 534 | ||
534 | down(&controller_sem); | 535 | mutex_lock(&controller_mutex); |
535 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 536 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
536 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) | 537 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) |
537 | continue; | 538 | continue; |
538 | register_appl(capi_cards[i], applid, &ap->rparam); | 539 | register_appl(capi_cards[i], applid, &ap->rparam); |
539 | } | 540 | } |
540 | up(&controller_sem); | 541 | mutex_unlock(&controller_mutex); |
541 | 542 | ||
542 | if (showcapimsgs & 1) { | 543 | if (showcapimsgs & 1) { |
543 | printk(KERN_DEBUG "kcapi: appl %d up\n", applid); | 544 | printk(KERN_DEBUG "kcapi: appl %d up\n", applid); |
@@ -560,13 +561,13 @@ u16 capi20_release(struct capi20_appl *ap) | |||
560 | capi_applications[ap->applid - 1] = NULL; | 561 | capi_applications[ap->applid - 1] = NULL; |
561 | write_unlock_irqrestore(&application_lock, flags); | 562 | write_unlock_irqrestore(&application_lock, flags); |
562 | 563 | ||
563 | down(&controller_sem); | 564 | mutex_lock(&controller_mutex); |
564 | for (i = 0; i < CAPI_MAXCONTR; i++) { | 565 | for (i = 0; i < CAPI_MAXCONTR; i++) { |
565 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) | 566 | if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) |
566 | continue; | 567 | continue; |
567 | release_appl(capi_cards[i], ap->applid); | 568 | release_appl(capi_cards[i], ap->applid); |
568 | } | 569 | } |
569 | up(&controller_sem); | 570 | mutex_unlock(&controller_mutex); |
570 | 571 | ||
571 | flush_scheduled_work(); | 572 | flush_scheduled_work(); |
572 | skb_queue_purge(&ap->recv_queue); | 573 | skb_queue_purge(&ap->recv_queue); |
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index df9d65201819..27332506f9f7 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #define HISAX_STATUS_BUFSIZE 4096 | 27 | #define HISAX_STATUS_BUFSIZE 4096 |
28 | #define INCLUDE_INLINE_FUNCS | ||
29 | 28 | ||
30 | /* | 29 | /* |
31 | * This structure array contains one entry per card. An entry looks | 30 | * This structure array contains one entry per card. An entry looks |
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c index 110e9fd669c5..f8ca4b323331 100644 --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c | |||
@@ -108,7 +108,6 @@ static const char *ITACVer[] = | |||
108 | #define ELSA_ASSIGN 4 | 108 | #define ELSA_ASSIGN 4 |
109 | 109 | ||
110 | #define RS_ISR_PASS_LIMIT 256 | 110 | #define RS_ISR_PASS_LIMIT 256 |
111 | #define _INLINE_ inline | ||
112 | #define FLG_MODEM_ACTIVE 1 | 111 | #define FLG_MODEM_ACTIVE 1 |
113 | /* IPAC AUX */ | 112 | /* IPAC AUX */ |
114 | #define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */ | 113 | #define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */ |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 690a1aae0b34..0c13795dca38 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -172,11 +172,9 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
172 | 172 | ||
173 | memset(stats, 0, sizeof(struct net_device_stats)); | 173 | memset(stats, 0, sizeof(struct net_device_stats)); |
174 | 174 | ||
175 | for (i=0; i < NR_CPUS; i++) { | 175 | for_each_cpu(i) { |
176 | struct net_device_stats *lb_stats; | 176 | struct net_device_stats *lb_stats; |
177 | 177 | ||
178 | if (!cpu_possible(i)) | ||
179 | continue; | ||
180 | lb_stats = &per_cpu(loopback_stats, i); | 178 | lb_stats = &per_cpu(loopback_stats, i); |
181 | stats->rx_bytes += lb_stats->rx_bytes; | 179 | stats->rx_bytes += lb_stats->rx_bytes; |
182 | stats->tx_bytes += lb_stats->tx_bytes; | 180 | stats->tx_bytes += lb_stats->tx_bytes; |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index f608c12e3e8b..b2073fce8216 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/rwsem.h> | 46 | #include <linux/rwsem.h> |
47 | #include <linux/stddef.h> | 47 | #include <linux/stddef.h> |
48 | #include <linux/device.h> | 48 | #include <linux/device.h> |
49 | #include <linux/mutex.h> | ||
49 | #include <net/slhc_vj.h> | 50 | #include <net/slhc_vj.h> |
50 | #include <asm/atomic.h> | 51 | #include <asm/atomic.h> |
51 | 52 | ||
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map); | |||
198 | static void cardmap_destroy(struct cardmap **map); | 199 | static void cardmap_destroy(struct cardmap **map); |
199 | 200 | ||
200 | /* | 201 | /* |
201 | * all_ppp_sem protects the all_ppp_units mapping. | 202 | * all_ppp_mutex protects the all_ppp_units mapping. |
202 | * It also ensures that finding a ppp unit in the all_ppp_units map | 203 | * It also ensures that finding a ppp unit in the all_ppp_units map |
203 | * and updating its file.refcnt field is atomic. | 204 | * and updating its file.refcnt field is atomic. |
204 | */ | 205 | */ |
205 | static DECLARE_MUTEX(all_ppp_sem); | 206 | static DEFINE_MUTEX(all_ppp_mutex); |
206 | static struct cardmap *all_ppp_units; | 207 | static struct cardmap *all_ppp_units; |
207 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); | 208 | static atomic_t ppp_unit_count = ATOMIC_INIT(0); |
208 | 209 | ||
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
804 | /* Attach to an existing ppp unit */ | 805 | /* Attach to an existing ppp unit */ |
805 | if (get_user(unit, p)) | 806 | if (get_user(unit, p)) |
806 | break; | 807 | break; |
807 | down(&all_ppp_sem); | 808 | mutex_lock(&all_ppp_mutex); |
808 | err = -ENXIO; | 809 | err = -ENXIO; |
809 | ppp = ppp_find_unit(unit); | 810 | ppp = ppp_find_unit(unit); |
810 | if (ppp != 0) { | 811 | if (ppp != 0) { |
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file, | |||
812 | file->private_data = &ppp->file; | 813 | file->private_data = &ppp->file; |
813 | err = 0; | 814 | err = 0; |
814 | } | 815 | } |
815 | up(&all_ppp_sem); | 816 | mutex_unlock(&all_ppp_mutex); |
816 | break; | 817 | break; |
817 | 818 | ||
818 | case PPPIOCATTCHAN: | 819 | case PPPIOCATTCHAN: |
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp) | |||
2446 | dev->do_ioctl = ppp_net_ioctl; | 2447 | dev->do_ioctl = ppp_net_ioctl; |
2447 | 2448 | ||
2448 | ret = -EEXIST; | 2449 | ret = -EEXIST; |
2449 | down(&all_ppp_sem); | 2450 | mutex_lock(&all_ppp_mutex); |
2450 | if (unit < 0) | 2451 | if (unit < 0) |
2451 | unit = cardmap_find_first_free(all_ppp_units); | 2452 | unit = cardmap_find_first_free(all_ppp_units); |
2452 | else if (cardmap_get(all_ppp_units, unit) != NULL) | 2453 | else if (cardmap_get(all_ppp_units, unit) != NULL) |
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp) | |||
2465 | 2466 | ||
2466 | atomic_inc(&ppp_unit_count); | 2467 | atomic_inc(&ppp_unit_count); |
2467 | cardmap_set(&all_ppp_units, unit, ppp); | 2468 | cardmap_set(&all_ppp_units, unit, ppp); |
2468 | up(&all_ppp_sem); | 2469 | mutex_unlock(&all_ppp_mutex); |
2469 | *retp = 0; | 2470 | *retp = 0; |
2470 | return ppp; | 2471 | return ppp; |
2471 | 2472 | ||
2472 | out2: | 2473 | out2: |
2473 | up(&all_ppp_sem); | 2474 | mutex_unlock(&all_ppp_mutex); |
2474 | free_netdev(dev); | 2475 | free_netdev(dev); |
2475 | out1: | 2476 | out1: |
2476 | kfree(ppp); | 2477 | kfree(ppp); |
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2500 | { | 2501 | { |
2501 | struct net_device *dev; | 2502 | struct net_device *dev; |
2502 | 2503 | ||
2503 | down(&all_ppp_sem); | 2504 | mutex_lock(&all_ppp_mutex); |
2504 | ppp_lock(ppp); | 2505 | ppp_lock(ppp); |
2505 | dev = ppp->dev; | 2506 | dev = ppp->dev; |
2506 | ppp->dev = NULL; | 2507 | ppp->dev = NULL; |
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp) | |||
2514 | ppp->file.dead = 1; | 2515 | ppp->file.dead = 1; |
2515 | ppp->owner = NULL; | 2516 | ppp->owner = NULL; |
2516 | wake_up_interruptible(&ppp->file.rwait); | 2517 | wake_up_interruptible(&ppp->file.rwait); |
2517 | up(&all_ppp_sem); | 2518 | mutex_unlock(&all_ppp_mutex); |
2518 | } | 2519 | } |
2519 | 2520 | ||
2520 | /* | 2521 | /* |
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp) | |||
2556 | 2557 | ||
2557 | /* | 2558 | /* |
2558 | * Locate an existing ppp unit. | 2559 | * Locate an existing ppp unit. |
2559 | * The caller should have locked the all_ppp_sem. | 2560 | * The caller should have locked the all_ppp_mutex. |
2560 | */ | 2561 | */ |
2561 | static struct ppp * | 2562 | static struct ppp * |
2562 | ppp_find_unit(int unit) | 2563 | ppp_find_unit(int unit) |
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2601 | int ret = -ENXIO; | 2602 | int ret = -ENXIO; |
2602 | int hdrlen; | 2603 | int hdrlen; |
2603 | 2604 | ||
2604 | down(&all_ppp_sem); | 2605 | mutex_lock(&all_ppp_mutex); |
2605 | ppp = ppp_find_unit(unit); | 2606 | ppp = ppp_find_unit(unit); |
2606 | if (ppp == 0) | 2607 | if (ppp == 0) |
2607 | goto out; | 2608 | goto out; |
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit) | |||
2626 | outl: | 2627 | outl: |
2627 | write_unlock_bh(&pch->upl); | 2628 | write_unlock_bh(&pch->upl); |
2628 | out: | 2629 | out: |
2629 | up(&all_ppp_sem); | 2630 | mutex_unlock(&all_ppp_mutex); |
2630 | return ret; | 2631 | return ret; |
2631 | } | 2632 | } |
2632 | 2633 | ||
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 78193e4bbdb5..330d3869b41e 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -38,9 +38,8 @@ void free_cpu_buffers(void) | |||
38 | { | 38 | { |
39 | int i; | 39 | int i; |
40 | 40 | ||
41 | for_each_online_cpu(i) { | 41 | for_each_online_cpu(i) |
42 | vfree(cpu_buffer[i].buffer); | 42 | vfree(cpu_buffer[i].buffer); |
43 | } | ||
44 | } | 43 | } |
45 | 44 | ||
46 | int alloc_cpu_buffers(void) | 45 | int alloc_cpu_buffers(void) |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 5e38cd7335f7..c89c98a2cca8 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -448,11 +448,7 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc | |||
448 | break; | 448 | break; |
449 | 449 | ||
450 | case SMALL_TAG_END: | 450 | case SMALL_TAG_END: |
451 | if (option_independent != option) | 451 | return p + 2; |
452 | printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_ENDDEP tag\n"); | ||
453 | p = p + 2; | ||
454 | return (unsigned char *)p; | ||
455 | break; | ||
456 | 452 | ||
457 | default: /* an unkown tag */ | 453 | default: /* an unkown tag */ |
458 | len_err: | 454 | len_err: |
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index fafeeae52675..f9930552ab54 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c | |||
@@ -151,9 +151,9 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args) | |||
151 | return -ENODEV; | 151 | return -ENODEV; |
152 | dasd_enable_device(device); | 152 | dasd_enable_device(device); |
153 | /* Formatting the dasd device can change the capacity. */ | 153 | /* Formatting the dasd device can change the capacity. */ |
154 | down(&bdev->bd_sem); | 154 | mutex_lock(&bdev->bd_mutex); |
155 | i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); | 155 | i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); |
156 | up(&bdev->bd_sem); | 156 | mutex_unlock(&bdev->bd_mutex); |
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
@@ -184,9 +184,9 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args) | |||
184 | * Set i_size to zero, since read, write, etc. check against this | 184 | * Set i_size to zero, since read, write, etc. check against this |
185 | * value. | 185 | * value. |
186 | */ | 186 | */ |
187 | down(&bdev->bd_sem); | 187 | mutex_lock(&bdev->bd_mutex); |
188 | i_size_write(bdev->bd_inode, 0); | 188 | i_size_write(bdev->bd_inode, 0); |
189 | up(&bdev->bd_sem); | 189 | mutex_unlock(&bdev->bd_mutex); |
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 0cf0e4c7ac0c..39b760a24241 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/ide.h> | 47 | #include <linux/ide.h> |
48 | #include <linux/scatterlist.h> | 48 | #include <linux/scatterlist.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/mutex.h> | ||
50 | 51 | ||
51 | #include <asm/io.h> | 52 | #include <asm/io.h> |
52 | #include <asm/bitops.h> | 53 | #include <asm/bitops.h> |
@@ -109,7 +110,7 @@ typedef struct ide_scsi_obj { | |||
109 | unsigned long log; /* log flags */ | 110 | unsigned long log; /* log flags */ |
110 | } idescsi_scsi_t; | 111 | } idescsi_scsi_t; |
111 | 112 | ||
112 | static DECLARE_MUTEX(idescsi_ref_sem); | 113 | static DEFINE_MUTEX(idescsi_ref_mutex); |
113 | 114 | ||
114 | #define ide_scsi_g(disk) \ | 115 | #define ide_scsi_g(disk) \ |
115 | container_of((disk)->private_data, struct ide_scsi_obj, driver) | 116 | container_of((disk)->private_data, struct ide_scsi_obj, driver) |
@@ -118,19 +119,19 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) | |||
118 | { | 119 | { |
119 | struct ide_scsi_obj *scsi = NULL; | 120 | struct ide_scsi_obj *scsi = NULL; |
120 | 121 | ||
121 | down(&idescsi_ref_sem); | 122 | mutex_lock(&idescsi_ref_mutex); |
122 | scsi = ide_scsi_g(disk); | 123 | scsi = ide_scsi_g(disk); |
123 | if (scsi) | 124 | if (scsi) |
124 | scsi_host_get(scsi->host); | 125 | scsi_host_get(scsi->host); |
125 | up(&idescsi_ref_sem); | 126 | mutex_unlock(&idescsi_ref_mutex); |
126 | return scsi; | 127 | return scsi; |
127 | } | 128 | } |
128 | 129 | ||
129 | static void ide_scsi_put(struct ide_scsi_obj *scsi) | 130 | static void ide_scsi_put(struct ide_scsi_obj *scsi) |
130 | { | 131 | { |
131 | down(&idescsi_ref_sem); | 132 | mutex_lock(&idescsi_ref_mutex); |
132 | scsi_host_put(scsi->host); | 133 | scsi_host_put(scsi->host); |
133 | up(&idescsi_ref_sem); | 134 | mutex_unlock(&idescsi_ref_mutex); |
134 | } | 135 | } |
135 | 136 | ||
136 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) | 137 | static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index f9c1192dc15e..7c80711e18ed 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -71,7 +71,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); | |||
71 | #define SR_CAPABILITIES \ | 71 | #define SR_CAPABILITIES \ |
72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ | 72 | (CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \ |
73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ | 73 | CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \ |
74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \ | 74 | CDC_PLAY_AUDIO|CDC_RESET|CDC_DRIVE_STATUS| \ |
75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ | 75 | CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ |
76 | CDC_MRW|CDC_MRW_W|CDC_RAM) | 76 | CDC_MRW|CDC_MRW_W|CDC_RAM) |
77 | 77 | ||
@@ -118,7 +118,6 @@ static struct cdrom_device_ops sr_dops = { | |||
118 | .get_mcn = sr_get_mcn, | 118 | .get_mcn = sr_get_mcn, |
119 | .reset = sr_reset, | 119 | .reset = sr_reset, |
120 | .audio_ioctl = sr_audio_ioctl, | 120 | .audio_ioctl = sr_audio_ioctl, |
121 | .dev_ioctl = sr_dev_ioctl, | ||
122 | .capability = SR_CAPABILITIES, | 121 | .capability = SR_CAPABILITIES, |
123 | .generic_packet = sr_packet, | 122 | .generic_packet = sr_packet, |
124 | }; | 123 | }; |
@@ -456,17 +455,33 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
456 | { | 455 | { |
457 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 456 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); |
458 | struct scsi_device *sdev = cd->device; | 457 | struct scsi_device *sdev = cd->device; |
458 | void __user *argp = (void __user *)arg; | ||
459 | int ret; | ||
459 | 460 | ||
460 | /* | 461 | /* |
461 | * Send SCSI addressing ioctls directly to mid level, send other | 462 | * Send SCSI addressing ioctls directly to mid level, send other |
462 | * ioctls to cdrom/block level. | 463 | * ioctls to cdrom/block level. |
463 | */ | 464 | */ |
464 | switch (cmd) { | 465 | switch (cmd) { |
465 | case SCSI_IOCTL_GET_IDLUN: | 466 | case SCSI_IOCTL_GET_IDLUN: |
466 | case SCSI_IOCTL_GET_BUS_NUMBER: | 467 | case SCSI_IOCTL_GET_BUS_NUMBER: |
467 | return scsi_ioctl(sdev, cmd, (void __user *)arg); | 468 | return scsi_ioctl(sdev, cmd, argp); |
468 | } | 469 | } |
469 | return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | 470 | |
471 | ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | ||
472 | if (ret != ENOSYS) | ||
473 | return ret; | ||
474 | |||
475 | /* | ||
476 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
477 | * cannot execute it in the current device state. In either | ||
478 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
479 | * if it doesn't recognise the ioctl | ||
480 | */ | ||
481 | ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL); | ||
482 | if (ret != -ENODEV) | ||
483 | return ret; | ||
484 | return scsi_ioctl(sdev, cmd, argp); | ||
470 | } | 485 | } |
471 | 486 | ||
472 | static int sr_block_media_changed(struct gendisk *disk) | 487 | static int sr_block_media_changed(struct gendisk *disk) |
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index d2bcd99c272f..d65de9621b27 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h | |||
@@ -55,7 +55,6 @@ int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); | |||
55 | int sr_reset(struct cdrom_device_info *); | 55 | int sr_reset(struct cdrom_device_info *); |
56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); | 56 | int sr_select_speed(struct cdrom_device_info *cdi, int speed); |
57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); | 57 | int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); |
58 | int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long); | ||
59 | 58 | ||
60 | int sr_is_xa(Scsi_CD *); | 59 | int sr_is_xa(Scsi_CD *); |
61 | 60 | ||
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index b65462f76484..d1268cb46837 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -562,22 +562,3 @@ int sr_is_xa(Scsi_CD *cd) | |||
562 | #endif | 562 | #endif |
563 | return is_xa; | 563 | return is_xa; |
564 | } | 564 | } |
565 | |||
566 | int sr_dev_ioctl(struct cdrom_device_info *cdi, | ||
567 | unsigned int cmd, unsigned long arg) | ||
568 | { | ||
569 | Scsi_CD *cd = cdi->handle; | ||
570 | int ret; | ||
571 | |||
572 | ret = scsi_nonblockable_ioctl(cd->device, cmd, | ||
573 | (void __user *)arg, NULL); | ||
574 | /* | ||
575 | * ENODEV means that we didn't recognise the ioctl, or that we | ||
576 | * cannot execute it in the current device state. In either | ||
577 | * case fall through to scsi_ioctl, which will return ENDOEV again | ||
578 | * if it doesn't recognise the ioctl | ||
579 | */ | ||
580 | if (ret != -ENODEV) | ||
581 | return ret; | ||
582 | return scsi_ioctl(cd->device, cmd, (void __user *)arg); | ||
583 | } | ||
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c index 7f0f35a05dca..b88a7c1158af 100644 --- a/drivers/serial/68328serial.c +++ b/drivers/serial/68328serial.c | |||
@@ -101,8 +101,6 @@ struct tty_driver *serial_driver; | |||
101 | 101 | ||
102 | #define RS_ISR_PASS_LIMIT 256 | 102 | #define RS_ISR_PASS_LIMIT 256 |
103 | 103 | ||
104 | #define _INLINE_ inline | ||
105 | |||
106 | static void change_speed(struct m68k_serial *info); | 104 | static void change_speed(struct m68k_serial *info); |
107 | 105 | ||
108 | /* | 106 | /* |
@@ -262,7 +260,7 @@ static void batten_down_hatches(void) | |||
262 | /* Drop into the debugger */ | 260 | /* Drop into the debugger */ |
263 | } | 261 | } |
264 | 262 | ||
265 | static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status) | 263 | static void status_handle(struct m68k_serial *info, unsigned short status) |
266 | { | 264 | { |
267 | #if 0 | 265 | #if 0 |
268 | if(status & DCD) { | 266 | if(status & DCD) { |
@@ -289,7 +287,8 @@ static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short stat | |||
289 | return; | 287 | return; |
290 | } | 288 | } |
291 | 289 | ||
292 | static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) | 290 | static void receive_chars(struct m68k_serial *info, struct pt_regs *regs, |
291 | unsigned short rx) | ||
293 | { | 292 | { |
294 | struct tty_struct *tty = info->tty; | 293 | struct tty_struct *tty = info->tty; |
295 | m68328_uart *uart = &uart_addr[info->line]; | 294 | m68328_uart *uart = &uart_addr[info->line]; |
@@ -359,7 +358,7 @@ clear_and_exit: | |||
359 | return; | 358 | return; |
360 | } | 359 | } |
361 | 360 | ||
362 | static _INLINE_ void transmit_chars(struct m68k_serial *info) | 361 | static void transmit_chars(struct m68k_serial *info) |
363 | { | 362 | { |
364 | m68328_uart *uart = &uart_addr[info->line]; | 363 | m68328_uart *uart = &uart_addr[info->line]; |
365 | 364 | ||
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c index 29f94bbb79be..948880ac5878 100644 --- a/drivers/serial/au1x00_uart.c +++ b/drivers/serial/au1x00_uart.c | |||
@@ -133,13 +133,12 @@ static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = { | |||
133 | { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO }, | 133 | { "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO }, |
134 | }; | 134 | }; |
135 | 135 | ||
136 | static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) | 136 | static unsigned int serial_in(struct uart_8250_port *up, int offset) |
137 | { | 137 | { |
138 | return au_readl((unsigned long)up->port.membase + offset); | 138 | return au_readl((unsigned long)up->port.membase + offset); |
139 | } | 139 | } |
140 | 140 | ||
141 | static _INLINE_ void | 141 | static void serial_out(struct uart_8250_port *up, int offset, int value) |
142 | serial_out(struct uart_8250_port *up, int offset, int value) | ||
143 | { | 142 | { |
144 | au_writel(value, (unsigned long)up->port.membase + offset); | 143 | au_writel(value, (unsigned long)up->port.membase + offset); |
145 | } | 144 | } |
@@ -237,7 +236,7 @@ static void serial8250_enable_ms(struct uart_port *port) | |||
237 | serial_out(up, UART_IER, up->ier); | 236 | serial_out(up, UART_IER, up->ier); |
238 | } | 237 | } |
239 | 238 | ||
240 | static _INLINE_ void | 239 | static void |
241 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | 240 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) |
242 | { | 241 | { |
243 | struct tty_struct *tty = up->port.info->tty; | 242 | struct tty_struct *tty = up->port.info->tty; |
@@ -312,7 +311,7 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | |||
312 | spin_lock(&up->port.lock); | 311 | spin_lock(&up->port.lock); |
313 | } | 312 | } |
314 | 313 | ||
315 | static _INLINE_ void transmit_chars(struct uart_8250_port *up) | 314 | static void transmit_chars(struct uart_8250_port *up) |
316 | { | 315 | { |
317 | struct circ_buf *xmit = &up->port.info->xmit; | 316 | struct circ_buf *xmit = &up->port.info->xmit; |
318 | int count; | 317 | int count; |
@@ -346,7 +345,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up) | |||
346 | serial8250_stop_tx(&up->port); | 345 | serial8250_stop_tx(&up->port); |
347 | } | 346 | } |
348 | 347 | ||
349 | static _INLINE_ void check_modem_status(struct uart_8250_port *up) | 348 | static void check_modem_status(struct uart_8250_port *up) |
350 | { | 349 | { |
351 | int status; | 350 | int status; |
352 | 351 | ||
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index be12623d8544..89700141f87e 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -481,8 +481,6 @@ static char *serial_version = "$Revision: 1.25 $"; | |||
481 | #include "serial_compat.h" | 481 | #include "serial_compat.h" |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | #define _INLINE_ inline | ||
485 | |||
486 | struct tty_driver *serial_driver; | 484 | struct tty_driver *serial_driver; |
487 | 485 | ||
488 | /* serial subtype definitions */ | 486 | /* serial subtype definitions */ |
@@ -591,8 +589,6 @@ static void rs_throttle(struct tty_struct * tty); | |||
591 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); | 589 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); |
592 | static int rs_write(struct tty_struct * tty, int from_user, | 590 | static int rs_write(struct tty_struct * tty, int from_user, |
593 | const unsigned char *buf, int count); | 591 | const unsigned char *buf, int count); |
594 | extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user, | ||
595 | const unsigned char *buf, int count); | ||
596 | #ifdef CONFIG_ETRAX_RS485 | 592 | #ifdef CONFIG_ETRAX_RS485 |
597 | static int e100_write_rs485(struct tty_struct * tty, int from_user, | 593 | static int e100_write_rs485(struct tty_struct * tty, int from_user, |
598 | const unsigned char *buf, int count); | 594 | const unsigned char *buf, int count); |
@@ -1538,8 +1534,7 @@ e100_enable_rxdma_irq(struct e100_serial *info) | |||
1538 | 1534 | ||
1539 | /* the tx DMA uses only dma_descr interrupt */ | 1535 | /* the tx DMA uses only dma_descr interrupt */ |
1540 | 1536 | ||
1541 | static _INLINE_ void | 1537 | static void e100_disable_txdma_irq(struct e100_serial *info) |
1542 | e100_disable_txdma_irq(struct e100_serial *info) | ||
1543 | { | 1538 | { |
1544 | #ifdef SERIAL_DEBUG_INTR | 1539 | #ifdef SERIAL_DEBUG_INTR |
1545 | printk("txdma_irq(%d): 0\n",info->line); | 1540 | printk("txdma_irq(%d): 0\n",info->line); |
@@ -1548,8 +1543,7 @@ e100_disable_txdma_irq(struct e100_serial *info) | |||
1548 | *R_IRQ_MASK2_CLR = info->irq; | 1543 | *R_IRQ_MASK2_CLR = info->irq; |
1549 | } | 1544 | } |
1550 | 1545 | ||
1551 | static _INLINE_ void | 1546 | static void e100_enable_txdma_irq(struct e100_serial *info) |
1552 | e100_enable_txdma_irq(struct e100_serial *info) | ||
1553 | { | 1547 | { |
1554 | #ifdef SERIAL_DEBUG_INTR | 1548 | #ifdef SERIAL_DEBUG_INTR |
1555 | printk("txdma_irq(%d): 1\n",info->line); | 1549 | printk("txdma_irq(%d): 1\n",info->line); |
@@ -1558,8 +1552,7 @@ e100_enable_txdma_irq(struct e100_serial *info) | |||
1558 | *R_IRQ_MASK2_SET = info->irq; | 1552 | *R_IRQ_MASK2_SET = info->irq; |
1559 | } | 1553 | } |
1560 | 1554 | ||
1561 | static _INLINE_ void | 1555 | static void e100_disable_txdma_channel(struct e100_serial *info) |
1562 | e100_disable_txdma_channel(struct e100_serial *info) | ||
1563 | { | 1556 | { |
1564 | unsigned long flags; | 1557 | unsigned long flags; |
1565 | 1558 | ||
@@ -1599,8 +1592,7 @@ e100_disable_txdma_channel(struct e100_serial *info) | |||
1599 | } | 1592 | } |
1600 | 1593 | ||
1601 | 1594 | ||
1602 | static _INLINE_ void | 1595 | static void e100_enable_txdma_channel(struct e100_serial *info) |
1603 | e100_enable_txdma_channel(struct e100_serial *info) | ||
1604 | { | 1596 | { |
1605 | unsigned long flags; | 1597 | unsigned long flags; |
1606 | 1598 | ||
@@ -1625,8 +1617,7 @@ e100_enable_txdma_channel(struct e100_serial *info) | |||
1625 | restore_flags(flags); | 1617 | restore_flags(flags); |
1626 | } | 1618 | } |
1627 | 1619 | ||
1628 | static _INLINE_ void | 1620 | static void e100_disable_rxdma_channel(struct e100_serial *info) |
1629 | e100_disable_rxdma_channel(struct e100_serial *info) | ||
1630 | { | 1621 | { |
1631 | unsigned long flags; | 1622 | unsigned long flags; |
1632 | 1623 | ||
@@ -1665,8 +1656,7 @@ e100_disable_rxdma_channel(struct e100_serial *info) | |||
1665 | } | 1656 | } |
1666 | 1657 | ||
1667 | 1658 | ||
1668 | static _INLINE_ void | 1659 | static void e100_enable_rxdma_channel(struct e100_serial *info) |
1669 | e100_enable_rxdma_channel(struct e100_serial *info) | ||
1670 | { | 1660 | { |
1671 | unsigned long flags; | 1661 | unsigned long flags; |
1672 | 1662 | ||
@@ -1913,9 +1903,7 @@ rs_start(struct tty_struct *tty) | |||
1913 | * This routine is used by the interrupt handler to schedule | 1903 | * This routine is used by the interrupt handler to schedule |
1914 | * processing in the software interrupt portion of the driver. | 1904 | * processing in the software interrupt portion of the driver. |
1915 | */ | 1905 | */ |
1916 | static _INLINE_ void | 1906 | static void rs_sched_event(struct e100_serial *info, int event) |
1917 | rs_sched_event(struct e100_serial *info, | ||
1918 | int event) | ||
1919 | { | 1907 | { |
1920 | if (info->event & (1 << event)) | 1908 | if (info->event & (1 << event)) |
1921 | return; | 1909 | return; |
@@ -2155,8 +2143,9 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl | |||
2155 | return 1; | 2143 | return 1; |
2156 | } | 2144 | } |
2157 | 2145 | ||
2158 | extern _INLINE_ unsigned int | 2146 | static unsigned int handle_descr_data(struct e100_serial *info, |
2159 | handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl) | 2147 | struct etrax_dma_descr *descr, |
2148 | unsigned int recvl) | ||
2160 | { | 2149 | { |
2161 | struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer; | 2150 | struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer; |
2162 | 2151 | ||
@@ -2182,8 +2171,7 @@ handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsig | |||
2182 | return recvl; | 2171 | return recvl; |
2183 | } | 2172 | } |
2184 | 2173 | ||
2185 | static _INLINE_ unsigned int | 2174 | static unsigned int handle_all_descr_data(struct e100_serial *info) |
2186 | handle_all_descr_data(struct e100_serial *info) | ||
2187 | { | 2175 | { |
2188 | struct etrax_dma_descr *descr; | 2176 | struct etrax_dma_descr *descr; |
2189 | unsigned int recvl; | 2177 | unsigned int recvl; |
@@ -2230,8 +2218,7 @@ handle_all_descr_data(struct e100_serial *info) | |||
2230 | return ret; | 2218 | return ret; |
2231 | } | 2219 | } |
2232 | 2220 | ||
2233 | static _INLINE_ void | 2221 | static void receive_chars_dma(struct e100_serial *info) |
2234 | receive_chars_dma(struct e100_serial *info) | ||
2235 | { | 2222 | { |
2236 | struct tty_struct *tty; | 2223 | struct tty_struct *tty; |
2237 | unsigned char rstat; | 2224 | unsigned char rstat; |
@@ -2292,8 +2279,7 @@ receive_chars_dma(struct e100_serial *info) | |||
2292 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); | 2279 | *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); |
2293 | } | 2280 | } |
2294 | 2281 | ||
2295 | static _INLINE_ int | 2282 | static int start_recv_dma(struct e100_serial *info) |
2296 | start_recv_dma(struct e100_serial *info) | ||
2297 | { | 2283 | { |
2298 | struct etrax_dma_descr *descr = info->rec_descr; | 2284 | struct etrax_dma_descr *descr = info->rec_descr; |
2299 | struct etrax_recv_buffer *buffer; | 2285 | struct etrax_recv_buffer *buffer; |
@@ -2348,11 +2334,6 @@ start_receive(struct e100_serial *info) | |||
2348 | } | 2334 | } |
2349 | 2335 | ||
2350 | 2336 | ||
2351 | static _INLINE_ void | ||
2352 | status_handle(struct e100_serial *info, unsigned short status) | ||
2353 | { | ||
2354 | } | ||
2355 | |||
2356 | /* the bits in the MASK2 register are laid out like this: | 2337 | /* the bits in the MASK2 register are laid out like this: |
2357 | DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR | 2338 | DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR |
2358 | where I is the input channel and O is the output channel for the port. | 2339 | where I is the input channel and O is the output channel for the port. |
@@ -2454,8 +2435,7 @@ rec_interrupt(int irq, void *dev_id, struct pt_regs * regs) | |||
2454 | return IRQ_RETVAL(handled); | 2435 | return IRQ_RETVAL(handled); |
2455 | } /* rec_interrupt */ | 2436 | } /* rec_interrupt */ |
2456 | 2437 | ||
2457 | static _INLINE_ int | 2438 | static int force_eop_if_needed(struct e100_serial *info) |
2458 | force_eop_if_needed(struct e100_serial *info) | ||
2459 | { | 2439 | { |
2460 | /* We check data_avail bit to determine if data has | 2440 | /* We check data_avail bit to determine if data has |
2461 | * arrived since last time | 2441 | * arrived since last time |
@@ -2499,8 +2479,7 @@ force_eop_if_needed(struct e100_serial *info) | |||
2499 | return 1; | 2479 | return 1; |
2500 | } | 2480 | } |
2501 | 2481 | ||
2502 | extern _INLINE_ void | 2482 | static void flush_to_flip_buffer(struct e100_serial *info) |
2503 | flush_to_flip_buffer(struct e100_serial *info) | ||
2504 | { | 2483 | { |
2505 | struct tty_struct *tty; | 2484 | struct tty_struct *tty; |
2506 | struct etrax_recv_buffer *buffer; | 2485 | struct etrax_recv_buffer *buffer; |
@@ -2611,8 +2590,7 @@ flush_to_flip_buffer(struct e100_serial *info) | |||
2611 | tty_flip_buffer_push(tty); | 2590 | tty_flip_buffer_push(tty); |
2612 | } | 2591 | } |
2613 | 2592 | ||
2614 | static _INLINE_ void | 2593 | static void check_flush_timeout(struct e100_serial *info) |
2615 | check_flush_timeout(struct e100_serial *info) | ||
2616 | { | 2594 | { |
2617 | /* Flip what we've got (if we can) */ | 2595 | /* Flip what we've got (if we can) */ |
2618 | flush_to_flip_buffer(info); | 2596 | flush_to_flip_buffer(info); |
@@ -2741,7 +2719,7 @@ TODO: The break will be delayed until an F or V character is received. | |||
2741 | 2719 | ||
2742 | */ | 2720 | */ |
2743 | 2721 | ||
2744 | extern _INLINE_ | 2722 | static |
2745 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | 2723 | struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) |
2746 | { | 2724 | { |
2747 | unsigned long data_read; | 2725 | unsigned long data_read; |
@@ -2875,8 +2853,7 @@ more_data: | |||
2875 | return info; | 2853 | return info; |
2876 | } | 2854 | } |
2877 | 2855 | ||
2878 | extern _INLINE_ | 2856 | static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) |
2879 | struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | ||
2880 | { | 2857 | { |
2881 | unsigned char rstat; | 2858 | unsigned char rstat; |
2882 | 2859 | ||
@@ -2995,7 +2972,7 @@ struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2995 | return info; | 2972 | return info; |
2996 | } /* handle_ser_rx_interrupt */ | 2973 | } /* handle_ser_rx_interrupt */ |
2997 | 2974 | ||
2998 | extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info) | 2975 | static void handle_ser_tx_interrupt(struct e100_serial *info) |
2999 | { | 2976 | { |
3000 | unsigned long flags; | 2977 | unsigned long flags; |
3001 | 2978 | ||
@@ -3621,9 +3598,8 @@ rs_flush_chars(struct tty_struct *tty) | |||
3621 | restore_flags(flags); | 3598 | restore_flags(flags); |
3622 | } | 3599 | } |
3623 | 3600 | ||
3624 | extern _INLINE_ int | 3601 | static int rs_raw_write(struct tty_struct * tty, int from_user, |
3625 | rs_raw_write(struct tty_struct * tty, int from_user, | 3602 | const unsigned char *buf, int count) |
3626 | const unsigned char *buf, int count) | ||
3627 | { | 3603 | { |
3628 | int c, ret = 0; | 3604 | int c, ret = 0; |
3629 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3605 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
@@ -4710,7 +4686,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4710 | * /proc fs routines.... | 4686 | * /proc fs routines.... |
4711 | */ | 4687 | */ |
4712 | 4688 | ||
4713 | extern _INLINE_ int line_info(char *buf, struct e100_serial *info) | 4689 | static int line_info(char *buf, struct e100_serial *info) |
4714 | { | 4690 | { |
4715 | char stat_buf[30]; | 4691 | char stat_buf[30]; |
4716 | int ret; | 4692 | int ret; |
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c index 876bc5e027bb..e9c10c0a30fc 100644 --- a/drivers/serial/m32r_sio.c +++ b/drivers/serial/m32r_sio.c | |||
@@ -248,17 +248,17 @@ static void sio_error(int *status) | |||
248 | 248 | ||
249 | #endif /* CONFIG_SERIAL_M32R_PLDSIO */ | 249 | #endif /* CONFIG_SERIAL_M32R_PLDSIO */ |
250 | 250 | ||
251 | static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset) | 251 | static unsigned int sio_in(struct uart_sio_port *up, int offset) |
252 | { | 252 | { |
253 | return __sio_in(up->port.iobase + offset); | 253 | return __sio_in(up->port.iobase + offset); |
254 | } | 254 | } |
255 | 255 | ||
256 | static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value) | 256 | static void sio_out(struct uart_sio_port *up, int offset, int value) |
257 | { | 257 | { |
258 | __sio_out(value, up->port.iobase + offset); | 258 | __sio_out(value, up->port.iobase + offset); |
259 | } | 259 | } |
260 | 260 | ||
261 | static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) | 261 | static unsigned int serial_in(struct uart_sio_port *up, int offset) |
262 | { | 262 | { |
263 | if (!offset) | 263 | if (!offset) |
264 | return 0; | 264 | return 0; |
@@ -266,8 +266,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) | |||
266 | return __sio_in(offset); | 266 | return __sio_in(offset); |
267 | } | 267 | } |
268 | 268 | ||
269 | static _INLINE_ void | 269 | static void serial_out(struct uart_sio_port *up, int offset, int value) |
270 | serial_out(struct uart_sio_port *up, int offset, int value) | ||
271 | { | 270 | { |
272 | if (!offset) | 271 | if (!offset) |
273 | return; | 272 | return; |
@@ -326,8 +325,8 @@ static void m32r_sio_enable_ms(struct uart_port *port) | |||
326 | serial_out(up, UART_IER, up->ier); | 325 | serial_out(up, UART_IER, up->ier); |
327 | } | 326 | } |
328 | 327 | ||
329 | static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | 328 | static void receive_chars(struct uart_sio_port *up, int *status, |
330 | struct pt_regs *regs) | 329 | struct pt_regs *regs) |
331 | { | 330 | { |
332 | struct tty_struct *tty = up->port.info->tty; | 331 | struct tty_struct *tty = up->port.info->tty; |
333 | unsigned char ch; | 332 | unsigned char ch; |
@@ -400,7 +399,7 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | |||
400 | tty_flip_buffer_push(tty); | 399 | tty_flip_buffer_push(tty); |
401 | } | 400 | } |
402 | 401 | ||
403 | static _INLINE_ void transmit_chars(struct uart_sio_port *up) | 402 | static void transmit_chars(struct uart_sio_port *up) |
404 | { | 403 | { |
405 | struct circ_buf *xmit = &up->port.info->xmit; | 404 | struct circ_buf *xmit = &up->port.info->xmit; |
406 | int count; | 405 | int count; |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 7fc3d3b41d18..9fe2283d91e5 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -102,9 +102,7 @@ struct uart_sunsu_port { | |||
102 | #endif | 102 | #endif |
103 | }; | 103 | }; |
104 | 104 | ||
105 | #define _INLINE_ | 105 | static unsigned int serial_in(struct uart_sunsu_port *up, int offset) |
106 | |||
107 | static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset) | ||
108 | { | 106 | { |
109 | offset <<= up->port.regshift; | 107 | offset <<= up->port.regshift; |
110 | 108 | ||
@@ -121,8 +119,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset) | |||
121 | } | 119 | } |
122 | } | 120 | } |
123 | 121 | ||
124 | static _INLINE_ void | 122 | static void serial_out(struct uart_sunsu_port *up, int offset, int value) |
125 | serial_out(struct uart_sunsu_port *up, int offset, int value) | ||
126 | { | 123 | { |
127 | #ifndef CONFIG_SPARC64 | 124 | #ifndef CONFIG_SPARC64 |
128 | /* | 125 | /* |
@@ -316,7 +313,7 @@ static void sunsu_enable_ms(struct uart_port *port) | |||
316 | spin_unlock_irqrestore(&up->port.lock, flags); | 313 | spin_unlock_irqrestore(&up->port.lock, flags); |
317 | } | 314 | } |
318 | 315 | ||
319 | static _INLINE_ struct tty_struct * | 316 | static struct tty_struct * |
320 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) | 317 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) |
321 | { | 318 | { |
322 | struct tty_struct *tty = up->port.info->tty; | 319 | struct tty_struct *tty = up->port.info->tty; |
@@ -395,7 +392,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs | |||
395 | return tty; | 392 | return tty; |
396 | } | 393 | } |
397 | 394 | ||
398 | static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) | 395 | static void transmit_chars(struct uart_sunsu_port *up) |
399 | { | 396 | { |
400 | struct circ_buf *xmit = &up->port.info->xmit; | 397 | struct circ_buf *xmit = &up->port.info->xmit; |
401 | int count; | 398 | int count; |
@@ -431,7 +428,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) | |||
431 | __stop_tx(up); | 428 | __stop_tx(up); |
432 | } | 429 | } |
433 | 430 | ||
434 | static _INLINE_ void check_modem_status(struct uart_sunsu_port *up) | 431 | static void check_modem_status(struct uart_sunsu_port *up) |
435 | { | 432 | { |
436 | int status; | 433 | int status; |
437 | 434 | ||
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 6756d0fab6fe..2dffa8e303b2 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c | |||
@@ -186,8 +186,6 @@ static struct tty_driver *serial_driver; | |||
186 | #define RS_STROBE_TIME 10 | 186 | #define RS_STROBE_TIME 10 |
187 | #define RS_ISR_PASS_LIMIT 256 | 187 | #define RS_ISR_PASS_LIMIT 256 |
188 | 188 | ||
189 | #define _INLINE_ inline | ||
190 | |||
191 | static void probe_sccs(void); | 189 | static void probe_sccs(void); |
192 | static void change_speed(struct dec_serial *info); | 190 | static void change_speed(struct dec_serial *info); |
193 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); | 191 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout); |
@@ -344,14 +342,13 @@ static inline void rs_recv_clear(struct dec_zschannel *zsc) | |||
344 | * This routine is used by the interrupt handler to schedule | 342 | * This routine is used by the interrupt handler to schedule |
345 | * processing in the software interrupt portion of the driver. | 343 | * processing in the software interrupt portion of the driver. |
346 | */ | 344 | */ |
347 | static _INLINE_ void rs_sched_event(struct dec_serial *info, int event) | 345 | static void rs_sched_event(struct dec_serial *info, int event) |
348 | { | 346 | { |
349 | info->event |= 1 << event; | 347 | info->event |= 1 << event; |
350 | tasklet_schedule(&info->tlet); | 348 | tasklet_schedule(&info->tlet); |
351 | } | 349 | } |
352 | 350 | ||
353 | static _INLINE_ void receive_chars(struct dec_serial *info, | 351 | static void receive_chars(struct dec_serial *info, struct pt_regs *regs) |
354 | struct pt_regs *regs) | ||
355 | { | 352 | { |
356 | struct tty_struct *tty = info->tty; | 353 | struct tty_struct *tty = info->tty; |
357 | unsigned char ch, stat, flag; | 354 | unsigned char ch, stat, flag; |
@@ -441,7 +438,7 @@ static void transmit_chars(struct dec_serial *info) | |||
441 | rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); | 438 | rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); |
442 | } | 439 | } |
443 | 440 | ||
444 | static _INLINE_ void status_handle(struct dec_serial *info) | 441 | static void status_handle(struct dec_serial *info) |
445 | { | 442 | { |
446 | unsigned char stat; | 443 | unsigned char stat; |
447 | 444 | ||