aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/suspend.c5
-rw-r--r--drivers/block/cciss.c2
-rw-r--r--drivers/block/floppy.c17
-rw-r--r--drivers/block/loop.c18
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/pktcdvd.c27
-rw-r--r--drivers/block/rd.c4
-rw-r--r--drivers/cdrom/cdrom.c874
-rw-r--r--drivers/cdrom/cdu31a.c8
-rw-r--r--drivers/cdrom/cm206.c44
-rw-r--r--drivers/cdrom/sbpcd.c710
-rw-r--r--drivers/cdrom/viocd.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/amiserial.c18
-rw-r--r--drivers/char/generic_serial.c14
-rw-r--r--drivers/char/hvcs.c9
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/n_tty.c10
-rw-r--r--drivers/char/nwflash.c11
-rw-r--r--drivers/char/raw.c23
-rw-r--r--drivers/char/ser_a2232.c4
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc_event.c5
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/tty_io.c50
-rw-r--r--drivers/char/vme_scc.c2
-rw-r--r--drivers/char/vt.c22
-rw-r--r--drivers/char/watchdog/pcwd_usb.c7
-rw-r--r--drivers/connector/connector.c15
-rw-r--r--drivers/firmware/dcdbas.c23
-rw-r--r--drivers/ide/ide-cd.c110
-rw-r--r--drivers/ide/ide-disk.c11
-rw-r--r--drivers/ide/ide-floppy.c11
-rw-r--r--drivers/ide/ide-tape.c19
-rw-r--r--drivers/isdn/capi/kcapi.c17
-rw-r--r--drivers/isdn/hisax/config.c1
-rw-r--r--drivers/isdn/hisax/elsa.c1
-rw-r--r--drivers/macintosh/macio_asic.c5
-rw-r--r--drivers/macintosh/smu.c4
-rw-r--r--drivers/macintosh/therm_pm72.c2
-rw-r--r--drivers/macintosh/via-pmu.c5
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c1
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/Makefile4
-rw-r--r--drivers/net/au1000_eth.c18
-rw-r--r--drivers/net/depca.c2
-rw-r--r--drivers/net/ixp2000/enp2611.c2
-rw-r--r--drivers/net/ixp2000/ixpdev.c2
-rw-r--r--drivers/net/loopback.c4
-rw-r--r--drivers/net/ppp_generic.c25
-rw-r--r--drivers/net/sis900.c1
-rw-r--r--drivers/net/skge.c105
-rw-r--r--drivers/net/skge.h1
-rw-r--r--drivers/net/sky2.c33
-rw-r--r--drivers/net/sky2.h71
-rw-r--r--drivers/net/tulip/de2104x.c2
-rw-r--r--drivers/oprofile/cpu_buffer.c3
-rw-r--r--drivers/parport/parport_serial.c75
-rw-r--r--drivers/pnp/pnpbios/rsparser.c6
-rw-r--r--drivers/s390/block/dasd_ioctl.c8
-rw-r--r--drivers/s390/net/qeth_main.c57
-rw-r--r--drivers/s390/net/qeth_proc.c56
-rw-r--r--drivers/s390/net/qeth_sys.c2
-rw-r--r--drivers/scsi/Kconfig4
-rw-r--r--drivers/scsi/Makefile4
-rw-r--r--drivers/scsi/ahci.c135
-rw-r--r--drivers/scsi/ide-scsi.c11
-rw-r--r--drivers/scsi/libata-bmdma.c39
-rw-r--r--drivers/scsi/libata-core.c140
-rw-r--r--drivers/scsi/libata-scsi.c140
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/sata_mv.c5
-rw-r--r--drivers/scsi/sata_svw.c56
-rw-r--r--drivers/scsi/sata_vsc.c124
-rw-r--r--drivers/scsi/sr.c37
-rw-r--r--drivers/scsi/sr.h1
-rw-r--r--drivers/scsi/sr_ioctl.c19
-rw-r--r--drivers/serial/21285.c19
-rw-r--r--drivers/serial/68328serial.c9
-rw-r--r--drivers/serial/8250.c26
-rw-r--r--drivers/serial/8250_early.c9
-rw-r--r--drivers/serial/amba-pl010.c24
-rw-r--r--drivers/serial/amba-pl011.c20
-rw-r--r--drivers/serial/at91_serial.c24
-rw-r--r--drivers/serial/au1x00_uart.c37
-rw-r--r--drivers/serial/clps711x.c24
-rw-r--r--drivers/serial/crisv10.c68
-rw-r--r--drivers/serial/dz.c12
-rw-r--r--drivers/serial/imx.c26
-rw-r--r--drivers/serial/ip22zilog.c11
-rw-r--r--drivers/serial/m32r_sio.c41
-rw-r--r--drivers/serial/mpc52xx_uart.c11
-rw-r--r--drivers/serial/pmac_zilog.c23
-rw-r--r--drivers/serial/pxa.c26
-rw-r--r--drivers/serial/s3c2410.c26
-rw-r--r--drivers/serial/sa1100.c26
-rw-r--r--drivers/serial/serial_core.c21
-rw-r--r--drivers/serial/serial_lh7a40x.c17
-rw-r--r--drivers/serial/serial_txx9.c26
-rw-r--r--drivers/serial/sunsab.c10
-rw-r--r--drivers/serial/sunsu.c39
-rw-r--r--drivers/serial/sunzilog.c13
-rw-r--r--drivers/serial/vr41xx_siu.c16
-rw-r--r--drivers/tc/zs.c9
107 files changed, 2080 insertions, 1871 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);
3269clean1: 3269clean1:
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];
413static struct timer_list motor_off_timer[N_DRIVE]; 414static struct timer_list motor_off_timer[N_DRIVE];
414static struct gendisk *disks[N_DRIVE]; 415static struct gendisk *disks[N_DRIVE];
415static struct block_device *opened_bdev[N_DRIVE]; 416static struct block_device *opened_bdev[N_DRIVE];
416static DECLARE_MUTEX(open_lock); 417static DEFINE_MUTEX(open_lock);
417static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; 418static 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;
3790out: 3791out:
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();
3798out2: 3799out2:
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 @@
81static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 82static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
82static struct proc_dir_entry *pkt_proc; 83static struct proc_dir_entry *pkt_proc;
83static int pkt_major; 84static int pkt_major;
84static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ 85static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
85static mempool_t *psd_pool; 86static 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
2050out_dec: 2051out_dec:
2051 pd->refcnt--; 2052 pd->refcnt--;
2052out: 2053out:
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 2198static 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 */
2203int 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); 2231static 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); 2248static 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: { 2257static 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 */ 2273static 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: { 2302static 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)) 2330static 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: { 2339static 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: { 2349static 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
2374static 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
2387static 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
2406static 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 2417static 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: { 2429static 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: { 2449static 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 */
2481static 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
2511static 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
2517static 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
2550static 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
2573static 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
2603static 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
2617static 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}
2635static 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
2649static 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
2669static 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 */
2689int 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
2671static int scd_dev_ioctl(struct cdrom_device_info *cdi, 2671static 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
1164static 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
1186static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) 1160static 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)
1350static int cm206_block_ioctl(struct inode *inode, struct file *file, 1323static 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 */
4168static 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
4489static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd, 4163static 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,
4788static void sbp_transfer(struct request *req) 4462static 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
5376static int sbpcd_block_media_changed(struct gendisk *disk) 5369static 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
633static int __init find_capability(const char *type) 633static int __init find_capability(const char *type)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 05ba410682a3..b524f5ba78a9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -695,7 +695,7 @@ config NVRAM
695 695
696config RTC 696config RTC
697 tristate "Enhanced Real Time Clock Support" 697 tristate "Enhanced Real Time Clock Support"
698 depends on !PPC32 && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV 698 depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV
699 ---help--- 699 ---help---
700 If you say Y here and create a character special file /dev/rtc with 700 If you say Y here and create a character special file /dev/rtc with
701 major number 10 and minor number 135 using mknod ("man mknod"), you 701 major number 10 and minor number 135 using mknod ("man mknod"), you
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
103static char *serial_name = "Amiga-builtin serial driver"; 97static 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 */
256static _INLINE_ void rs_sched_event(struct async_struct *info, 250static 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
263static _INLINE_ void receive_chars(struct async_struct *info) 257static 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
352static _INLINE_ void transmit_chars(struct async_struct *info) 346static 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
392static _INLINE_ void check_modem_status(struct async_struct *info) 386static 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 */
1962static _INLINE_ void show_serial_version(void) 1956static 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/hvcs.c b/drivers/char/hvcs.c
index 831eb4e8d9d3..f7ac31856572 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -118,7 +118,7 @@
118 * the hvcs_final_close() function in order to get it out of the spinlock. 118 * the hvcs_final_close() function in order to get it out of the spinlock.
119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping 119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping
120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from 120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from
121 * arch/ppc64/hvcserver.h. 121 * include/asm-powerpc/hvcserver.h
122 * 122 *
123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to 123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to
124 * prevent possible lockup with realtime scheduling as similarily pointed out by 124 * prevent possible lockup with realtime scheduling as similarily pointed out by
@@ -168,9 +168,10 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
168 168
169/* 169/*
170 * The hcall interface involves putting 8 chars into each of two registers. 170 * The hcall interface involves putting 8 chars into each of two registers.
171 * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16] 171 * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c)
172 * to long[2]. It would work without __ALIGNED__, but a little (tiny) bit 172 * by casting char[16] to long[2]. It would work without __ALIGNED__, but a
173 * slower because an unaligned load is slower than aligned load. 173 * little (tiny) bit slower because an unaligned load is slower than aligned
174 * load.
174 */ 175 */
175#define __ALIGNED__ __attribute__((__aligned__(8))) 176#define __ALIGNED__ __attribute__((__aligned__(8)))
176 177
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 */
183static char *stli_tmpwritebuf; 183static char *stli_tmpwritebuf;
184static 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;
56static int gbWriteBase64Enable; 57static int gbWriteBase64Enable;
57static volatile unsigned char *FLASH_BASE; 58static volatile unsigned char *FLASH_BASE;
58static int gbFlashSize = KFLASH_SIZE; 59static int gbFlashSize = KFLASH_SIZE;
59static DECLARE_MUTEX(nwflash_sem); 60static DEFINE_MUTEX(nwflash_mutex);
60 61
61extern spinlock_t gpio_lock; 62extern 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
30static struct class *raw_class; 31static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 32static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 33static DEFINE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 34static 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
84out2: 85out2:
@@ -86,7 +87,7 @@ out2:
86out1: 87out1:
87 blkdev_put(bdev); 88 blkdev_put(bdev);
88out: 89out:
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 */
150static char *stl_tmpwritebuf; 150static char *stl_tmpwritebuf;
151static 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 */
133DECLARE_MUTEX(tty_sem); 133DEFINE_MUTEX(tty_mutex);
134 134
135#ifdef CONFIG_UNIX98_PTYS 135#ifdef CONFIG_UNIX98_PTYS
136extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ 136extern 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 */
1449static int init_dev(struct tty_driver *driver, int idx, 1449static int init_dev(struct tty_driver *driver, int idx,
@@ -1640,7 +1640,7 @@ fast_track:
1640success: 1640success:
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 */
1644end_init: 1644end_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 }
2082got_driver: 2082got_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 */
2498static void con_close(struct tty_struct *tty, struct file *filp) 2498static 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
2521static void vc_init(struct vc_data *vc, unsigned int rows, 2521static 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 */
2876static void blank_screen_t(unsigned long dummy) 2876static 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
3237int 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 {
143static struct usb_pcwd_private *usb_pcwd_device; 144static struct usb_pcwd_private *usb_pcwd_device;
144 145
145/* prevent races between open() and disconnect() */ 146/* prevent races between open() and disconnect() */
146static DECLARE_MUTEX (disconnect_sem); 147static DEFINE_MUTEX(disconnect_mutex);
147 148
148/* local function prototypes */ 149/* local function prototypes */
149static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); 150static 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);
41MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); 42MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
42MODULE_PARM_DESC(cn_val, "Connector's main device val."); 43MODULE_PARM_DESC(cn_val, "Connector's main device val.");
43 44
44static DECLARE_MUTEX(notify_lock); 45static DEFINE_MUTEX(notify_lock);
45static LIST_HEAD(notify_list); 46static LIST_HEAD(notify_list);
46 47
47static struct cn_dev cdev; 48static 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(&notify_lock); 264 mutex_lock(&notify_lock);
264 list_for_each_entry(ent, &notify_list, notify_entry) { 265 list_for_each_entry(ent, &notify_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(&notify_lock); 297 mutex_unlock(&notify_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(&notify_lock); 411 mutex_lock(&notify_lock);
411 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) { 412 list_for_each_entry_safe(ent, n, &notify_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(&notify_lock); 418 mutex_unlock(&notify_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(&notify_lock); 433 mutex_lock(&notify_lock);
433 list_add(&ent->notify_entry, &notify_list); 434 list_add(&ent->notify_entry, &notify_list);
434 up(&notify_lock); 435 mutex_unlock(&notify_lock);
435} 436}
436 437
437static int __init cn_init(void) 438static 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;
48static dma_addr_t smi_data_buf_handle; 49static dma_addr_t smi_data_buf_handle;
49static unsigned long smi_data_buf_size; 50static unsigned long smi_data_buf_size;
50static u32 smi_data_buf_phys_addr; 51static u32 smi_data_buf_phys_addr;
51static DECLARE_MUTEX(smi_data_lock); 52static DEFINE_MUTEX(smi_data_lock);
52 53
53static unsigned int host_control_action; 54static unsigned int host_control_action;
54static unsigned int host_control_smi_type; 55static 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);
167out: 168out:
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;
185out: 186out:
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
336out: 337out:
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
327static DECLARE_MUTEX(idecd_ref_sem); 328static 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
348static void ide_cd_put(struct cdrom_info *cd) 349static 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
2473static 2474static
2474int 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
2519static
2520int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, 2475int 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
3324static 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
3344static 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
3370static int idecd_ioctl (struct inode *inode, struct file *file, 3363static 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
81static DECLARE_MUTEX(idedisk_ref_sem); 82static 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
102static void ide_disk_put(struct ide_disk_obj *idkp) 103static 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
520static DECLARE_MUTEX(idefloppy_ref_sem); 521static 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
541static void ide_floppy_put(struct ide_floppy_obj *floppy) 542static 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
1014static DECLARE_MUTEX(idetape_ref_sem); 1015static DEFINE_MUTEX(idetape_ref_mutex);
1015 1016
1016static struct class *idetape_sysfs_class; 1017static 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
1037static void ide_tape_put(struct ide_tape_obj *tape) 1038static 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
36static char *revision = "$Revision: 1.1.2.8 $"; 37static char *revision = "$Revision: 1.1.2.8 $";
37 38
@@ -66,7 +67,7 @@ LIST_HEAD(capi_drivers);
66DEFINE_RWLOCK(capi_drivers_list_lock); 67DEFINE_RWLOCK(capi_drivers_list_lock);
67 68
68static DEFINE_RWLOCK(application_lock); 69static DEFINE_RWLOCK(application_lock);
69static DECLARE_MUTEX(controller_sem); 70static DEFINE_MUTEX(controller_mutex);
70 71
71struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 72struct capi20_appl *capi_applications[CAPI_MAXAPPL];
72struct capi_ctr *capi_cards[CAPI_MAXCONTR]; 73struct 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/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 69596f6438e9..431bd37225a1 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -550,15 +550,12 @@ static void macio_pci_add_devices(struct macio_chip *chip)
550 */ 550 */
551int macio_register_driver(struct macio_driver *drv) 551int macio_register_driver(struct macio_driver *drv)
552{ 552{
553 int count = 0;
554
555 /* initialize common driver fields */ 553 /* initialize common driver fields */
556 drv->driver.name = drv->name; 554 drv->driver.name = drv->name;
557 drv->driver.bus = &macio_bus_type; 555 drv->driver.bus = &macio_bus_type;
558 556
559 /* register with core */ 557 /* register with core */
560 count = driver_register(&drv->driver); 558 return driver_register(&drv->driver);
561 return count ? count : 1;
562} 559}
563 560
564/** 561/**
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index db2ae71d07ef..4eb05d7143d8 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -629,8 +629,6 @@ static struct of_platform_driver smu_of_platform_driver =
629 629
630static int __init smu_init_sysfs(void) 630static int __init smu_init_sysfs(void)
631{ 631{
632 int rc;
633
634 /* 632 /*
635 * Due to sysfs bogosity, a sysdev is not a real device, so 633 * Due to sysfs bogosity, a sysdev is not a real device, so
636 * we should in fact create both if we want sysdev semantics 634 * we should in fact create both if we want sysdev semantics
@@ -639,7 +637,7 @@ static int __init smu_init_sysfs(void)
639 * I'm a bit too far from figuring out how that works with those 637 * I'm a bit too far from figuring out how that works with those
640 * new chipsets, but that will come back and bite us 638 * new chipsets, but that will come back and bite us
641 */ 639 */
642 rc = of_register_driver(&smu_of_platform_driver); 640 of_register_driver(&smu_of_platform_driver);
643 return 0; 641 return 0;
644} 642}
645 643
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4f50ee5767a2..231146f439dd 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -104,7 +104,6 @@
104#include <linux/kernel.h> 104#include <linux/kernel.h>
105#include <linux/delay.h> 105#include <linux/delay.h>
106#include <linux/sched.h> 106#include <linux/sched.h>
107#include <linux/i2c.h>
108#include <linux/slab.h> 107#include <linux/slab.h>
109#include <linux/init.h> 108#include <linux/init.h>
110#include <linux/spinlock.h> 109#include <linux/spinlock.h>
@@ -113,7 +112,6 @@
113#include <linux/reboot.h> 112#include <linux/reboot.h>
114#include <linux/kmod.h> 113#include <linux/kmod.h>
115#include <linux/i2c.h> 114#include <linux/i2c.h>
116#include <linux/i2c-dev.h>
117#include <asm/prom.h> 115#include <asm/prom.h>
118#include <asm/machdep.h> 116#include <asm/machdep.h>
119#include <asm/io.h> 117#include <asm/io.h>
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4a478eb0e27d..4f5f3abc9cb3 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -161,7 +161,9 @@ static int drop_interrupts;
161#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 161#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
162static int option_lid_wakeup = 1; 162static int option_lid_wakeup = 1;
163#endif /* CONFIG_PM && CONFIG_PPC32 */ 163#endif /* CONFIG_PM && CONFIG_PPC32 */
164#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT)
164static int sleep_in_progress; 165static int sleep_in_progress;
166#endif
165static unsigned long async_req_locks; 167static unsigned long async_req_locks;
166static unsigned int pmu_irq_stats[11]; 168static unsigned int pmu_irq_stats[11];
167 169
@@ -2201,8 +2203,7 @@ pmac_wakeup_devices(void)
2201#define GRACKLE_NAP (1<<4) 2203#define GRACKLE_NAP (1<<4)
2202#define GRACKLE_SLEEP (1<<3) 2204#define GRACKLE_SLEEP (1<<3)
2203 2205
2204int 2206static int powerbook_sleep_grackle(void)
2205powerbook_sleep_grackle(void)
2206{ 2207{
2207 unsigned long save_l2cr; 2208 unsigned long save_l2cr;
2208 unsigned short pmcr1; 2209 unsigned short pmcr1;
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 423bfa2432c0..3f7967feaf5b 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -15,7 +15,6 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/wait.h> 16#include <linux/wait.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/i2c-dev.h>
19#include <asm/prom.h> 18#include <asm/prom.h>
20#include <asm/machdep.h> 19#include <asm/machdep.h>
21#include <asm/io.h> 20#include <asm/io.h>
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index 8e99d408fddd..eae1189d6c41 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -11,7 +11,6 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/i2c-dev.h>
15#include <asm/prom.h> 14#include <asm/prom.h>
16#include <asm/pmac_low_i2c.h> 15#include <asm/pmac_low_i2c.h>
17 16
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 24e51d5e97fc..e295a07a1ebc 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/i2c-dev.h>
17#include <asm/semaphore.h> 16#include <asm/semaphore.h>
18#include <asm/prom.h> 17#include <asm/prom.h>
19#include <asm/smu.h> 18#include <asm/smu.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 00993e8ba589..e20b849a22e8 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2172,6 +2172,7 @@ config BNX2
2172config SPIDER_NET 2172config SPIDER_NET
2173 tristate "Spider Gigabit Ethernet driver" 2173 tristate "Spider Gigabit Ethernet driver"
2174 depends on PCI && PPC_CELL 2174 depends on PCI && PPC_CELL
2175 select FW_LOADER
2175 help 2176 help
2176 This driver supports the Gigabit Ethernet chips present on the 2177 This driver supports the Gigabit Ethernet chips present on the
2177 Cell Processor-Based Blades from IBM. 2178 Cell Processor-Based Blades from IBM.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 00e72b12fb92..b90468aea077 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -58,8 +58,8 @@ obj-$(CONFIG_STNIC) += stnic.o 8390.o
58obj-$(CONFIG_FEALNX) += fealnx.o 58obj-$(CONFIG_FEALNX) += fealnx.o
59obj-$(CONFIG_TIGON3) += tg3.o 59obj-$(CONFIG_TIGON3) += tg3.o
60obj-$(CONFIG_BNX2) += bnx2.o 60obj-$(CONFIG_BNX2) += bnx2.o
61spidernet-y += spider_net.o spider_net_ethtool.o sungem_phy.o 61spidernet-y += spider_net.o spider_net_ethtool.o
62obj-$(CONFIG_SPIDER_NET) += spidernet.o 62obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o
63obj-$(CONFIG_TC35815) += tc35815.o 63obj-$(CONFIG_TC35815) += tc35815.o
64obj-$(CONFIG_SKGE) += skge.o 64obj-$(CONFIG_SKGE) += skge.o
65obj-$(CONFIG_SKY2) += sky2.o 65obj-$(CONFIG_SKY2) += sky2.o
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index cd0b1dccfb61..1363083b4d83 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -90,8 +90,6 @@ static void au1000_tx_timeout(struct net_device *);
90static int au1000_set_config(struct net_device *dev, struct ifmap *map); 90static int au1000_set_config(struct net_device *dev, struct ifmap *map);
91static void set_rx_mode(struct net_device *); 91static void set_rx_mode(struct net_device *);
92static struct net_device_stats *au1000_get_stats(struct net_device *); 92static struct net_device_stats *au1000_get_stats(struct net_device *);
93static inline void update_tx_stats(struct net_device *, u32, u32);
94static inline void update_rx_stats(struct net_device *, u32);
95static void au1000_timer(unsigned long); 93static void au1000_timer(unsigned long);
96static int au1000_ioctl(struct net_device *, struct ifreq *, int); 94static int au1000_ioctl(struct net_device *, struct ifreq *, int);
97static int mdio_read(struct net_device *, int, int); 95static int mdio_read(struct net_device *, int, int);
@@ -1825,16 +1823,11 @@ static void __exit au1000_cleanup_module(void)
1825 } 1823 }
1826} 1824}
1827 1825
1828 1826static void update_tx_stats(struct net_device *dev, u32 status)
1829static inline void
1830update_tx_stats(struct net_device *dev, u32 status, u32 pkt_len)
1831{ 1827{
1832 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1828 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1833 struct net_device_stats *ps = &aup->stats; 1829 struct net_device_stats *ps = &aup->stats;
1834 1830
1835 ps->tx_packets++;
1836 ps->tx_bytes += pkt_len;
1837
1838 if (status & TX_FRAME_ABORTED) { 1831 if (status & TX_FRAME_ABORTED) {
1839 if (dev->if_port == IF_PORT_100BASEFX) { 1832 if (dev->if_port == IF_PORT_100BASEFX) {
1840 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) { 1833 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) {
@@ -1867,7 +1860,7 @@ static void au1000_tx_ack(struct net_device *dev)
1867 ptxd = aup->tx_dma_ring[aup->tx_tail]; 1860 ptxd = aup->tx_dma_ring[aup->tx_tail];
1868 1861
1869 while (ptxd->buff_stat & TX_T_DONE) { 1862 while (ptxd->buff_stat & TX_T_DONE) {
1870 update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff); 1863 update_tx_stats(dev, ptxd->status);
1871 ptxd->buff_stat &= ~TX_T_DONE; 1864 ptxd->buff_stat &= ~TX_T_DONE;
1872 ptxd->len = 0; 1865 ptxd->len = 0;
1873 au_sync(); 1866 au_sync();
@@ -1889,6 +1882,7 @@ static void au1000_tx_ack(struct net_device *dev)
1889static int au1000_tx(struct sk_buff *skb, struct net_device *dev) 1882static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1890{ 1883{
1891 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1884 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1885 struct net_device_stats *ps = &aup->stats;
1892 volatile tx_dma_t *ptxd; 1886 volatile tx_dma_t *ptxd;
1893 u32 buff_stat; 1887 u32 buff_stat;
1894 db_dest_t *pDB; 1888 db_dest_t *pDB;
@@ -1908,7 +1902,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1908 return 1; 1902 return 1;
1909 } 1903 }
1910 else if (buff_stat & TX_T_DONE) { 1904 else if (buff_stat & TX_T_DONE) {
1911 update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff); 1905 update_tx_stats(dev, ptxd->status);
1912 ptxd->len = 0; 1906 ptxd->len = 0;
1913 } 1907 }
1914 1908
@@ -1928,6 +1922,9 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1928 else 1922 else
1929 ptxd->len = skb->len; 1923 ptxd->len = skb->len;
1930 1924
1925 ps->tx_packets++;
1926 ps->tx_bytes += ptxd->len;
1927
1931 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE; 1928 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
1932 au_sync(); 1929 au_sync();
1933 dev_kfree_skb(skb); 1930 dev_kfree_skb(skb);
@@ -1936,7 +1933,6 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1936 return 0; 1933 return 0;
1937} 1934}
1938 1935
1939
1940static inline void update_rx_stats(struct net_device *dev, u32 status) 1936static inline void update_rx_stats(struct net_device *dev, u32 status)
1941{ 1937{
1942 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1938 struct au1000_private *aup = (struct au1000_private *) dev->priv;
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 03804cc38be0..0941d40f046f 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1412,7 +1412,7 @@ static int __init depca_mca_probe(struct device *device)
1412 irq = 11; 1412 irq = 11;
1413 break; 1413 break;
1414 default: 1414 default:
1415 printk("%s: mca_probe IRQ error. You should never get here (%d).\n", dev->name, where); 1415 printk("%s: mca_probe IRQ error. You should never get here (%d).\n", mdev->name, where);
1416 return -EINVAL; 1416 return -EINVAL;
1417 } 1417 }
1418 1418
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c
index d82651a97bae..6f7dce8eba51 100644
--- a/drivers/net/ixp2000/enp2611.c
+++ b/drivers/net/ixp2000/enp2611.c
@@ -16,7 +16,7 @@
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h> 19#include <asm/hardware/uengine.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include "ixpdev.h" 22#include "ixpdev.h"
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 09f03f493bea..77f104a005f3 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -16,7 +16,7 @@
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h> 19#include <asm/hardware/uengine.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include "ixp2400_rx.ucode" 22#include "ixp2400_rx.ucode"
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);
198static void cardmap_destroy(struct cardmap **map); 199static 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 */
205static DECLARE_MUTEX(all_ppp_sem); 206static DEFINE_MUTEX(all_ppp_mutex);
206static struct cardmap *all_ppp_units; 207static struct cardmap *all_ppp_units;
207static atomic_t ppp_unit_count = ATOMIC_INIT(0); 208static 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
2472out2: 2473out2:
2473 up(&all_ppp_sem); 2474 mutex_unlock(&all_ppp_mutex);
2474 free_netdev(dev); 2475 free_netdev(dev);
2475out1: 2476out1:
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 */
2561static struct ppp * 2562static struct ppp *
2562ppp_find_unit(int unit) 2563ppp_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/net/sis900.c b/drivers/net/sis900.c
index a1cb07cdb60f..253440a98022 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -128,6 +128,7 @@ static const struct mii_chip_info {
128 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN }, 128 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN },
129 { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN }, 129 { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN },
130 { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN }, 130 { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN },
131 { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN },
131 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN }, 132 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN },
132 { "AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, HOME}, 133 { "AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, HOME},
133 { "ICS LAN PHY", 0x0015, 0xF440, LAN }, 134 { "ICS LAN PHY", 0x0015, 0xF440, LAN },
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 4eda81d41b10..35dbf05c7f06 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -44,7 +44,7 @@
44#include "skge.h" 44#include "skge.h"
45 45
46#define DRV_NAME "skge" 46#define DRV_NAME "skge"
47#define DRV_VERSION "1.4" 47#define DRV_VERSION "1.5"
48#define PFX DRV_NAME " " 48#define PFX DRV_NAME " "
49 49
50#define DEFAULT_TX_RING_SIZE 128 50#define DEFAULT_TX_RING_SIZE 128
@@ -357,7 +357,7 @@ static struct net_device_stats *skge_get_stats(struct net_device *dev)
357 skge->net_stats.rx_bytes = data[1]; 357 skge->net_stats.rx_bytes = data[1];
358 skge->net_stats.tx_packets = data[2] + data[4] + data[6]; 358 skge->net_stats.tx_packets = data[2] + data[4] + data[6];
359 skge->net_stats.rx_packets = data[3] + data[5] + data[7]; 359 skge->net_stats.rx_packets = data[3] + data[5] + data[7];
360 skge->net_stats.multicast = data[5] + data[7]; 360 skge->net_stats.multicast = data[3] + data[5];
361 skge->net_stats.collisions = data[10]; 361 skge->net_stats.collisions = data[10];
362 skge->net_stats.tx_aborted_errors = data[12]; 362 skge->net_stats.tx_aborted_errors = data[12];
363 363
@@ -781,7 +781,7 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
781 * Note: DMA address is not changed by chip. 781 * Note: DMA address is not changed by chip.
782 * MTU not changed while receiver active. 782 * MTU not changed while receiver active.
783 */ 783 */
784static void skge_rx_reuse(struct skge_element *e, unsigned int size) 784static inline void skge_rx_reuse(struct skge_element *e, unsigned int size)
785{ 785{
786 struct skge_rx_desc *rd = e->desc; 786 struct skge_rx_desc *rd = e->desc;
787 787
@@ -829,7 +829,7 @@ static int skge_rx_fill(struct skge_port *skge)
829 do { 829 do {
830 struct sk_buff *skb; 830 struct sk_buff *skb;
831 831
832 skb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN); 832 skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
833 if (!skb) 833 if (!skb)
834 return -ENOMEM; 834 return -ENOMEM;
835 835
@@ -847,8 +847,7 @@ static void skge_link_up(struct skge_port *skge)
847 LED_BLK_OFF|LED_SYNC_OFF|LED_ON); 847 LED_BLK_OFF|LED_SYNC_OFF|LED_ON);
848 848
849 netif_carrier_on(skge->netdev); 849 netif_carrier_on(skge->netdev);
850 if (skge->tx_avail > MAX_SKB_FRAGS + 1) 850 netif_wake_queue(skge->netdev);
851 netif_wake_queue(skge->netdev);
852 851
853 if (netif_msg_link(skge)) 852 if (netif_msg_link(skge))
854 printk(KERN_INFO PFX 853 printk(KERN_INFO PFX
@@ -2155,7 +2154,7 @@ static int skge_up(struct net_device *dev)
2155 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); 2154 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
2156 2155
2157 if (dev->mtu > RX_BUF_SIZE) 2156 if (dev->mtu > RX_BUF_SIZE)
2158 skge->rx_buf_size = dev->mtu + ETH_HLEN + NET_IP_ALIGN; 2157 skge->rx_buf_size = dev->mtu + ETH_HLEN;
2159 else 2158 else
2160 skge->rx_buf_size = RX_BUF_SIZE; 2159 skge->rx_buf_size = RX_BUF_SIZE;
2161 2160
@@ -2190,8 +2189,6 @@ static int skge_up(struct net_device *dev)
2190 if (err) 2189 if (err)
2191 goto free_rx_ring; 2190 goto free_rx_ring;
2192 2191
2193 skge->tx_avail = skge->tx_ring.count - 1;
2194
2195 /* Initialize MAC */ 2192 /* Initialize MAC */
2196 spin_lock_bh(&hw->phy_lock); 2193 spin_lock_bh(&hw->phy_lock);
2197 if (hw->chip_id == CHIP_ID_GENESIS) 2194 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2294,6 +2291,12 @@ static int skge_down(struct net_device *dev)
2294 return 0; 2291 return 0;
2295} 2292}
2296 2293
2294static inline int skge_avail(const struct skge_ring *ring)
2295{
2296 return ((ring->to_clean > ring->to_use) ? 0 : ring->count)
2297 + (ring->to_clean - ring->to_use) - 1;
2298}
2299
2297static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev) 2300static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2298{ 2301{
2299 struct skge_port *skge = netdev_priv(dev); 2302 struct skge_port *skge = netdev_priv(dev);
@@ -2314,7 +2317,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2314 return NETDEV_TX_LOCKED; 2317 return NETDEV_TX_LOCKED;
2315 } 2318 }
2316 2319
2317 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2320 if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) {
2318 if (!netif_queue_stopped(dev)) { 2321 if (!netif_queue_stopped(dev)) {
2319 netif_stop_queue(dev); 2322 netif_stop_queue(dev);
2320 2323
@@ -2390,8 +2393,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2390 dev->name, e - ring->start, skb->len); 2393 dev->name, e - ring->start, skb->len);
2391 2394
2392 ring->to_use = e->next; 2395 ring->to_use = e->next;
2393 skge->tx_avail -= skb_shinfo(skb)->nr_frags + 1; 2396 if (skge_avail(&skge->tx_ring) <= MAX_SKB_FRAGS + 1) {
2394 if (skge->tx_avail <= MAX_SKB_FRAGS + 1) {
2395 pr_debug("%s: transmit queue full\n", dev->name); 2397 pr_debug("%s: transmit queue full\n", dev->name);
2396 netif_stop_queue(dev); 2398 netif_stop_queue(dev);
2397 } 2399 }
@@ -2404,35 +2406,37 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2404 return NETDEV_TX_OK; 2406 return NETDEV_TX_OK;
2405} 2407}
2406 2408
2407static inline void skge_tx_free(struct skge_hw *hw, struct skge_element *e) 2409static void skge_tx_complete(struct skge_port *skge, struct skge_element *last)
2408{ 2410{
2409 /* This ring element can be skb or fragment */ 2411 struct pci_dev *pdev = skge->hw->pdev;
2410 if (e->skb) { 2412 struct skge_element *e;
2411 pci_unmap_single(hw->pdev, 2413
2412 pci_unmap_addr(e, mapaddr), 2414 for (e = skge->tx_ring.to_clean; e != last; e = e->next) {
2413 pci_unmap_len(e, maplen), 2415 struct sk_buff *skb = e->skb;
2414 PCI_DMA_TODEVICE); 2416 int i;
2415 dev_kfree_skb(e->skb); 2417
2416 e->skb = NULL; 2418 e->skb = NULL;
2417 } else { 2419 pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
2418 pci_unmap_page(hw->pdev, 2420 skb_headlen(skb), PCI_DMA_TODEVICE);
2419 pci_unmap_addr(e, mapaddr), 2421
2420 pci_unmap_len(e, maplen), 2422 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2421 PCI_DMA_TODEVICE); 2423 e = e->next;
2424 pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
2425 skb_shinfo(skb)->frags[i].size,
2426 PCI_DMA_TODEVICE);
2427 }
2428
2429 dev_kfree_skb(skb);
2422 } 2430 }
2431 skge->tx_ring.to_clean = e;
2423} 2432}
2424 2433
2425static void skge_tx_clean(struct skge_port *skge) 2434static void skge_tx_clean(struct skge_port *skge)
2426{ 2435{
2427 struct skge_ring *ring = &skge->tx_ring;
2428 struct skge_element *e;
2429 2436
2430 spin_lock_bh(&skge->tx_lock); 2437 spin_lock_bh(&skge->tx_lock);
2431 for (e = ring->to_clean; e != ring->to_use; e = e->next) { 2438 skge_tx_complete(skge, skge->tx_ring.to_use);
2432 ++skge->tx_avail; 2439 netif_wake_queue(skge->netdev);
2433 skge_tx_free(skge->hw, e);
2434 }
2435 ring->to_clean = e;
2436 spin_unlock_bh(&skge->tx_lock); 2440 spin_unlock_bh(&skge->tx_lock);
2437} 2441}
2438 2442
@@ -2592,7 +2596,7 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2592 goto error; 2596 goto error;
2593 2597
2594 if (len < RX_COPY_THRESHOLD) { 2598 if (len < RX_COPY_THRESHOLD) {
2595 skb = dev_alloc_skb(len + 2); 2599 skb = alloc_skb(len + 2, GFP_ATOMIC);
2596 if (!skb) 2600 if (!skb)
2597 goto resubmit; 2601 goto resubmit;
2598 2602
@@ -2607,10 +2611,11 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2607 skge_rx_reuse(e, skge->rx_buf_size); 2611 skge_rx_reuse(e, skge->rx_buf_size);
2608 } else { 2612 } else {
2609 struct sk_buff *nskb; 2613 struct sk_buff *nskb;
2610 nskb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN); 2614 nskb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_ATOMIC);
2611 if (!nskb) 2615 if (!nskb)
2612 goto resubmit; 2616 goto resubmit;
2613 2617
2618 skb_reserve(nskb, NET_IP_ALIGN);
2614 pci_unmap_single(skge->hw->pdev, 2619 pci_unmap_single(skge->hw->pdev,
2615 pci_unmap_addr(e, mapaddr), 2620 pci_unmap_addr(e, mapaddr),
2616 pci_unmap_len(e, maplen), 2621 pci_unmap_len(e, maplen),
@@ -2661,30 +2666,29 @@ resubmit:
2661static void skge_tx_done(struct skge_port *skge) 2666static void skge_tx_done(struct skge_port *skge)
2662{ 2667{
2663 struct skge_ring *ring = &skge->tx_ring; 2668 struct skge_ring *ring = &skge->tx_ring;
2664 struct skge_element *e; 2669 struct skge_element *e, *last;
2665 2670
2666 spin_lock(&skge->tx_lock); 2671 spin_lock(&skge->tx_lock);
2667 for (e = ring->to_clean; prefetch(e->next), e != ring->to_use; e = e->next) { 2672 last = ring->to_clean;
2673 for (e = ring->to_clean; e != ring->to_use; e = e->next) {
2668 struct skge_tx_desc *td = e->desc; 2674 struct skge_tx_desc *td = e->desc;
2669 u32 control;
2670 2675
2671 rmb(); 2676 if (td->control & BMU_OWN)
2672 control = td->control;
2673 if (control & BMU_OWN)
2674 break; 2677 break;
2675 2678
2676 if (unlikely(netif_msg_tx_done(skge))) 2679 if (td->control & BMU_EOF) {
2677 printk(KERN_DEBUG PFX "%s: tx done slot %td status 0x%x\n", 2680 last = e->next;
2678 skge->netdev->name, e - ring->start, td->status); 2681 if (unlikely(netif_msg_tx_done(skge)))
2679 2682 printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
2680 skge_tx_free(skge->hw, e); 2683 skge->netdev->name, e - ring->start);
2681 e->skb = NULL; 2684 }
2682 ++skge->tx_avail;
2683 } 2685 }
2684 ring->to_clean = e; 2686
2687 skge_tx_complete(skge, last);
2688
2685 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F); 2689 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
2686 2690
2687 if (skge->tx_avail > MAX_SKB_FRAGS + 1) 2691 if (skge_avail(&skge->tx_ring) > MAX_SKB_FRAGS + 1)
2688 netif_wake_queue(skge->netdev); 2692 netif_wake_queue(skge->netdev);
2689 2693
2690 spin_unlock(&skge->tx_lock); 2694 spin_unlock(&skge->tx_lock);
@@ -2718,8 +2722,7 @@ static int skge_poll(struct net_device *dev, int *budget)
2718 netif_receive_skb(skb); 2722 netif_receive_skb(skb);
2719 2723
2720 ++work_done; 2724 ++work_done;
2721 } else 2725 }
2722 skge_rx_reuse(e, skge->rx_buf_size);
2723 } 2726 }
2724 ring->to_clean = e; 2727 ring->to_clean = e;
2725 2728
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 2efdacc290e5..1f1ce88c8186 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2418,7 +2418,6 @@ struct skge_port {
2418 int port; 2418 int port;
2419 2419
2420 spinlock_t tx_lock; 2420 spinlock_t tx_lock;
2421 u32 tx_avail;
2422 struct skge_ring tx_ring; 2421 struct skge_ring tx_ring;
2423 struct skge_ring rx_ring; 2422 struct skge_ring rx_ring;
2424 2423
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index f08fe6c884b2..68f9c206a620 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1175,7 +1175,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1175 /* just drop the packet if non-linear expansion fails */ 1175 /* just drop the packet if non-linear expansion fails */
1176 if (skb_header_cloned(skb) && 1176 if (skb_header_cloned(skb) &&
1177 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { 1177 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
1178 dev_kfree_skb_any(skb); 1178 dev_kfree_skb(skb);
1179 goto out_unlock; 1179 goto out_unlock;
1180 } 1180 }
1181 1181
@@ -1324,7 +1324,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1324 PCI_DMA_TODEVICE); 1324 PCI_DMA_TODEVICE);
1325 } 1325 }
1326 1326
1327 dev_kfree_skb_any(skb); 1327 dev_kfree_skb(skb);
1328 } 1328 }
1329 1329
1330 sky2->tx_cons = put; 1330 sky2->tx_cons = put;
@@ -2478,17 +2478,34 @@ static const struct sky2_stat {
2478 { "rx_unicast", GM_RXF_UC_OK }, 2478 { "rx_unicast", GM_RXF_UC_OK },
2479 { "tx_mac_pause", GM_TXF_MPAUSE }, 2479 { "tx_mac_pause", GM_TXF_MPAUSE },
2480 { "rx_mac_pause", GM_RXF_MPAUSE }, 2480 { "rx_mac_pause", GM_RXF_MPAUSE },
2481 { "collisions", GM_TXF_SNG_COL }, 2481 { "collisions", GM_TXF_COL },
2482 { "late_collision",GM_TXF_LAT_COL }, 2482 { "late_collision",GM_TXF_LAT_COL },
2483 { "aborted", GM_TXF_ABO_COL }, 2483 { "aborted", GM_TXF_ABO_COL },
2484 { "single_collisions", GM_TXF_SNG_COL },
2484 { "multi_collisions", GM_TXF_MUL_COL }, 2485 { "multi_collisions", GM_TXF_MUL_COL },
2485 { "fifo_underrun", GM_TXE_FIFO_UR }, 2486
2486 { "fifo_overflow", GM_RXE_FIFO_OV }, 2487 { "rx_short", GM_RXF_SHT },
2487 { "rx_toolong", GM_RXF_LNG_ERR },
2488 { "rx_jabber", GM_RXF_JAB_PKT },
2489 { "rx_runt", GM_RXE_FRAG }, 2488 { "rx_runt", GM_RXE_FRAG },
2489 { "rx_64_byte_packets", GM_RXF_64B },
2490 { "rx_65_to_127_byte_packets", GM_RXF_127B },
2491 { "rx_128_to_255_byte_packets", GM_RXF_255B },
2492 { "rx_256_to_511_byte_packets", GM_RXF_511B },
2493 { "rx_512_to_1023_byte_packets", GM_RXF_1023B },
2494 { "rx_1024_to_1518_byte_packets", GM_RXF_1518B },
2495 { "rx_1518_to_max_byte_packets", GM_RXF_MAX_SZ },
2490 { "rx_too_long", GM_RXF_LNG_ERR }, 2496 { "rx_too_long", GM_RXF_LNG_ERR },
2497 { "rx_fifo_overflow", GM_RXE_FIFO_OV },
2498 { "rx_jabber", GM_RXF_JAB_PKT },
2491 { "rx_fcs_error", GM_RXF_FCS_ERR }, 2499 { "rx_fcs_error", GM_RXF_FCS_ERR },
2500
2501 { "tx_64_byte_packets", GM_TXF_64B },
2502 { "tx_65_to_127_byte_packets", GM_TXF_127B },
2503 { "tx_128_to_255_byte_packets", GM_TXF_255B },
2504 { "tx_256_to_511_byte_packets", GM_TXF_511B },
2505 { "tx_512_to_1023_byte_packets", GM_TXF_1023B },
2506 { "tx_1024_to_1518_byte_packets", GM_TXF_1518B },
2507 { "tx_1519_to_max_byte_packets", GM_TXF_MAX_SZ },
2508 { "tx_fifo_underrun", GM_TXE_FIFO_UR },
2492}; 2509};
2493 2510
2494static u32 sky2_get_rx_csum(struct net_device *dev) 2511static u32 sky2_get_rx_csum(struct net_device *dev)
@@ -2590,7 +2607,7 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
2590 sky2->net_stats.rx_bytes = data[1]; 2607 sky2->net_stats.rx_bytes = data[1];
2591 sky2->net_stats.tx_packets = data[2] + data[4] + data[6]; 2608 sky2->net_stats.tx_packets = data[2] + data[4] + data[6];
2592 sky2->net_stats.rx_packets = data[3] + data[5] + data[7]; 2609 sky2->net_stats.rx_packets = data[3] + data[5] + data[7];
2593 sky2->net_stats.multicast = data[5] + data[7]; 2610 sky2->net_stats.multicast = data[3] + data[5];
2594 sky2->net_stats.collisions = data[10]; 2611 sky2->net_stats.collisions = data[10];
2595 sky2->net_stats.tx_aborted_errors = data[12]; 2612 sky2->net_stats.tx_aborted_errors = data[12];
2596 2613
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index d63cd5a1b71c..2838f661b393 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1373,23 +1373,23 @@ enum {
1373 GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */ 1373 GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */
1374 GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */ 1374 GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */
1375 GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */ 1375 GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */
1376/* MIB Counters */
1377 GM_MIB_CNT_BASE = 0x0100, /* Base Address of MIB Counters */
1378 GM_MIB_CNT_SIZE = 256,
1376}; 1379};
1377 1380
1378/* MIB Counters */
1379#define GM_MIB_CNT_BASE 0x0100 /* Base Address of MIB Counters */
1380#define GM_MIB_CNT_SIZE 44 /* Number of MIB Counters */
1381 1381
1382/* 1382/*
1383 * MIB Counters base address definitions (low word) - 1383 * MIB Counters base address definitions (low word) -
1384 * use offset 4 for access to high word (32 bit r/o) 1384 * use offset 4 for access to high word (32 bit r/o)
1385 */ 1385 */
1386enum { 1386enum {
1387 GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */ 1387 GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */
1388 GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */ 1388 GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */
1389 GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */ 1389 GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */
1390 GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */ 1390 GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */
1391 GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */ 1391 GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */
1392 /* GM_MIB_CNT_BASE + 40: reserved */ 1392
1393 GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */ 1393 GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */
1394 GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */ 1394 GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */
1395 GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */ 1395 GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */
@@ -1397,37 +1397,36 @@ enum {
1397 GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */ 1397 GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */
1398 GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */ 1398 GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */
1399 GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */ 1399 GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */
1400 GM_RXF_127B = GM_MIB_CNT_BASE + 104, /* 65-127 Byte Rx Frame */ 1400 GM_RXF_127B = GM_MIB_CNT_BASE + 104,/* 65-127 Byte Rx Frame */
1401 GM_RXF_255B = GM_MIB_CNT_BASE + 112, /* 128-255 Byte Rx Frame */ 1401 GM_RXF_255B = GM_MIB_CNT_BASE + 112,/* 128-255 Byte Rx Frame */
1402 GM_RXF_511B = GM_MIB_CNT_BASE + 120, /* 256-511 Byte Rx Frame */ 1402 GM_RXF_511B = GM_MIB_CNT_BASE + 120,/* 256-511 Byte Rx Frame */
1403 GM_RXF_1023B = GM_MIB_CNT_BASE + 128, /* 512-1023 Byte Rx Frame */ 1403 GM_RXF_1023B = GM_MIB_CNT_BASE + 128,/* 512-1023 Byte Rx Frame */
1404 GM_RXF_1518B = GM_MIB_CNT_BASE + 136, /* 1024-1518 Byte Rx Frame */ 1404 GM_RXF_1518B = GM_MIB_CNT_BASE + 136,/* 1024-1518 Byte Rx Frame */
1405 GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144, /* 1519-MaxSize Byte Rx Frame */ 1405 GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144,/* 1519-MaxSize Byte Rx Frame */
1406 GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152, /* Rx Frame too Long Error */ 1406 GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152,/* Rx Frame too Long Error */
1407 GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160, /* Rx Jabber Packet Frame */ 1407 GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160,/* Rx Jabber Packet Frame */
1408 /* GM_MIB_CNT_BASE + 168: reserved */ 1408
1409 GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176, /* Rx FIFO overflow Event */ 1409 GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176,/* Rx FIFO overflow Event */
1410 /* GM_MIB_CNT_BASE + 184: reserved */ 1410 GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192,/* Unicast Frames Xmitted OK */
1411 GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192, /* Unicast Frames Xmitted OK */ 1411 GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200,/* Broadcast Frames Xmitted OK */
1412 GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200, /* Broadcast Frames Xmitted OK */ 1412 GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208,/* Pause MAC Ctrl Frames Xmitted */
1413 GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208, /* Pause MAC Ctrl Frames Xmitted */ 1413 GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216,/* Multicast Frames Xmitted OK */
1414 GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216, /* Multicast Frames Xmitted OK */ 1414 GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224,/* Octets Transmitted OK Low */
1415 GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224, /* Octets Transmitted OK Low */ 1415 GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232,/* Octets Transmitted OK High */
1416 GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232, /* Octets Transmitted OK High */ 1416 GM_TXF_64B = GM_MIB_CNT_BASE + 240,/* 64 Byte Tx Frame */
1417 GM_TXF_64B = GM_MIB_CNT_BASE + 240, /* 64 Byte Tx Frame */ 1417 GM_TXF_127B = GM_MIB_CNT_BASE + 248,/* 65-127 Byte Tx Frame */
1418 GM_TXF_127B = GM_MIB_CNT_BASE + 248, /* 65-127 Byte Tx Frame */ 1418 GM_TXF_255B = GM_MIB_CNT_BASE + 256,/* 128-255 Byte Tx Frame */
1419 GM_TXF_255B = GM_MIB_CNT_BASE + 256, /* 128-255 Byte Tx Frame */ 1419 GM_TXF_511B = GM_MIB_CNT_BASE + 264,/* 256-511 Byte Tx Frame */
1420 GM_TXF_511B = GM_MIB_CNT_BASE + 264, /* 256-511 Byte Tx Frame */ 1420 GM_TXF_1023B = GM_MIB_CNT_BASE + 272,/* 512-1023 Byte Tx Frame */
1421 GM_TXF_1023B = GM_MIB_CNT_BASE + 272, /* 512-1023 Byte Tx Frame */ 1421 GM_TXF_1518B = GM_MIB_CNT_BASE + 280,/* 1024-1518 Byte Tx Frame */
1422 GM_TXF_1518B = GM_MIB_CNT_BASE + 280, /* 1024-1518 Byte Tx Frame */ 1422 GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288,/* 1519-MaxSize Byte Tx Frame */
1423 GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288, /* 1519-MaxSize Byte Tx Frame */ 1423
1424 1424 GM_TXF_COL = GM_MIB_CNT_BASE + 304,/* Tx Collision */
1425 GM_TXF_COL = GM_MIB_CNT_BASE + 304, /* Tx Collision */ 1425 GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312,/* Tx Late Collision */
1426 GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312, /* Tx Late Collision */ 1426 GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320,/* Tx aborted due to Exces. Col. */
1427 GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320, /* Tx aborted due to Exces. Col. */ 1427 GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328,/* Tx Multiple Collision */
1428 GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328, /* Tx Multiple Collision */ 1428 GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336,/* Tx Single Collision */
1429 GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336, /* Tx Single Collision */ 1429 GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344,/* Tx FIFO Underrun Event */
1430 GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344, /* Tx FIFO Underrun Event */
1431}; 1430};
1432 1431
1433/* GMAC Bit Definitions */ 1432/* GMAC Bit Definitions */
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 6299e186c73f..e3dd144d326b 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1327,11 +1327,11 @@ static void de_clean_rings (struct de_private *de)
1327 struct sk_buff *skb = de->tx_skb[i].skb; 1327 struct sk_buff *skb = de->tx_skb[i].skb;
1328 if ((skb) && (skb != DE_DUMMY_SKB)) { 1328 if ((skb) && (skb != DE_DUMMY_SKB)) {
1329 if (skb != DE_SETUP_SKB) { 1329 if (skb != DE_SETUP_SKB) {
1330 dev_kfree_skb(skb);
1331 de->net_stats.tx_dropped++; 1330 de->net_stats.tx_dropped++;
1332 pci_unmap_single(de->pdev, 1331 pci_unmap_single(de->pdev,
1333 de->tx_skb[i].mapping, 1332 de->tx_skb[i].mapping,
1334 skb->len, PCI_DMA_TODEVICE); 1333 skb->len, PCI_DMA_TODEVICE);
1334 dev_kfree_skb(skb);
1335 } else { 1335 } else {
1336 pci_unmap_single(de->pdev, 1336 pci_unmap_single(de->pdev,
1337 de->tx_skb[i].mapping, 1337 de->tx_skb[i].mapping,
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
46int alloc_cpu_buffers(void) 45int alloc_cpu_buffers(void)
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 10845253c9e0..d121644646b9 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -31,14 +31,8 @@ enum parport_pc_pci_cards {
31 netmos_9xx5_combo, 31 netmos_9xx5_combo,
32 netmos_9855, 32 netmos_9855,
33 avlab_1s1p, 33 avlab_1s1p,
34 avlab_1s1p_650,
35 avlab_1s1p_850,
36 avlab_1s2p, 34 avlab_1s2p,
37 avlab_1s2p_650,
38 avlab_1s2p_850,
39 avlab_2s1p, 35 avlab_2s1p,
40 avlab_2s1p_650,
41 avlab_2s1p_850,
42 siig_1s1p_10x, 36 siig_1s1p_10x,
43 siig_2s1p_10x, 37 siig_2s1p_10x,
44 siig_2p1s_20x, 38 siig_2p1s_20x,
@@ -85,14 +79,8 @@ static struct parport_pc_pci cards[] __devinitdata = {
85 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init }, 79 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init },
86 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init }, 80 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init },
87 /* avlab_1s1p */ { 1, { { 1, 2}, } }, 81 /* avlab_1s1p */ { 1, { { 1, 2}, } },
88 /* avlab_1s1p_650 */ { 1, { { 1, 2}, } },
89 /* avlab_1s1p_850 */ { 1, { { 1, 2}, } },
90 /* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} }, 82 /* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} },
91 /* avlab_1s2p_650 */ { 2, { { 1, 2}, { 3, 4 },} },
92 /* avlab_1s2p_850 */ { 2, { { 1, 2}, { 3, 4 },} },
93 /* avlab_2s1p */ { 1, { { 2, 3}, } }, 83 /* avlab_2s1p */ { 1, { { 2, 3}, } },
94 /* avlab_2s1p_650 */ { 1, { { 2, 3}, } },
95 /* avlab_2s1p_850 */ { 1, { { 2, 3}, } },
96 /* siig_1s1p_10x */ { 1, { { 3, 4 }, } }, 84 /* siig_1s1p_10x */ { 1, { { 3, 4 }, } },
97 /* siig_2s1p_10x */ { 1, { { 4, 5 }, } }, 85 /* siig_2s1p_10x */ { 1, { { 4, 5 }, } },
98 /* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } }, 86 /* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } },
@@ -119,15 +107,24 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
119 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855, 107 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 }, 108 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 },
121 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 109 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
122 { 0x14db, 0x2110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p}, 110 { PCI_VENDOR_ID_AFAVLAB, 0x2110,
123 { 0x14db, 0x2111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_650}, 111 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
124 { 0x14db, 0x2112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_850}, 112 { PCI_VENDOR_ID_AFAVLAB, 0x2111,
125 { 0x14db, 0x2140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p}, 113 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
126 { 0x14db, 0x2141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_650}, 114 { PCI_VENDOR_ID_AFAVLAB, 0x2112,
127 { 0x14db, 0x2142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_850}, 115 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
128 { 0x14db, 0x2160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p}, 116 { PCI_VENDOR_ID_AFAVLAB, 0x2140,
129 { 0x14db, 0x2161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_650}, 117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
130 { 0x14db, 0x2162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_850}, 118 { PCI_VENDOR_ID_AFAVLAB, 0x2141,
119 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
120 { PCI_VENDOR_ID_AFAVLAB, 0x2142,
121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
122 { PCI_VENDOR_ID_AFAVLAB, 0x2160,
123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
124 { PCI_VENDOR_ID_AFAVLAB, 0x2161,
125 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
126 { PCI_VENDOR_ID_AFAVLAB, 0x2162,
127 PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
131 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550, 128 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, siig_1s1p_10x }, 129 PCI_ANY_ID, PCI_ANY_ID, 0, 0, siig_1s1p_10x },
133 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650, 130 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650,
@@ -201,54 +198,18 @@ static struct pciserial_board pci_parport_serial_boards[] __devinitdata = {
201 .base_baud = 115200, 198 .base_baud = 115200,
202 .uart_offset = 8, 199 .uart_offset = 8,
203 }, 200 },
204 [avlab_1s1p_650] = { /* nt */
205 .flags = FL_BASE0 | FL_BASE_BARS,
206 .num_ports = 1,
207 .base_baud = 115200,
208 .uart_offset = 8,
209 },
210 [avlab_1s1p_850] = { /* nt */
211 .flags = FL_BASE0 | FL_BASE_BARS,
212 .num_ports = 1,
213 .base_baud = 115200,
214 .uart_offset = 8,
215 },
216 [avlab_1s2p] = { /* n/t */ 201 [avlab_1s2p] = { /* n/t */
217 .flags = FL_BASE0 | FL_BASE_BARS, 202 .flags = FL_BASE0 | FL_BASE_BARS,
218 .num_ports = 1, 203 .num_ports = 1,
219 .base_baud = 115200, 204 .base_baud = 115200,
220 .uart_offset = 8, 205 .uart_offset = 8,
221 }, 206 },
222 [avlab_1s2p_650] = { /* nt */
223 .flags = FL_BASE0 | FL_BASE_BARS,
224 .num_ports = 1,
225 .base_baud = 115200,
226 .uart_offset = 8,
227 },
228 [avlab_1s2p_850] = { /* nt */
229 .flags = FL_BASE0 | FL_BASE_BARS,
230 .num_ports = 1,
231 .base_baud = 115200,
232 .uart_offset = 8,
233 },
234 [avlab_2s1p] = { /* n/t */ 207 [avlab_2s1p] = { /* n/t */
235 .flags = FL_BASE0 | FL_BASE_BARS, 208 .flags = FL_BASE0 | FL_BASE_BARS,
236 .num_ports = 2, 209 .num_ports = 2,
237 .base_baud = 115200, 210 .base_baud = 115200,
238 .uart_offset = 8, 211 .uart_offset = 8,
239 }, 212 },
240 [avlab_2s1p_650] = { /* nt */
241 .flags = FL_BASE0 | FL_BASE_BARS,
242 .num_ports = 2,
243 .base_baud = 115200,
244 .uart_offset = 8,
245 },
246 [avlab_2s1p_850] = { /* nt */
247 .flags = FL_BASE0 | FL_BASE_BARS,
248 .num_ports = 2,
249 .base_baud = 115200,
250 .uart_offset = 8,
251 },
252 [siig_1s1p_10x] = { 213 [siig_1s1p_10x] = {
253 .flags = FL_BASE2, 214 .flags = FL_BASE2,
254 .num_ports = 1, 215 .num_ports = 1,
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/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index dba7f7f02e79..021cd5d08c61 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1364,7 +1364,7 @@ qeth_wait_for_buffer(struct qeth_channel *channel)
1364static void 1364static void
1365qeth_clear_cmd_buffers(struct qeth_channel *channel) 1365qeth_clear_cmd_buffers(struct qeth_channel *channel)
1366{ 1366{
1367 int cnt = 0; 1367 int cnt;
1368 1368
1369 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++) 1369 for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++)
1370 qeth_release_buffer(channel,&channel->iob[cnt]); 1370 qeth_release_buffer(channel,&channel->iob[cnt]);
@@ -2814,11 +2814,11 @@ qeth_handle_send_error(struct qeth_card *card,
2814 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); 2814 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2815 return QETH_SEND_ERROR_LINK_FAILURE; 2815 return QETH_SEND_ERROR_LINK_FAILURE;
2816 case 3: 2816 case 3:
2817 default:
2817 QETH_DBF_TEXT(trace, 1, "SIGAcc3"); 2818 QETH_DBF_TEXT(trace, 1, "SIGAcc3");
2818 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); 2819 QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
2819 return QETH_SEND_ERROR_KICK_IT; 2820 return QETH_SEND_ERROR_KICK_IT;
2820 } 2821 }
2821 return QETH_SEND_ERROR_LINK_FAILURE;
2822} 2822}
2823 2823
2824void 2824void
@@ -3865,6 +3865,7 @@ qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
3865 if ((hdr_mac == QETH_TR_MAC_NC) || 3865 if ((hdr_mac == QETH_TR_MAC_NC) ||
3866 (hdr_mac == QETH_TR_MAC_C)) 3866 (hdr_mac == QETH_TR_MAC_C))
3867 return RTN_MULTICAST; 3867 return RTN_MULTICAST;
3868 break;
3868 /* eth or so multicast? */ 3869 /* eth or so multicast? */
3869 default: 3870 default:
3870 if ((hdr_mac == QETH_ETH_MAC_V4) || 3871 if ((hdr_mac == QETH_ETH_MAC_V4) ||
@@ -4419,6 +4420,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4419 int elements_needed = 0; 4420 int elements_needed = 0;
4420 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 4421 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
4421 struct qeth_eddp_context *ctx = NULL; 4422 struct qeth_eddp_context *ctx = NULL;
4423 int tx_bytes = skb->len;
4422 int rc; 4424 int rc;
4423 4425
4424 QETH_DBF_TEXT(trace, 6, "sendpkt"); 4426 QETH_DBF_TEXT(trace, 6, "sendpkt");
@@ -4499,7 +4501,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4499 elements_needed, ctx); 4501 elements_needed, ctx);
4500 if (!rc){ 4502 if (!rc){
4501 card->stats.tx_packets++; 4503 card->stats.tx_packets++;
4502 card->stats.tx_bytes += skb->len; 4504 card->stats.tx_bytes += tx_bytes;
4503#ifdef CONFIG_QETH_PERF_STATS 4505#ifdef CONFIG_QETH_PERF_STATS
4504 if (skb_shinfo(skb)->tso_size && 4506 if (skb_shinfo(skb)->tso_size &&
4505 !(large_send == QETH_LARGE_SEND_NO)) { 4507 !(large_send == QETH_LARGE_SEND_NO)) {
@@ -4585,38 +4587,11 @@ qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
4585 case MII_NCONFIG: /* network interface config */ 4587 case MII_NCONFIG: /* network interface config */
4586 break; 4588 break;
4587 default: 4589 default:
4588 rc = 0;
4589 break; 4590 break;
4590 } 4591 }
4591 return rc; 4592 return rc;
4592} 4593}
4593 4594
4594static void
4595qeth_mdio_write(struct net_device *dev, int phy_id, int regnum, int value)
4596{
4597 switch(regnum){
4598 case MII_BMCR: /* Basic mode control register */
4599 case MII_BMSR: /* Basic mode status register */
4600 case MII_PHYSID1: /* PHYS ID 1 */
4601 case MII_PHYSID2: /* PHYS ID 2 */
4602 case MII_ADVERTISE: /* Advertisement control reg */
4603 case MII_LPA: /* Link partner ability reg */
4604 case MII_EXPANSION: /* Expansion register */
4605 case MII_DCOUNTER: /* disconnect counter */
4606 case MII_FCSCOUNTER: /* false carrier counter */
4607 case MII_NWAYTEST: /* N-way auto-neg test register */
4608 case MII_RERRCOUNTER: /* rx error counter */
4609 case MII_SREVISION: /* silicon revision */
4610 case MII_RESV1: /* reserved 1 */
4611 case MII_LBRERROR: /* loopback, rx, bypass error */
4612 case MII_PHYADDR: /* physical address */
4613 case MII_RESV2: /* reserved 2 */
4614 case MII_TPISTATUS: /* TPI status for 10mbps */
4615 case MII_NCONFIG: /* network interface config */
4616 default:
4617 break;
4618 }
4619}
4620 4595
4621static inline const char * 4596static inline const char *
4622qeth_arp_get_error_cause(int *rc) 4597qeth_arp_get_error_cause(int *rc)
@@ -5236,21 +5211,6 @@ qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5236 mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id, 5211 mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id,
5237 mii_data->reg_num); 5212 mii_data->reg_num);
5238 break; 5213 break;
5239 case SIOCSMIIREG:
5240 rc = -EOPNOTSUPP;
5241 break;
5242 /* TODO: remove return if qeth_mdio_write does something */
5243 if (!capable(CAP_NET_ADMIN)){
5244 rc = -EPERM;
5245 break;
5246 }
5247 mii_data = if_mii(rq);
5248 if (mii_data->phy_id != 0)
5249 rc = -EINVAL;
5250 else
5251 qeth_mdio_write(dev, mii_data->phy_id, mii_data->reg_num,
5252 mii_data->val_in);
5253 break;
5254 default: 5214 default:
5255 rc = -EOPNOTSUPP; 5215 rc = -EOPNOTSUPP;
5256 } 5216 }
@@ -6900,7 +6860,7 @@ qeth_send_setassparms(struct qeth_card *card, struct qeth_cmd_buffer *iob,
6900 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); 6860 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
6901 if (len <= sizeof(__u32)) 6861 if (len <= sizeof(__u32))
6902 cmd->data.setassparms.data.flags_32bit = (__u32) data; 6862 cmd->data.setassparms.data.flags_32bit = (__u32) data;
6903 else if (len > sizeof(__u32)) 6863 else /* (len > sizeof(__u32)) */
6904 memcpy(&cmd->data.setassparms.data, (void *) data, len); 6864 memcpy(&cmd->data.setassparms.data, (void *) data, len);
6905 6865
6906 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param); 6866 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param);
@@ -7379,11 +7339,6 @@ qeth_setrouting_v6(struct qeth_card *card)
7379 qeth_correct_routing_type(card, &card->options.route6.type, 7339 qeth_correct_routing_type(card, &card->options.route6.type,
7380 QETH_PROT_IPV6); 7340 QETH_PROT_IPV6);
7381 7341
7382 if ((card->options.route6.type == NO_ROUTER) ||
7383 ((card->info.type == QETH_CARD_TYPE_OSAE) &&
7384 (card->options.route6.type == MULTICAST_ROUTER) &&
7385 !qeth_is_supported6(card,IPA_OSA_MC_ROUTER)))
7386 return 0;
7387 rc = qeth_send_setrouting(card, card->options.route6.type, 7342 rc = qeth_send_setrouting(card, card->options.route6.type,
7388 QETH_PROT_IPV6); 7343 QETH_PROT_IPV6);
7389 if (rc) { 7344 if (rc) {
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 3c6339df879d..360d782c7ada 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -74,7 +74,7 @@ qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
74static inline const char * 74static inline const char *
75qeth_get_router_str(struct qeth_card *card, int ipv) 75qeth_get_router_str(struct qeth_card *card, int ipv)
76{ 76{
77 int routing_type = 0; 77 enum qeth_routing_types routing_type = NO_ROUTER;
78 78
79 if (ipv == 4) { 79 if (ipv == 4) {
80 routing_type = card->options.route4.type; 80 routing_type = card->options.route4.type;
@@ -86,26 +86,26 @@ qeth_get_router_str(struct qeth_card *card, int ipv)
86#endif /* CONFIG_QETH_IPV6 */ 86#endif /* CONFIG_QETH_IPV6 */
87 } 87 }
88 88
89 if (routing_type == PRIMARY_ROUTER) 89 switch (routing_type){
90 case PRIMARY_ROUTER:
90 return "pri"; 91 return "pri";
91 else if (routing_type == SECONDARY_ROUTER) 92 case SECONDARY_ROUTER:
92 return "sec"; 93 return "sec";
93 else if (routing_type == MULTICAST_ROUTER) { 94 case MULTICAST_ROUTER:
94 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 95 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
95 return "mc+"; 96 return "mc+";
96 return "mc"; 97 return "mc";
97 } else if (routing_type == PRIMARY_CONNECTOR) { 98 case PRIMARY_CONNECTOR:
98 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 99 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
99 return "p+c"; 100 return "p+c";
100 return "p.c"; 101 return "p.c";
101 } else if (routing_type == SECONDARY_CONNECTOR) { 102 case SECONDARY_CONNECTOR:
102 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) 103 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
103 return "s+c"; 104 return "s+c";
104 return "s.c"; 105 return "s.c";
105 } else if (routing_type == NO_ROUTER) 106 default: /* NO_ROUTER */
106 return "no"; 107 return "no";
107 else 108 }
108 return "unk";
109} 109}
110 110
111static int 111static int
@@ -192,27 +192,27 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
192 CARD_DDEV_ID(card), 192 CARD_DDEV_ID(card),
193 QETH_CARD_IFNAME(card) 193 QETH_CARD_IFNAME(card)
194 ); 194 );
195 seq_printf(s, " Skb's/buffers received : %li/%i\n" 195 seq_printf(s, " Skb's/buffers received : %lu/%u\n"
196 " Skb's/buffers sent : %li/%i\n\n", 196 " Skb's/buffers sent : %lu/%u\n\n",
197 card->stats.rx_packets, card->perf_stats.bufs_rec, 197 card->stats.rx_packets, card->perf_stats.bufs_rec,
198 card->stats.tx_packets, card->perf_stats.bufs_sent 198 card->stats.tx_packets, card->perf_stats.bufs_sent
199 ); 199 );
200 seq_printf(s, " Skb's/buffers sent without packing : %li/%i\n" 200 seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n"
201 " Skb's/buffers sent with packing : %i/%i\n\n", 201 " Skb's/buffers sent with packing : %u/%u\n\n",
202 card->stats.tx_packets - card->perf_stats.skbs_sent_pack, 202 card->stats.tx_packets - card->perf_stats.skbs_sent_pack,
203 card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack, 203 card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack,
204 card->perf_stats.skbs_sent_pack, 204 card->perf_stats.skbs_sent_pack,
205 card->perf_stats.bufs_sent_pack 205 card->perf_stats.bufs_sent_pack
206 ); 206 );
207 seq_printf(s, " Skbs sent in SG mode : %i\n" 207 seq_printf(s, " Skbs sent in SG mode : %u\n"
208 " Skb fragments sent in SG mode : %i\n\n", 208 " Skb fragments sent in SG mode : %u\n\n",
209 card->perf_stats.sg_skbs_sent, 209 card->perf_stats.sg_skbs_sent,
210 card->perf_stats.sg_frags_sent); 210 card->perf_stats.sg_frags_sent);
211 seq_printf(s, " large_send tx (in Kbytes) : %i\n" 211 seq_printf(s, " large_send tx (in Kbytes) : %u\n"
212 " large_send count : %i\n\n", 212 " large_send count : %u\n\n",
213 card->perf_stats.large_send_bytes >> 10, 213 card->perf_stats.large_send_bytes >> 10,
214 card->perf_stats.large_send_cnt); 214 card->perf_stats.large_send_cnt);
215 seq_printf(s, " Packing state changes no pkg.->packing : %i/%i\n" 215 seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n"
216 " Watermarks L/H : %i/%i\n" 216 " Watermarks L/H : %i/%i\n"
217 " Current buffer usage (outbound q's) : " 217 " Current buffer usage (outbound q's) : "
218 "%i/%i/%i/%i\n\n", 218 "%i/%i/%i/%i\n\n",
@@ -229,16 +229,16 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
229 atomic_read(&card->qdio.out_qs[3]->used_buffers) 229 atomic_read(&card->qdio.out_qs[3]->used_buffers)
230 : 0 230 : 0
231 ); 231 );
232 seq_printf(s, " Inbound handler time (in us) : %i\n" 232 seq_printf(s, " Inbound handler time (in us) : %u\n"
233 " Inbound handler count : %i\n" 233 " Inbound handler count : %u\n"
234 " Inbound do_QDIO time (in us) : %i\n" 234 " Inbound do_QDIO time (in us) : %u\n"
235 " Inbound do_QDIO count : %i\n\n" 235 " Inbound do_QDIO count : %u\n\n"
236 " Outbound handler time (in us) : %i\n" 236 " Outbound handler time (in us) : %u\n"
237 " Outbound handler count : %i\n\n" 237 " Outbound handler count : %u\n\n"
238 " Outbound time (in us, incl QDIO) : %i\n" 238 " Outbound time (in us, incl QDIO) : %u\n"
239 " Outbound count : %i\n" 239 " Outbound count : %u\n"
240 " Outbound do_QDIO time (in us) : %i\n" 240 " Outbound do_QDIO time (in us) : %u\n"
241 " Outbound do_QDIO count : %i\n\n", 241 " Outbound do_QDIO count : %u\n\n",
242 card->perf_stats.inbound_time, 242 card->perf_stats.inbound_time,
243 card->perf_stats.inbound_cnt, 243 card->perf_stats.inbound_cnt,
244 card->perf_stats.inbound_do_qdio_time, 244 card->perf_stats.inbound_do_qdio_time,
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index c1831f572585..f2a076a2b2f1 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -115,7 +115,7 @@ qeth_dev_portno_store(struct device *dev, struct device_attribute *attr, const c
115 return -EPERM; 115 return -EPERM;
116 116
117 portno = simple_strtoul(buf, &tmp, 16); 117 portno = simple_strtoul(buf, &tmp, 16);
118 if ((portno < 0) || (portno > MAX_PORTNO)){ 118 if (portno > MAX_PORTNO){
119 PRINT_WARN("portno 0x%X is out of range\n", portno); 119 PRINT_WARN("portno 0x%X is out of range\n", portno);
120 return -EINVAL; 120 return -EINVAL;
121 } 121 }
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5c94a5d4efc0..4035920ce3d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -595,10 +595,10 @@ config SCSI_SATA_VIA
595 If unsure, say N. 595 If unsure, say N.
596 596
597config SCSI_SATA_VITESSE 597config SCSI_SATA_VITESSE
598 tristate "VITESSE VSC-7174 SATA support" 598 tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
599 depends on SCSI_SATA && PCI 599 depends on SCSI_SATA && PCI
600 help 600 help
601 This option enables support for Vitesse VSC7174 Serial ATA. 601 This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
602 602
603 If unsure, say N. 603 If unsure, say N.
604 604
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 15dc2e00e1b2..e513c3158ad9 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -117,7 +117,6 @@ obj-$(CONFIG_SCSI_PPA) += ppa.o
117obj-$(CONFIG_SCSI_IMM) += imm.o 117obj-$(CONFIG_SCSI_IMM) += imm.o
118obj-$(CONFIG_JAZZ_ESP) += NCR53C9x.o jazz_esp.o 118obj-$(CONFIG_JAZZ_ESP) += NCR53C9x.o jazz_esp.o
119obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o 119obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o
120obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
121obj-$(CONFIG_SCSI_FCAL) += fcal.o 120obj-$(CONFIG_SCSI_FCAL) += fcal.o
122obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o 121obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
123obj-$(CONFIG_SCSI_NSP32) += nsp32.o 122obj-$(CONFIG_SCSI_NSP32) += nsp32.o
@@ -148,6 +147,9 @@ obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o
148obj-$(CONFIG_CHR_DEV_SG) += sg.o 147obj-$(CONFIG_CHR_DEV_SG) += sg.o
149obj-$(CONFIG_CHR_DEV_SCH) += ch.o 148obj-$(CONFIG_CHR_DEV_SCH) += ch.o
150 149
150# This goes last, so that "real" scsi devices probe earlier
151obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
152
151scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 153scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
152 scsicam.o scsi_error.o scsi_lib.o \ 154 scsicam.o scsi_error.o scsi_lib.o \
153 scsi_scan.o scsi_sysfs.o \ 155 scsi_scan.o scsi_sysfs.o \
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index a1ddbba2cbdf..ffba65656a83 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -513,6 +513,138 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, u32 opts)
513 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); 513 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
514} 514}
515 515
516static int ahci_poll_register(void __iomem *reg, u32 mask, u32 val,
517 unsigned long interval_msec,
518 unsigned long timeout_msec)
519{
520 unsigned long timeout;
521 u32 tmp;
522
523 timeout = jiffies + (timeout_msec * HZ) / 1000;
524 do {
525 tmp = readl(reg);
526 if ((tmp & mask) == val)
527 return 0;
528 msleep(interval_msec);
529 } while (time_before(jiffies, timeout));
530
531 return -1;
532}
533
534static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class)
535{
536 struct ahci_host_priv *hpriv = ap->host_set->private_data;
537 struct ahci_port_priv *pp = ap->private_data;
538 void __iomem *mmio = ap->host_set->mmio_base;
539 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
540 const u32 cmd_fis_len = 5; /* five dwords */
541 const char *reason = NULL;
542 struct ata_taskfile tf;
543 u8 *fis;
544 int rc;
545
546 DPRINTK("ENTER\n");
547
548 /* prepare for SRST (AHCI-1.1 10.4.1) */
549 rc = ahci_stop_engine(ap);
550 if (rc) {
551 reason = "failed to stop engine";
552 goto fail_restart;
553 }
554
555 /* check BUSY/DRQ, perform Command List Override if necessary */
556 ahci_tf_read(ap, &tf);
557 if (tf.command & (ATA_BUSY | ATA_DRQ)) {
558 u32 tmp;
559
560 if (!(hpriv->cap & HOST_CAP_CLO)) {
561 rc = -EIO;
562 reason = "port busy but no CLO";
563 goto fail_restart;
564 }
565
566 tmp = readl(port_mmio + PORT_CMD);
567 tmp |= PORT_CMD_CLO;
568 writel(tmp, port_mmio + PORT_CMD);
569 readl(port_mmio + PORT_CMD); /* flush */
570
571 if (ahci_poll_register(port_mmio + PORT_CMD, PORT_CMD_CLO, 0x0,
572 1, 500)) {
573 rc = -EIO;
574 reason = "CLO failed";
575 goto fail_restart;
576 }
577 }
578
579 /* restart engine */
580 ahci_start_engine(ap);
581
582 ata_tf_init(ap, &tf, 0);
583 fis = pp->cmd_tbl;
584
585 /* issue the first D2H Register FIS */
586 ahci_fill_cmd_slot(pp, cmd_fis_len | AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY);
587
588 tf.ctl |= ATA_SRST;
589 ata_tf_to_fis(&tf, fis, 0);
590 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
591
592 writel(1, port_mmio + PORT_CMD_ISSUE);
593 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
594
595 if (ahci_poll_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x0, 1, 500)) {
596 rc = -EIO;
597 reason = "1st FIS failed";
598 goto fail;
599 }
600
601 /* spec says at least 5us, but be generous and sleep for 1ms */
602 msleep(1);
603
604 /* issue the second D2H Register FIS */
605 ahci_fill_cmd_slot(pp, cmd_fis_len);
606
607 tf.ctl &= ~ATA_SRST;
608 ata_tf_to_fis(&tf, fis, 0);
609 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
610
611 writel(1, port_mmio + PORT_CMD_ISSUE);
612 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
613
614 /* spec mandates ">= 2ms" before checking status.
615 * We wait 150ms, because that was the magic delay used for
616 * ATAPI devices in Hale Landis's ATADRVR, for the period of time
617 * between when the ATA command register is written, and then
618 * status is checked. Because waiting for "a while" before
619 * checking status is fine, post SRST, we perform this magic
620 * delay here as well.
621 */
622 msleep(150);
623
624 *class = ATA_DEV_NONE;
625 if (sata_dev_present(ap)) {
626 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
627 rc = -EIO;
628 reason = "device not ready";
629 goto fail;
630 }
631 *class = ahci_dev_classify(ap);
632 }
633
634 DPRINTK("EXIT, class=%u\n", *class);
635 return 0;
636
637 fail_restart:
638 ahci_start_engine(ap);
639 fail:
640 if (verbose)
641 printk(KERN_ERR "ata%u: softreset failed (%s)\n",
642 ap->id, reason);
643 else
644 DPRINTK("EXIT, rc=%d reason=\"%s\"\n", rc, reason);
645 return rc;
646}
647
516static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class) 648static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class)
517{ 649{
518 int rc; 650 int rc;
@@ -553,7 +685,8 @@ static void ahci_postreset(struct ata_port *ap, unsigned int *class)
553 685
554static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes) 686static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes)
555{ 687{
556 return ata_drive_probe_reset(ap, NULL, NULL, ahci_hardreset, 688 return ata_drive_probe_reset(ap, ata_std_probeinit,
689 ahci_softreset, ahci_hardreset,
557 ahci_postreset, classes); 690 ahci_postreset, classes);
558} 691}
559 692
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
112static DECLARE_MUTEX(idescsi_ref_sem); 113static 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
129static void ide_scsi_put(struct ide_scsi_obj *scsi) 130static 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
136static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host) 137static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host)
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index a93336adcd23..96b4d2160df8 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -214,6 +214,8 @@ static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile
214 * Issues MMIO write to ATA command register, with proper 214 * Issues MMIO write to ATA command register, with proper
215 * synchronization with interrupt handler / other threads. 215 * synchronization with interrupt handler / other threads.
216 * 216 *
217 * FIXME: missing write posting for 400nS delay enforcement
218 *
217 * LOCKING: 219 * LOCKING:
218 * spin_lock_irqsave(host_set lock) 220 * spin_lock_irqsave(host_set lock)
219 */ 221 */
@@ -648,6 +650,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
648 goto err_out_regions; 650 goto err_out_regions;
649 } 651 }
650 652
653 /* FIXME: If we get no DMA mask we should fall back to PIO */
651 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 654 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
652 if (rc) 655 if (rc)
653 goto err_out_regions; 656 goto err_out_regions;
@@ -699,5 +702,41 @@ err_out:
699 return rc; 702 return rc;
700} 703}
701 704
705/**
706 * ata_pci_clear_simplex - attempt to kick device out of simplex
707 * @pdev: PCI device
708 *
709 * Some PCI ATA devices report simplex mode but in fact can be told to
710 * enter non simplex mode. This implements the neccessary logic to
711 * perform the task on such devices. Calling it on other devices will
712 * have -undefined- behaviour.
713 */
714
715int ata_pci_clear_simplex(struct pci_dev *pdev)
716{
717 unsigned long bmdma = pci_resource_start(pdev, 4);
718 u8 simplex;
719
720 if (bmdma == 0)
721 return -ENOENT;
722
723 simplex = inb(bmdma + 0x02);
724 outb(simplex & 0x60, bmdma + 0x02);
725 simplex = inb(bmdma + 0x02);
726 if (simplex & 0x80)
727 return -EOPNOTSUPP;
728 return 0;
729}
730
731unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long xfer_mask)
732{
733 /* Filter out DMA modes if the device has been configured by
734 the BIOS as PIO only */
735
736 if (ap->ioaddr.bmdma_addr == 0)
737 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
738 return xfer_mask;
739}
740
702#endif /* CONFIG_PCI */ 741#endif /* CONFIG_PCI */
703 742
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 64dce00e9c46..0314abd97f2d 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -962,6 +962,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
962 spin_unlock_irqrestore(&ap->host_set->lock, flags); 962 spin_unlock_irqrestore(&ap->host_set->lock, flags);
963 963
964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { 964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) {
965 ata_port_flush_task(ap);
966
965 spin_lock_irqsave(&ap->host_set->lock, flags); 967 spin_lock_irqsave(&ap->host_set->lock, flags);
966 968
967 /* We're racing with irq here. If we lose, the 969 /* We're racing with irq here. If we lose, the
@@ -1219,13 +1221,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1219 * common ATA, ATAPI feature tests 1221 * common ATA, ATAPI feature tests
1220 */ 1222 */
1221 1223
1222 /* we require DMA support (bits 8 of word 49) */
1223 if (!ata_id_has_dma(id)) {
1224 printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
1225 rc = -EINVAL;
1226 goto err_out_nosup;
1227 }
1228
1229 /* find max transfer mode; for printk only */ 1224 /* find max transfer mode; for printk only */
1230 xfer_mask = ata_id_xfermask(id); 1225 xfer_mask = ata_id_xfermask(id);
1231 1226
@@ -1737,7 +1732,7 @@ static int ata_host_set_pio(struct ata_port *ap)
1737 continue; 1732 continue;
1738 1733
1739 if (!dev->pio_mode) { 1734 if (!dev->pio_mode) {
1740 printk(KERN_WARNING "ata%u: no PIO support\n", ap->id); 1735 printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
1741 return -1; 1736 return -1;
1742 } 1737 }
1743 1738
@@ -1999,9 +1994,19 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
1999 * status is checked. Because waiting for "a while" before 1994 * status is checked. Because waiting for "a while" before
2000 * checking status is fine, post SRST, we perform this magic 1995 * checking status is fine, post SRST, we perform this magic
2001 * delay here as well. 1996 * delay here as well.
1997 *
1998 * Old drivers/ide uses the 2mS rule and then waits for ready
2002 */ 1999 */
2003 msleep(150); 2000 msleep(150);
2004 2001
2002
2003 /* Before we perform post reset processing we want to see if
2004 the bus shows 0xFF because the odd clown forgets the D7 pulldown
2005 resistor */
2006
2007 if (ata_check_status(ap) == 0xFF)
2008 return 1; /* Positive is failure for some reason */
2009
2005 ata_bus_post_reset(ap, devmask); 2010 ata_bus_post_reset(ap, devmask);
2006 2011
2007 return 0; 2012 return 0;
@@ -2551,48 +2556,72 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
2551} 2556}
2552 2557
2553static const char * const ata_dma_blacklist [] = { 2558static const char * const ata_dma_blacklist [] = {
2554 "WDC AC11000H", 2559 "WDC AC11000H", NULL,
2555 "WDC AC22100H", 2560 "WDC AC22100H", NULL,
2556 "WDC AC32500H", 2561 "WDC AC32500H", NULL,
2557 "WDC AC33100H", 2562 "WDC AC33100H", NULL,
2558 "WDC AC31600H", 2563 "WDC AC31600H", NULL,
2559 "WDC AC32100H", 2564 "WDC AC32100H", "24.09P07",
2560 "WDC AC23200L", 2565 "WDC AC23200L", "21.10N21",
2561 "Compaq CRD-8241B", 2566 "Compaq CRD-8241B", NULL,
2562 "CRD-8400B", 2567 "CRD-8400B", NULL,
2563 "CRD-8480B", 2568 "CRD-8480B", NULL,
2564 "CRD-8482B", 2569 "CRD-8482B", NULL,
2565 "CRD-84", 2570 "CRD-84", NULL,
2566 "SanDisk SDP3B", 2571 "SanDisk SDP3B", NULL,
2567 "SanDisk SDP3B-64", 2572 "SanDisk SDP3B-64", NULL,
2568 "SANYO CD-ROM CRD", 2573 "SANYO CD-ROM CRD", NULL,
2569 "HITACHI CDR-8", 2574 "HITACHI CDR-8", NULL,
2570 "HITACHI CDR-8335", 2575 "HITACHI CDR-8335", NULL,
2571 "HITACHI CDR-8435", 2576 "HITACHI CDR-8435", NULL,
2572 "Toshiba CD-ROM XM-6202B", 2577 "Toshiba CD-ROM XM-6202B", NULL,
2573 "TOSHIBA CD-ROM XM-1702BC", 2578 "TOSHIBA CD-ROM XM-1702BC", NULL,
2574 "CD-532E-A", 2579 "CD-532E-A", NULL,
2575 "E-IDE CD-ROM CR-840", 2580 "E-IDE CD-ROM CR-840", NULL,
2576 "CD-ROM Drive/F5A", 2581 "CD-ROM Drive/F5A", NULL,
2577 "WPI CDD-820", 2582 "WPI CDD-820", NULL,
2578 "SAMSUNG CD-ROM SC-148C", 2583 "SAMSUNG CD-ROM SC-148C", NULL,
2579 "SAMSUNG CD-ROM SC", 2584 "SAMSUNG CD-ROM SC", NULL,
2580 "SanDisk SDP3B-64", 2585 "SanDisk SDP3B-64", NULL,
2581 "ATAPI CD-ROM DRIVE 40X MAXIMUM", 2586 "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,
2582 "_NEC DV5800A", 2587 "_NEC DV5800A", NULL,
2588 "SAMSUNG CD-ROM SN-124", "N001"
2583}; 2589};
2590
2591static int ata_strim(char *s, size_t len)
2592{
2593 len = strnlen(s, len);
2594
2595 /* ATAPI specifies that empty space is blank-filled; remove blanks */
2596 while ((len > 0) && (s[len - 1] == ' ')) {
2597 len--;
2598 s[len] = 0;
2599 }
2600 return len;
2601}
2584 2602
2585static int ata_dma_blacklisted(const struct ata_device *dev) 2603static int ata_dma_blacklisted(const struct ata_device *dev)
2586{ 2604{
2587 unsigned char model_num[41]; 2605 unsigned char model_num[40];
2606 unsigned char model_rev[16];
2607 unsigned int nlen, rlen;
2588 int i; 2608 int i;
2589 2609
2590 ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num)); 2610 ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
2591 2611 sizeof(model_num));
2592 for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i++) 2612 ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
2593 if (!strcmp(ata_dma_blacklist[i], model_num)) 2613 sizeof(model_rev));
2594 return 1; 2614 nlen = ata_strim(model_num, sizeof(model_num));
2615 rlen = ata_strim(model_rev, sizeof(model_rev));
2595 2616
2617 for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i += 2) {
2618 if (!strncmp(ata_dma_blacklist[i], model_num, nlen)) {
2619 if (ata_dma_blacklist[i+1] == NULL)
2620 return 1;
2621 if (!strncmp(ata_dma_blacklist[i], model_rev, rlen))
2622 return 1;
2623 }
2624 }
2596 return 0; 2625 return 0;
2597} 2626}
2598 2627
@@ -2863,6 +2892,8 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2863 ata_fill_sg(qc); 2892 ata_fill_sg(qc);
2864} 2893}
2865 2894
2895void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
2896
2866/** 2897/**
2867 * ata_sg_init_one - Associate command with memory buffer 2898 * ata_sg_init_one - Associate command with memory buffer
2868 * @qc: Command to be associated 2899 * @qc: Command to be associated
@@ -3907,7 +3938,6 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
3907 3938
3908 case ATA_PROT_ATAPI: 3939 case ATA_PROT_ATAPI:
3909 case ATA_PROT_PIO: 3940 case ATA_PROT_PIO:
3910 case ATA_PROT_PIO_MULT:
3911 if (ap->flags & ATA_FLAG_PIO_DMA) 3941 if (ap->flags & ATA_FLAG_PIO_DMA)
3912 return 1; 3942 return 1;
3913 3943
@@ -4199,14 +4229,17 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
4199 4229
4200void ata_bmdma_irq_clear(struct ata_port *ap) 4230void ata_bmdma_irq_clear(struct ata_port *ap)
4201{ 4231{
4202 if (ap->flags & ATA_FLAG_MMIO) { 4232 if (!ap->ioaddr.bmdma_addr)
4203 void __iomem *mmio = ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS; 4233 return;
4204 writeb(readb(mmio), mmio);
4205 } else {
4206 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4207 outb(inb(addr), addr);
4208 }
4209 4234
4235 if (ap->flags & ATA_FLAG_MMIO) {
4236 void __iomem *mmio =
4237 ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
4238 writeb(readb(mmio), mmio);
4239 } else {
4240 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4241 outb(inb(addr), addr);
4242 }
4210} 4243}
4211 4244
4212 4245
@@ -4337,9 +4370,9 @@ idle_irq:
4337 4370
4338#ifdef ATA_IRQ_TRAP 4371#ifdef ATA_IRQ_TRAP
4339 if ((ap->stats.idle_irq % 1000) == 0) { 4372 if ((ap->stats.idle_irq % 1000) == 0) {
4340 handled = 1;
4341 ata_irq_ack(ap, 0); /* debug trap */ 4373 ata_irq_ack(ap, 0); /* debug trap */
4342 printk(KERN_WARNING "ata%d: irq trap\n", ap->id); 4374 printk(KERN_WARNING "ata%d: irq trap\n", ap->id);
4375 return 1;
4343 } 4376 }
4344#endif 4377#endif
4345 return 0; /* irq not handled */ 4378 return 0; /* irq not handled */
@@ -5064,6 +5097,7 @@ EXPORT_SYMBOL_GPL(ata_port_stop);
5064EXPORT_SYMBOL_GPL(ata_host_stop); 5097EXPORT_SYMBOL_GPL(ata_host_stop);
5065EXPORT_SYMBOL_GPL(ata_interrupt); 5098EXPORT_SYMBOL_GPL(ata_interrupt);
5066EXPORT_SYMBOL_GPL(ata_qc_prep); 5099EXPORT_SYMBOL_GPL(ata_qc_prep);
5100EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
5067EXPORT_SYMBOL_GPL(ata_bmdma_setup); 5101EXPORT_SYMBOL_GPL(ata_bmdma_setup);
5068EXPORT_SYMBOL_GPL(ata_bmdma_start); 5102EXPORT_SYMBOL_GPL(ata_bmdma_start);
5069EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear); 5103EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear);
@@ -5109,6 +5143,8 @@ EXPORT_SYMBOL_GPL(ata_pci_init_one);
5109EXPORT_SYMBOL_GPL(ata_pci_remove_one); 5143EXPORT_SYMBOL_GPL(ata_pci_remove_one);
5110EXPORT_SYMBOL_GPL(ata_pci_device_suspend); 5144EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
5111EXPORT_SYMBOL_GPL(ata_pci_device_resume); 5145EXPORT_SYMBOL_GPL(ata_pci_device_resume);
5146EXPORT_SYMBOL_GPL(ata_pci_default_filter);
5147EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
5112#endif /* CONFIG_PCI */ 5148#endif /* CONFIG_PCI */
5113 5149
5114EXPORT_SYMBOL_GPL(ata_device_suspend); 5150EXPORT_SYMBOL_GPL(ata_device_suspend);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index bd9f2176f79a..a1259b242b8e 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -521,13 +521,11 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
521 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 521 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
522 id, drv_stat); 522 id, drv_stat);
523 523
524 /* For our last chance pick, use medium read error because 524 /* We need a sensible error return here, which is tricky, and one
525 * it's much more common than an ATA drive telling you a write 525 that won't cause people to do things like return a disk wrongly */
526 * has failed. 526 *sk = ABORTED_COMMAND;
527 */ 527 *asc = 0x00;
528 *sk = MEDIUM_ERROR; 528 *ascq = 0x00;
529 *asc = 0x11; /* "unrecovered read error" */
530 *ascq = 0x04; /* "auto-reallocation failed" */
531 529
532 translate_done: 530 translate_done:
533 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " 531 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to "
@@ -672,6 +670,41 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
672 } 670 }
673} 671}
674 672
673static void ata_scsi_sdev_config(struct scsi_device *sdev)
674{
675 sdev->use_10_for_rw = 1;
676 sdev->use_10_for_ms = 1;
677}
678
679static void ata_scsi_dev_config(struct scsi_device *sdev,
680 struct ata_device *dev)
681{
682 unsigned int max_sectors;
683
684 /* TODO: 2048 is an arbitrary number, not the
685 * hardware maximum. This should be increased to
686 * 65534 when Jens Axboe's patch for dynamically
687 * determining max_sectors is merged.
688 */
689 max_sectors = ATA_MAX_SECTORS;
690 if (dev->flags & ATA_DFLAG_LBA48)
691 max_sectors = 2048;
692 if (dev->max_sectors)
693 max_sectors = dev->max_sectors;
694
695 blk_queue_max_sectors(sdev->request_queue, max_sectors);
696
697 /*
698 * SATA DMA transfers must be multiples of 4 byte, so
699 * we need to pad ATAPI transfers using an extra sg.
700 * Decrement max hw segments accordingly.
701 */
702 if (dev->class == ATA_DEV_ATAPI) {
703 request_queue_t *q = sdev->request_queue;
704 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
705 }
706}
707
675/** 708/**
676 * ata_scsi_slave_config - Set SCSI device attributes 709 * ata_scsi_slave_config - Set SCSI device attributes
677 * @sdev: SCSI device to examine 710 * @sdev: SCSI device to examine
@@ -686,41 +719,18 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
686 719
687int ata_scsi_slave_config(struct scsi_device *sdev) 720int ata_scsi_slave_config(struct scsi_device *sdev)
688{ 721{
689 sdev->use_10_for_rw = 1; 722 ata_scsi_sdev_config(sdev);
690 sdev->use_10_for_ms = 1;
691 723
692 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); 724 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
693 725
694 if (sdev->id < ATA_MAX_DEVICES) { 726 if (sdev->id < ATA_MAX_DEVICES) {
695 struct ata_port *ap; 727 struct ata_port *ap;
696 struct ata_device *dev; 728 struct ata_device *dev;
697 unsigned int max_sectors;
698 729
699 ap = (struct ata_port *) &sdev->host->hostdata[0]; 730 ap = (struct ata_port *) &sdev->host->hostdata[0];
700 dev = &ap->device[sdev->id]; 731 dev = &ap->device[sdev->id];
701 732
702 /* TODO: 2048 is an arbitrary number, not the 733 ata_scsi_dev_config(sdev, dev);
703 * hardware maximum. This should be increased to
704 * 65534 when Jens Axboe's patch for dynamically
705 * determining max_sectors is merged.
706 */
707 max_sectors = ATA_MAX_SECTORS;
708 if (dev->flags & ATA_DFLAG_LBA48)
709 max_sectors = 2048;
710 if (dev->max_sectors)
711 max_sectors = dev->max_sectors;
712
713 blk_queue_max_sectors(sdev->request_queue, max_sectors);
714
715 /*
716 * SATA DMA transfers must be multiples of 4 byte, so
717 * we need to pad ATAPI transfers using an extra sg.
718 * Decrement max hw segments accordingly.
719 */
720 if (dev->class == ATA_DEV_ATAPI) {
721 request_queue_t *q = sdev->request_queue;
722 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
723 }
724 } 734 }
725 735
726 return 0; /* scsi layer doesn't check return value, sigh */ 736 return 0; /* scsi layer doesn't check return value, sigh */
@@ -1552,7 +1562,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1552 * @buflen: Response buffer length. 1562 * @buflen: Response buffer length.
1553 * 1563 *
1554 * Returns standard device identification data associated 1564 * Returns standard device identification data associated
1555 * with non-EVPD INQUIRY command output. 1565 * with non-VPD INQUIRY command output.
1556 * 1566 *
1557 * LOCKING: 1567 * LOCKING:
1558 * spin_lock_irqsave(host_set lock) 1568 * spin_lock_irqsave(host_set lock)
@@ -1603,12 +1613,12 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1603} 1613}
1604 1614
1605/** 1615/**
1606 * ata_scsiop_inq_00 - Simulate INQUIRY EVPD page 0, list of pages 1616 * ata_scsiop_inq_00 - Simulate INQUIRY VPD page 0, list of pages
1607 * @args: device IDENTIFY data / SCSI command of interest. 1617 * @args: device IDENTIFY data / SCSI command of interest.
1608 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1618 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1609 * @buflen: Response buffer length. 1619 * @buflen: Response buffer length.
1610 * 1620 *
1611 * Returns list of inquiry EVPD pages available. 1621 * Returns list of inquiry VPD pages available.
1612 * 1622 *
1613 * LOCKING: 1623 * LOCKING:
1614 * spin_lock_irqsave(host_set lock) 1624 * spin_lock_irqsave(host_set lock)
@@ -1622,7 +1632,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1622 0x80, /* page 0x80, unit serial no page */ 1632 0x80, /* page 0x80, unit serial no page */
1623 0x83 /* page 0x83, device ident page */ 1633 0x83 /* page 0x83, device ident page */
1624 }; 1634 };
1625 rbuf[3] = sizeof(pages); /* number of supported EVPD pages */ 1635 rbuf[3] = sizeof(pages); /* number of supported VPD pages */
1626 1636
1627 if (buflen > 6) 1637 if (buflen > 6)
1628 memcpy(rbuf + 4, pages, sizeof(pages)); 1638 memcpy(rbuf + 4, pages, sizeof(pages));
@@ -1631,7 +1641,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1631} 1641}
1632 1642
1633/** 1643/**
1634 * ata_scsiop_inq_80 - Simulate INQUIRY EVPD page 80, device serial number 1644 * ata_scsiop_inq_80 - Simulate INQUIRY VPD page 80, device serial number
1635 * @args: device IDENTIFY data / SCSI command of interest. 1645 * @args: device IDENTIFY data / SCSI command of interest.
1636 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1646 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1637 * @buflen: Response buffer length. 1647 * @buflen: Response buffer length.
@@ -1660,16 +1670,16 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1660 return 0; 1670 return 0;
1661} 1671}
1662 1672
1663static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1664
1665/** 1673/**
1666 * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity 1674 * ata_scsiop_inq_83 - Simulate INQUIRY VPD page 83, device identity
1667 * @args: device IDENTIFY data / SCSI command of interest. 1675 * @args: device IDENTIFY data / SCSI command of interest.
1668 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1676 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1669 * @buflen: Response buffer length. 1677 * @buflen: Response buffer length.
1670 * 1678 *
1671 * Returns device identification. Currently hardcoded to 1679 * Yields two logical unit device identification designators:
1672 * return "Linux ATA-SCSI simulator". 1680 * - vendor specific ASCII containing the ATA serial number
1681 * - SAT defined "t10 vendor id based" containing ASCII vendor
1682 * name ("ATA "), model and serial numbers.
1673 * 1683 *
1674 * LOCKING: 1684 * LOCKING:
1675 * spin_lock_irqsave(host_set lock) 1685 * spin_lock_irqsave(host_set lock)
@@ -1678,16 +1688,39 @@ static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1678unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, 1688unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1679 unsigned int buflen) 1689 unsigned int buflen)
1680{ 1690{
1681 rbuf[1] = 0x83; /* this page code */ 1691 int num;
1682 rbuf[3] = 4 + strlen(inq_83_str); /* page len */ 1692 const int sat_model_serial_desc_len = 68;
1693 const int ata_model_byte_len = 40;
1683 1694
1684 /* our one and only identification descriptor (vendor-specific) */ 1695 rbuf[1] = 0x83; /* this page code */
1685 if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) { 1696 num = 4;
1686 rbuf[4 + 0] = 2; /* code set: ASCII */ 1697
1687 rbuf[4 + 3] = strlen(inq_83_str); 1698 if (buflen > (ATA_SERNO_LEN + num + 3)) {
1688 memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str)); 1699 /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
1700 rbuf[num + 0] = 2;
1701 rbuf[num + 3] = ATA_SERNO_LEN;
1702 num += 4;
1703 ata_id_string(args->id, (unsigned char *) rbuf + num,
1704 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1705 num += ATA_SERNO_LEN;
1689 } 1706 }
1690 1707 if (buflen > (sat_model_serial_desc_len + num + 3)) {
1708 /* SAT defined lu model and serial numbers descriptor */
1709 /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
1710 rbuf[num + 0] = 2;
1711 rbuf[num + 1] = 1;
1712 rbuf[num + 3] = sat_model_serial_desc_len;
1713 num += 4;
1714 memcpy(rbuf + num, "ATA ", 8);
1715 num += 8;
1716 ata_id_string(args->id, (unsigned char *) rbuf + num,
1717 ATA_ID_PROD_OFS, ata_model_byte_len);
1718 num += ata_model_byte_len;
1719 ata_id_string(args->id, (unsigned char *) rbuf + num,
1720 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1721 num += ATA_SERNO_LEN;
1722 }
1723 rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */
1691 return 0; 1724 return 0;
1692} 1725}
1693 1726
@@ -2366,9 +2399,6 @@ ata_scsi_map_proto(u8 byte1)
2366 2399
2367 case 4: /* PIO Data-in */ 2400 case 4: /* PIO Data-in */
2368 case 5: /* PIO Data-out */ 2401 case 5: /* PIO Data-out */
2369 if (byte1 & 0xe0) {
2370 return ATA_PROT_PIO_MULT;
2371 }
2372 return ATA_PROT_PIO; 2402 return ATA_PROT_PIO;
2373 2403
2374 case 10: /* Device Reset */ 2404 case 10: /* Device Reset */
@@ -2407,6 +2437,10 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2407 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) 2437 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2408 goto invalid_fld; 2438 goto invalid_fld;
2409 2439
2440 if (scsicmd[1] & 0xe0)
2441 /* PIO multi not supported yet */
2442 goto invalid_fld;
2443
2410 /* 2444 /*
2411 * 12 and 16 byte CDBs use different offsets to 2445 * 12 and 16 byte CDBs use different offsets to
2412 * provide the various register values. 2446 * provide the various register values.
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index b3dc5f85ae0b..3c85c4b66e19 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -321,7 +321,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
321 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); 321 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
322 i += 4; 322 i += 4;
323 323
324 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", nelem, 324 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
325 (unsigned long)addr, len); 325 (unsigned long)addr, len);
326 } 326 }
327 return i; 327 return i;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 874c5be0843c..275ed9bd898c 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1262,6 +1262,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1262 void __iomem *port_mmio = mv_ap_base(ap); 1262 void __iomem *port_mmio = mv_ap_base(ap);
1263 struct mv_port_priv *pp = ap->private_data; 1263 struct mv_port_priv *pp = ap->private_data;
1264 u32 out_ptr; 1264 u32 out_ptr;
1265 u8 ata_status;
1265 1266
1266 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1267 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1267 1268
@@ -1269,6 +1270,8 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1269 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1270 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1270 pp->rsp_consumer); 1271 pp->rsp_consumer);
1271 1272
1273 ata_status = pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT;
1274
1272 /* increment our consumer index... */ 1275 /* increment our consumer index... */
1273 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); 1276 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
1274 1277
@@ -1283,7 +1286,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1283 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1286 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1284 1287
1285 /* Return ATA status register for completed CRPB */ 1288 /* Return ATA status register for completed CRPB */
1286 return (pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT); 1289 return ata_status;
1287} 1290}
1288 1291
1289/** 1292/**
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 051e47d975ca..724f0ed6a52d 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -56,33 +56,35 @@
56#define DRV_NAME "sata_svw" 56#define DRV_NAME "sata_svw"
57#define DRV_VERSION "1.07" 57#define DRV_VERSION "1.07"
58 58
59/* Taskfile registers offsets */ 59enum {
60#define K2_SATA_TF_CMD_OFFSET 0x00 60 /* Taskfile registers offsets */
61#define K2_SATA_TF_DATA_OFFSET 0x00 61 K2_SATA_TF_CMD_OFFSET = 0x00,
62#define K2_SATA_TF_ERROR_OFFSET 0x04 62 K2_SATA_TF_DATA_OFFSET = 0x00,
63#define K2_SATA_TF_NSECT_OFFSET 0x08 63 K2_SATA_TF_ERROR_OFFSET = 0x04,
64#define K2_SATA_TF_LBAL_OFFSET 0x0c 64 K2_SATA_TF_NSECT_OFFSET = 0x08,
65#define K2_SATA_TF_LBAM_OFFSET 0x10 65 K2_SATA_TF_LBAL_OFFSET = 0x0c,
66#define K2_SATA_TF_LBAH_OFFSET 0x14 66 K2_SATA_TF_LBAM_OFFSET = 0x10,
67#define K2_SATA_TF_DEVICE_OFFSET 0x18 67 K2_SATA_TF_LBAH_OFFSET = 0x14,
68#define K2_SATA_TF_CMDSTAT_OFFSET 0x1c 68 K2_SATA_TF_DEVICE_OFFSET = 0x18,
69#define K2_SATA_TF_CTL_OFFSET 0x20 69 K2_SATA_TF_CMDSTAT_OFFSET = 0x1c,
70 70 K2_SATA_TF_CTL_OFFSET = 0x20,
71/* DMA base */ 71
72#define K2_SATA_DMA_CMD_OFFSET 0x30 72 /* DMA base */
73 73 K2_SATA_DMA_CMD_OFFSET = 0x30,
74/* SCRs base */ 74
75#define K2_SATA_SCR_STATUS_OFFSET 0x40 75 /* SCRs base */
76#define K2_SATA_SCR_ERROR_OFFSET 0x44 76 K2_SATA_SCR_STATUS_OFFSET = 0x40,
77#define K2_SATA_SCR_CONTROL_OFFSET 0x48 77 K2_SATA_SCR_ERROR_OFFSET = 0x44,
78 78 K2_SATA_SCR_CONTROL_OFFSET = 0x48,
79/* Others */ 79
80#define K2_SATA_SICR1_OFFSET 0x80 80 /* Others */
81#define K2_SATA_SICR2_OFFSET 0x84 81 K2_SATA_SICR1_OFFSET = 0x80,
82#define K2_SATA_SIM_OFFSET 0x88 82 K2_SATA_SICR2_OFFSET = 0x84,
83 83 K2_SATA_SIM_OFFSET = 0x88,
84/* Port stride */ 84
85#define K2_SATA_PORT_OFFSET 0x100 85 /* Port stride */
86 K2_SATA_PORT_OFFSET = 0x100,
87};
86 88
87static u8 k2_stat_check_status(struct ata_port *ap); 89static u8 k2_stat_check_status(struct ata_port *ap);
88 90
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index ee75b9b38ae8..9701a806539d 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,52 +47,58 @@
47#include <linux/libata.h> 47#include <linux/libata.h>
48 48
49#define DRV_NAME "sata_vsc" 49#define DRV_NAME "sata_vsc"
50#define DRV_VERSION "1.1" 50#define DRV_VERSION "1.2"
51 51
52/* Interrupt register offsets (from chip base address) */ 52enum {
53#define VSC_SATA_INT_STAT_OFFSET 0x00 53 /* Interrupt register offsets (from chip base address) */
54#define VSC_SATA_INT_MASK_OFFSET 0x04 54 VSC_SATA_INT_STAT_OFFSET = 0x00,
55 55 VSC_SATA_INT_MASK_OFFSET = 0x04,
56/* Taskfile registers offsets */ 56
57#define VSC_SATA_TF_CMD_OFFSET 0x00 57 /* Taskfile registers offsets */
58#define VSC_SATA_TF_DATA_OFFSET 0x00 58 VSC_SATA_TF_CMD_OFFSET = 0x00,
59#define VSC_SATA_TF_ERROR_OFFSET 0x04 59 VSC_SATA_TF_DATA_OFFSET = 0x00,
60#define VSC_SATA_TF_FEATURE_OFFSET 0x06 60 VSC_SATA_TF_ERROR_OFFSET = 0x04,
61#define VSC_SATA_TF_NSECT_OFFSET 0x08 61 VSC_SATA_TF_FEATURE_OFFSET = 0x06,
62#define VSC_SATA_TF_LBAL_OFFSET 0x0c 62 VSC_SATA_TF_NSECT_OFFSET = 0x08,
63#define VSC_SATA_TF_LBAM_OFFSET 0x10 63 VSC_SATA_TF_LBAL_OFFSET = 0x0c,
64#define VSC_SATA_TF_LBAH_OFFSET 0x14 64 VSC_SATA_TF_LBAM_OFFSET = 0x10,
65#define VSC_SATA_TF_DEVICE_OFFSET 0x18 65 VSC_SATA_TF_LBAH_OFFSET = 0x14,
66#define VSC_SATA_TF_STATUS_OFFSET 0x1c 66 VSC_SATA_TF_DEVICE_OFFSET = 0x18,
67#define VSC_SATA_TF_COMMAND_OFFSET 0x1d 67 VSC_SATA_TF_STATUS_OFFSET = 0x1c,
68#define VSC_SATA_TF_ALTSTATUS_OFFSET 0x28 68 VSC_SATA_TF_COMMAND_OFFSET = 0x1d,
69#define VSC_SATA_TF_CTL_OFFSET 0x29 69 VSC_SATA_TF_ALTSTATUS_OFFSET = 0x28,
70 70 VSC_SATA_TF_CTL_OFFSET = 0x29,
71/* DMA base */ 71
72#define VSC_SATA_UP_DESCRIPTOR_OFFSET 0x64 72 /* DMA base */
73#define VSC_SATA_UP_DATA_BUFFER_OFFSET 0x6C 73 VSC_SATA_UP_DESCRIPTOR_OFFSET = 0x64,
74#define VSC_SATA_DMA_CMD_OFFSET 0x70 74 VSC_SATA_UP_DATA_BUFFER_OFFSET = 0x6C,
75 75 VSC_SATA_DMA_CMD_OFFSET = 0x70,
76/* SCRs base */ 76
77#define VSC_SATA_SCR_STATUS_OFFSET 0x100 77 /* SCRs base */
78#define VSC_SATA_SCR_ERROR_OFFSET 0x104 78 VSC_SATA_SCR_STATUS_OFFSET = 0x100,
79#define VSC_SATA_SCR_CONTROL_OFFSET 0x108 79 VSC_SATA_SCR_ERROR_OFFSET = 0x104,
80 80 VSC_SATA_SCR_CONTROL_OFFSET = 0x108,
81/* Port stride */ 81
82#define VSC_SATA_PORT_OFFSET 0x200 82 /* Port stride */
83 83 VSC_SATA_PORT_OFFSET = 0x200,
84/* Error interrupt status bit offsets */ 84
85#define VSC_SATA_INT_ERROR_E_OFFSET 2 85 /* Error interrupt status bit offsets */
86#define VSC_SATA_INT_ERROR_P_OFFSET 4 86 VSC_SATA_INT_ERROR_CRC = 0x40,
87#define VSC_SATA_INT_ERROR_T_OFFSET 5 87 VSC_SATA_INT_ERROR_T = 0x20,
88#define VSC_SATA_INT_ERROR_M_OFFSET 1 88 VSC_SATA_INT_ERROR_P = 0x10,
89 VSC_SATA_INT_ERROR_R = 0x8,
90 VSC_SATA_INT_ERROR_E = 0x4,
91 VSC_SATA_INT_ERROR_M = 0x2,
92 VSC_SATA_INT_PHY_CHANGE = 0x1,
93 VSC_SATA_INT_ERROR = (VSC_SATA_INT_ERROR_CRC | VSC_SATA_INT_ERROR_T | \
94 VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \
95 VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \
96 VSC_SATA_INT_PHY_CHANGE),
97};
98
99
89#define is_vsc_sata_int_err(port_idx, int_status) \ 100#define is_vsc_sata_int_err(port_idx, int_status) \
90 (int_status & ((1 << (VSC_SATA_INT_ERROR_E_OFFSET + (8 * port_idx))) | \ 101 (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx)))
91 (1 << (VSC_SATA_INT_ERROR_P_OFFSET + (8 * port_idx))) | \
92 (1 << (VSC_SATA_INT_ERROR_T_OFFSET + (8 * port_idx))) | \
93 (1 << (VSC_SATA_INT_ERROR_M_OFFSET + (8 * port_idx))) \
94 )\
95 )
96 102
97 103
98static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 104static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
@@ -215,14 +221,6 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
215 221
216 ap = host_set->ports[i]; 222 ap = host_set->ports[i];
217 223
218 if (is_vsc_sata_int_err(i, int_status)) {
219 u32 err_status;
220 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
221 err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
222 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
223 handled++;
224 }
225
226 if (ap && !(ap->flags & 224 if (ap && !(ap->flags &
227 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { 225 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
228 struct ata_queued_cmd *qc; 226 struct ata_queued_cmd *qc;
@@ -230,12 +228,26 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
230 qc = ata_qc_from_tag(ap, ap->active_tag); 228 qc = ata_qc_from_tag(ap, ap->active_tag);
231 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 229 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
232 handled += ata_host_intr(ap, qc); 230 handled += ata_host_intr(ap, qc);
233 } else { 231 } else if (is_vsc_sata_int_err(i, int_status)) {
234 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); 232 /*
233 * On some chips (i.e. Intel 31244), an error
234 * interrupt will sneak in at initialization
235 * time (phy state changes). Clearing the SCR
236 * error register is not required, but it prevents
237 * the phy state change interrupts from recurring
238 * later.
239 */
240 u32 err_status;
241 err_status = vsc_sata_scr_read(ap, SCR_ERROR);
242 printk(KERN_DEBUG "%s: clearing interrupt, "
243 "status %x; sata err status %x\n",
244 __FUNCTION__,
245 int_status, err_status);
246 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
247 /* Clear interrupt status */
235 ata_chk_status(ap); 248 ata_chk_status(ap);
236 handled++; 249 handled++;
237 } 250 }
238
239 } 251 }
240 } 252 }
241 } 253 }
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
472static int sr_block_media_changed(struct gendisk *disk) 487static 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 *);
55int sr_reset(struct cdrom_device_info *); 55int sr_reset(struct cdrom_device_info *);
56int sr_select_speed(struct cdrom_device_info *cdi, int speed); 56int sr_select_speed(struct cdrom_device_info *cdi, int speed);
57int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 57int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
58int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long);
59 58
60int sr_is_xa(Scsi_CD *); 59int 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
566int 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/21285.c b/drivers/serial/21285.c
index 8c5c276c5577..7572665a8855 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -375,23 +375,18 @@ static void serial21285_setup_ports(void)
375} 375}
376 376
377#ifdef CONFIG_SERIAL_21285_CONSOLE 377#ifdef CONFIG_SERIAL_21285_CONSOLE
378static void serial21285_console_putchar(struct uart_port *port, int ch)
379{
380 while (*CSR_UARTFLG & 0x20)
381 barrier();
382 *CSR_UARTDR = ch;
383}
378 384
379static void 385static void
380serial21285_console_write(struct console *co, const char *s, 386serial21285_console_write(struct console *co, const char *s,
381 unsigned int count) 387 unsigned int count)
382{ 388{
383 int i; 389 uart_console_write(&serial21285_port, s, count, serial21285_console_putchar);
384
385 for (i = 0; i < count; i++) {
386 while (*CSR_UARTFLG & 0x20)
387 barrier();
388 *CSR_UARTDR = s[i];
389 if (s[i] == '\n') {
390 while (*CSR_UARTFLG & 0x20)
391 barrier();
392 *CSR_UARTDR = '\r';
393 }
394 }
395} 390}
396 391
397static void __init 392static void __init
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
106static void change_speed(struct m68k_serial *info); 104static 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
265static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status) 263static 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
292static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx) 290static 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
362static _INLINE_ void transmit_chars(struct m68k_serial *info) 361static 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/8250.c b/drivers/serial/8250.c
index 7aca22c9976d..5996d3cd0ed8 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2182,6 +2182,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
2182 } 2182 }
2183} 2183}
2184 2184
2185static void serial8250_console_putchar(struct uart_port *port, int ch)
2186{
2187 struct uart_8250_port *up = (struct uart_8250_port *)port;
2188
2189 wait_for_xmitr(up, UART_LSR_THRE);
2190 serial_out(up, UART_TX, ch);
2191}
2192
2185/* 2193/*
2186 * Print a string to the serial port trying not to disturb 2194 * Print a string to the serial port trying not to disturb
2187 * any possible real use of the port... 2195 * any possible real use of the port...
@@ -2193,7 +2201,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2193{ 2201{
2194 struct uart_8250_port *up = &serial8250_ports[co->index]; 2202 struct uart_8250_port *up = &serial8250_ports[co->index];
2195 unsigned int ier; 2203 unsigned int ier;
2196 int i;
2197 2204
2198 touch_nmi_watchdog(); 2205 touch_nmi_watchdog();
2199 2206
@@ -2207,22 +2214,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2207 else 2214 else
2208 serial_out(up, UART_IER, 0); 2215 serial_out(up, UART_IER, 0);
2209 2216
2210 /* 2217 uart_console_write(&up->port, s, count, serial8250_console_putchar);
2211 * Now, do each character
2212 */
2213 for (i = 0; i < count; i++, s++) {
2214 wait_for_xmitr(up, UART_LSR_THRE);
2215
2216 /*
2217 * Send the character out.
2218 * If a LF, also do CR...
2219 */
2220 serial_out(up, UART_TX, *s);
2221 if (*s == 10) {
2222 wait_for_xmitr(up, UART_LSR_THRE);
2223 serial_out(up, UART_TX, 13);
2224 }
2225 }
2226 2218
2227 /* 2219 /*
2228 * Finally, wait for transmitter to become empty 2220 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 59ba5d993b4b..7e511199b4c5 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -74,7 +74,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
74 } 74 }
75} 75}
76 76
77static void __init putc(struct uart_port *port, unsigned char c) 77static void __init putc(struct uart_port *port, int c)
78{ 78{
79 wait_for_xmitr(port); 79 wait_for_xmitr(port);
80 serial_out(port, UART_TX, c); 80 serial_out(port, UART_TX, c);
@@ -89,12 +89,7 @@ static void __init early_uart_write(struct console *console, const char *s, unsi
89 ier = serial_in(port, UART_IER); 89 ier = serial_in(port, UART_IER);
90 serial_out(port, UART_IER, 0); 90 serial_out(port, UART_IER, 0);
91 91
92 while (*s && count-- > 0) { 92 uart_console_write(port, s, count, putc);
93 putc(port, *s);
94 if (*s == '\n')
95 putc(port, '\r');
96 s++;
97 }
98 93
99 /* Wait for transmitter to become empty and restore the IER */ 94 /* Wait for transmitter to become empty and restore the IER */
100 wait_for_xmitr(port); 95 wait_for_xmitr(port);
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 321a3b3a5728..e04d5e82d9ae 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -591,12 +591,18 @@ static struct uart_amba_port amba_ports[UART_NR] = {
591 591
592#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE 592#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
593 593
594static void pl010_console_putchar(struct uart_port *port, int ch)
595{
596 while (!UART_TX_READY(UART_GET_FR(port)))
597 barrier();
598 UART_PUT_CHAR(port, ch);
599}
600
594static void 601static void
595pl010_console_write(struct console *co, const char *s, unsigned int count) 602pl010_console_write(struct console *co, const char *s, unsigned int count)
596{ 603{
597 struct uart_port *port = &amba_ports[co->index].port; 604 struct uart_port *port = &amba_ports[co->index].port;
598 unsigned int status, old_cr; 605 unsigned int status, old_cr;
599 int i;
600 606
601 /* 607 /*
602 * First save the CR then disable the interrupts 608 * First save the CR then disable the interrupts
@@ -604,21 +610,7 @@ pl010_console_write(struct console *co, const char *s, unsigned int count)
604 old_cr = UART_GET_CR(port); 610 old_cr = UART_GET_CR(port);
605 UART_PUT_CR(port, UART01x_CR_UARTEN); 611 UART_PUT_CR(port, UART01x_CR_UARTEN);
606 612
607 /* 613 uart_console_write(port, s, count, pl010_console_putchar);
608 * Now, do each character
609 */
610 for (i = 0; i < count; i++) {
611 do {
612 status = UART_GET_FR(port);
613 } while (!UART_TX_READY(status));
614 UART_PUT_CHAR(port, s[i]);
615 if (s[i] == '\n') {
616 do {
617 status = UART_GET_FR(port);
618 } while (!UART_TX_READY(status));
619 UART_PUT_CHAR(port, '\r');
620 }
621 }
622 614
623 /* 615 /*
624 * Finally, wait for transmitter to become empty 616 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 034a029e356e..3d966cfc9a38 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -587,14 +587,12 @@ static struct uart_amba_port *amba_ports[UART_NR];
587 587
588#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE 588#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
589 589
590static inline void 590static void pl011_console_putchar(struct uart_port *port, int ch)
591pl011_console_write_char(struct uart_amba_port *uap, char ch)
592{ 591{
593 unsigned int status; 592 struct uart_amba_port *uap = (struct uart_amba_port *)port;
594 593
595 do { 594 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
596 status = readw(uap->port.membase + UART01x_FR); 595 barrier();
597 } while (status & UART01x_FR_TXFF);
598 writew(ch, uap->port.membase + UART01x_DR); 596 writew(ch, uap->port.membase + UART01x_DR);
599} 597}
600 598
@@ -603,7 +601,6 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
603{ 601{
604 struct uart_amba_port *uap = amba_ports[co->index]; 602 struct uart_amba_port *uap = amba_ports[co->index];
605 unsigned int status, old_cr, new_cr; 603 unsigned int status, old_cr, new_cr;
606 int i;
607 604
608 clk_enable(uap->clk); 605 clk_enable(uap->clk);
609 606
@@ -615,14 +612,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
615 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 612 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
616 writew(new_cr, uap->port.membase + UART011_CR); 613 writew(new_cr, uap->port.membase + UART011_CR);
617 614
618 /* 615 uart_console_write(&uap->port, s, count, pl011_console_putchar);
619 * Now, do each character
620 */
621 for (i = 0; i < count; i++) {
622 pl011_console_write_char(uap, s[i]);
623 if (s[i] == '\n')
624 pl011_console_write_char(uap, '\r');
625 }
626 616
627 /* 617 /*
628 * Finally, wait for transmitter to become empty 618 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/at91_serial.c b/drivers/serial/at91_serial.c
index 2113feb75c39..6547fe0cef96 100644
--- a/drivers/serial/at91_serial.c
+++ b/drivers/serial/at91_serial.c
@@ -711,6 +711,12 @@ void __init at91_register_uart(int idx, int port)
711} 711}
712 712
713#ifdef CONFIG_SERIAL_AT91_CONSOLE 713#ifdef CONFIG_SERIAL_AT91_CONSOLE
714static void at91_console_putchar(struct uart_port *port, int ch)
715{
716 while (!(UART_GET_CSR(port) & AT91_US_TXRDY))
717 barrier();
718 UART_PUT_CHAR(port, ch);
719}
714 720
715/* 721/*
716 * Interrupts are disabled on entering 722 * Interrupts are disabled on entering
@@ -718,7 +724,7 @@ void __init at91_register_uart(int idx, int port)
718static void at91_console_write(struct console *co, const char *s, u_int count) 724static void at91_console_write(struct console *co, const char *s, u_int count)
719{ 725{
720 struct uart_port *port = at91_ports + co->index; 726 struct uart_port *port = at91_ports + co->index;
721 unsigned int status, i, imr; 727 unsigned int status, imr;
722 728
723 /* 729 /*
724 * First, save IMR and then disable interrupts 730 * First, save IMR and then disable interrupts
@@ -726,21 +732,7 @@ static void at91_console_write(struct console *co, const char *s, u_int count)
726 imr = UART_GET_IMR(port); /* get interrupt mask */ 732 imr = UART_GET_IMR(port); /* get interrupt mask */
727 UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY); 733 UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY);
728 734
729 /* 735 uart_console_write(port, s, count, at91_console_putchar);
730 * Now, do each character
731 */
732 for (i = 0; i < count; i++) {
733 do {
734 status = UART_GET_CSR(port);
735 } while (!(status & AT91_US_TXRDY));
736 UART_PUT_CHAR(port, s[i]);
737 if (s[i] == '\n') {
738 do {
739 status = UART_GET_CSR(port);
740 } while (!(status & AT91_US_TXRDY));
741 UART_PUT_CHAR(port, '\r');
742 }
743 }
744 736
745 /* 737 /*
746 * Finally, wait for transmitter to become empty 738 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c
index 344022fe53ef..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
136static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) 136static 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
141static _INLINE_ void 141static void serial_out(struct uart_8250_port *up, int offset, int value)
142serial_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
240static _INLINE_ void 239static void
241receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) 240receive_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
315static _INLINE_ void transmit_chars(struct uart_8250_port *up) 314static 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
349static _INLINE_ void check_modem_status(struct uart_8250_port *up) 348static void check_modem_status(struct uart_8250_port *up)
350{ 349{
351 int status; 350 int status;
352 351
@@ -1121,6 +1120,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up)
1121 } 1120 }
1122} 1121}
1123 1122
1123static void au1x00_console_putchar(struct uart_port *port, int ch)
1124{
1125 struct uart_8250_port *up = (struct uart_8250_port *)port;
1126
1127 wait_for_xmitr(up);
1128 serial_out(up, UART_TX, ch);
1129}
1130
1124/* 1131/*
1125 * Print a string to the serial port trying not to disturb 1132 * Print a string to the serial port trying not to disturb
1126 * any possible real use of the port... 1133 * any possible real use of the port...
@@ -1132,7 +1139,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
1132{ 1139{
1133 struct uart_8250_port *up = &serial8250_ports[co->index]; 1140 struct uart_8250_port *up = &serial8250_ports[co->index];
1134 unsigned int ier; 1141 unsigned int ier;
1135 int i;
1136 1142
1137 /* 1143 /*
1138 * First save the UER then disable the interrupts 1144 * First save the UER then disable the interrupts
@@ -1140,22 +1146,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
1140 ier = serial_in(up, UART_IER); 1146 ier = serial_in(up, UART_IER);
1141 serial_out(up, UART_IER, 0); 1147 serial_out(up, UART_IER, 0);
1142 1148
1143 /* 1149 uart_console_write(&up->port, s, count, au1x00_console_putchar);
1144 * Now, do each character
1145 */
1146 for (i = 0; i < count; i++, s++) {
1147 wait_for_xmitr(up);
1148
1149 /*
1150 * Send the character out.
1151 * If a LF, also do CR...
1152 */
1153 serial_out(up, UART_TX, *s);
1154 if (*s == 10) {
1155 wait_for_xmitr(up);
1156 serial_out(up, UART_TX, 13);
1157 }
1158 }
1159 1150
1160 /* 1151 /*
1161 * Finally, wait for transmitter to become empty 1152 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index ce7b2e4ecd17..2691112c84ad 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -424,6 +424,13 @@ static struct uart_port clps711x_ports[UART_NR] = {
424}; 424};
425 425
426#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE 426#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
427static void clps711xuart_console_putchar(struct uart_port *port, int ch)
428{
429 while (clps_readl(SYSFLG(port)) & SYSFLG_UTXFF)
430 barrier();
431 clps_writel(ch, UARTDR(port));
432}
433
427/* 434/*
428 * Print a string to the serial port trying not to disturb 435 * Print a string to the serial port trying not to disturb
429 * any possible real use of the port... 436 * any possible real use of the port...
@@ -438,7 +445,6 @@ clps711xuart_console_write(struct console *co, const char *s,
438{ 445{
439 struct uart_port *port = clps711x_ports + co->index; 446 struct uart_port *port = clps711x_ports + co->index;
440 unsigned int status, syscon; 447 unsigned int status, syscon;
441 int i;
442 448
443 /* 449 /*
444 * Ensure that the port is enabled. 450 * Ensure that the port is enabled.
@@ -446,21 +452,7 @@ clps711xuart_console_write(struct console *co, const char *s,
446 syscon = clps_readl(SYSCON(port)); 452 syscon = clps_readl(SYSCON(port));
447 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port)); 453 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port));
448 454
449 /* 455 uart_console_write(port, s, count, clps711xuart_console_putchar);
450 * Now, do each character
451 */
452 for (i = 0; i < count; i++) {
453 do {
454 status = clps_readl(SYSFLG(port));
455 } while (status & SYSFLG_UTXFF);
456 clps_writel(s[i], UARTDR(port));
457 if (s[i] == '\n') {
458 do {
459 status = clps_readl(SYSFLG(port));
460 } while (status & SYSFLG_UTXFF);
461 clps_writel('\r', UARTDR(port));
462 }
463 }
464 456
465 /* 457 /*
466 * Finally, wait for transmitter to become empty 458 * Finally, wait for transmitter to become empty
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
486struct tty_driver *serial_driver; 484struct 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);
591static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 589static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
592static int rs_write(struct tty_struct * tty, int from_user, 590static int rs_write(struct tty_struct * tty, int from_user,
593 const unsigned char *buf, int count); 591 const unsigned char *buf, int count);
594extern _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
597static int e100_write_rs485(struct tty_struct * tty, int from_user, 593static 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
1541static _INLINE_ void 1537static void e100_disable_txdma_irq(struct e100_serial *info)
1542e100_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
1551static _INLINE_ void 1546static void e100_enable_txdma_irq(struct e100_serial *info)
1552e100_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
1561static _INLINE_ void 1555static void e100_disable_txdma_channel(struct e100_serial *info)
1562e100_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
1602static _INLINE_ void 1595static void e100_enable_txdma_channel(struct e100_serial *info)
1603e100_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
1628static _INLINE_ void 1620static void e100_disable_rxdma_channel(struct e100_serial *info)
1629e100_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
1668static _INLINE_ void 1659static void e100_enable_rxdma_channel(struct e100_serial *info)
1669e100_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 */
1916static _INLINE_ void 1906static void rs_sched_event(struct e100_serial *info, int event)
1917rs_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
2158extern _INLINE_ unsigned int 2146static unsigned int handle_descr_data(struct e100_serial *info,
2159handle_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
2185static _INLINE_ unsigned int 2174static unsigned int handle_all_descr_data(struct e100_serial *info)
2186handle_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
2233static _INLINE_ void 2221static void receive_chars_dma(struct e100_serial *info)
2234receive_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
2295static _INLINE_ int 2282static int start_recv_dma(struct e100_serial *info)
2296start_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
2351static _INLINE_ void
2352status_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
2457static _INLINE_ int 2438static int force_eop_if_needed(struct e100_serial *info)
2458force_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
2502extern _INLINE_ void 2482static void flush_to_flip_buffer(struct e100_serial *info)
2503flush_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
2614static _INLINE_ void 2593static void check_flush_timeout(struct e100_serial *info)
2615check_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
2744extern _INLINE_ 2722static
2745struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2723struct 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
2878extern _INLINE_ 2856static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
2879struct 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
2998extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info) 2975static 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
3624extern _INLINE_ int 3601static int rs_raw_write(struct tty_struct * tty, int from_user,
3625rs_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
4713extern _INLINE_ int line_info(char *buf, struct e100_serial *info) 4689static 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/dz.c b/drivers/serial/dz.c
index ba5541de673b..bf71bad5c34f 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -674,11 +674,12 @@ static void dz_reset(struct dz_port *dport)
674} 674}
675 675
676#ifdef CONFIG_SERIAL_DZ_CONSOLE 676#ifdef CONFIG_SERIAL_DZ_CONSOLE
677static void dz_console_put_char(struct dz_port *dport, unsigned char ch) 677static void dz_console_putchar(struct uart_port *port, int ch)
678{ 678{
679 struct dz_port *dport = (struct dz_port *)uport;
679 unsigned long flags; 680 unsigned long flags;
680 int loops = 2500; 681 int loops = 2500;
681 unsigned short tmp = ch; 682 unsigned short tmp = (unsigned char)ch;
682 /* this code sends stuff out to serial device - spinning its 683 /* this code sends stuff out to serial device - spinning its
683 wheels and waiting. */ 684 wheels and waiting. */
684 685
@@ -694,6 +695,7 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
694 695
695 spin_unlock_irqrestore(&dport->port.lock, flags); 696 spin_unlock_irqrestore(&dport->port.lock, flags);
696} 697}
698
697/* 699/*
698 * ------------------------------------------------------------------- 700 * -------------------------------------------------------------------
699 * dz_console_print () 701 * dz_console_print ()
@@ -710,11 +712,7 @@ static void dz_console_print(struct console *cons,
710#ifdef DEBUG_DZ 712#ifdef DEBUG_DZ
711 prom_printf((char *) str); 713 prom_printf((char *) str);
712#endif 714#endif
713 while (count--) { 715 uart_console_write(&dport->port, str, count, dz_console_putchar);
714 if (*str == '\n')
715 dz_console_put_char(dport, '\r');
716 dz_console_put_char(dport, *str++);
717 }
718} 716}
719 717
720static int __init dz_console_setup(struct console *co, char *options) 718static int __init dz_console_setup(struct console *co, char *options)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 4d53fb5ca87b..c3b7a6673e9c 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -743,6 +743,13 @@ static void __init imx_init_ports(void)
743} 743}
744 744
745#ifdef CONFIG_SERIAL_IMX_CONSOLE 745#ifdef CONFIG_SERIAL_IMX_CONSOLE
746static void imx_console_putchar(struct uart_port *port, int ch)
747{
748 struct imx_port *sport = (struct imx_port *)port;
749 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
750 barrier();
751 URTX0((u32)sport->port.membase) = ch;
752}
746 753
747/* 754/*
748 * Interrupts are disabled on entering 755 * Interrupts are disabled on entering
@@ -751,7 +758,7 @@ static void
751imx_console_write(struct console *co, const char *s, unsigned int count) 758imx_console_write(struct console *co, const char *s, unsigned int count)
752{ 759{
753 struct imx_port *sport = &imx_ports[co->index]; 760 struct imx_port *sport = &imx_ports[co->index];
754 unsigned int old_ucr1, old_ucr2, i; 761 unsigned int old_ucr1, old_ucr2;
755 762
756 /* 763 /*
757 * First, save UCR1/2 and then disable interrupts 764 * First, save UCR1/2 and then disable interrupts
@@ -764,22 +771,7 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
764 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); 771 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
765 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN; 772 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
766 773
767 /* 774 uart_console_write(&sport->port, s, count, imx_console_putchar);
768 * Now, do each character
769 */
770 for (i = 0; i < count; i++) {
771
772 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
773 barrier();
774
775 URTX0((u32)sport->port.membase) = s[i];
776
777 if (s[i] == '\n') {
778 while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
779 barrier();
780 URTX0((u32)sport->port.membase) = '\r';
781 }
782 }
783 775
784 /* 776 /*
785 * Finally, wait for transmitter to become empty 777 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 193722d680cf..651772474ac1 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -967,8 +967,9 @@ static struct zilog_layout * __init get_zs(int chip)
967#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */ 967#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
968 968
969#ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE 969#ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE
970static void ip22zilog_put_char(struct zilog_channel *channel, unsigned char ch) 970static void ip22zilog_put_char(struct uart_port *port, int ch)
971{ 971{
972 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
972 int loops = ZS_PUT_CHAR_MAX_DELAY; 973 int loops = ZS_PUT_CHAR_MAX_DELAY;
973 974
974 /* This is a timed polling loop so do not switch the explicit 975 /* This is a timed polling loop so do not switch the explicit
@@ -992,16 +993,10 @@ static void
992ip22zilog_console_write(struct console *con, const char *s, unsigned int count) 993ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
993{ 994{
994 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index]; 995 struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
995 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
996 unsigned long flags; 996 unsigned long flags;
997 int i;
998 997
999 spin_lock_irqsave(&up->port.lock, flags); 998 spin_lock_irqsave(&up->port.lock, flags);
1000 for (i = 0; i < count; i++, s++) { 999 uart_console_write(&up->port, s, count, ip22zilog_put_char);
1001 ip22zilog_put_char(channel, *s);
1002 if (*s == 10)
1003 ip22zilog_put_char(channel, 13);
1004 }
1005 udelay(2); 1000 udelay(2);
1006 spin_unlock_irqrestore(&up->port.lock, flags); 1001 spin_unlock_irqrestore(&up->port.lock, flags);
1007} 1002}
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
index 242a04104393..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
251static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset) 251static 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
256static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value) 256static 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
261static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset) 261static 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
269static _INLINE_ void 269static void serial_out(struct uart_sio_port *up, int offset, int value)
270serial_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
329static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, 328static 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
403static _INLINE_ void transmit_chars(struct uart_sio_port *up) 402static 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;
@@ -1039,6 +1038,14 @@ static inline void wait_for_xmitr(struct uart_sio_port *up)
1039 } 1038 }
1040} 1039}
1041 1040
1041static void m32r_sio_console_putchar(struct uart_port *port, int ch)
1042{
1043 struct uart_sio_port *up = (struct uart_sio_port *)port;
1044
1045 wait_for_xmitr(up);
1046 sio_out(up, SIOTXB, ch);
1047}
1048
1042/* 1049/*
1043 * Print a string to the serial port trying not to disturb 1050 * Print a string to the serial port trying not to disturb
1044 * any possible real use of the port... 1051 * any possible real use of the port...
@@ -1058,23 +1065,7 @@ static void m32r_sio_console_write(struct console *co, const char *s,
1058 ier = sio_in(up, SIOTRCR); 1065 ier = sio_in(up, SIOTRCR);
1059 sio_out(up, SIOTRCR, 0); 1066 sio_out(up, SIOTRCR, 0);
1060 1067
1061 /* 1068 uart_console_write(&up->port, s, count, m32r_sio_console_putchar);
1062 * Now, do each character
1063 */
1064 for (i = 0; i < count; i++, s++) {
1065 wait_for_xmitr(up);
1066
1067 /*
1068 * Send the character out.
1069 * If a LF, also do CR...
1070 */
1071 sio_out(up, SIOTXB, *s);
1072
1073 if (*s == 10) {
1074 wait_for_xmitr(up);
1075 sio_out(up, SIOTXB, 13);
1076 }
1077 }
1078 1069
1079 /* 1070 /*
1080 * Finally, wait for transmitter to become empty 1071 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 61dd17d7bace..928e6cf12dca 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -603,15 +603,14 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
603 udelay(1); 603 udelay(1);
604 604
605 /* Write all the chars */ 605 /* Write all the chars */
606 for ( i=0 ; i<count ; i++ ) { 606 for (i = 0; i < count; i++, s++) {
607
608 /* Send the char */
609 out_8(&psc->mpc52xx_psc_buffer_8, *s);
610
611 /* Line return handling */ 607 /* Line return handling */
612 if ( *s++ == '\n' ) 608 if (*s == '\n')
613 out_8(&psc->mpc52xx_psc_buffer_8, '\r'); 609 out_8(&psc->mpc52xx_psc_buffer_8, '\r');
614 610
611 /* Send the char */
612 out_8(&psc->mpc52xx_psc_buffer_8, *s);
613
615 /* Wait the TX buffer to be empty */ 614 /* Wait the TX buffer to be empty */
616 j = 20000; /* Maximum wait */ 615 j = 20000; /* Maximum wait */
617 while (!(in_be16(&psc->mpc52xx_psc_status) & 616 while (!(in_be16(&psc->mpc52xx_psc_status) &
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 9b7ed58cb53b..513ff8597707 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1916,6 +1916,16 @@ static void __exit exit_pmz(void)
1916 1916
1917#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 1917#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
1918 1918
1919static void pmz_console_putchar(struct uart_port *port, int ch)
1920{
1921 struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
1922
1923 /* Wait for the transmit buffer to empty. */
1924 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1925 udelay(5);
1926 write_zsdata(uap, ch);
1927}
1928
1919/* 1929/*
1920 * Print a string to the serial port trying not to disturb 1930 * Print a string to the serial port trying not to disturb
1921 * any possible real use of the port... 1931 * any possible real use of the port...
@@ -1924,7 +1934,6 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
1924{ 1934{
1925 struct uart_pmac_port *uap = &pmz_ports[con->index]; 1935 struct uart_pmac_port *uap = &pmz_ports[con->index];
1926 unsigned long flags; 1936 unsigned long flags;
1927 int i;
1928 1937
1929 if (ZS_IS_ASLEEP(uap)) 1938 if (ZS_IS_ASLEEP(uap))
1930 return; 1939 return;
@@ -1934,17 +1943,7 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
1934 write_zsreg(uap, R1, uap->curregs[1] & ~TxINT_ENAB); 1943 write_zsreg(uap, R1, uap->curregs[1] & ~TxINT_ENAB);
1935 write_zsreg(uap, R5, uap->curregs[5] | TxENABLE | RTS | DTR); 1944 write_zsreg(uap, R5, uap->curregs[5] | TxENABLE | RTS | DTR);
1936 1945
1937 for (i = 0; i < count; i++) { 1946 uart_console_write(&uap->port, s, count, pmz_console_putchar);
1938 /* Wait for the transmit buffer to empty. */
1939 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1940 udelay(5);
1941 write_zsdata(uap, s[i]);
1942 if (s[i] == 10) {
1943 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
1944 udelay(5);
1945 write_zsdata(uap, R13);
1946 }
1947 }
1948 1947
1949 /* Restore the values in the registers. */ 1948 /* Restore the values in the registers. */
1950 write_zsreg(uap, R1, uap->curregs[1]); 1949 write_zsreg(uap, R1, uap->curregs[1]);
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 10535f00301f..77d4568ccc3a 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -619,6 +619,14 @@ static inline void wait_for_xmitr(struct uart_pxa_port *up)
619 } 619 }
620} 620}
621 621
622static void serial_pxa_console_putchar(struct uart_port *port, int ch)
623{
624 struct uart_pxa_port *up = (struct uart_pxa_port *)port;
625
626 wait_for_xmitr(up);
627 serial_out(up, UART_TX, ch);
628}
629
622/* 630/*
623 * Print a string to the serial port trying not to disturb 631 * Print a string to the serial port trying not to disturb
624 * any possible real use of the port... 632 * any possible real use of the port...
@@ -630,7 +638,6 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
630{ 638{
631 struct uart_pxa_port *up = &serial_pxa_ports[co->index]; 639 struct uart_pxa_port *up = &serial_pxa_ports[co->index];
632 unsigned int ier; 640 unsigned int ier;
633 int i;
634 641
635 /* 642 /*
636 * First save the IER then disable the interrupts 643 * First save the IER then disable the interrupts
@@ -638,22 +645,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
638 ier = serial_in(up, UART_IER); 645 ier = serial_in(up, UART_IER);
639 serial_out(up, UART_IER, UART_IER_UUE); 646 serial_out(up, UART_IER, UART_IER_UUE);
640 647
641 /* 648 uart_console_write(&up->port, s, count, serial_pxa_console_putchar);
642 * Now, do each character
643 */
644 for (i = 0; i < count; i++, s++) {
645 wait_for_xmitr(up);
646
647 /*
648 * Send the character out.
649 * If a LF, also do CR...
650 */
651 serial_out(up, UART_TX, *s);
652 if (*s == 10) {
653 wait_for_xmitr(up);
654 serial_out(up, UART_TX, 13);
655 }
656 }
657 649
658 /* 650 /*
659 * Finally, wait for transmitter to become empty 651 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 00d7c0ad8cbf..f5aac92fb798 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1586,25 +1586,19 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
1586} 1586}
1587 1587
1588static void 1588static void
1589s3c24xx_serial_console_write(struct console *co, const char *s, 1589s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
1590 unsigned int count)
1591{ 1590{
1592 int i;
1593 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1591 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
1592 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1593 barrier();
1594 wr_regb(cons_uart, S3C2410_UTXH, ch);
1595}
1594 1596
1595 for (i = 0; i < count; i++) { 1597static void
1596 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon)) 1598s3c24xx_serial_console_write(struct console *co, const char *s,
1597 barrier(); 1599 unsigned int count)
1598 1600{
1599 wr_regb(cons_uart, S3C2410_UTXH, s[i]); 1601 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
1600
1601 if (s[i] == '\n') {
1602 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
1603 barrier();
1604
1605 wr_regb(cons_uart, S3C2410_UTXH, '\r');
1606 }
1607 }
1608} 1602}
1609 1603
1610static void __init 1604static void __init
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 2c00b8625852..c2d9068b491d 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -689,6 +689,14 @@ void __init sa1100_register_uart(int idx, int port)
689 689
690 690
691#ifdef CONFIG_SERIAL_SA1100_CONSOLE 691#ifdef CONFIG_SERIAL_SA1100_CONSOLE
692static void sa1100_console_putchar(struct uart_port *port, int ch)
693{
694 struct sa1100_port *sport = (struct sa1100_port *)port;
695
696 while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
697 barrier();
698 UART_PUT_CHAR(sport, ch);
699}
692 700
693/* 701/*
694 * Interrupts are disabled on entering 702 * Interrupts are disabled on entering
@@ -697,7 +705,7 @@ static void
697sa1100_console_write(struct console *co, const char *s, unsigned int count) 705sa1100_console_write(struct console *co, const char *s, unsigned int count)
698{ 706{
699 struct sa1100_port *sport = &sa1100_ports[co->index]; 707 struct sa1100_port *sport = &sa1100_ports[co->index];
700 unsigned int old_utcr3, status, i; 708 unsigned int old_utcr3, status;
701 709
702 /* 710 /*
703 * First, save UTCR3 and then disable interrupts 711 * First, save UTCR3 and then disable interrupts
@@ -706,21 +714,7 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count)
706 UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) | 714 UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
707 UTCR3_TXE); 715 UTCR3_TXE);
708 716
709 /* 717 uart_console_write(&sport->port, s, count, sa1100_console_putchar);
710 * Now, do each character
711 */
712 for (i = 0; i < count; i++) {
713 do {
714 status = UART_GET_UTSR1(sport);
715 } while (!(status & UTSR1_TNF));
716 UART_PUT_CHAR(sport, s[i]);
717 if (s[i] == '\n') {
718 do {
719 status = UART_GET_UTSR1(sport);
720 } while (!(status & UTSR1_TNF));
721 UART_PUT_CHAR(sport, '\r');
722 }
723 }
724 718
725 /* 719 /*
726 * Finally, wait for transmitter to become empty 720 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index cc1faa31d124..fcd7744c4253 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1755,6 +1755,27 @@ static int uart_read_proc(char *page, char **start, off_t off,
1755 1755
1756#ifdef CONFIG_SERIAL_CORE_CONSOLE 1756#ifdef CONFIG_SERIAL_CORE_CONSOLE
1757/* 1757/*
1758 * uart_console_write - write a console message to a serial port
1759 * @port: the port to write the message
1760 * @s: array of characters
1761 * @count: number of characters in string to write
1762 * @write: function to write character to port
1763 */
1764void uart_console_write(struct uart_port *port, const char *s,
1765 unsigned int count,
1766 void (*putchar)(struct uart_port *, int))
1767{
1768 unsigned int i;
1769
1770 for (i = 0; i < count; i++, s++) {
1771 if (*s == '\n')
1772 putchar(port, '\r');
1773 putchar(port, *s);
1774 }
1775}
1776EXPORT_SYMBOL_GPL(uart_console_write);
1777
1778/*
1758 * Check whether an invalid uart number has been specified, and 1779 * Check whether an invalid uart number has been specified, and
1759 * if so, search for the first available port that does have 1780 * if so, search for the first available port that does have
1760 * console support. 1781 * console support.
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 04186eaae227..aa521b8e0d4e 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -543,6 +543,12 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
543#else 543#else
544# define LH7A40X_CONSOLE &lh7a40x_console 544# define LH7A40X_CONSOLE &lh7a40x_console
545 545
546static void lh7a40xuart_console_putchar(struct uart_port *port, int ch)
547{
548 while (UR(port, UART_R_STATUS) & nTxRdy)
549 ;
550 UR(port, UART_R_DATA) = ch;
551}
546 552
547static void lh7a40xuart_console_write (struct console* co, 553static void lh7a40xuart_console_write (struct console* co,
548 const char* s, 554 const char* s,
@@ -556,16 +562,7 @@ static void lh7a40xuart_console_write (struct console* co,
556 UR (port, UART_R_INTEN) = 0; /* Disable all interrupts */ 562 UR (port, UART_R_INTEN) = 0; /* Disable all interrupts */
557 BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */ 563 BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */
558 564
559 for (; count-- > 0; ++s) { 565 uart_console_write(port, s, count, lh7a40xuart_console_putchar);
560 while (UR (port, UART_R_STATUS) & nTxRdy)
561 ;
562 UR (port, UART_R_DATA) = *s;
563 if (*s == '\n') {
564 while ((UR (port, UART_R_STATUS) & TxBusy))
565 ;
566 UR (port, UART_R_DATA) = '\r';
567 }
568 }
569 566
570 /* Wait until all characters are sent */ 567 /* Wait until all characters are sent */
571 while (UR (port, UART_R_STATUS) & TxBusy) 568 while (UR (port, UART_R_STATUS) & TxBusy)
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 141173efd463..b848b7d94412 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -863,6 +863,14 @@ static inline void wait_for_xmitr(struct uart_txx9_port *up)
863 } 863 }
864} 864}
865 865
866static void serial_txx9_console_putchar(struct uart_port *port, int ch)
867{
868 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
869
870 wait_for_xmitr(up);
871 sio_out(up, TXX9_SITFIFO, ch);
872}
873
866/* 874/*
867 * Print a string to the serial port trying not to disturb 875 * Print a string to the serial port trying not to disturb
868 * any possible real use of the port... 876 * any possible real use of the port...
@@ -874,7 +882,6 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
874{ 882{
875 struct uart_txx9_port *up = &serial_txx9_ports[co->index]; 883 struct uart_txx9_port *up = &serial_txx9_ports[co->index];
876 unsigned int ier, flcr; 884 unsigned int ier, flcr;
877 int i;
878 885
879 /* 886 /*
880 * First save the UER then disable the interrupts 887 * First save the UER then disable the interrupts
@@ -888,22 +895,7 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
888 if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES)) 895 if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES))
889 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES); 896 sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES);
890 897
891 /* 898 uart_console_write(&up->port, s, count, serial_txx9_console_putchar);
892 * Now, do each character
893 */
894 for (i = 0; i < count; i++, s++) {
895 wait_for_xmitr(up);
896
897 /*
898 * Send the character out.
899 * If a LF, also do CR...
900 */
901 sio_out(up, TXX9_SITFIFO, *s);
902 if (*s == 10) {
903 wait_for_xmitr(up);
904 sio_out(up, TXX9_SITFIFO, 13);
905 }
906 }
907 899
908 /* 900 /*
909 * Finally, wait for transmitter to become empty 901 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index a2fb0c2fb121..bfbe9dc90cca 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -861,8 +861,9 @@ static int num_channels;
861 861
862#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE 862#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
863 863
864static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char c) 864static void sunsab_console_putchar(struct uart_port *port, int c)
865{ 865{
866 struct uart_sunsab_port *up = (struct uart_sunsab_port *)port;
866 unsigned long flags; 867 unsigned long flags;
867 868
868 spin_lock_irqsave(&up->port.lock, flags); 869 spin_lock_irqsave(&up->port.lock, flags);
@@ -876,13 +877,8 @@ static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char
876static void sunsab_console_write(struct console *con, const char *s, unsigned n) 877static void sunsab_console_write(struct console *con, const char *s, unsigned n)
877{ 878{
878 struct uart_sunsab_port *up = &sunsab_ports[con->index]; 879 struct uart_sunsab_port *up = &sunsab_ports[con->index];
879 int i;
880 880
881 for (i = 0; i < n; i++) { 881 uart_console_write(&up->port, s, n, sunsab_console_putchar);
882 if (*s == '\n')
883 sunsab_console_putchar(up, '\r');
884 sunsab_console_putchar(up, *s++);
885 }
886 sunsab_tec_wait(up); 882 sunsab_tec_wait(up);
887} 883}
888 884
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 46c44b83f57c..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_ 105static unsigned int serial_in(struct uart_sunsu_port *up, int offset)
106
107static _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
124static _INLINE_ void 122static void serial_out(struct uart_sunsu_port *up, int offset, int value)
125serial_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
319static _INLINE_ struct tty_struct * 316static struct tty_struct *
320receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) 317receive_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
398static _INLINE_ void transmit_chars(struct uart_sunsu_port *up) 395static 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
434static _INLINE_ void check_modem_status(struct uart_sunsu_port *up) 431static void check_modem_status(struct uart_sunsu_port *up)
435{ 432{
436 int status; 433 int status;
437 434
@@ -1377,6 +1374,14 @@ static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)
1377 } 1374 }
1378} 1375}
1379 1376
1377static void sunsu_console_putchar(struct uart_port *port, int ch)
1378{
1379 struct uart_sunsu_port *up = (struct uart_sunsu_port *)port;
1380
1381 wait_for_xmitr(up);
1382 serial_out(up, UART_TX, ch);
1383}
1384
1380/* 1385/*
1381 * Print a string to the serial port trying not to disturb 1386 * Print a string to the serial port trying not to disturb
1382 * any possible real use of the port... 1387 * any possible real use of the port...
@@ -1386,7 +1391,6 @@ static void sunsu_console_write(struct console *co, const char *s,
1386{ 1391{
1387 struct uart_sunsu_port *up = &sunsu_ports[co->index]; 1392 struct uart_sunsu_port *up = &sunsu_ports[co->index];
1388 unsigned int ier; 1393 unsigned int ier;
1389 int i;
1390 1394
1391 /* 1395 /*
1392 * First save the UER then disable the interrupts 1396 * First save the UER then disable the interrupts
@@ -1394,22 +1398,7 @@ static void sunsu_console_write(struct console *co, const char *s,
1394 ier = serial_in(up, UART_IER); 1398 ier = serial_in(up, UART_IER);
1395 serial_out(up, UART_IER, 0); 1399 serial_out(up, UART_IER, 0);
1396 1400
1397 /* 1401 uart_console_write(&up->port, s, count, sunsu_console_putchar);
1398 * Now, do each character
1399 */
1400 for (i = 0; i < count; i++, s++) {
1401 wait_for_xmitr(up);
1402
1403 /*
1404 * Send the character out.
1405 * If a LF, also do CR...
1406 */
1407 serial_out(up, UART_TX, *s);
1408 if (*s == 10) {
1409 wait_for_xmitr(up);
1410 serial_out(up, UART_TX, 13);
1411 }
1412 }
1413 1402
1414 /* 1403 /*
1415 * Finally, wait for transmitter to become empty 1404 * Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 10b35c6f287d..cd49ebbf4a45 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1252,8 +1252,9 @@ static struct zilog_layout __iomem * __init get_zs(int chip, int node)
1252 1252
1253#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */ 1253#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
1254 1254
1255static void sunzilog_put_char(struct zilog_channel __iomem *channel, unsigned char ch) 1255static void sunzilog_putchar(struct uart_port *port, int ch)
1256{ 1256{
1257 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
1257 int loops = ZS_PUT_CHAR_MAX_DELAY; 1258 int loops = ZS_PUT_CHAR_MAX_DELAY;
1258 1259
1259 /* This is a timed polling loop so do not switch the explicit 1260 /* This is a timed polling loop so do not switch the explicit
@@ -1284,7 +1285,7 @@ static int sunzilog_serio_write(struct serio *serio, unsigned char ch)
1284 1285
1285 spin_lock_irqsave(&sunzilog_serio_lock, flags); 1286 spin_lock_irqsave(&sunzilog_serio_lock, flags);
1286 1287
1287 sunzilog_put_char(ZILOG_CHANNEL_FROM_PORT(&up->port), ch); 1288 sunzilog_putchar(&up->port, ch);
1288 1289
1289 spin_unlock_irqrestore(&sunzilog_serio_lock, flags); 1290 spin_unlock_irqrestore(&sunzilog_serio_lock, flags);
1290 1291
@@ -1325,16 +1326,10 @@ static void
1325sunzilog_console_write(struct console *con, const char *s, unsigned int count) 1326sunzilog_console_write(struct console *con, const char *s, unsigned int count)
1326{ 1327{
1327 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index]; 1328 struct uart_sunzilog_port *up = &sunzilog_port_table[con->index];
1328 struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
1329 unsigned long flags; 1329 unsigned long flags;
1330 int i;
1331 1330
1332 spin_lock_irqsave(&up->port.lock, flags); 1331 spin_lock_irqsave(&up->port.lock, flags);
1333 for (i = 0; i < count; i++, s++) { 1332 uart_console_write(&up->port, s, count, sunzilog_putchar);
1334 sunzilog_put_char(channel, *s);
1335 if (*s == 10)
1336 sunzilog_put_char(channel, 13);
1337 }
1338 udelay(2); 1333 udelay(2);
1339 spin_unlock_irqrestore(&up->port.lock, flags); 1334 spin_unlock_irqrestore(&up->port.lock, flags);
1340} 1335}
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index bd6294132c18..df5e8713fa31 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -821,25 +821,23 @@ static void wait_for_xmitr(struct uart_port *port)
821 } 821 }
822} 822}
823 823
824static void siu_console_putchar(struct uart_port *port, int ch)
825{
826 wait_for_xmitr(port);
827 siu_write(port, UART_TX, ch);
828}
829
824static void siu_console_write(struct console *con, const char *s, unsigned count) 830static void siu_console_write(struct console *con, const char *s, unsigned count)
825{ 831{
826 struct uart_port *port; 832 struct uart_port *port;
827 uint8_t ier; 833 uint8_t ier;
828 unsigned i;
829 834
830 port = &siu_uart_ports[con->index]; 835 port = &siu_uart_ports[con->index];
831 836
832 ier = siu_read(port, UART_IER); 837 ier = siu_read(port, UART_IER);
833 siu_write(port, UART_IER, 0); 838 siu_write(port, UART_IER, 0);
834 839
835 for (i = 0; i < count && *s != '\0'; i++, s++) { 840 uart_console_write(port, s, count, siu_console_putchar);
836 wait_for_xmitr(port);
837 siu_write(port, UART_TX, *s);
838 if (*s == '\n') {
839 wait_for_xmitr(port);
840 siu_write(port, UART_TX, '\r');
841 }
842 }
843 841
844 wait_for_xmitr(port); 842 wait_for_xmitr(port);
845 siu_write(port, UART_IER, ier); 843 siu_write(port, UART_IER, ier);
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
191static void probe_sccs(void); 189static void probe_sccs(void);
192static void change_speed(struct dec_serial *info); 190static void change_speed(struct dec_serial *info);
193static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 191static 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 */
347static _INLINE_ void rs_sched_event(struct dec_serial *info, int event) 345static 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
353static _INLINE_ void receive_chars(struct dec_serial *info, 351static 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
444static _INLINE_ void status_handle(struct dec_serial *info) 441static void status_handle(struct dec_serial *info)
445{ 442{
446 unsigned char stat; 443 unsigned char stat;
447 444