aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 12:30:16 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 12:30:16 -0400
commit15dbb5a3f971a28040ae6cbcd8bbdf19b629fa83 (patch)
treee65562d7300ac653207b1e45ec7e5960ddf78fff /drivers/scsi
parentbe697c3f137c9ed808753bbbc5d7751c6e5303fc (diff)
parent5fadd053d9bb4345ec6f405d24db4e7eb49cf81e (diff)
Merge branch 'master'
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/NCR5380.c2
-rw-r--r--drivers/scsi/aacraid/aacraid.h2
-rw-r--r--drivers/scsi/ahci.c10
-rw-r--r--drivers/scsi/ata_piix.c4
-rw-r--r--drivers/scsi/eata.c2
-rw-r--r--drivers/scsi/hosts.c3
-rw-r--r--drivers/scsi/libata-core.c282
-rw-r--r--drivers/scsi/libata-scsi.c24
-rw-r--r--drivers/scsi/libata.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c2
-rw-r--r--drivers/scsi/osst.c6
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_rscn.c2
-rw-r--r--drivers/scsi/sata_mv.c7
-rw-r--r--drivers/scsi/sata_nv.c6
-rw-r--r--drivers/scsi/sata_promise.c20
-rw-r--r--drivers/scsi/sata_qstor.c8
-rw-r--r--drivers/scsi/sata_sil.c6
-rw-r--r--drivers/scsi/sata_sil24.c2
-rw-r--r--drivers/scsi/sata_sis.c2
-rw-r--r--drivers/scsi/sata_svw.c4
-rw-r--r--drivers/scsi/sata_sx4.c29
-rw-r--r--drivers/scsi/sata_uli.c2
-rw-r--r--drivers/scsi/sata_via.c2
-rw-r--r--drivers/scsi/sata_vsc.c14
-rw-r--r--drivers/scsi/scsi.c8
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/scsi/scsi_ioctl.c3
-rw-r--r--drivers/scsi/scsi_lib.c9
-rw-r--r--drivers/scsi/scsi_transport_fc.c13
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--drivers/scsi/st.c6
36 files changed, 341 insertions, 157 deletions
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index d40ba0bd68a3..23392ae7df8b 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -91,7 +91,7 @@
91#ifndef NDEBUG 91#ifndef NDEBUG
92#define NDEBUG 0 92#define NDEBUG 0
93#endif 93#endif
94#ifndef NDEBUG 94#ifndef NDEBUG_ABORT
95#define NDEBUG_ABORT 0 95#define NDEBUG_ABORT 0
96#endif 96#endif
97 97
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 4a99d2f000f4..d54b1cc88d0d 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -19,7 +19,7 @@
19#define AAC_MAX_LUN (8) 19#define AAC_MAX_LUN (8)
20 20
21#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 21#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)512) 22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)256)
23 23
24/* 24/*
25 * These macros convert from physical channels to virtual channels 25 * These macros convert from physical channels to virtual channels
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 5ec866b00479..fe8187d6f58b 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -216,7 +216,7 @@ static Scsi_Host_Template ahci_sht = {
216 .ordered_flush = 1, 216 .ordered_flush = 1,
217}; 217};
218 218
219static struct ata_port_operations ahci_ops = { 219static const struct ata_port_operations ahci_ops = {
220 .port_disable = ata_port_disable, 220 .port_disable = ata_port_disable,
221 221
222 .check_status = ahci_check_status, 222 .check_status = ahci_check_status,
@@ -407,7 +407,7 @@ static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
407 return 0xffffffffU; 407 return 0xffffffffU;
408 } 408 }
409 409
410 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 410 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
411} 411}
412 412
413 413
@@ -425,7 +425,7 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
425 return; 425 return;
426 } 426 }
427 427
428 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 428 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
429} 429}
430 430
431static void ahci_phy_reset(struct ata_port *ap) 431static void ahci_phy_reset(struct ata_port *ap)
@@ -453,14 +453,14 @@ static void ahci_phy_reset(struct ata_port *ap)
453 453
454static u8 ahci_check_status(struct ata_port *ap) 454static u8 ahci_check_status(struct ata_port *ap)
455{ 455{
456 void *mmio = (void *) ap->ioaddr.cmd_addr; 456 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
457 457
458 return readl(mmio + PORT_TFDATA) & 0xFF; 458 return readl(mmio + PORT_TFDATA) & 0xFF;
459} 459}
460 460
461static u8 ahci_check_err(struct ata_port *ap) 461static u8 ahci_check_err(struct ata_port *ap)
462{ 462{
463 void *mmio = (void *) ap->ioaddr.cmd_addr; 463 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
464 464
465 return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF; 465 return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF;
466} 466}
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index d71cef767cec..be021478f416 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -147,7 +147,7 @@ static Scsi_Host_Template piix_sht = {
147 .ordered_flush = 1, 147 .ordered_flush = 1,
148}; 148};
149 149
150static struct ata_port_operations piix_pata_ops = { 150static const struct ata_port_operations piix_pata_ops = {
151 .port_disable = ata_port_disable, 151 .port_disable = ata_port_disable,
152 .set_piomode = piix_set_piomode, 152 .set_piomode = piix_set_piomode,
153 .set_dmamode = piix_set_dmamode, 153 .set_dmamode = piix_set_dmamode,
@@ -177,7 +177,7 @@ static struct ata_port_operations piix_pata_ops = {
177 .host_stop = ata_host_stop, 177 .host_stop = ata_host_stop,
178}; 178};
179 179
180static struct ata_port_operations piix_sata_ops = { 180static const struct ata_port_operations piix_sata_ops = {
181 .port_disable = ata_port_disable, 181 .port_disable = ata_port_disable,
182 182
183 .tf_load = ata_tf_load, 183 .tf_load = ata_tf_load,
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index c10e45b94b62..3d13fdee4fc2 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -1357,7 +1357,7 @@ static int port_detect(unsigned long port_base, unsigned int j,
1357 1357
1358 for (i = 0; i < shost->can_queue; i++) { 1358 for (i = 0; i < shost->can_queue; i++) {
1359 size_t sz = shost->sg_tablesize *sizeof(struct sg_list); 1359 size_t sz = shost->sg_tablesize *sizeof(struct sg_list);
1360 unsigned int gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC; 1360 gfp_t gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC;
1361 ha->cp[i].sglist = kmalloc(sz, gfp_mask); 1361 ha->cp[i].sglist = kmalloc(sz, gfp_mask);
1362 if (!ha->cp[i].sglist) { 1362 if (!ha->cp[i].sglist) {
1363 printk 1363 printk
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 02fe371b0ab8..f24d84538fd5 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -287,7 +287,8 @@ static void scsi_host_dev_release(struct device *dev)
287struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) 287struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
288{ 288{
289 struct Scsi_Host *shost; 289 struct Scsi_Host *shost;
290 int gfp_mask = GFP_KERNEL, rval; 290 gfp_t gfp_mask = GFP_KERNEL;
291 int rval;
291 292
292 if (sht->unchecked_isa_dma && privsize) 293 if (sht->unchecked_isa_dma && privsize)
293 gfp_mask |= __GFP_DMA; 294 gfp_mask |= __GFP_DMA;
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index b16955b0c4d1..ab8b7354452c 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -67,9 +67,9 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev);
67static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev); 67static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev);
68static void ata_set_mode(struct ata_port *ap); 68static void ata_set_mode(struct ata_port *ap);
69static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 69static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
70static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift); 70static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift);
71static int fgb(u32 bitmap); 71static int fgb(u32 bitmap);
72static int ata_choose_xfer_mode(struct ata_port *ap, 72static int ata_choose_xfer_mode(const struct ata_port *ap,
73 u8 *xfer_mode_out, 73 u8 *xfer_mode_out,
74 unsigned int *xfer_shift_out); 74 unsigned int *xfer_shift_out);
75static void __ata_qc_complete(struct ata_queued_cmd *qc); 75static void __ata_qc_complete(struct ata_queued_cmd *qc);
@@ -88,7 +88,7 @@ MODULE_LICENSE("GPL");
88MODULE_VERSION(DRV_VERSION); 88MODULE_VERSION(DRV_VERSION);
89 89
90/** 90/**
91 * ata_tf_load - send taskfile registers to host controller 91 * ata_tf_load_pio - send taskfile registers to host controller
92 * @ap: Port to which output is sent 92 * @ap: Port to which output is sent
93 * @tf: ATA taskfile register set 93 * @tf: ATA taskfile register set
94 * 94 *
@@ -98,7 +98,7 @@ MODULE_VERSION(DRV_VERSION);
98 * Inherited from caller. 98 * Inherited from caller.
99 */ 99 */
100 100
101static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf) 101static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf)
102{ 102{
103 struct ata_ioports *ioaddr = &ap->ioaddr; 103 struct ata_ioports *ioaddr = &ap->ioaddr;
104 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 104 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -156,7 +156,7 @@ static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf)
156 * Inherited from caller. 156 * Inherited from caller.
157 */ 157 */
158 158
159static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 159static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
160{ 160{
161 struct ata_ioports *ioaddr = &ap->ioaddr; 161 struct ata_ioports *ioaddr = &ap->ioaddr;
162 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 162 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -225,7 +225,7 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
225 * LOCKING: 225 * LOCKING:
226 * Inherited from caller. 226 * Inherited from caller.
227 */ 227 */
228void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 228void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
229{ 229{
230 if (ap->flags & ATA_FLAG_MMIO) 230 if (ap->flags & ATA_FLAG_MMIO)
231 ata_tf_load_mmio(ap, tf); 231 ata_tf_load_mmio(ap, tf);
@@ -245,7 +245,7 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
245 * spin_lock_irqsave(host_set lock) 245 * spin_lock_irqsave(host_set lock)
246 */ 246 */
247 247
248static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf) 248static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
249{ 249{
250 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 250 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
251 251
@@ -266,7 +266,7 @@ static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf)
266 * spin_lock_irqsave(host_set lock) 266 * spin_lock_irqsave(host_set lock)
267 */ 267 */
268 268
269static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 269static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
270{ 270{
271 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 271 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
272 272
@@ -286,7 +286,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
286 * LOCKING: 286 * LOCKING:
287 * spin_lock_irqsave(host_set lock) 287 * spin_lock_irqsave(host_set lock)
288 */ 288 */
289void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 289void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
290{ 290{
291 if (ap->flags & ATA_FLAG_MMIO) 291 if (ap->flags & ATA_FLAG_MMIO)
292 ata_exec_command_mmio(ap, tf); 292 ata_exec_command_mmio(ap, tf);
@@ -306,7 +306,7 @@ void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)
306 * Obtains host_set lock. 306 * Obtains host_set lock.
307 */ 307 */
308 308
309static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf) 309static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
310{ 310{
311 unsigned long flags; 311 unsigned long flags;
312 312
@@ -329,7 +329,7 @@ static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf)
329 * Obtains host_set lock. 329 * Obtains host_set lock.
330 */ 330 */
331 331
332static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf) 332static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
333{ 333{
334 ap->ops->tf_load(ap, tf); 334 ap->ops->tf_load(ap, tf);
335 335
@@ -349,7 +349,7 @@ static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
349 * spin_lock_irqsave(host_set lock) 349 * spin_lock_irqsave(host_set lock)
350 */ 350 */
351 351
352void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) 352void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf)
353{ 353{
354 ap->ops->tf_load(ap, tf); 354 ap->ops->tf_load(ap, tf);
355 ap->ops->exec_command(ap, tf); 355 ap->ops->exec_command(ap, tf);
@@ -559,7 +559,7 @@ u8 ata_chk_err(struct ata_port *ap)
559 * Inherited from caller. 559 * Inherited from caller.
560 */ 560 */
561 561
562void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp) 562void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
563{ 563{
564 fis[0] = 0x27; /* Register - Host to Device FIS */ 564 fis[0] = 0x27; /* Register - Host to Device FIS */
565 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number, 565 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number,
@@ -600,7 +600,7 @@ void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp)
600 * Inherited from caller. 600 * Inherited from caller.
601 */ 601 */
602 602
603void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf) 603void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
604{ 604{
605 tf->command = fis[2]; /* status */ 605 tf->command = fis[2]; /* status */
606 tf->feature = fis[3]; /* error */ 606 tf->feature = fis[3]; /* error */
@@ -846,7 +846,7 @@ static unsigned int ata_devchk(struct ata_port *ap,
846 * the event of failure. 846 * the event of failure.
847 */ 847 */
848 848
849unsigned int ata_dev_classify(struct ata_taskfile *tf) 849unsigned int ata_dev_classify(const struct ata_taskfile *tf)
850{ 850{
851 /* Apple's open source Darwin code hints that some devices only 851 /* Apple's open source Darwin code hints that some devices only
852 * put a proper signature into the LBA mid/high registers, 852 * put a proper signature into the LBA mid/high registers,
@@ -938,7 +938,7 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
938 * caller. 938 * caller.
939 */ 939 */
940 940
941void ata_dev_id_string(u16 *id, unsigned char *s, 941void ata_dev_id_string(const u16 *id, unsigned char *s,
942 unsigned int ofs, unsigned int len) 942 unsigned int ofs, unsigned int len)
943{ 943{
944 unsigned int c; 944 unsigned int c;
@@ -1055,7 +1055,7 @@ void ata_dev_select(struct ata_port *ap, unsigned int device,
1055 * caller. 1055 * caller.
1056 */ 1056 */
1057 1057
1058static inline void ata_dump_id(struct ata_device *dev) 1058static inline void ata_dump_id(const struct ata_device *dev)
1059{ 1059{
1060 DPRINTK("49==0x%04x " 1060 DPRINTK("49==0x%04x "
1061 "53==0x%04x " 1061 "53==0x%04x "
@@ -1083,6 +1083,31 @@ static inline void ata_dump_id(struct ata_device *dev)
1083 dev->id[93]); 1083 dev->id[93]);
1084} 1084}
1085 1085
1086/*
1087 * Compute the PIO modes available for this device. This is not as
1088 * trivial as it seems if we must consider early devices correctly.
1089 *
1090 * FIXME: pre IDE drive timing (do we care ?).
1091 */
1092
1093static unsigned int ata_pio_modes(const struct ata_device *adev)
1094{
1095 u16 modes;
1096
1097 /* Usual case. Word 53 indicates word 88 is valid */
1098 if (adev->id[ATA_ID_FIELD_VALID] & (1 << 2)) {
1099 modes = adev->id[ATA_ID_PIO_MODES] & 0x03;
1100 modes <<= 3;
1101 modes |= 0x7;
1102 return modes;
1103 }
1104
1105 /* If word 88 isn't valid then Word 51 holds the PIO timing number
1106 for the maximum. Turn it into a mask and return it */
1107 modes = (2 << (adev->id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ;
1108 return modes;
1109}
1110
1086/** 1111/**
1087 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1112 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1088 * @ap: port on which device we wish to probe resides 1113 * @ap: port on which device we wish to probe resides
@@ -1216,10 +1241,8 @@ retry:
1216 xfer_modes = dev->id[ATA_ID_UDMA_MODES]; 1241 xfer_modes = dev->id[ATA_ID_UDMA_MODES];
1217 if (!xfer_modes) 1242 if (!xfer_modes)
1218 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA; 1243 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;
1219 if (!xfer_modes) { 1244 if (!xfer_modes)
1220 xfer_modes = (dev->id[ATA_ID_PIO_MODES]) << (ATA_SHIFT_PIO + 3); 1245 xfer_modes = ata_pio_modes(dev);
1221 xfer_modes |= (0x7 << ATA_SHIFT_PIO);
1222 }
1223 1246
1224 ata_dump_id(dev); 1247 ata_dump_id(dev);
1225 1248
@@ -1333,7 +1356,7 @@ err_out:
1333} 1356}
1334 1357
1335 1358
1336static inline u8 ata_dev_knobble(struct ata_port *ap) 1359static inline u8 ata_dev_knobble(const struct ata_port *ap)
1337{ 1360{
1338 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id))); 1361 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id)));
1339} 1362}
@@ -1519,7 +1542,153 @@ void ata_port_disable(struct ata_port *ap)
1519 ap->flags |= ATA_FLAG_PORT_DISABLED; 1542 ap->flags |= ATA_FLAG_PORT_DISABLED;
1520} 1543}
1521 1544
1522static struct { 1545/*
1546 * This mode timing computation functionality is ported over from
1547 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
1548 */
1549/*
1550 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1551 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1552 * for PIO 5, which is a nonstandard extension and UDMA6, which
1553 * is currently supported only by Maxtor drives.
1554 */
1555
1556static const struct ata_timing ata_timing[] = {
1557
1558 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 },
1559 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 },
1560 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 },
1561 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 },
1562
1563 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 },
1564 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
1565 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
1566
1567/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
1568
1569 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
1570 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
1571 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
1572
1573 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
1574 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1575 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
1576
1577/* { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, */
1578 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 },
1579 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
1580
1581 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 },
1582 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 },
1583 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 },
1584
1585/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */
1586
1587 { 0xFF }
1588};
1589
1590#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
1591#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
1592
1593static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
1594{
1595 q->setup = EZ(t->setup * 1000, T);
1596 q->act8b = EZ(t->act8b * 1000, T);
1597 q->rec8b = EZ(t->rec8b * 1000, T);
1598 q->cyc8b = EZ(t->cyc8b * 1000, T);
1599 q->active = EZ(t->active * 1000, T);
1600 q->recover = EZ(t->recover * 1000, T);
1601 q->cycle = EZ(t->cycle * 1000, T);
1602 q->udma = EZ(t->udma * 1000, UT);
1603}
1604
1605void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
1606 struct ata_timing *m, unsigned int what)
1607{
1608 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
1609 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
1610 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
1611 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
1612 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
1613 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
1614 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
1615 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
1616}
1617
1618static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
1619{
1620 const struct ata_timing *t;
1621
1622 for (t = ata_timing; t->mode != speed; t++)
1623 if (t->mode == 0xFF)
1624 return NULL;
1625 return t;
1626}
1627
1628int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1629 struct ata_timing *t, int T, int UT)
1630{
1631 const struct ata_timing *s;
1632 struct ata_timing p;
1633
1634 /*
1635 * Find the mode.
1636 */
1637
1638 if (!(s = ata_timing_find_mode(speed)))
1639 return -EINVAL;
1640
1641 /*
1642 * If the drive is an EIDE drive, it can tell us it needs extended
1643 * PIO/MW_DMA cycle timing.
1644 */
1645
1646 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
1647 memset(&p, 0, sizeof(p));
1648 if(speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
1649 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO];
1650 else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY];
1651 } else if(speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) {
1652 p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN];
1653 }
1654 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
1655 }
1656
1657 /*
1658 * Convert the timing to bus clock counts.
1659 */
1660
1661 ata_timing_quantize(s, t, T, UT);
1662
1663 /*
1664 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
1665 * and some other commands. We have to ensure that the DMA cycle timing is
1666 * slower/equal than the fastest PIO timing.
1667 */
1668
1669 if (speed > XFER_PIO_4) {
1670 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
1671 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
1672 }
1673
1674 /*
1675 * Lenghten active & recovery time so that cycle time is correct.
1676 */
1677
1678 if (t->act8b + t->rec8b < t->cyc8b) {
1679 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
1680 t->rec8b = t->cyc8b - t->act8b;
1681 }
1682
1683 if (t->active + t->recover < t->cycle) {
1684 t->active += (t->cycle - (t->active + t->recover)) / 2;
1685 t->recover = t->cycle - t->active;
1686 }
1687
1688 return 0;
1689}
1690
1691static const struct {
1523 unsigned int shift; 1692 unsigned int shift;
1524 u8 base; 1693 u8 base;
1525} xfer_mode_classes[] = { 1694} xfer_mode_classes[] = {
@@ -1928,7 +2097,8 @@ err_out:
1928 DPRINTK("EXIT\n"); 2097 DPRINTK("EXIT\n");
1929} 2098}
1930 2099
1931static void ata_pr_blacklisted(struct ata_port *ap, struct ata_device *dev) 2100static void ata_pr_blacklisted(const struct ata_port *ap,
2101 const struct ata_device *dev)
1932{ 2102{
1933 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n", 2103 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n",
1934 ap->id, dev->devno); 2104 ap->id, dev->devno);
@@ -1966,7 +2136,7 @@ static const char * ata_dma_blacklist [] = {
1966 "_NEC DV5800A", 2136 "_NEC DV5800A",
1967}; 2137};
1968 2138
1969static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev) 2139static int ata_dma_blacklisted(const struct ata_device *dev)
1970{ 2140{
1971 unsigned char model_num[40]; 2141 unsigned char model_num[40];
1972 char *s; 2142 char *s;
@@ -1991,9 +2161,9 @@ static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev)
1991 return 0; 2161 return 0;
1992} 2162}
1993 2163
1994static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift) 2164static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
1995{ 2165{
1996 struct ata_device *master, *slave; 2166 const struct ata_device *master, *slave;
1997 unsigned int mask; 2167 unsigned int mask;
1998 2168
1999 master = &ap->device[0]; 2169 master = &ap->device[0];
@@ -2005,14 +2175,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2005 mask = ap->udma_mask; 2175 mask = ap->udma_mask;
2006 if (ata_dev_present(master)) { 2176 if (ata_dev_present(master)) {
2007 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff); 2177 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff);
2008 if (ata_dma_blacklisted(ap, master)) { 2178 if (ata_dma_blacklisted(master)) {
2009 mask = 0; 2179 mask = 0;
2010 ata_pr_blacklisted(ap, master); 2180 ata_pr_blacklisted(ap, master);
2011 } 2181 }
2012 } 2182 }
2013 if (ata_dev_present(slave)) { 2183 if (ata_dev_present(slave)) {
2014 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff); 2184 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff);
2015 if (ata_dma_blacklisted(ap, slave)) { 2185 if (ata_dma_blacklisted(slave)) {
2016 mask = 0; 2186 mask = 0;
2017 ata_pr_blacklisted(ap, slave); 2187 ata_pr_blacklisted(ap, slave);
2018 } 2188 }
@@ -2022,14 +2192,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2022 mask = ap->mwdma_mask; 2192 mask = ap->mwdma_mask;
2023 if (ata_dev_present(master)) { 2193 if (ata_dev_present(master)) {
2024 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07); 2194 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07);
2025 if (ata_dma_blacklisted(ap, master)) { 2195 if (ata_dma_blacklisted(master)) {
2026 mask = 0; 2196 mask = 0;
2027 ata_pr_blacklisted(ap, master); 2197 ata_pr_blacklisted(ap, master);
2028 } 2198 }
2029 } 2199 }
2030 if (ata_dev_present(slave)) { 2200 if (ata_dev_present(slave)) {
2031 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07); 2201 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07);
2032 if (ata_dma_blacklisted(ap, slave)) { 2202 if (ata_dma_blacklisted(slave)) {
2033 mask = 0; 2203 mask = 0;
2034 ata_pr_blacklisted(ap, slave); 2204 ata_pr_blacklisted(ap, slave);
2035 } 2205 }
@@ -2093,7 +2263,7 @@ static int fgb(u32 bitmap)
2093 * Zero on success, negative on error. 2263 * Zero on success, negative on error.
2094 */ 2264 */
2095 2265
2096static int ata_choose_xfer_mode(struct ata_port *ap, 2266static int ata_choose_xfer_mode(const struct ata_port *ap,
2097 u8 *xfer_mode_out, 2267 u8 *xfer_mode_out,
2098 unsigned int *xfer_shift_out) 2268 unsigned int *xfer_shift_out)
2099{ 2269{
@@ -2534,13 +2704,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2534 2704
2535/** 2705/**
2536 * ata_pio_poll - 2706 * ata_pio_poll -
2537 * @ap: 2707 * @ap: the target ata_port
2538 * 2708 *
2539 * LOCKING: 2709 * LOCKING:
2540 * None. (executing in kernel thread context) 2710 * None. (executing in kernel thread context)
2541 * 2711 *
2542 * RETURNS: 2712 * RETURNS:
2543 * 2713 * timeout value to use
2544 */ 2714 */
2545 2715
2546static unsigned long ata_pio_poll(struct ata_port *ap) 2716static unsigned long ata_pio_poll(struct ata_port *ap)
@@ -2581,8 +2751,8 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2581} 2751}
2582 2752
2583/** 2753/**
2584 * ata_pio_complete - 2754 * ata_pio_complete - check if drive is busy or idle
2585 * @ap: 2755 * @ap: the target ata_port
2586 * 2756 *
2587 * LOCKING: 2757 * LOCKING:
2588 * None. (executing in kernel thread context) 2758 * None. (executing in kernel thread context)
@@ -2634,7 +2804,7 @@ static int ata_pio_complete (struct ata_port *ap)
2634 2804
2635 2805
2636/** 2806/**
2637 * swap_buf_le16 - 2807 * swap_buf_le16 - swap halves of 16-words in place
2638 * @buf: Buffer to swap 2808 * @buf: Buffer to swap
2639 * @buf_words: Number of 16-bit words in buffer. 2809 * @buf_words: Number of 16-bit words in buffer.
2640 * 2810 *
@@ -2643,6 +2813,7 @@ static int ata_pio_complete (struct ata_port *ap)
2643 * vice-versa. 2813 * vice-versa.
2644 * 2814 *
2645 * LOCKING: 2815 * LOCKING:
2816 * Inherited from caller.
2646 */ 2817 */
2647void swap_buf_le16(u16 *buf, unsigned int buf_words) 2818void swap_buf_le16(u16 *buf, unsigned int buf_words)
2648{ 2819{
@@ -2665,7 +2836,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
2665 * 2836 *
2666 * LOCKING: 2837 * LOCKING:
2667 * Inherited from caller. 2838 * Inherited from caller.
2668 *
2669 */ 2839 */
2670 2840
2671static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf, 2841static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2711,7 +2881,6 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2711 * 2881 *
2712 * LOCKING: 2882 * LOCKING:
2713 * Inherited from caller. 2883 * Inherited from caller.
2714 *
2715 */ 2884 */
2716 2885
2717static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf, 2886static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2751,7 +2920,6 @@ static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
2751 * 2920 *
2752 * LOCKING: 2921 * LOCKING:
2753 * Inherited from caller. 2922 * Inherited from caller.
2754 *
2755 */ 2923 */
2756 2924
2757static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, 2925static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -3029,7 +3197,6 @@ next_sg:
3029 * 3197 *
3030 * LOCKING: 3198 * LOCKING:
3031 * Inherited from caller. 3199 * Inherited from caller.
3032 *
3033 */ 3200 */
3034 3201
3035static void atapi_pio_bytes(struct ata_queued_cmd *qc) 3202static void atapi_pio_bytes(struct ata_queued_cmd *qc)
@@ -3067,8 +3234,8 @@ err_out:
3067} 3234}
3068 3235
3069/** 3236/**
3070 * ata_pio_sector - 3237 * ata_pio_block - start PIO on a block
3071 * @ap: 3238 * @ap: the target ata_port
3072 * 3239 *
3073 * LOCKING: 3240 * LOCKING:
3074 * None. (executing in kernel thread context) 3241 * None. (executing in kernel thread context)
@@ -3080,7 +3247,7 @@ static void ata_pio_block(struct ata_port *ap)
3080 u8 status; 3247 u8 status;
3081 3248
3082 /* 3249 /*
3083 * This is purely hueristic. This is a fast path. 3250 * This is purely heuristic. This is a fast path.
3084 * Sometimes when we enter, BSY will be cleared in 3251 * Sometimes when we enter, BSY will be cleared in
3085 * a chk-status or two. If not, the drive is probably seeking 3252 * a chk-status or two. If not, the drive is probably seeking
3086 * or something. Snooze for a couple msecs, then 3253 * or something. Snooze for a couple msecs, then
@@ -3402,7 +3569,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3402 * 3569 *
3403 * LOCKING: 3570 * LOCKING:
3404 * spin_lock_irqsave(host_set lock) 3571 * spin_lock_irqsave(host_set lock)
3405 *
3406 */ 3572 */
3407void ata_qc_free(struct ata_queued_cmd *qc) 3573void ata_qc_free(struct ata_queued_cmd *qc)
3408{ 3574{
@@ -3422,7 +3588,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3422 * 3588 *
3423 * LOCKING: 3589 * LOCKING:
3424 * spin_lock_irqsave(host_set lock) 3590 * spin_lock_irqsave(host_set lock)
3425 *
3426 */ 3591 */
3427 3592
3428void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3593void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
@@ -4071,7 +4236,6 @@ idle_irq:
4071 * 4236 *
4072 * RETURNS: 4237 * RETURNS:
4073 * IRQ_NONE or IRQ_HANDLED. 4238 * IRQ_NONE or IRQ_HANDLED.
4074 *
4075 */ 4239 */
4076 4240
4077irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 4241irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
@@ -4114,6 +4278,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4114 * May be used as the port_start() entry in ata_port_operations. 4278 * May be used as the port_start() entry in ata_port_operations.
4115 * 4279 *
4116 * LOCKING: 4280 * LOCKING:
4281 * Inherited from caller.
4117 */ 4282 */
4118 4283
4119int ata_port_start (struct ata_port *ap) 4284int ata_port_start (struct ata_port *ap)
@@ -4139,6 +4304,7 @@ int ata_port_start (struct ata_port *ap)
4139 * May be used as the port_stop() entry in ata_port_operations. 4304 * May be used as the port_stop() entry in ata_port_operations.
4140 * 4305 *
4141 * LOCKING: 4306 * LOCKING:
4307 * Inherited from caller.
4142 */ 4308 */
4143 4309
4144void ata_port_stop (struct ata_port *ap) 4310void ata_port_stop (struct ata_port *ap)
@@ -4161,6 +4327,7 @@ void ata_host_stop (struct ata_host_set *host_set)
4161 * @do_unregister: 1 if we fully unregister, 0 to just stop the port 4327 * @do_unregister: 1 if we fully unregister, 0 to just stop the port
4162 * 4328 *
4163 * LOCKING: 4329 * LOCKING:
4330 * Inherited from caller.
4164 */ 4331 */
4165 4332
4166static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) 4333static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
@@ -4188,12 +4355,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
4188 * 4355 *
4189 * LOCKING: 4356 * LOCKING:
4190 * Inherited from caller. 4357 * Inherited from caller.
4191 *
4192 */ 4358 */
4193 4359
4194static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, 4360static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4195 struct ata_host_set *host_set, 4361 struct ata_host_set *host_set,
4196 struct ata_probe_ent *ent, unsigned int port_no) 4362 const struct ata_probe_ent *ent, unsigned int port_no)
4197{ 4363{
4198 unsigned int i; 4364 unsigned int i;
4199 4365
@@ -4249,10 +4415,9 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4249 * 4415 *
4250 * RETURNS: 4416 * RETURNS:
4251 * New ata_port on success, for NULL on error. 4417 * New ata_port on success, for NULL on error.
4252 *
4253 */ 4418 */
4254 4419
4255static struct ata_port * ata_host_add(struct ata_probe_ent *ent, 4420static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
4256 struct ata_host_set *host_set, 4421 struct ata_host_set *host_set,
4257 unsigned int port_no) 4422 unsigned int port_no)
4258{ 4423{
@@ -4297,10 +4462,9 @@ err_out:
4297 * 4462 *
4298 * RETURNS: 4463 * RETURNS:
4299 * Number of ports registered. Zero on error (no ports registered). 4464 * Number of ports registered. Zero on error (no ports registered).
4300 *
4301 */ 4465 */
4302 4466
4303int ata_device_add(struct ata_probe_ent *ent) 4467int ata_device_add(const struct ata_probe_ent *ent)
4304{ 4468{
4305 unsigned int count = 0, i; 4469 unsigned int count = 0, i;
4306 struct device *dev = ent->dev; 4470 struct device *dev = ent->dev;
@@ -4429,7 +4593,6 @@ err_out:
4429 * Inherited from calling layer (may sleep). 4593 * Inherited from calling layer (may sleep).
4430 */ 4594 */
4431 4595
4432
4433void ata_host_set_remove(struct ata_host_set *host_set) 4596void ata_host_set_remove(struct ata_host_set *host_set)
4434{ 4597{
4435 struct ata_port *ap; 4598 struct ata_port *ap;
@@ -4519,7 +4682,7 @@ void ata_std_ports(struct ata_ioports *ioaddr)
4519} 4682}
4520 4683
4521static struct ata_probe_ent * 4684static struct ata_probe_ent *
4522ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) 4685ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
4523{ 4686{
4524 struct ata_probe_ent *probe_ent; 4687 struct ata_probe_ent *probe_ent;
4525 4688
@@ -4619,7 +4782,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4619 if (!probe_ent) 4782 if (!probe_ent)
4620 return NULL; 4783 return NULL;
4621 4784
4622
4623 probe_ent->legacy_mode = 1; 4785 probe_ent->legacy_mode = 1;
4624 probe_ent->n_ports = 1; 4786 probe_ent->n_ports = 1;
4625 probe_ent->hard_port_no = port_num; 4787 probe_ent->hard_port_no = port_num;
@@ -4663,7 +4825,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4663 * 4825 *
4664 * RETURNS: 4826 * RETURNS:
4665 * Zero on success, negative on errno-based value on error. 4827 * Zero on success, negative on errno-based value on error.
4666 *
4667 */ 4828 */
4668 4829
4669int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 4830int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
@@ -4811,7 +4972,7 @@ err_out:
4811 * @pdev: PCI device that was removed 4972 * @pdev: PCI device that was removed
4812 * 4973 *
4813 * PCI layer indicates to libata via this hook that 4974 * PCI layer indicates to libata via this hook that
4814 * hot-unplug or module unload event has occured. 4975 * hot-unplug or module unload event has occurred.
4815 * Handle this by unregistering all objects associated 4976 * Handle this by unregistering all objects associated
4816 * with this PCI device. Free those objects. Then finally 4977 * with this PCI device. Free those objects. Then finally
4817 * release PCI resources and disable device. 4978 * release PCI resources and disable device.
@@ -4832,7 +4993,7 @@ void ata_pci_remove_one (struct pci_dev *pdev)
4832} 4993}
4833 4994
4834/* move to PCI subsystem */ 4995/* move to PCI subsystem */
4835int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) 4996int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
4836{ 4997{
4837 unsigned long tmp = 0; 4998 unsigned long tmp = 0;
4838 4999
@@ -4959,6 +5120,9 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
4959EXPORT_SYMBOL_GPL(ata_dev_config); 5120EXPORT_SYMBOL_GPL(ata_dev_config);
4960EXPORT_SYMBOL_GPL(ata_scsi_simulate); 5121EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4961 5122
5123EXPORT_SYMBOL_GPL(ata_timing_compute);
5124EXPORT_SYMBOL_GPL(ata_timing_merge);
5125
4962#ifdef CONFIG_PCI 5126#ifdef CONFIG_PCI
4963EXPORT_SYMBOL_GPL(pci_test_config_bits); 5127EXPORT_SYMBOL_GPL(pci_test_config_bits);
4964EXPORT_SYMBOL_GPL(ata_pci_host_stop); 5128EXPORT_SYMBOL_GPL(ata_pci_host_stop);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 90bf22204668..58858886d751 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -44,9 +44,9 @@
44 44
45#include "libata.h" 45#include "libata.h"
46 46
47typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, u8 *scsicmd); 47typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
48static struct ata_device * 48static struct ata_device *
49ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev); 49ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
50 50
51 51
52static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 52static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
@@ -418,7 +418,7 @@ int ata_scsi_error(struct Scsi_Host *host)
418 */ 418 */
419 419
420static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc, 420static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
421 u8 *scsicmd) 421 const u8 *scsicmd)
422{ 422{
423 struct ata_taskfile *tf = &qc->tf; 423 struct ata_taskfile *tf = &qc->tf;
424 424
@@ -485,7 +485,7 @@ invalid_fld:
485 * Zero on success, non-zero on error. 485 * Zero on success, non-zero on error.
486 */ 486 */
487 487
488static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 488static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
489{ 489{
490 struct ata_taskfile *tf = &qc->tf; 490 struct ata_taskfile *tf = &qc->tf;
491 491
@@ -512,7 +512,7 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
512 * @plen: the transfer length 512 * @plen: the transfer length
513 */ 513 */
514 514
515static void scsi_6_lba_len(u8 *scsicmd, u64 *plba, u32 *plen) 515static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
516{ 516{
517 u64 lba = 0; 517 u64 lba = 0;
518 u32 len = 0; 518 u32 len = 0;
@@ -539,7 +539,7 @@ static void scsi_6_lba_len(u8 *scsicmd, u64 *plba, u32 *plen)
539 * @plen: the transfer length 539 * @plen: the transfer length
540 */ 540 */
541 541
542static void scsi_10_lba_len(u8 *scsicmd, u64 *plba, u32 *plen) 542static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
543{ 543{
544 u64 lba = 0; 544 u64 lba = 0;
545 u32 len = 0; 545 u32 len = 0;
@@ -569,7 +569,7 @@ static void scsi_10_lba_len(u8 *scsicmd, u64 *plba, u32 *plen)
569 * @plen: the transfer length 569 * @plen: the transfer length
570 */ 570 */
571 571
572static void scsi_16_lba_len(u8 *scsicmd, u64 *plba, u32 *plen) 572static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
573{ 573{
574 u64 lba = 0; 574 u64 lba = 0;
575 u32 len = 0; 575 u32 len = 0;
@@ -608,7 +608,7 @@ static void scsi_16_lba_len(u8 *scsicmd, u64 *plba, u32 *plen)
608 * Zero on success, non-zero on error. 608 * Zero on success, non-zero on error.
609 */ 609 */
610 610
611static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 611static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
612{ 612{
613 struct ata_taskfile *tf = &qc->tf; 613 struct ata_taskfile *tf = &qc->tf;
614 struct ata_device *dev = qc->dev; 614 struct ata_device *dev = qc->dev;
@@ -734,7 +734,7 @@ nothing_to_do:
734 * Zero on success, non-zero on error. 734 * Zero on success, non-zero on error.
735 */ 735 */
736 736
737static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 737static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
738{ 738{
739 struct ata_taskfile *tf = &qc->tf; 739 struct ata_taskfile *tf = &qc->tf;
740 struct ata_device *dev = qc->dev; 740 struct ata_device *dev = qc->dev;
@@ -1688,7 +1688,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1688 * Zero on success, non-zero on failure. 1688 * Zero on success, non-zero on failure.
1689 */ 1689 */
1690 1690
1691static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 1691static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
1692{ 1692{
1693 struct scsi_cmnd *cmd = qc->scsicmd; 1693 struct scsi_cmnd *cmd = qc->scsicmd;
1694 struct ata_device *dev = qc->dev; 1694 struct ata_device *dev = qc->dev;
@@ -1757,7 +1757,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
1757 */ 1757 */
1758 1758
1759static struct ata_device * 1759static struct ata_device *
1760ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev) 1760ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
1761{ 1761{
1762 struct ata_device *dev; 1762 struct ata_device *dev;
1763 1763
@@ -1914,7 +1914,7 @@ void ata_scsi_simulate(u16 *id,
1914 void (*done)(struct scsi_cmnd *)) 1914 void (*done)(struct scsi_cmnd *))
1915{ 1915{
1916 struct ata_scsi_args args; 1916 struct ata_scsi_args args;
1917 u8 *scsicmd = cmd->cmnd; 1917 const u8 *scsicmd = cmd->cmnd;
1918 1918
1919 args.id = id; 1919 args.id = id;
1920 args.cmd = cmd; 1920 args.cmd = cmd;
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 67d752ca8ae2..3d60190584ba 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -48,7 +48,7 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc);
48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
49extern void ata_dev_select(struct ata_port *ap, unsigned int device, 49extern void ata_dev_select(struct ata_port *ap, unsigned int device,
50 unsigned int wait, unsigned int can_sleep); 50 unsigned int wait, unsigned int can_sleep);
51extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf); 51extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf);
52extern void swap_buf_le16(u16 *buf, unsigned int buf_words); 52extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
53 53
54 54
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index 0aba13ceaacf..352df47bcaca 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -39,7 +39,7 @@
39#define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */ 39#define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */
40 40
41static void * 41static void *
42lpfc_pool_kmalloc(unsigned int gfp_flags, void *data) 42lpfc_pool_kmalloc(gfp_t gfp_flags, void *data)
43{ 43{
44 return kmalloc((unsigned long)data, gfp_flags); 44 return kmalloc((unsigned long)data, gfp_flags);
45} 45}
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 3f2f2464fa63..af1133104b3f 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5146,7 +5146,8 @@ static long osst_compat_ioctl(struct file * file, unsigned int cmd_in, unsigned
5146/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */ 5146/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */
5147static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg ) 5147static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg )
5148{ 5148{
5149 int i, priority; 5149 int i;
5150 gfp_t priority;
5150 struct osst_buffer *tb; 5151 struct osst_buffer *tb;
5151 5152
5152 if (from_initialization) 5153 if (from_initialization)
@@ -5178,7 +5179,8 @@ static struct osst_buffer * new_tape_buffer( int from_initialization, int need_d
5178/* Try to allocate a temporary (while a user has the device open) enlarged tape buffer */ 5179/* Try to allocate a temporary (while a user has the device open) enlarged tape buffer */
5179static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) 5180static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5180{ 5181{
5181 int segs, nbr, max_segs, b_size, priority, order, got; 5182 int segs, nbr, max_segs, b_size, order, got;
5183 gfp_t priority;
5182 5184
5183 if (STbuffer->buffer_size >= OS_FRAME_SIZE) 5185 if (STbuffer->buffer_size >= OS_FRAME_SIZE)
5184 return 1; 5186 return 1;
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index f3ba6b447e81..1701e318a9f0 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -158,7 +158,7 @@ static Scsi_Host_Template adma_ata_sht = {
158 .bios_param = ata_std_bios_param, 158 .bios_param = ata_std_bios_param,
159}; 159};
160 160
161static struct ata_port_operations adma_ata_ops = { 161static const struct ata_port_operations adma_ata_ops = {
162 .port_disable = ata_port_disable, 162 .port_disable = ata_port_disable,
163 .tf_load = ata_tf_load, 163 .tf_load = ata_tf_load,
164 .tf_read = ata_tf_read, 164 .tf_read = ata_tf_read,
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 1ed32e7b5472..e451941ad81d 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -52,7 +52,7 @@ extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
52extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *); 52extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *);
53extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *); 53extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *);
54 54
55extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, int); 55extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t);
56 56
57extern int qla2x00_loop_resync(scsi_qla_host_t *); 57extern int qla2x00_loop_resync(scsi_qla_host_t *);
58 58
@@ -277,7 +277,7 @@ extern int qla2x00_fdmi_register(scsi_qla_host_t *);
277/* 277/*
278 * Global Function Prototypes in qla_rscn.c source file. 278 * Global Function Prototypes in qla_rscn.c source file.
279 */ 279 */
280extern fc_port_t *qla2x00_alloc_rscn_fcport(scsi_qla_host_t *, int); 280extern fc_port_t *qla2x00_alloc_rscn_fcport(scsi_qla_host_t *, gfp_t);
281extern int qla2x00_handle_port_rscn(scsi_qla_host_t *, uint32_t, fc_port_t *, 281extern int qla2x00_handle_port_rscn(scsi_qla_host_t *, uint32_t, fc_port_t *,
282 int); 282 int);
283extern void qla2x00_process_iodesc(scsi_qla_host_t *, struct mbx_entry *); 283extern void qla2x00_process_iodesc(scsi_qla_host_t *, struct mbx_entry *);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 23d095d3817b..fbb6feee40cf 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1685,7 +1685,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1685 * Returns a pointer to the allocated fcport, or NULL, if none available. 1685 * Returns a pointer to the allocated fcport, or NULL, if none available.
1686 */ 1686 */
1687fc_port_t * 1687fc_port_t *
1688qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) 1688qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
1689{ 1689{
1690 fc_port_t *fcport; 1690 fc_port_t *fcport;
1691 1691
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 8982978c42fd..7aec93f9d423 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1325,6 +1325,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1325 ha->brd_info = brd_info; 1325 ha->brd_info = brd_info;
1326 sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no); 1326 sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no);
1327 1327
1328 ha->dpc_pid = -1;
1329
1328 /* Configure PCI I/O space */ 1330 /* Configure PCI I/O space */
1329 ret = qla2x00_iospace_config(ha); 1331 ret = qla2x00_iospace_config(ha);
1330 if (ret) 1332 if (ret)
@@ -1448,7 +1450,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1448 */ 1450 */
1449 spin_lock_init(&ha->mbx_reg_lock); 1451 spin_lock_init(&ha->mbx_reg_lock);
1450 1452
1451 ha->dpc_pid = -1;
1452 init_completion(&ha->dpc_inited); 1453 init_completion(&ha->dpc_inited);
1453 init_completion(&ha->dpc_exited); 1454 init_completion(&ha->dpc_exited);
1454 1455
diff --git a/drivers/scsi/qla2xxx/qla_rscn.c b/drivers/scsi/qla2xxx/qla_rscn.c
index 1eba98828636..7534efcc8918 100644
--- a/drivers/scsi/qla2xxx/qla_rscn.c
+++ b/drivers/scsi/qla2xxx/qla_rscn.c
@@ -1066,7 +1066,7 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
1066 * Returns a pointer to the allocated RSCN fcport, or NULL, if none available. 1066 * Returns a pointer to the allocated RSCN fcport, or NULL, if none available.
1067 */ 1067 */
1068fc_port_t * 1068fc_port_t *
1069qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, int flags) 1069qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, gfp_t flags)
1070{ 1070{
1071 fc_port_t *fcport; 1071 fc_port_t *fcport;
1072 1072
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index e72140342d05..c40e9843b454 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -35,7 +35,7 @@
35#include <asm/io.h> 35#include <asm/io.h>
36 36
37#define DRV_NAME "sata_mv" 37#define DRV_NAME "sata_mv"
38#define DRV_VERSION "0.24" 38#define DRV_VERSION "0.25"
39 39
40enum { 40enum {
41 /* BAR's are enumerated in terms of pci_resource_start() terms */ 41 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -291,7 +291,7 @@ static Scsi_Host_Template mv_sht = {
291 .ordered_flush = 1, 291 .ordered_flush = 1,
292}; 292};
293 293
294static struct ata_port_operations mv_ops = { 294static const struct ata_port_operations mv_ops = {
295 .port_disable = ata_port_disable, 295 .port_disable = ata_port_disable,
296 296
297 .tf_load = ata_tf_load, 297 .tf_load = ata_tf_load,
@@ -801,7 +801,8 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
801 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len); 801 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len);
802 } 802 }
803 if (0 < qc->n_elem) { 803 if (0 < qc->n_elem) {
804 pp->sg_tbl[qc->n_elem - 1].flags_size |= EPRD_FLAG_END_OF_TBL; 804 pp->sg_tbl[qc->n_elem - 1].flags_size |=
805 cpu_to_le32(EPRD_FLAG_END_OF_TBL);
805 } 806 }
806} 807}
807 808
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index ada45f74afde..73c2c5a29049 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -238,7 +238,7 @@ static Scsi_Host_Template nv_sht = {
238 .ordered_flush = 1, 238 .ordered_flush = 1,
239}; 239};
240 240
241static struct ata_port_operations nv_ops = { 241static const struct ata_port_operations nv_ops = {
242 .port_disable = ata_port_disable, 242 .port_disable = ata_port_disable,
243 .tf_load = ata_tf_load, 243 .tf_load = ata_tf_load,
244 .tf_read = ata_tf_read, 244 .tf_read = ata_tf_read,
@@ -331,7 +331,7 @@ static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
331 return 0xffffffffU; 331 return 0xffffffffU;
332 332
333 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 333 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
334 return readl((void*)ap->ioaddr.scr_addr + (sc_reg * 4)); 334 return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
335 else 335 else
336 return inl(ap->ioaddr.scr_addr + (sc_reg * 4)); 336 return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
337} 337}
@@ -345,7 +345,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
345 return; 345 return;
346 346
347 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 347 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
348 writel(val, (void*)ap->ioaddr.scr_addr + (sc_reg * 4)); 348 writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
349 else 349 else
350 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 350 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
351} 351}
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index f67deb0a55c9..9ca07becc49a 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -87,8 +87,8 @@ static void pdc_port_stop(struct ata_port *ap);
87static void pdc_pata_phy_reset(struct ata_port *ap); 87static void pdc_pata_phy_reset(struct ata_port *ap);
88static void pdc_sata_phy_reset(struct ata_port *ap); 88static void pdc_sata_phy_reset(struct ata_port *ap);
89static void pdc_qc_prep(struct ata_queued_cmd *qc); 89static void pdc_qc_prep(struct ata_queued_cmd *qc);
90static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); 90static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
91static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); 91static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
92static void pdc_irq_clear(struct ata_port *ap); 92static void pdc_irq_clear(struct ata_port *ap);
93static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 93static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
94 94
@@ -113,7 +113,7 @@ static Scsi_Host_Template pdc_ata_sht = {
113 .ordered_flush = 1, 113 .ordered_flush = 1,
114}; 114};
115 115
116static struct ata_port_operations pdc_sata_ops = { 116static const struct ata_port_operations pdc_sata_ops = {
117 .port_disable = ata_port_disable, 117 .port_disable = ata_port_disable,
118 .tf_load = pdc_tf_load_mmio, 118 .tf_load = pdc_tf_load_mmio,
119 .tf_read = ata_tf_read, 119 .tf_read = ata_tf_read,
@@ -136,7 +136,7 @@ static struct ata_port_operations pdc_sata_ops = {
136 .host_stop = ata_pci_host_stop, 136 .host_stop = ata_pci_host_stop,
137}; 137};
138 138
139static struct ata_port_operations pdc_pata_ops = { 139static const struct ata_port_operations pdc_pata_ops = {
140 .port_disable = ata_port_disable, 140 .port_disable = ata_port_disable,
141 .tf_load = pdc_tf_load_mmio, 141 .tf_load = pdc_tf_load_mmio,
142 .tf_read = ata_tf_read, 142 .tf_read = ata_tf_read,
@@ -327,7 +327,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
327{ 327{
328 if (sc_reg > SCR_CONTROL) 328 if (sc_reg > SCR_CONTROL)
329 return 0xffffffffU; 329 return 0xffffffffU;
330 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 330 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
331} 331}
332 332
333 333
@@ -336,7 +336,7 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
336{ 336{
337 if (sc_reg > SCR_CONTROL) 337 if (sc_reg > SCR_CONTROL)
338 return; 338 return;
339 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 339 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
340} 340}
341 341
342static void pdc_qc_prep(struct ata_queued_cmd *qc) 342static void pdc_qc_prep(struct ata_queued_cmd *qc)
@@ -526,8 +526,8 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
526 526
527 pp->pkt[2] = seq; 527 pp->pkt[2] = seq;
528 wmb(); /* flush PRD, pkt writes */ 528 wmb(); /* flush PRD, pkt writes */
529 writel(pp->pkt_dma, (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 529 writel(pp->pkt_dma, (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
530 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ 530 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */
531} 531}
532 532
533static int pdc_qc_issue_prot(struct ata_queued_cmd *qc) 533static int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
@@ -549,7 +549,7 @@ static int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
549 return ata_qc_issue_prot(qc); 549 return ata_qc_issue_prot(qc);
550} 550}
551 551
552static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 552static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
553{ 553{
554 WARN_ON (tf->protocol == ATA_PROT_DMA || 554 WARN_ON (tf->protocol == ATA_PROT_DMA ||
555 tf->protocol == ATA_PROT_NODATA); 555 tf->protocol == ATA_PROT_NODATA);
@@ -557,7 +557,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
557} 557}
558 558
559 559
560static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 560static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
561{ 561{
562 WARN_ON (tf->protocol == ATA_PROT_DMA || 562 WARN_ON (tf->protocol == ATA_PROT_DMA ||
563 tf->protocol == ATA_PROT_NODATA); 563 tf->protocol == ATA_PROT_NODATA);
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index a604afafaecc..6e0c749b6cb4 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -51,8 +51,6 @@ enum {
51 QS_PRD_BYTES = QS_MAX_PRD * 16, 51 QS_PRD_BYTES = QS_MAX_PRD * 16,
52 QS_PKT_BYTES = QS_CPB_BYTES + QS_PRD_BYTES, 52 QS_PKT_BYTES = QS_CPB_BYTES + QS_PRD_BYTES,
53 53
54 QS_DMA_BOUNDARY = ~0UL,
55
56 /* global register offsets */ 54 /* global register offsets */
57 QS_HCF_CNFG3 = 0x0003, /* host configuration offset */ 55 QS_HCF_CNFG3 = 0x0003, /* host configuration offset */
58 QS_HID_HPHY = 0x0004, /* host physical interface info */ 56 QS_HID_HPHY = 0x0004, /* host physical interface info */
@@ -101,6 +99,10 @@ enum {
101 board_2068_idx = 0, /* QStor 4-port SATA/RAID */ 99 board_2068_idx = 0, /* QStor 4-port SATA/RAID */
102}; 100};
103 101
102enum {
103 QS_DMA_BOUNDARY = ~0UL
104};
105
104typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t; 106typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t;
105 107
106struct qs_port_priv { 108struct qs_port_priv {
@@ -145,7 +147,7 @@ static Scsi_Host_Template qs_ata_sht = {
145 .bios_param = ata_std_bios_param, 147 .bios_param = ata_std_bios_param,
146}; 148};
147 149
148static struct ata_port_operations qs_ata_ops = { 150static const struct ata_port_operations qs_ata_ops = {
149 .port_disable = ata_port_disable, 151 .port_disable = ata_port_disable,
150 .tf_load = ata_tf_load, 152 .tf_load = ata_tf_load,
151 .tf_read = ata_tf_read, 153 .tf_read = ata_tf_read,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index ba98a175ee3a..3a056173fb95 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -150,7 +150,7 @@ static Scsi_Host_Template sil_sht = {
150 .ordered_flush = 1, 150 .ordered_flush = 1,
151}; 151};
152 152
153static struct ata_port_operations sil_ops = { 153static const struct ata_port_operations sil_ops = {
154 .port_disable = ata_port_disable, 154 .port_disable = ata_port_disable,
155 .dev_config = sil_dev_config, 155 .dev_config = sil_dev_config,
156 .tf_load = ata_tf_load, 156 .tf_load = ata_tf_load,
@@ -289,7 +289,7 @@ static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_re
289 289
290static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) 290static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
291{ 291{
292 void *mmio = (void *) sil_scr_addr(ap, sc_reg); 292 void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
293 if (mmio) 293 if (mmio)
294 return readl(mmio); 294 return readl(mmio);
295 return 0xffffffffU; 295 return 0xffffffffU;
@@ -297,7 +297,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
297 297
298static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 298static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
299{ 299{
300 void *mmio = (void *) sil_scr_addr(ap, sc_reg); 300 void *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
301 if (mmio) 301 if (mmio)
302 writel(val, mmio); 302 writel(val, mmio);
303} 303}
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 19857814d69f..32d730bd5bb6 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -275,7 +275,7 @@ static Scsi_Host_Template sil24_sht = {
275 .ordered_flush = 1, /* NCQ not supported yet */ 275 .ordered_flush = 1, /* NCQ not supported yet */
276}; 276};
277 277
278static struct ata_port_operations sil24_ops = { 278static const struct ata_port_operations sil24_ops = {
279 .port_disable = ata_port_disable, 279 .port_disable = ata_port_disable,
280 280
281 .check_status = sil24_check_status, 281 .check_status = sil24_check_status,
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 0761a3234fcf..057f7b98b6c4 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -102,7 +102,7 @@ static Scsi_Host_Template sis_sht = {
102 .ordered_flush = 1, 102 .ordered_flush = 1,
103}; 103};
104 104
105static struct ata_port_operations sis_ops = { 105static const struct ata_port_operations sis_ops = {
106 .port_disable = ata_port_disable, 106 .port_disable = ata_port_disable,
107 .tf_load = ata_tf_load, 107 .tf_load = ata_tf_load,
108 .tf_read = ata_tf_read, 108 .tf_read = ata_tf_read,
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index d89d968bedac..e0f9570bc6dd 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -102,7 +102,7 @@ static void k2_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
102} 102}
103 103
104 104
105static void k2_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 105static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
106{ 106{
107 struct ata_ioports *ioaddr = &ap->ioaddr; 107 struct ata_ioports *ioaddr = &ap->ioaddr;
108 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 108 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -297,7 +297,7 @@ static Scsi_Host_Template k2_sata_sht = {
297}; 297};
298 298
299 299
300static struct ata_port_operations k2_sata_ops = { 300static const struct ata_port_operations k2_sata_ops = {
301 .port_disable = ata_port_disable, 301 .port_disable = ata_port_disable,
302 .tf_load = k2_sata_tf_load, 302 .tf_load = k2_sata_tf_load,
303 .tf_read = k2_sata_tf_read, 303 .tf_read = k2_sata_tf_read,
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index a9f9f7685a59..1908c588ebb9 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -137,7 +137,7 @@ struct pdc_port_priv {
137}; 137};
138 138
139struct pdc_host_priv { 139struct pdc_host_priv {
140 void *dimm_mmio; 140 void __iomem *dimm_mmio;
141 141
142 unsigned int doing_hdma; 142 unsigned int doing_hdma;
143 unsigned int hdma_prod; 143 unsigned int hdma_prod;
@@ -157,8 +157,8 @@ static void pdc_20621_phy_reset (struct ata_port *ap);
157static int pdc_port_start(struct ata_port *ap); 157static int pdc_port_start(struct ata_port *ap);
158static void pdc_port_stop(struct ata_port *ap); 158static void pdc_port_stop(struct ata_port *ap);
159static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 159static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
160static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); 160static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
161static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); 161static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
162static void pdc20621_host_stop(struct ata_host_set *host_set); 162static void pdc20621_host_stop(struct ata_host_set *host_set);
163static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); 163static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
164static int pdc20621_detect_dimm(struct ata_probe_ent *pe); 164static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
@@ -196,7 +196,7 @@ static Scsi_Host_Template pdc_sata_sht = {
196 .ordered_flush = 1, 196 .ordered_flush = 1,
197}; 197};
198 198
199static struct ata_port_operations pdc_20621_ops = { 199static const struct ata_port_operations pdc_20621_ops = {
200 .port_disable = ata_port_disable, 200 .port_disable = ata_port_disable,
201 .tf_load = pdc_tf_load_mmio, 201 .tf_load = pdc_tf_load_mmio,
202 .tf_read = ata_tf_read, 202 .tf_read = ata_tf_read,
@@ -248,7 +248,7 @@ static void pdc20621_host_stop(struct ata_host_set *host_set)
248{ 248{
249 struct pci_dev *pdev = to_pci_dev(host_set->dev); 249 struct pci_dev *pdev = to_pci_dev(host_set->dev);
250 struct pdc_host_priv *hpriv = host_set->private_data; 250 struct pdc_host_priv *hpriv = host_set->private_data;
251 void *dimm_mmio = hpriv->dimm_mmio; 251 void __iomem *dimm_mmio = hpriv->dimm_mmio;
252 252
253 pci_iounmap(pdev, dimm_mmio); 253 pci_iounmap(pdev, dimm_mmio);
254 kfree(hpriv); 254 kfree(hpriv);
@@ -670,8 +670,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
670 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ 670 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */
671 671
672 writel(port_ofs + PDC_DIMM_ATA_PKT, 672 writel(port_ofs + PDC_DIMM_ATA_PKT,
673 (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 673 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
674 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 674 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
675 VPRINTK("submitted ofs 0x%x (%u), seq %u\n", 675 VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
676 port_ofs + PDC_DIMM_ATA_PKT, 676 port_ofs + PDC_DIMM_ATA_PKT,
677 port_ofs + PDC_DIMM_ATA_PKT, 677 port_ofs + PDC_DIMM_ATA_PKT,
@@ -748,8 +748,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
748 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); 748 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
749 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); 749 readl(mmio + PDC_20621_SEQCTL + (seq * 4));
750 writel(port_ofs + PDC_DIMM_ATA_PKT, 750 writel(port_ofs + PDC_DIMM_ATA_PKT,
751 (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 751 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
752 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 752 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
753 } 753 }
754 754
755 /* step two - execute ATA command */ 755 /* step two - execute ATA command */
@@ -900,7 +900,7 @@ out:
900 DPRINTK("EXIT\n"); 900 DPRINTK("EXIT\n");
901} 901}
902 902
903static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 903static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
904{ 904{
905 WARN_ON (tf->protocol == ATA_PROT_DMA || 905 WARN_ON (tf->protocol == ATA_PROT_DMA ||
906 tf->protocol == ATA_PROT_NODATA); 906 tf->protocol == ATA_PROT_NODATA);
@@ -908,7 +908,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
908} 908}
909 909
910 910
911static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 911static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
912{ 912{
913 WARN_ON (tf->protocol == ATA_PROT_DMA || 913 WARN_ON (tf->protocol == ATA_PROT_DMA ||
914 tf->protocol == ATA_PROT_NODATA); 914 tf->protocol == ATA_PROT_NODATA);
@@ -1015,7 +1015,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1015 idx++; 1015 idx++;
1016 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size : 1016 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size :
1017 (long) (window_size - offset); 1017 (long) (window_size - offset);
1018 memcpy_toio((char *) (dimm_mmio + offset / 4), (char *) psource, dist); 1018 memcpy_toio(dimm_mmio + offset / 4, psource, dist);
1019 writel(0x01, mmio + PDC_GENERAL_CTLR); 1019 writel(0x01, mmio + PDC_GENERAL_CTLR);
1020 readl(mmio + PDC_GENERAL_CTLR); 1020 readl(mmio + PDC_GENERAL_CTLR);
1021 1021
@@ -1024,8 +1024,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1024 for (; (long) size >= (long) window_size ;) { 1024 for (; (long) size >= (long) window_size ;) {
1025 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1025 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1026 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1026 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1027 memcpy_toio((char *) (dimm_mmio), (char *) psource, 1027 memcpy_toio(dimm_mmio, psource, window_size / 4);
1028 window_size / 4);
1029 writel(0x01, mmio + PDC_GENERAL_CTLR); 1028 writel(0x01, mmio + PDC_GENERAL_CTLR);
1030 readl(mmio + PDC_GENERAL_CTLR); 1029 readl(mmio + PDC_GENERAL_CTLR);
1031 psource += window_size; 1030 psource += window_size;
@@ -1036,7 +1035,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1036 if (size) { 1035 if (size) {
1037 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1036 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1038 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1037 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1039 memcpy_toio((char *) (dimm_mmio), (char *) psource, size / 4); 1038 memcpy_toio(dimm_mmio, psource, size / 4);
1040 writel(0x01, mmio + PDC_GENERAL_CTLR); 1039 writel(0x01, mmio + PDC_GENERAL_CTLR);
1041 readl(mmio + PDC_GENERAL_CTLR); 1040 readl(mmio + PDC_GENERAL_CTLR);
1042 } 1041 }
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 9c06f2abe7f7..d68dc7d3422c 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -90,7 +90,7 @@ static Scsi_Host_Template uli_sht = {
90 .ordered_flush = 1, 90 .ordered_flush = 1,
91}; 91};
92 92
93static struct ata_port_operations uli_ops = { 93static const struct ata_port_operations uli_ops = {
94 .port_disable = ata_port_disable, 94 .port_disable = ata_port_disable,
95 95
96 .tf_load = ata_tf_load, 96 .tf_load = ata_tf_load,
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 565872479b9a..80e291a909a9 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -109,7 +109,7 @@ static Scsi_Host_Template svia_sht = {
109 .ordered_flush = 1, 109 .ordered_flush = 1,
110}; 110};
111 111
112static struct ata_port_operations svia_sata_ops = { 112static const struct ata_port_operations svia_sata_ops = {
113 .port_disable = ata_port_disable, 113 .port_disable = ata_port_disable,
114 114
115 .tf_load = ata_tf_load, 115 .tf_load = ata_tf_load,
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 92378d768c86..028d4ab15c01 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -86,7 +86,7 @@ static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
86{ 86{
87 if (sc_reg > SCR_CONTROL) 87 if (sc_reg > SCR_CONTROL)
88 return 0xffffffffU; 88 return 0xffffffffU;
89 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 89 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
90} 90}
91 91
92 92
@@ -95,16 +95,16 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
95{ 95{
96 if (sc_reg > SCR_CONTROL) 96 if (sc_reg > SCR_CONTROL)
97 return; 97 return;
98 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 98 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
99} 99}
100 100
101 101
102static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) 102static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
103{ 103{
104 unsigned long mask_addr; 104 void __iomem *mask_addr;
105 u8 mask; 105 u8 mask;
106 106
107 mask_addr = (unsigned long) ap->host_set->mmio_base + 107 mask_addr = ap->host_set->mmio_base +
108 VSC_SATA_INT_MASK_OFFSET + ap->port_no; 108 VSC_SATA_INT_MASK_OFFSET + ap->port_no;
109 mask = readb(mask_addr); 109 mask = readb(mask_addr);
110 if (ctl & ATA_NIEN) 110 if (ctl & ATA_NIEN)
@@ -115,7 +115,7 @@ static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
115} 115}
116 116
117 117
118static void vsc_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 118static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
119{ 119{
120 struct ata_ioports *ioaddr = &ap->ioaddr; 120 struct ata_ioports *ioaddr = &ap->ioaddr;
121 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 121 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -231,7 +231,7 @@ static Scsi_Host_Template vsc_sata_sht = {
231}; 231};
232 232
233 233
234static struct ata_port_operations vsc_sata_ops = { 234static const struct ata_port_operations vsc_sata_ops = {
235 .port_disable = ata_port_disable, 235 .port_disable = ata_port_disable,
236 .tf_load = vsc_sata_tf_load, 236 .tf_load = vsc_sata_tf_load,
237 .tf_read = vsc_sata_tf_read, 237 .tf_read = vsc_sata_tf_read,
@@ -283,7 +283,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
283 struct ata_probe_ent *probe_ent = NULL; 283 struct ata_probe_ent *probe_ent = NULL;
284 unsigned long base; 284 unsigned long base;
285 int pci_dev_busy = 0; 285 int pci_dev_busy = 0;
286 void *mmio_base; 286 void __iomem *mmio_base;
287 int rc; 287 int rc;
288 288
289 if (!printed_version++) 289 if (!printed_version++)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1f0ebabf6d47..a5711d545d71 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -130,7 +130,7 @@ EXPORT_SYMBOL(scsi_device_types);
130 * Returns: Pointer to request block. 130 * Returns: Pointer to request block.
131 */ 131 */
132struct scsi_request *scsi_allocate_request(struct scsi_device *sdev, 132struct scsi_request *scsi_allocate_request(struct scsi_device *sdev,
133 int gfp_mask) 133 gfp_t gfp_mask)
134{ 134{
135 const int offset = ALIGN(sizeof(struct scsi_request), 4); 135 const int offset = ALIGN(sizeof(struct scsi_request), 4);
136 const int size = offset + sizeof(struct request); 136 const int size = offset + sizeof(struct request);
@@ -196,7 +196,7 @@ struct scsi_host_cmd_pool {
196 unsigned int users; 196 unsigned int users;
197 char *name; 197 char *name;
198 unsigned int slab_flags; 198 unsigned int slab_flags;
199 unsigned int gfp_mask; 199 gfp_t gfp_mask;
200}; 200};
201 201
202static struct scsi_host_cmd_pool scsi_cmd_pool = { 202static struct scsi_host_cmd_pool scsi_cmd_pool = {
@@ -213,7 +213,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
213static DECLARE_MUTEX(host_cmd_pool_mutex); 213static DECLARE_MUTEX(host_cmd_pool_mutex);
214 214
215static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 215static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
216 int gfp_mask) 216 gfp_t gfp_mask)
217{ 217{
218 struct scsi_cmnd *cmd; 218 struct scsi_cmnd *cmd;
219 219
@@ -245,7 +245,7 @@ static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
245 * 245 *
246 * Returns: The allocated scsi command structure. 246 * Returns: The allocated scsi command structure.
247 */ 247 */
248struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int gfp_mask) 248struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
249{ 249{
250 struct scsi_cmnd *cmd; 250 struct scsi_cmnd *cmd;
251 251
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 64fc9e21f35b..e69477d1889b 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -185,6 +185,7 @@ static struct {
185 {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 185 {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
186 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 186 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
187 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 187 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
188 {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
188 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, 189 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
189 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN}, 190 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
190 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */ 191 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ad5342165079..52b348c36d56 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1645,6 +1645,8 @@ int scsi_error_handler(void *data)
1645 set_current_state(TASK_INTERRUPTIBLE); 1645 set_current_state(TASK_INTERRUPTIBLE);
1646 } 1646 }
1647 1647
1648 __set_current_state(TASK_RUNNING);
1649
1648 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d" 1650 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d"
1649 " exiting\n",shost->host_no)); 1651 " exiting\n",shost->host_no));
1650 1652
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index de7f98cc38fe..6a3f6aae8a97 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -205,7 +205,8 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
205 unsigned int inlen, outlen, cmdlen; 205 unsigned int inlen, outlen, cmdlen;
206 unsigned int needed, buf_needed; 206 unsigned int needed, buf_needed;
207 int timeout, retries, result; 207 int timeout, retries, result;
208 int data_direction, gfp_mask = GFP_KERNEL; 208 int data_direction;
209 gfp_t gfp_mask = GFP_KERNEL;
209 210
210 if (!sic) 211 if (!sic)
211 return -EINVAL; 212 return -EINVAL;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index dc9c772bc874..3ff538809786 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -97,7 +97,6 @@ int scsi_insert_special_req(struct scsi_request *sreq, int at_head)
97} 97}
98 98
99static void scsi_run_queue(struct request_queue *q); 99static void scsi_run_queue(struct request_queue *q);
100static void scsi_release_buffers(struct scsi_cmnd *cmd);
101 100
102/* 101/*
103 * Function: scsi_unprep_request() 102 * Function: scsi_unprep_request()
@@ -678,7 +677,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
678 return NULL; 677 return NULL;
679} 678}
680 679
681static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, int gfp_mask) 680static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
682{ 681{
683 struct scsi_host_sg_pool *sgp; 682 struct scsi_host_sg_pool *sgp;
684 struct scatterlist *sgl; 683 struct scatterlist *sgl;
@@ -1040,8 +1039,10 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1040 * if sg table allocation fails, requeue request later. 1039 * if sg table allocation fails, requeue request later.
1041 */ 1040 */
1042 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); 1041 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC);
1043 if (unlikely(!sgpnt)) 1042 if (unlikely(!sgpnt)) {
1043 scsi_unprep_request(req);
1044 return BLKPREP_DEFER; 1044 return BLKPREP_DEFER;
1045 }
1045 1046
1046 cmd->request_buffer = (char *) sgpnt; 1047 cmd->request_buffer = (char *) sgpnt;
1047 cmd->request_bufflen = req->nr_sectors << 9; 1048 cmd->request_bufflen = req->nr_sectors << 9;
@@ -1245,8 +1246,8 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1245 */ 1246 */
1246 ret = scsi_init_io(cmd); 1247 ret = scsi_init_io(cmd);
1247 switch(ret) { 1248 switch(ret) {
1249 /* For BLKPREP_KILL/DEFER the cmd was released */
1248 case BLKPREP_KILL: 1250 case BLKPREP_KILL:
1249 /* BLKPREP_KILL return also releases the command */
1250 goto kill; 1251 goto kill;
1251 case BLKPREP_DEFER: 1252 case BLKPREP_DEFER:
1252 goto defer; 1253 goto defer;
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2cab556b6e82..771e97ef136e 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -819,12 +819,15 @@ show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf)
819 return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name); 819 return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
820} 820}
821 821
822#define get_list_head_entry(pos, head, member) \
823 pos = list_entry((head)->next, typeof(*pos), member)
824
822static ssize_t 825static ssize_t
823store_fc_private_host_tgtid_bind_type(struct class_device *cdev, 826store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
824 const char *buf, size_t count) 827 const char *buf, size_t count)
825{ 828{
826 struct Scsi_Host *shost = transport_class_to_shost(cdev); 829 struct Scsi_Host *shost = transport_class_to_shost(cdev);
827 struct fc_rport *rport, *next_rport; 830 struct fc_rport *rport;
828 enum fc_tgtid_binding_type val; 831 enum fc_tgtid_binding_type val;
829 unsigned long flags; 832 unsigned long flags;
830 833
@@ -834,9 +837,13 @@ store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
834 /* if changing bind type, purge all unused consistent bindings */ 837 /* if changing bind type, purge all unused consistent bindings */
835 if (val != fc_host_tgtid_bind_type(shost)) { 838 if (val != fc_host_tgtid_bind_type(shost)) {
836 spin_lock_irqsave(shost->host_lock, flags); 839 spin_lock_irqsave(shost->host_lock, flags);
837 list_for_each_entry_safe(rport, next_rport, 840 while (!list_empty(&fc_host_rport_bindings(shost))) {
838 &fc_host_rport_bindings(shost), peers) 841 get_list_head_entry(rport,
842 &fc_host_rport_bindings(shost), peers);
843 spin_unlock_irqrestore(shost->host_lock, flags);
839 fc_rport_terminate(rport); 844 fc_rport_terminate(rport);
845 spin_lock_irqsave(shost->host_lock, flags);
846 }
840 spin_unlock_irqrestore(shost->host_lock, flags); 847 spin_unlock_irqrestore(shost->host_lock, flags);
841 } 848 }
842 849
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ad94367df430..fd56b7ec88b6 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2644,7 +2644,7 @@ static char *
2644sg_page_malloc(int rqSz, int lowDma, int *retSzp) 2644sg_page_malloc(int rqSz, int lowDma, int *retSzp)
2645{ 2645{
2646 char *resp = NULL; 2646 char *resp = NULL;
2647 int page_mask; 2647 gfp_t page_mask;
2648 int order, a_size; 2648 int order, a_size;
2649 int resSz = rqSz; 2649 int resSz = rqSz;
2650 2650
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index d001c046551b..927d700f0073 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3577,7 +3577,8 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
3577static struct st_buffer * 3577static struct st_buffer *
3578 new_tape_buffer(int from_initialization, int need_dma, int max_sg) 3578 new_tape_buffer(int from_initialization, int need_dma, int max_sg)
3579{ 3579{
3580 int i, priority, got = 0, segs = 0; 3580 int i, got = 0, segs = 0;
3581 gfp_t priority;
3581 struct st_buffer *tb; 3582 struct st_buffer *tb;
3582 3583
3583 if (from_initialization) 3584 if (from_initialization)
@@ -3610,7 +3611,8 @@ static struct st_buffer *
3610/* Try to allocate enough space in the tape buffer */ 3611/* Try to allocate enough space in the tape buffer */
3611static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) 3612static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
3612{ 3613{
3613 int segs, nbr, max_segs, b_size, priority, order, got; 3614 int segs, nbr, max_segs, b_size, order, got;
3615 gfp_t priority;
3614 3616
3615 if (new_size <= STbuffer->buffer_size) 3617 if (new_size <= STbuffer->buffer_size)
3616 return 1; 3618 return 1;