Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (29 commits)
ide-tape: bump minor driver version
ide-tape: cleanup the remaining codestyle issues
ide-tape: fix syntax error in idetape_identify_device()
ide-tape: remove leftover OnStream support warning
ide-tape: collect module-related macro calls at the end
ide-tape: include proper headers
ide-tape: remove unused "length" arg from idetape_create_read_buffer_cmd()
ide-tape: remove struct idetape_id_gcw
ide-tape: cleanup and fix comments
ide-tape: shorten some function names
ide-tape: remove idetape_increase_max_pipeline_stages()
ide-tape: struct idetape_tape_t: shorten member names v2
ide-tape: struct idetape_tape_t: remove unused members
ide-tape: remove typedef idetape_chrdev_direction_t
ide-tape: simplify code branching in the interrupt handler
ide-tape: remove unreachable code chunk
ide-tape: remove struct idetape_read_position_result_t
ide-tape: refactor the debug logging facility
ide: add ide_read_error() inline helper
ide: add ide_read_[alt]status() inline helpers
...

+1825 -1593
+3
Documentation/kernel-parameters.txt
··· 780 780 loop use the MONITOR/MWAIT idle loop anyways. Performance should be the same 781 781 as idle=poll. 782 782 783 + ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem 784 + Claim all unknown PCI IDE storage controllers. 785 + 783 786 ignore_loglevel [KNL] 784 787 Ignore loglevel setting - this will print /all/ 785 788 kernel messages to the console. Useful for debugging.
+9
drivers/ide/Kconfig
··· 1009 1009 normally be on; disable it only if you are running a custom hard 1010 1010 drive subsystem through an expansion card. 1011 1011 1012 + config BLK_DEV_PALMCHIP_BK3710 1013 + tristate "Palmchip bk3710 IDE controller support" 1014 + depends on ARCH_DAVINCI 1015 + select BLK_DEV_IDEDMA_PCI 1016 + help 1017 + Say Y here if you want to support the onchip IDE controller on the 1018 + TI DaVinci SoC 1019 + 1020 + 1012 1021 config BLK_DEV_MPC8xx_IDE 1013 1022 tristate "MPC8xx IDE support" 1014 1023 depends on 8xx && (LWMON || IVMS8 || IVML24 || TQM8xxL) && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE
+1
drivers/ide/arm/Makefile
··· 2 2 obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o 3 3 obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o 4 4 obj-$(CONFIG_BLK_DEV_IDE_BAST) += bast-ide.o 5 + obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o 5 6 6 7 ifeq ($(CONFIG_IDE_ARM), m) 7 8 obj-m += ide_arm.o
+1 -1
drivers/ide/arm/icside.c
··· 365 365 if (icside_dma_test_irq(drive)) 366 366 return; 367 367 368 - ide_dump_status(drive, "DMA timeout", HWIF(drive)->INB(IDE_STATUS_REG)); 368 + ide_dump_status(drive, "DMA timeout", ide_read_status(drive)); 369 369 370 370 icside_dma_end(drive); 371 371 }
+395
drivers/ide/arm/palm_bk3710.c
··· 1 + /* 2 + * Palmchip bk3710 IDE controller 3 + * 4 + * Copyright (C) 2006 Texas Instruments. 5 + * Copyright (C) 2007 MontaVista Software, Inc., <source@mvista.com> 6 + * 7 + * ---------------------------------------------------------------------------- 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License as published by 11 + * the Free Software Foundation; either version 2 of the License, or 12 + * (at your option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software 21 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 + * ---------------------------------------------------------------------------- 23 + * 24 + */ 25 + 26 + #include <linux/types.h> 27 + #include <linux/module.h> 28 + #include <linux/kernel.h> 29 + #include <linux/ioport.h> 30 + #include <linux/hdreg.h> 31 + #include <linux/ide.h> 32 + #include <linux/delay.h> 33 + #include <linux/init.h> 34 + #include <linux/clk.h> 35 + #include <linux/platform_device.h> 36 + 37 + /* Offset of the primary interface registers */ 38 + #define IDE_PALM_ATA_PRI_REG_OFFSET 0x1F0 39 + 40 + /* Primary Control Offset */ 41 + #define IDE_PALM_ATA_PRI_CTL_OFFSET 0x3F6 42 + 43 + /* 44 + * PalmChip 3710 IDE Controller UDMA timing structure Definition 45 + */ 46 + struct palm_bk3710_udmatiming { 47 + unsigned int rptime; /* Ready to pause time */ 48 + unsigned int cycletime; /* Cycle Time */ 49 + }; 50 + 51 + #define BK3710_BMICP 0x00 52 + #define BK3710_BMISP 0x02 53 + #define BK3710_BMIDTP 0x04 54 + #define BK3710_BMICS 0x08 55 + #define BK3710_BMISS 0x0A 56 + #define BK3710_BMIDTS 0x0C 57 + #define BK3710_IDETIMP 0x40 58 + #define BK3710_IDETIMS 0x42 59 + #define BK3710_SIDETIM 0x44 60 + #define BK3710_SLEWCTL 0x45 61 + #define BK3710_IDESTATUS 0x47 62 + #define BK3710_UDMACTL 0x48 63 + #define BK3710_UDMATIM 0x4A 64 + #define BK3710_MISCCTL 0x50 65 + #define BK3710_REGSTB 0x54 66 + #define BK3710_REGRCVR 0x58 67 + #define BK3710_DATSTB 0x5C 68 + #define BK3710_DATRCVR 0x60 69 + #define BK3710_DMASTB 0x64 70 + #define BK3710_DMARCVR 0x68 71 + #define BK3710_UDMASTB 0x6C 72 + #define BK3710_UDMATRP 0x70 73 + #define BK3710_UDMAENV 0x74 74 + #define BK3710_IORDYTMP 0x78 75 + #define BK3710_IORDYTMS 0x7C 76 + 77 + #include "../ide-timing.h" 78 + 79 + static long ide_palm_clk; 80 + 81 + static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { 82 + {160, 240}, /* UDMA Mode 0 */ 83 + {125, 160}, /* UDMA Mode 1 */ 84 + {100, 120}, /* UDMA Mode 2 */ 85 + {100, 90}, /* UDMA Mode 3 */ 86 + {85, 60}, /* UDMA Mode 4 */ 87 + }; 88 + 89 + static struct clk *ideclkp; 90 + 91 + static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, 92 + unsigned int mode) 93 + { 94 + u8 tenv, trp, t0; 95 + u32 val32; 96 + u16 val16; 97 + 98 + /* DMA Data Setup */ 99 + t0 = (palm_bk3710_udmatimings[mode].cycletime + ide_palm_clk - 1) 100 + / ide_palm_clk - 1; 101 + tenv = (20 + ide_palm_clk - 1) / ide_palm_clk - 1; 102 + trp = (palm_bk3710_udmatimings[mode].rptime + ide_palm_clk - 1) 103 + / ide_palm_clk - 1; 104 + 105 + /* udmatim Register */ 106 + val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); 107 + val16 |= (mode << (dev ? 4 : 0)); 108 + writew(val16, base + BK3710_UDMATIM); 109 + 110 + /* udmastb Ultra DMA Access Strobe Width */ 111 + val32 = readl(base + BK3710_UDMASTB) & (0xFF << (dev ? 0 : 8)); 112 + val32 |= (t0 << (dev ? 8 : 0)); 113 + writel(val32, base + BK3710_UDMASTB); 114 + 115 + /* udmatrp Ultra DMA Ready to Pause Time */ 116 + val32 = readl(base + BK3710_UDMATRP) & (0xFF << (dev ? 0 : 8)); 117 + val32 |= (trp << (dev ? 8 : 0)); 118 + writel(val32, base + BK3710_UDMATRP); 119 + 120 + /* udmaenv Ultra DMA envelop Time */ 121 + val32 = readl(base + BK3710_UDMAENV) & (0xFF << (dev ? 0 : 8)); 122 + val32 |= (tenv << (dev ? 8 : 0)); 123 + writel(val32, base + BK3710_UDMAENV); 124 + 125 + /* Enable UDMA for Device */ 126 + val16 = readw(base + BK3710_UDMACTL) | (1 << dev); 127 + writew(val16, base + BK3710_UDMACTL); 128 + } 129 + 130 + static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev, 131 + unsigned short min_cycle, 132 + unsigned int mode) 133 + { 134 + u8 td, tkw, t0; 135 + u32 val32; 136 + u16 val16; 137 + struct ide_timing *t; 138 + int cycletime; 139 + 140 + t = ide_timing_find_mode(mode); 141 + cycletime = max_t(int, t->cycle, min_cycle); 142 + 143 + /* DMA Data Setup */ 144 + t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; 145 + td = (t->active + ide_palm_clk - 1) / ide_palm_clk; 146 + tkw = t0 - td - 1; 147 + td -= 1; 148 + 149 + val32 = readl(base + BK3710_DMASTB) & (0xFF << (dev ? 0 : 8)); 150 + val32 |= (td << (dev ? 8 : 0)); 151 + writel(val32, base + BK3710_DMASTB); 152 + 153 + val32 = readl(base + BK3710_DMARCVR) & (0xFF << (dev ? 0 : 8)); 154 + val32 |= (tkw << (dev ? 8 : 0)); 155 + writel(val32, base + BK3710_DMARCVR); 156 + 157 + /* Disable UDMA for Device */ 158 + val16 = readw(base + BK3710_UDMACTL) & ~(1 << dev); 159 + writew(val16, base + BK3710_UDMACTL); 160 + } 161 + 162 + static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, 163 + unsigned int dev, unsigned int cycletime, 164 + unsigned int mode) 165 + { 166 + u8 t2, t2i, t0; 167 + u32 val32; 168 + struct ide_timing *t; 169 + 170 + /* PIO Data Setup */ 171 + t0 = (cycletime + ide_palm_clk - 1) / ide_palm_clk; 172 + t2 = (ide_timing_find_mode(XFER_PIO_0 + mode)->active + 173 + ide_palm_clk - 1) / ide_palm_clk; 174 + 175 + t2i = t0 - t2 - 1; 176 + t2 -= 1; 177 + 178 + val32 = readl(base + BK3710_DATSTB) & (0xFF << (dev ? 0 : 8)); 179 + val32 |= (t2 << (dev ? 8 : 0)); 180 + writel(val32, base + BK3710_DATSTB); 181 + 182 + val32 = readl(base + BK3710_DATRCVR) & (0xFF << (dev ? 0 : 8)); 183 + val32 |= (t2i << (dev ? 8 : 0)); 184 + writel(val32, base + BK3710_DATRCVR); 185 + 186 + if (mate && mate->present) { 187 + u8 mode2 = ide_get_best_pio_mode(mate, 255, 4); 188 + 189 + if (mode2 < mode) 190 + mode = mode2; 191 + } 192 + 193 + /* TASKFILE Setup */ 194 + t = ide_timing_find_mode(XFER_PIO_0 + mode); 195 + t0 = (t->cyc8b + ide_palm_clk - 1) / ide_palm_clk; 196 + t2 = (t->act8b + ide_palm_clk - 1) / ide_palm_clk; 197 + 198 + t2i = t0 - t2 - 1; 199 + t2 -= 1; 200 + 201 + val32 = readl(base + BK3710_REGSTB) & (0xFF << (dev ? 0 : 8)); 202 + val32 |= (t2 << (dev ? 8 : 0)); 203 + writel(val32, base + BK3710_REGSTB); 204 + 205 + val32 = readl(base + BK3710_REGRCVR) & (0xFF << (dev ? 0 : 8)); 206 + val32 |= (t2i << (dev ? 8 : 0)); 207 + writel(val32, base + BK3710_REGRCVR); 208 + } 209 + 210 + static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed) 211 + { 212 + int is_slave = drive->dn & 1; 213 + void __iomem *base = (void *)drive->hwif->dma_base; 214 + 215 + if (xferspeed >= XFER_UDMA_0) { 216 + palm_bk3710_setudmamode(base, is_slave, 217 + xferspeed - XFER_UDMA_0); 218 + } else { 219 + palm_bk3710_setdmamode(base, is_slave, drive->id->eide_dma_min, 220 + xferspeed); 221 + } 222 + } 223 + 224 + static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio) 225 + { 226 + unsigned int cycle_time; 227 + int is_slave = drive->dn & 1; 228 + ide_drive_t *mate; 229 + void __iomem *base = (void *)drive->hwif->dma_base; 230 + 231 + /* 232 + * Obtain the drive PIO data for tuning the Palm Chip registers 233 + */ 234 + cycle_time = ide_pio_cycle_time(drive, pio); 235 + mate = ide_get_paired_drive(drive); 236 + palm_bk3710_setpiomode(base, mate, is_slave, cycle_time, pio); 237 + } 238 + 239 + static void __devinit palm_bk3710_chipinit(void __iomem *base) 240 + { 241 + /* 242 + * enable the reset_en of ATA controller so that when ata signals 243 + * are brought out, by writing into device config. at that 244 + * time por_n signal should not be 'Z' and have a stable value. 245 + */ 246 + writel(0x0300, base + BK3710_MISCCTL); 247 + 248 + /* wait for some time and deassert the reset of ATA Device. */ 249 + mdelay(100); 250 + 251 + /* Deassert the Reset */ 252 + writel(0x0200, base + BK3710_MISCCTL); 253 + 254 + /* 255 + * Program the IDETIMP Register Value based on the following assumptions 256 + * 257 + * (ATA_IDETIMP_IDEEN , ENABLE ) | 258 + * (ATA_IDETIMP_SLVTIMEN , DISABLE) | 259 + * (ATA_IDETIMP_RDYSMPL , 70NS) | 260 + * (ATA_IDETIMP_RDYRCVRY , 50NS) | 261 + * (ATA_IDETIMP_DMAFTIM1 , PIOCOMP) | 262 + * (ATA_IDETIMP_PREPOST1 , DISABLE) | 263 + * (ATA_IDETIMP_RDYSEN1 , DISABLE) | 264 + * (ATA_IDETIMP_PIOFTIM1 , DISABLE) | 265 + * (ATA_IDETIMP_DMAFTIM0 , PIOCOMP) | 266 + * (ATA_IDETIMP_PREPOST0 , DISABLE) | 267 + * (ATA_IDETIMP_RDYSEN0 , DISABLE) | 268 + * (ATA_IDETIMP_PIOFTIM0 , DISABLE) 269 + */ 270 + writew(0xB388, base + BK3710_IDETIMP); 271 + 272 + /* 273 + * Configure SIDETIM Register 274 + * (ATA_SIDETIM_RDYSMPS1 ,120NS ) | 275 + * (ATA_SIDETIM_RDYRCYS1 ,120NS ) 276 + */ 277 + writeb(0, base + BK3710_SIDETIM); 278 + 279 + /* 280 + * UDMACTL Ultra-ATA DMA Control 281 + * (ATA_UDMACTL_UDMAP1 , 0 ) | 282 + * (ATA_UDMACTL_UDMAP0 , 0 ) 283 + * 284 + */ 285 + writew(0, base + BK3710_UDMACTL); 286 + 287 + /* 288 + * MISCCTL Miscellaneous Conrol Register 289 + * (ATA_MISCCTL_RSTMODEP , 1) | 290 + * (ATA_MISCCTL_RESETP , 0) | 291 + * (ATA_MISCCTL_TIMORIDE , 1) 292 + */ 293 + writel(0x201, base + BK3710_MISCCTL); 294 + 295 + /* 296 + * IORDYTMP IORDY Timer for Primary Register 297 + * (ATA_IORDYTMP_IORDYTMP , 0xffff ) 298 + */ 299 + writel(0xFFFF, base + BK3710_IORDYTMP); 300 + 301 + /* 302 + * Configure BMISP Register 303 + * (ATA_BMISP_DMAEN1 , DISABLE ) | 304 + * (ATA_BMISP_DMAEN0 , DISABLE ) | 305 + * (ATA_BMISP_IORDYINT , CLEAR) | 306 + * (ATA_BMISP_INTRSTAT , CLEAR) | 307 + * (ATA_BMISP_DMAERROR , CLEAR) 308 + */ 309 + writew(0, base + BK3710_BMISP); 310 + 311 + palm_bk3710_setpiomode(base, NULL, 0, 600, 0); 312 + palm_bk3710_setpiomode(base, NULL, 1, 600, 0); 313 + } 314 + static int __devinit palm_bk3710_probe(struct platform_device *pdev) 315 + { 316 + hw_regs_t ide_ctlr_info; 317 + int index = 0; 318 + int pribase; 319 + struct clk *clkp; 320 + struct resource *mem, *irq; 321 + ide_hwif_t *hwif; 322 + void __iomem *base; 323 + 324 + clkp = clk_get(NULL, "IDECLK"); 325 + if (IS_ERR(clkp)) 326 + return -ENODEV; 327 + 328 + ideclkp = clkp; 329 + clk_enable(ideclkp); 330 + ide_palm_clk = clk_get_rate(ideclkp)/100000; 331 + ide_palm_clk = (10000/ide_palm_clk) + 1; 332 + /* Register the IDE interface with Linux ATA Interface */ 333 + memset(&ide_ctlr_info, 0, sizeof(ide_ctlr_info)); 334 + 335 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 336 + if (mem == NULL) { 337 + printk(KERN_ERR "failed to get memory region resource\n"); 338 + return -ENODEV; 339 + } 340 + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 341 + if (irq == NULL) { 342 + printk(KERN_ERR "failed to get IRQ resource\n"); 343 + return -ENODEV; 344 + } 345 + 346 + base = (void *)mem->start; 347 + 348 + /* Configure the Palm Chip controller */ 349 + palm_bk3710_chipinit(base); 350 + 351 + pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET; 352 + for (index = 0; index < IDE_NR_PORTS - 2; index++) 353 + ide_ctlr_info.io_ports[index] = pribase + index; 354 + ide_ctlr_info.io_ports[IDE_CONTROL_OFFSET] = mem->start + 355 + IDE_PALM_ATA_PRI_CTL_OFFSET; 356 + ide_ctlr_info.irq = irq->start; 357 + ide_ctlr_info.chipset = ide_palm3710; 358 + 359 + if (ide_register_hw(&ide_ctlr_info, NULL, &hwif) < 0) { 360 + printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n"); 361 + return -ENODEV; 362 + } 363 + 364 + hwif->set_pio_mode = &palm_bk3710_set_pio_mode; 365 + hwif->set_dma_mode = &palm_bk3710_set_dma_mode; 366 + hwif->mmio = 1; 367 + default_hwif_mmiops(hwif); 368 + hwif->cbl = ATA_CBL_PATA80; 369 + hwif->ultra_mask = 0x1f; /* Ultra DMA Mode 4 Max 370 + (input clk 99MHz) */ 371 + hwif->mwdma_mask = 0x7; 372 + hwif->drives[0].autotune = 1; 373 + hwif->drives[1].autotune = 1; 374 + 375 + ide_setup_dma(hwif, mem->start); 376 + 377 + return 0; 378 + } 379 + 380 + static struct platform_driver platform_bk_driver = { 381 + .driver = { 382 + .name = "palm_bk3710", 383 + }, 384 + .probe = palm_bk3710_probe, 385 + .remove = NULL, 386 + }; 387 + 388 + static int __init palm_bk3710_init(void) 389 + { 390 + return platform_driver_register(&platform_bk_driver); 391 + } 392 + 393 + module_init(palm_bk3710_init); 394 + MODULE_LICENSE("GPL"); 395 +
+22 -11
drivers/ide/cris/ide-cris.c
··· 753 753 cris_ide_set_speed(TYPE_DMA, 0, strobe, hold); 754 754 } 755 755 756 + static void __init cris_setup_ports(hw_regs_t *hw, unsigned long base) 757 + { 758 + int i; 759 + 760 + memset(hw, 0, sizeof(*hw)); 761 + 762 + for (i = 0; i <= 7; i++) 763 + hw->io_ports[i] = base + cris_ide_reg_addr(i, 0, 1); 764 + 765 + /* 766 + * the IDE control register is at ATA address 6, 767 + * with CS1 active instead of CS0 768 + */ 769 + hw->io_ports[IDE_CONTROL_OFFSET] = base + cris_ide_reg_addr(6, 1, 0); 770 + 771 + hw->irq = ide_default_irq(0); 772 + hw->ack_intr = cris_ide_ack_intr; 773 + } 774 + 756 775 static const struct ide_port_info cris_port_info __initdata = { 757 776 .chipset = ide_etrax100, 758 777 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | ··· 784 765 static int __init init_e100_ide(void) 785 766 { 786 767 hw_regs_t hw; 787 - int ide_offsets[IDE_NR_PORTS], h, i; 768 + int h; 788 769 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 789 770 790 771 printk("ide: ETRAX FS built-in ATA DMA controller\n"); 791 772 792 - for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) 793 - ide_offsets[i] = cris_ide_reg_addr(i, 0, 1); 794 - 795 - /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */ 796 - ide_offsets[IDE_CONTROL_OFFSET] = cris_ide_reg_addr(6, 1, 0); 797 - 798 773 for (h = 0; h < 4; h++) { 799 774 ide_hwif_t *hwif = NULL; 800 775 801 - ide_setup_ports(&hw, cris_ide_base_address(h), 802 - ide_offsets, 803 - 0, 0, cris_ide_ack_intr, 804 - ide_default_irq(0)); 776 + cris_setup_ports(&hw, cris_ide_base_address(h)); 777 + 805 778 hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); 806 779 if (hwif == NULL) 807 780 continue;
+1 -1
drivers/ide/ide-acpi.c
··· 171 171 static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif) 172 172 { 173 173 struct device *dev = hwif->gendev.parent; 174 - acpi_handle dev_handle; 174 + acpi_handle uninitialized_var(dev_handle); 175 175 acpi_integer pcidevfn; 176 176 acpi_handle chan_handle; 177 177 int err;
+5 -4
drivers/ide/ide-cd.c
··· 295 295 int stat, err, sense_key; 296 296 297 297 /* Check for errors. */ 298 - stat = HWIF(drive)->INB(IDE_STATUS_REG); 298 + stat = ide_read_status(drive); 299 + 299 300 if (stat_ret) 300 301 *stat_ret = stat; 301 302 ··· 304 303 return 0; 305 304 306 305 /* Get the IDE error register. */ 307 - err = HWIF(drive)->INB(IDE_ERROR_REG); 306 + err = ide_read_error(drive); 308 307 sense_key = err >> 4; 309 308 310 309 if (rq == NULL) { ··· 693 692 /* Some drives (ASUS) seem to tell us that status 694 693 * info is available. just get it and ignore. 695 694 */ 696 - (void) HWIF(drive)->INB(IDE_STATUS_REG); 695 + (void)ide_read_status(drive); 697 696 return 0; 698 697 } else { 699 698 /* Drive wants a command packet, or invalid ireason... */ ··· 1327 1326 if (blk_fs_request(rq)) { 1328 1327 if (info->cd_flags & IDE_CD_FLAG_SEEKING) { 1329 1328 unsigned long elapsed = jiffies - info->start_seek; 1330 - int stat = HWIF(drive)->INB(IDE_STATUS_REG); 1329 + int stat = ide_read_status(drive); 1331 1330 1332 1331 if ((stat & SEEK_STAT) != SEEK_STAT) { 1333 1332 if (elapsed < IDECD_SEEK_TIMEOUT) {
+2 -1
drivers/ide/ide-dma.c
··· 147 147 u8 stat = 0, dma_stat = 0; 148 148 149 149 dma_stat = HWIF(drive)->ide_dma_end(drive); 150 - stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */ 150 + stat = ide_read_status(drive); 151 + 151 152 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { 152 153 if (!dma_stat) { 153 154 struct request *rq = HWGROUP(drive)->rq;
+3 -3
drivers/ide/ide-floppy.c
··· 465 465 idefloppy_pc_t *pc; 466 466 struct request *rq; 467 467 468 - (void)drive->hwif->INB(IDE_ERROR_REG); 468 + (void)ide_read_error(drive); 469 469 pc = idefloppy_next_pc_storage(drive); 470 470 rq = idefloppy_next_rq_storage(drive); 471 471 idefloppy_create_request_sense_cmd(pc); ··· 501 501 } 502 502 503 503 /* Clear the interrupt */ 504 - stat = drive->hwif->INB(IDE_STATUS_REG); 504 + stat = ide_read_status(drive); 505 505 506 506 /* No more interrupts */ 507 507 if ((stat & DRQ_STAT) == 0) { ··· 1246 1246 u8 stat; 1247 1247 1248 1248 local_irq_save(flags); 1249 - stat = drive->hwif->INB(IDE_STATUS_REG); 1249 + stat = ide_read_status(drive); 1250 1250 local_irq_restore(flags); 1251 1251 1252 1252 progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
+8 -2
drivers/ide/ide-generic.c
··· 20 20 if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) 21 21 ide_get_lock(NULL, NULL); /* for atari only */ 22 22 23 - for (i = 0; i < MAX_HWIFS; i++) 24 - idx[i] = ide_hwifs[i].present ? 0xff : i; 23 + for (i = 0; i < MAX_HWIFS; i++) { 24 + ide_hwif_t *hwif = &ide_hwifs[i]; 25 + 26 + if (hwif->io_ports[IDE_DATA_OFFSET] && !hwif->present) 27 + idx[i] = i; 28 + else 29 + idx[i] = 0xff; 30 + } 25 31 26 32 ide_device_add_all(idx, NULL); 27 33
+7 -7
drivers/ide/ide-io.c
··· 466 466 return ide_stopped; 467 467 } 468 468 469 - if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 469 + if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 470 470 rq->errors |= ERROR_RESET; 471 471 472 472 if ((rq->errors & ERROR_RESET) == ERROR_RESET) { ··· 493 493 /* add decoding error stuff */ 494 494 } 495 495 496 - if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 496 + if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 497 497 /* force an abort */ 498 498 hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG); 499 499 ··· 821 821 #ifdef DEBUG 822 822 printk("%s: DRIVE_CMD (null)\n", drive->name); 823 823 #endif 824 - ide_end_drive_cmd(drive, 825 - hwif->INB(IDE_STATUS_REG), 826 - hwif->INB(IDE_ERROR_REG)); 824 + ide_end_drive_cmd(drive, ide_read_status(drive), ide_read_error(drive)); 825 + 827 826 return ide_stopped; 828 827 } 829 828 ··· 1230 1231 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); 1231 1232 (void)HWIF(drive)->ide_dma_end(drive); 1232 1233 ret = ide_error(drive, "dma timeout error", 1233 - hwif->INB(IDE_STATUS_REG)); 1234 + ide_read_status(drive)); 1234 1235 } else { 1235 1236 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); 1236 1237 hwif->dma_timeout(drive); ··· 1354 1355 startstop = ide_dma_timeout_retry(drive, wait); 1355 1356 } else 1356 1357 startstop = 1357 - ide_error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG)); 1358 + ide_error(drive, "irq timeout", 1359 + ide_read_status(drive)); 1358 1360 } 1359 1361 drive->service_time = jiffies - drive->service_start; 1360 1362 spin_lock_irq(&ide_lock);
+28 -17
drivers/ide/ide-iops.c
··· 430 430 * about possible isa-pnp and pci-pnp issues yet. 431 431 */ 432 432 if (IDE_CONTROL_REG) 433 - stat = hwif->INB(IDE_ALTSTATUS_REG); 433 + stat = ide_read_altstatus(drive); 434 434 else 435 435 /* Note: this may clear a pending IRQ!! */ 436 - stat = hwif->INB(IDE_STATUS_REG); 436 + stat = ide_read_status(drive); 437 437 438 438 if (stat & BUSY_STAT) 439 439 /* drive busy: definitely not interrupting */ ··· 458 458 */ 459 459 static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) 460 460 { 461 - ide_hwif_t *hwif = drive->hwif; 462 461 unsigned long flags; 463 462 int i; 464 463 u8 stat; 465 464 466 465 udelay(1); /* spec allows drive 400ns to assert "BUSY" */ 467 - if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { 466 + stat = ide_read_status(drive); 467 + 468 + if (stat & BUSY_STAT) { 468 469 local_irq_set(flags); 469 470 timeout += jiffies; 470 - while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) { 471 + while ((stat = ide_read_status(drive)) & BUSY_STAT) { 471 472 if (time_after(jiffies, timeout)) { 472 473 /* 473 474 * One last read after the timeout in case 474 475 * heavy interrupt load made us not make any 475 476 * progress during the timeout.. 476 477 */ 477 - stat = hwif->INB(IDE_STATUS_REG); 478 + stat = ide_read_status(drive); 478 479 if (!(stat & BUSY_STAT)) 479 480 break; 480 481 ··· 495 494 */ 496 495 for (i = 0; i < 10; i++) { 497 496 udelay(1); 498 - if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad)) { 497 + stat = ide_read_status(drive); 498 + 499 + if (OK_STAT(stat, good, bad)) { 499 500 *rstat = stat; 500 501 return 0; 501 502 } ··· 620 617 ide_hwif_t *hwif = drive->hwif; 621 618 struct hd_driveid *id; 622 619 unsigned long timeout, flags; 620 + u8 stat; 623 621 624 622 /* 625 623 * Re-read drive->id for possible DMA mode ··· 637 633 SELECT_MASK(drive, 0); 638 634 return 0; /* drive timed-out */ 639 635 } 636 + 640 637 msleep(50); /* give drive a breather */ 641 - } while (hwif->INB(IDE_ALTSTATUS_REG) & BUSY_STAT); 638 + stat = ide_read_altstatus(drive); 639 + } while (stat & BUSY_STAT); 640 + 642 641 msleep(50); /* wait for IRQ and DRQ_STAT */ 643 - if (!OK_STAT(hwif->INB(IDE_STATUS_REG),DRQ_STAT,BAD_R_STAT)) { 642 + stat = ide_read_status(drive); 643 + 644 + if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { 644 645 SELECT_MASK(drive, 0); 645 646 printk("%s: CHECK for good STATUS\n", drive->name); 646 647 return 0; ··· 658 649 return 0; 659 650 } 660 651 ata_input_data(drive, id, SECTOR_WORDS); 661 - (void) hwif->INB(IDE_STATUS_REG); /* clear drive IRQ */ 652 + (void)ide_read_status(drive); /* clear drive IRQ */ 662 653 local_irq_enable(); 663 654 local_irq_restore(flags); 664 655 ide_fix_driveid(id); ··· 859 850 static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) 860 851 { 861 852 ide_hwgroup_t *hwgroup = HWGROUP(drive); 862 - ide_hwif_t *hwif = HWIF(drive); 863 853 u8 stat; 864 854 865 855 SELECT_DRIVE(drive); 866 856 udelay (10); 857 + stat = ide_read_status(drive); 867 858 868 - if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { 859 + if (OK_STAT(stat, 0, BUSY_STAT)) 869 860 printk("%s: ATAPI reset complete\n", drive->name); 870 - } else { 861 + else { 871 862 if (time_before(jiffies, hwgroup->poll_timeout)) { 872 - BUG_ON(HWGROUP(drive)->handler != NULL); 873 863 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 874 864 /* continue polling */ 875 865 return ide_started; ··· 906 898 } 907 899 } 908 900 909 - if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { 901 + tmp = ide_read_status(drive); 902 + 903 + if (!OK_STAT(tmp, 0, BUSY_STAT)) { 910 904 if (time_before(jiffies, hwgroup->poll_timeout)) { 911 - BUG_ON(HWGROUP(drive)->handler != NULL); 912 905 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 913 906 /* continue polling */ 914 907 return ide_started; ··· 918 909 drive->failures++; 919 910 } else { 920 911 printk("%s: reset: ", hwif->name); 921 - if ((tmp = hwif->INB(IDE_ERROR_REG)) == 1) { 912 + tmp = ide_read_error(drive); 913 + 914 + if (tmp == 1) { 922 915 printk("success\n"); 923 916 drive->failures = 0; 924 917 } else {
+1 -1
drivers/ide/ide-lib.c
··· 578 578 } 579 579 printk("}\n"); 580 580 if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { 581 - err = drive->hwif->INB(IDE_ERROR_REG); 581 + err = ide_read_error(drive); 582 582 printk("%s: %s: error=0x%02x ", drive->name, msg, err); 583 583 if (drive->media == ide_disk) 584 584 ide_dump_ata_error(drive, err);
+25 -22
drivers/ide/ide-probe.c
··· 264 264 static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) 265 265 { 266 266 ide_hwif_t *hwif = HWIF(drive); 267 - int rc; 268 - unsigned long hd_status; 267 + int use_altstatus = 0, rc; 269 268 unsigned long timeout; 270 269 u8 s = 0, a = 0; 271 270 ··· 272 273 msleep(50); 273 274 274 275 if (IDE_CONTROL_REG) { 275 - a = hwif->INB(IDE_ALTSTATUS_REG); 276 - s = hwif->INB(IDE_STATUS_REG); 277 - if ((a ^ s) & ~INDEX_STAT) { 278 - printk(KERN_INFO "%s: probing with STATUS(0x%02x) instead of " 279 - "ALTSTATUS(0x%02x)\n", drive->name, s, a); 276 + a = ide_read_altstatus(drive); 277 + s = ide_read_status(drive); 278 + if ((a ^ s) & ~INDEX_STAT) 280 279 /* ancient Seagate drives, broken interfaces */ 281 - hd_status = IDE_STATUS_REG; 282 - } else { 280 + printk(KERN_INFO "%s: probing with STATUS(0x%02x) " 281 + "instead of ALTSTATUS(0x%02x)\n", 282 + drive->name, s, a); 283 + else 283 284 /* use non-intrusive polling */ 284 - hd_status = IDE_ALTSTATUS_REG; 285 - } 286 - } else 287 - hd_status = IDE_STATUS_REG; 285 + use_altstatus = 1; 286 + } 288 287 289 288 /* set features register for atapi 290 289 * identify command to be sure of reply ··· 303 306 } 304 307 /* give drive a breather */ 305 308 msleep(50); 306 - } while ((hwif->INB(hd_status)) & BUSY_STAT); 309 + s = use_altstatus ? ide_read_altstatus(drive) 310 + : ide_read_status(drive); 311 + } while (s & BUSY_STAT); 307 312 308 313 /* wait for IRQ and DRQ_STAT */ 309 314 msleep(50); 310 - if (OK_STAT((hwif->INB(IDE_STATUS_REG)), DRQ_STAT, BAD_R_STAT)) { 315 + s = ide_read_status(drive); 316 + 317 + if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { 311 318 unsigned long flags; 312 319 313 320 /* local CPU only; some systems need this */ ··· 321 320 /* drive responded with ID */ 322 321 rc = 0; 323 322 /* clear drive IRQ */ 324 - (void) hwif->INB(IDE_STATUS_REG); 323 + (void)ide_read_status(drive); 325 324 local_irq_restore(flags); 326 325 } else { 327 326 /* drive refused ID */ ··· 368 367 369 368 ide_set_irq(drive, 0); 370 369 /* clear drive IRQ */ 371 - (void) hwif->INB(IDE_STATUS_REG); 370 + (void)ide_read_status(drive); 372 371 udelay(5); 373 372 irq = probe_irq_off(cookie); 374 373 if (!hwif->irq) { ··· 456 455 return 3; 457 456 } 458 457 459 - if (OK_STAT((hwif->INB(IDE_STATUS_REG)), READY_STAT, BUSY_STAT) || 458 + stat = ide_read_status(drive); 459 + 460 + if (OK_STAT(stat, READY_STAT, BUSY_STAT) || 460 461 drive->present || cmd == WIN_PIDENTIFY) { 461 462 /* send cmd and wait */ 462 463 if ((rc = try_to_identify(drive, cmd))) { ··· 466 463 rc = try_to_identify(drive,cmd); 467 464 } 468 465 469 - stat = hwif->INB(IDE_STATUS_REG); 466 + stat = ide_read_status(drive); 470 467 471 468 if (stat == (BUSY_STAT | READY_STAT)) 472 469 return 4; ··· 485 482 } 486 483 487 484 /* ensure drive IRQ is clear */ 488 - stat = hwif->INB(IDE_STATUS_REG); 485 + stat = ide_read_status(drive); 489 486 490 487 if (rc == 1) 491 488 printk(KERN_ERR "%s: no response (status = 0x%02x)\n", ··· 499 496 SELECT_DRIVE(&hwif->drives[0]); 500 497 msleep(50); 501 498 /* ensure drive irq is clear */ 502 - (void) hwif->INB(IDE_STATUS_REG); 499 + (void)ide_read_status(drive); 503 500 } 504 501 return rc; 505 502 } ··· 524 521 525 522 msleep(50); 526 523 527 - stat = hwif->INB(IDE_STATUS_REG); 524 + stat = ide_read_status(drive); 528 525 529 526 if (!OK_STAT(stat, 0, BAD_STAT)) 530 527 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
+1
drivers/ide/ide-proc.c
··· 65 65 case ide_4drives: name = "4drives"; break; 66 66 case ide_pmac: name = "mac-io"; break; 67 67 case ide_au1xxx: name = "au1xxx"; break; 68 + case ide_palm3710: name = "palm3710"; break; 68 69 case ide_etrax100: name = "etrax100"; break; 69 70 case ide_acorn: name = "acorn"; break; 70 71 default: name = "(unknown)"; break;
+1126 -1274
drivers/ide/ide-tape.c
··· 15 15 * Documentation/ide/ChangeLog.ide-tape.1995-2002 16 16 */ 17 17 18 - #define IDETAPE_VERSION "1.19" 18 + #define IDETAPE_VERSION "1.20" 19 19 20 20 #include <linux/module.h> 21 21 #include <linux/types.h> ··· 39 39 #include <scsi/scsi.h> 40 40 41 41 #include <asm/byteorder.h> 42 - #include <asm/irq.h> 43 - #include <asm/uaccess.h> 44 - #include <asm/io.h> 42 + #include <linux/irq.h> 43 + #include <linux/uaccess.h> 44 + #include <linux/io.h> 45 45 #include <asm/unaligned.h> 46 46 #include <linux/mtio.h> 47 + 48 + enum { 49 + /* output errors only */ 50 + DBG_ERR = (1 << 0), 51 + /* output all sense key/asc */ 52 + DBG_SENSE = (1 << 1), 53 + /* info regarding all chrdev-related procedures */ 54 + DBG_CHRDEV = (1 << 2), 55 + /* all remaining procedures */ 56 + DBG_PROCS = (1 << 3), 57 + /* buffer alloc info (pc_stack & rq_stack) */ 58 + DBG_PCRQ_STACK = (1 << 4), 59 + }; 60 + 61 + /* define to see debug info */ 62 + #define IDETAPE_DEBUG_LOG 0 63 + 64 + #if IDETAPE_DEBUG_LOG 65 + #define debug_log(lvl, fmt, args...) \ 66 + { \ 67 + if (tape->debug_mask & lvl) \ 68 + printk(KERN_INFO "ide-tape: " fmt, ## args); \ 69 + } 70 + #else 71 + #define debug_log(lvl, fmt, args...) do {} while (0) 72 + #endif 47 73 48 74 /**************************** Tunable parameters *****************************/ 49 75 50 76 51 77 /* 52 - * Pipelined mode parameters. 78 + * Pipelined mode parameters. 53 79 * 54 - * We try to use the minimum number of stages which is enough to 55 - * keep the tape constantly streaming. To accomplish that, we implement 56 - * a feedback loop around the maximum number of stages: 80 + * We try to use the minimum number of stages which is enough to keep the tape 81 + * constantly streaming. To accomplish that, we implement a feedback loop around 82 + * the maximum number of stages: 57 83 * 58 - * We start from MIN maximum stages (we will not even use MIN stages 59 - * if we don't need them), increment it by RATE*(MAX-MIN) 60 - * whenever we sense that the pipeline is empty, until we reach 61 - * the optimum value or until we reach MAX. 84 + * We start from MIN maximum stages (we will not even use MIN stages if we don't 85 + * need them), increment it by RATE*(MAX-MIN) whenever we sense that the 86 + * pipeline is empty, until we reach the optimum value or until we reach MAX. 62 87 * 63 - * Setting the following parameter to 0 is illegal: the pipelined mode 64 - * cannot be disabled (calculate_speeds() divides by tape->max_stages.) 88 + * Setting the following parameter to 0 is illegal: the pipelined mode cannot be 89 + * disabled (idetape_calculate_speeds() divides by tape->max_stages.) 65 90 */ 66 91 #define IDETAPE_MIN_PIPELINE_STAGES 1 67 92 #define IDETAPE_MAX_PIPELINE_STAGES 400 68 93 #define IDETAPE_INCREASE_STAGES_RATE 20 69 94 70 95 /* 71 - * The following are used to debug the driver: 96 + * After each failed packet command we issue a request sense command and retry 97 + * the packet command IDETAPE_MAX_PC_RETRIES times. 72 98 * 73 - * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control. 74 - * 75 - * Setting them to 0 will restore normal operation mode: 76 - * 77 - * 1. Disable logging normal successful operations. 78 - * 2. Disable self-sanity checks. 79 - * 3. Errors will still be logged, of course. 80 - * 81 - * All the #if DEBUG code will be removed some day, when the driver 82 - * is verified to be stable enough. This will make it much more 83 - * esthetic. 84 - */ 85 - #define IDETAPE_DEBUG_LOG 0 86 - 87 - /* 88 - * After each failed packet command we issue a request sense command 89 - * and retry the packet command IDETAPE_MAX_PC_RETRIES times. 90 - * 91 - * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries. 99 + * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries. 92 100 */ 93 101 #define IDETAPE_MAX_PC_RETRIES 3 94 102 95 103 /* 96 - * With each packet command, we allocate a buffer of 97 - * IDETAPE_PC_BUFFER_SIZE bytes. This is used for several packet 98 - * commands (Not for READ/WRITE commands). 104 + * With each packet command, we allocate a buffer of IDETAPE_PC_BUFFER_SIZE 105 + * bytes. This is used for several packet commands (Not for READ/WRITE commands) 99 106 */ 100 107 #define IDETAPE_PC_BUFFER_SIZE 256 101 108 ··· 121 114 #define IDETAPE_WAIT_CMD (900*HZ) 122 115 123 116 /* 124 - * The following parameter is used to select the point in the internal 125 - * tape fifo in which we will start to refill the buffer. Decreasing 126 - * the following parameter will improve the system's latency and 127 - * interactive response, while using a high value might improve system 128 - * throughput. 117 + * The following parameter is used to select the point in the internal tape fifo 118 + * in which we will start to refill the buffer. Decreasing the following 119 + * parameter will improve the system's latency and interactive response, while 120 + * using a high value might improve system throughput. 129 121 */ 130 - #define IDETAPE_FIFO_THRESHOLD 2 122 + #define IDETAPE_FIFO_THRESHOLD 2 131 123 132 124 /* 133 - * DSC polling parameters. 125 + * DSC polling parameters. 134 126 * 135 - * Polling for DSC (a single bit in the status register) is a very 136 - * important function in ide-tape. There are two cases in which we 137 - * poll for DSC: 127 + * Polling for DSC (a single bit in the status register) is a very important 128 + * function in ide-tape. There are two cases in which we poll for DSC: 138 129 * 139 - * 1. Before a read/write packet command, to ensure that we 140 - * can transfer data from/to the tape's data buffers, without 141 - * causing an actual media access. In case the tape is not 142 - * ready yet, we take out our request from the device 143 - * request queue, so that ide.c will service requests from 144 - * the other device on the same interface meanwhile. 130 + * 1. Before a read/write packet command, to ensure that we can transfer data 131 + * from/to the tape's data buffers, without causing an actual media access. 132 + * In case the tape is not ready yet, we take out our request from the device 133 + * request queue, so that ide.c could service requests from the other device 134 + * on the same interface in the meantime. 145 135 * 146 - * 2. After the successful initialization of a "media access 147 - * packet command", which is a command which can take a long 148 - * time to complete (it can be several seconds or even an hour). 136 + * 2. After the successful initialization of a "media access packet command", 137 + * which is a command that can take a long time to complete (the interval can 138 + * range from several seconds to even an hour). Again, we postpone our request 139 + * in the middle to free the bus for the other device. The polling frequency 140 + * here should be lower than the read/write frequency since those media access 141 + * commands are slow. We start from a "fast" frequency - IDETAPE_DSC_MA_FAST 142 + * (1 second), and if we don't receive DSC after IDETAPE_DSC_MA_THRESHOLD 143 + * (5 min), we switch it to a lower frequency - IDETAPE_DSC_MA_SLOW (1 min). 149 144 * 150 - * Again, we postpone our request in the middle to free the bus 151 - * for the other device. The polling frequency here should be 152 - * lower than the read/write frequency since those media access 153 - * commands are slow. We start from a "fast" frequency - 154 - * IDETAPE_DSC_MA_FAST (one second), and if we don't receive DSC 155 - * after IDETAPE_DSC_MA_THRESHOLD (5 minutes), we switch it to a 156 - * lower frequency - IDETAPE_DSC_MA_SLOW (1 minute). 157 - * 158 - * We also set a timeout for the timer, in case something goes wrong. 159 - * The timeout should be longer then the maximum execution time of a 160 - * tape operation. 145 + * We also set a timeout for the timer, in case something goes wrong. The 146 + * timeout should be longer then the maximum execution time of a tape operation. 161 147 */ 162 - 163 - /* 164 - * DSC timings. 165 - */ 148 + 149 + /* DSC timings. */ 166 150 #define IDETAPE_DSC_RW_MIN 5*HZ/100 /* 50 msec */ 167 151 #define IDETAPE_DSC_RW_MAX 40*HZ/100 /* 400 msec */ 168 152 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ /* 2 minutes */ ··· 164 166 165 167 /*************************** End of tunable parameters ***********************/ 166 168 167 - /* 168 - * Read/Write error simulation 169 - */ 169 + /* Read/Write error simulation */ 170 170 #define SIMULATE_ERRORS 0 171 171 172 - /* 173 - * For general magnetic tape device compatibility. 174 - */ 175 - typedef enum { 176 - idetape_direction_none, 177 - idetape_direction_read, 178 - idetape_direction_write 179 - } idetape_chrdev_direction_t; 172 + /* tape directions */ 173 + enum { 174 + IDETAPE_DIR_NONE = (1 << 0), 175 + IDETAPE_DIR_READ = (1 << 1), 176 + IDETAPE_DIR_WRITE = (1 << 2), 177 + }; 180 178 181 179 struct idetape_bh { 182 180 u32 b_size; ··· 181 187 char *b_data; 182 188 }; 183 189 184 - /* 185 - * Our view of a packet command. 186 - */ 187 190 typedef struct idetape_packet_command_s { 188 - u8 c[12]; /* Actual packet bytes */ 189 - int retries; /* On each retry, we increment retries */ 190 - int error; /* Error code */ 191 - int request_transfer; /* Bytes to transfer */ 192 - int actually_transferred; /* Bytes actually transferred */ 193 - int buffer_size; /* Size of our data buffer */ 191 + /* Actual packet bytes */ 192 + u8 c[12]; 193 + /* On each retry, we increment retries */ 194 + int retries; 195 + /* Error code */ 196 + int error; 197 + /* Bytes to transfer */ 198 + int request_transfer; 199 + /* Bytes actually transferred */ 200 + int actually_transferred; 201 + /* Size of our data buffer */ 202 + int buffer_size; 194 203 struct idetape_bh *bh; 195 204 char *b_data; 196 205 int b_count; 197 - u8 *buffer; /* Data buffer */ 198 - u8 *current_position; /* Pointer into the above buffer */ 199 - ide_startstop_t (*callback) (ide_drive_t *); /* Called when this packet command is completed */ 200 - u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE]; /* Temporary buffer */ 201 - unsigned long flags; /* Status/Action bit flags: long for set_bit */ 206 + /* Data buffer */ 207 + u8 *buffer; 208 + /* Pointer into the above buffer */ 209 + u8 *current_position; 210 + /* Called when this packet command is completed */ 211 + ide_startstop_t (*callback) (ide_drive_t *); 212 + /* Temporary buffer */ 213 + u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE]; 214 + /* Status/Action bit flags: long for set_bit */ 215 + unsigned long flags; 202 216 } idetape_pc_t; 203 217 204 218 /* ··· 225 223 /* Data direction */ 226 224 #define PC_WRITING 5 227 225 228 - /* 229 - * A pipeline stage. 230 - */ 226 + /* A pipeline stage. */ 231 227 typedef struct idetape_stage_s { 232 228 struct request rq; /* The corresponding request */ 233 229 struct idetape_bh *bh; /* The data buffers */ ··· 233 233 } idetape_stage_t; 234 234 235 235 /* 236 - * Most of our global data which we need to save even as we leave the 237 - * driver due to an interrupt or a timer event is stored in a variable 238 - * of type idetape_tape_t, defined below. 236 + * Most of our global data which we need to save even as we leave the driver due 237 + * to an interrupt or a timer event is stored in the struct defined below. 239 238 */ 240 239 typedef struct ide_tape_obj { 241 240 ide_drive_t *drive; ··· 270 271 int rq_stack_index; 271 272 272 273 /* 273 - * DSC polling variables. 274 + * DSC polling variables. 274 275 * 275 - * While polling for DSC we use postponed_rq to postpone the 276 - * current request so that ide.c will be able to service 277 - * pending requests on the other device. Note that at most 278 - * we will have only one DSC (usually data transfer) request 279 - * in the device request queue. Additional requests can be 280 - * queued in our internal pipeline, but they will be visible 281 - * to ide.c only one at a time. 276 + * While polling for DSC we use postponed_rq to postpone the current 277 + * request so that ide.c will be able to service pending requests on the 278 + * other device. Note that at most we will have only one DSC (usually 279 + * data transfer) request in the device request queue. Additional 280 + * requests can be queued in our internal pipeline, but they will be 281 + * visible to ide.c only one at a time. 282 282 */ 283 283 struct request *postponed_rq; 284 284 /* The time in which we started polling for DSC */ ··· 285 287 /* Timer used to poll for dsc */ 286 288 struct timer_list dsc_timer; 287 289 /* Read/Write dsc polling frequency */ 288 - unsigned long best_dsc_rw_frequency; 289 - /* The current polling frequency */ 290 - unsigned long dsc_polling_frequency; 291 - /* Maximum waiting time */ 290 + unsigned long best_dsc_rw_freq; 291 + unsigned long dsc_poll_freq; 292 292 unsigned long dsc_timeout; 293 293 294 - /* 295 - * Read position information 296 - */ 294 + /* Read position information */ 297 295 u8 partition; 298 296 /* Current block */ 299 - unsigned int first_frame_position; 300 - unsigned int last_frame_position; 301 - unsigned int blocks_in_buffer; 297 + unsigned int first_frame; 302 298 303 - /* 304 - * Last error information 305 - */ 299 + /* Last error information */ 306 300 u8 sense_key, asc, ascq; 307 301 308 - /* 309 - * Character device operation 310 - */ 302 + /* Character device operation */ 311 303 unsigned int minor; 312 304 /* device name */ 313 305 char name[4]; 314 306 /* Current character device data transfer direction */ 315 - idetape_chrdev_direction_t chrdev_direction; 307 + u8 chrdev_dir; 316 308 317 - /* 318 - * Device information 319 - */ 320 - /* Usually 512 or 1024 bytes */ 321 - unsigned short tape_block_size; 309 + /* tape block size, usually 512 or 1024 bytes */ 310 + unsigned short blk_size; 322 311 int user_bs_factor; 323 312 324 313 /* Copy of the tape's Capabilities and Mechanical Page */ 325 314 u8 caps[20]; 326 315 327 316 /* 328 - * Active data transfer request parameters. 317 + * Active data transfer request parameters. 329 318 * 330 - * At most, there is only one ide-tape originated data transfer 331 - * request in the device request queue. This allows ide.c to 332 - * easily service requests from the other device when we 333 - * postpone our active request. In the pipelined operation 334 - * mode, we use our internal pipeline structure to hold 335 - * more data requests. 336 - * 337 - * The data buffer size is chosen based on the tape's 338 - * recommendation. 319 + * At most, there is only one ide-tape originated data transfer request 320 + * in the device request queue. This allows ide.c to easily service 321 + * requests from the other device when we postpone our active request. 322 + * In the pipelined operation mode, we use our internal pipeline 323 + * structure to hold more data requests. The data buffer size is chosen 324 + * based on the tape's recommendation. 339 325 */ 340 - /* Pointer to the request which is waiting in the device request queue */ 341 - struct request *active_data_request; 342 - /* Data buffer size (chosen based on the tape's recommendation */ 326 + /* ptr to the request which is waiting in the device request queue */ 327 + struct request *active_data_rq; 328 + /* Data buffer size chosen based on the tape's recommendation */ 343 329 int stage_size; 344 330 idetape_stage_t *merge_stage; 345 331 int merge_stage_size; 346 332 struct idetape_bh *bh; 347 333 char *b_data; 348 334 int b_count; 349 - 335 + 350 336 /* 351 - * Pipeline parameters. 337 + * Pipeline parameters. 352 338 * 353 - * To accomplish non-pipelined mode, we simply set the following 354 - * variables to zero (or NULL, where appropriate). 339 + * To accomplish non-pipelined mode, we simply set the following 340 + * variables to zero (or NULL, where appropriate). 355 341 */ 356 342 /* Number of currently used stages */ 357 343 int nr_stages; ··· 360 378 /* Status/Action flags: long for set_bit */ 361 379 unsigned long flags; 362 380 /* protects the ide-tape queue */ 363 - spinlock_t spinlock; 381 + spinlock_t lock; 364 382 365 - /* 366 - * Measures average tape speed 367 - */ 383 + /* Measures average tape speed */ 368 384 unsigned long avg_time; 369 385 int avg_size; 370 386 int avg_speed; 371 - 372 - char vendor_id[10]; 373 - char product_id[18]; 374 - char firmware_revision[6]; 375 - int firmware_revision_num; 376 387 377 388 /* the door is currently locked */ 378 389 int door_locked; ··· 375 400 char write_prot; 376 401 377 402 /* 378 - * Limit the number of times a request can 379 - * be postponed, to avoid an infinite postpone 380 - * deadlock. 403 + * Limit the number of times a request can be postponed, to avoid an 404 + * infinite postpone deadlock. 381 405 */ 382 - /* request postpone count limit */ 383 406 int postpone_cnt; 384 407 385 408 /* ··· 392 419 int tape_head; 393 420 int last_tape_head; 394 421 395 - /* 396 - * Speed control at the tape buffers input/output 397 - */ 422 + /* Speed control at the tape buffers input/output */ 398 423 unsigned long insert_time; 399 424 int insert_size; 400 425 int insert_speed; 401 426 int max_insert_speed; 402 427 int measure_insert_time; 403 428 404 - /* 405 - * Measure tape still time, in milliseconds 406 - */ 407 - unsigned long tape_still_time_begin; 408 - int tape_still_time; 409 - 410 - /* 411 - * Speed regulation negative feedback loop 412 - */ 429 + /* Speed regulation negative feedback loop */ 413 430 int speed_control; 414 431 int pipeline_head_speed; 415 432 int controlled_pipeline_head_speed; 416 433 int uncontrolled_pipeline_head_speed; 417 434 int controlled_last_pipeline_head; 418 - int uncontrolled_last_pipeline_head; 419 435 unsigned long uncontrolled_pipeline_head_time; 420 436 unsigned long controlled_pipeline_head_time; 421 437 int controlled_previous_pipeline_head; ··· 413 451 unsigned long uncontrolled_previous_head_time; 414 452 int restart_speed_control_req; 415 453 416 - /* 417 - * Debug_level determines amount of debugging output; 418 - * can be changed using /proc/ide/hdx/settings 419 - * 0 : almost no debugging output 420 - * 1 : 0+output errors only 421 - * 2 : 1+output all sensekey/asc 422 - * 3 : 2+follow all chrdev related procedures 423 - * 4 : 3+follow all procedures 424 - * 5 : 4+include pc_stack rq_stack info 425 - * 6 : 5+USE_COUNT updates 426 - */ 427 - int debug_level; 454 + u32 debug_mask; 428 455 } idetape_tape_t; 429 456 430 457 static DEFINE_MUTEX(idetape_ref_mutex); ··· 446 495 mutex_unlock(&idetape_ref_mutex); 447 496 } 448 497 449 - /* 450 - * Tape door status 451 - */ 498 + /* Tape door status */ 452 499 #define DOOR_UNLOCKED 0 453 500 #define DOOR_LOCKED 1 454 501 #define DOOR_EXPLICITLY_LOCKED 2 ··· 466 517 /* 0 = no tape is loaded, so we don't rewind after ejecting */ 467 518 #define IDETAPE_MEDIUM_PRESENT 9 468 519 469 - /* 470 - * Some defines for the READ BUFFER command 471 - */ 520 + /* A define for the READ BUFFER command */ 472 521 #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 473 522 474 - /* 475 - * Some defines for the SPACE command 476 - */ 523 + /* Some defines for the SPACE command */ 477 524 #define IDETAPE_SPACE_OVER_FILEMARK 1 478 525 #define IDETAPE_SPACE_TO_EOD 3 479 526 480 - /* 481 - * Some defines for the LOAD UNLOAD command 482 - */ 527 + /* Some defines for the LOAD UNLOAD command */ 483 528 #define IDETAPE_LU_LOAD_MASK 1 484 529 #define IDETAPE_LU_RETENSION_MASK 2 485 530 #define IDETAPE_LU_EOT_MASK 4 486 531 487 532 /* 488 - * Special requests for our block device strategy routine. 533 + * Special requests for our block device strategy routine. 489 534 * 490 - * In order to service a character device command, we add special 491 - * requests to the tail of our block device request queue and wait 492 - * for their completion. 535 + * In order to service a character device command, we add special requests to 536 + * the tail of our block device request queue and wait for their completion. 493 537 */ 494 538 495 539 enum { ··· 493 551 REQ_IDETAPE_READ_BUFFER = (1 << 4), 494 552 }; 495 553 496 - /* 497 - * Error codes which are returned in rq->errors to the higher part 498 - * of the driver. 499 - */ 554 + /* Error codes returned in rq->errors to the higher part of the driver. */ 500 555 #define IDETAPE_ERROR_GENERAL 101 501 556 #define IDETAPE_ERROR_FILEMARK 102 502 557 #define IDETAPE_ERROR_EOD 103 503 - 504 - /* 505 - * The following is used to format the general configuration word of 506 - * the ATAPI IDENTIFY DEVICE command. 507 - */ 508 - struct idetape_id_gcw { 509 - unsigned packet_size :2; /* Packet Size */ 510 - unsigned reserved234 :3; /* Reserved */ 511 - unsigned drq_type :2; /* Command packet DRQ type */ 512 - unsigned removable :1; /* Removable media */ 513 - unsigned device_type :5; /* Device type */ 514 - unsigned reserved13 :1; /* Reserved */ 515 - unsigned protocol :2; /* Protocol type */ 516 - }; 517 - 518 - /* 519 - * READ POSITION packet command - Data Format (From Table 6-57) 520 - */ 521 - typedef struct { 522 - unsigned reserved0_10 :2; /* Reserved */ 523 - unsigned bpu :1; /* Block Position Unknown */ 524 - unsigned reserved0_543 :3; /* Reserved */ 525 - unsigned eop :1; /* End Of Partition */ 526 - unsigned bop :1; /* Beginning Of Partition */ 527 - u8 partition; /* Partition Number */ 528 - u8 reserved2, reserved3; /* Reserved */ 529 - u32 first_block; /* First Block Location */ 530 - u32 last_block; /* Last Block Location (Optional) */ 531 - u8 reserved12; /* Reserved */ 532 - u8 blocks_in_buffer[3]; /* Blocks In Buffer - (Optional) */ 533 - u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */ 534 - } idetape_read_position_result_t; 535 558 536 559 /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ 537 560 #define IDETAPE_BLOCK_DESCRIPTOR 0 538 561 #define IDETAPE_CAPABILITIES_PAGE 0x2a 539 562 540 563 /* 541 - * The variables below are used for the character device interface. 542 - * Additional state variables are defined in our ide_drive_t structure. 564 + * The variables below are used for the character device interface. Additional 565 + * state variables are defined in our ide_drive_t structure. 543 566 */ 544 - static struct ide_tape_obj * idetape_devs[MAX_HWIFS * MAX_DRIVES]; 567 + static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; 545 568 546 569 #define ide_tape_f(file) ((file)->private_data) 547 570 ··· 523 616 } 524 617 525 618 /* 526 - * Function declarations 527 - * 528 - */ 529 - static int idetape_chrdev_release (struct inode *inode, struct file *filp); 530 - static void idetape_write_release (ide_drive_t *drive, unsigned int minor); 531 - 532 - /* 533 619 * Too bad. The drive wants to send us data which we are not ready to accept. 534 620 * Just throw it away. 535 621 */ 536 - static void idetape_discard_data (ide_drive_t *drive, unsigned int bcount) 622 + static void idetape_discard_data(ide_drive_t *drive, unsigned int bcount) 537 623 { 538 624 while (bcount--) 539 625 (void) HWIF(drive)->INB(IDE_DATA_REG); 540 626 } 541 627 542 - static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount) 628 + static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, 629 + unsigned int bcount) 543 630 { 544 631 struct idetape_bh *bh = pc->bh; 545 632 int count; ··· 545 644 idetape_discard_data(drive, bcount); 546 645 return; 547 646 } 548 - count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); 549 - HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); 647 + count = min( 648 + (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), 649 + bcount); 650 + HWIF(drive)->atapi_input_bytes(drive, bh->b_data + 651 + atomic_read(&bh->b_count), count); 550 652 bcount -= count; 551 653 atomic_add(count, &bh->b_count); 552 654 if (atomic_read(&bh->b_count) == bh->b_size) { ··· 561 657 pc->bh = bh; 562 658 } 563 659 564 - static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount) 660 + static void idetape_output_buffers(ide_drive_t *drive, idetape_pc_t *pc, 661 + unsigned int bcount) 565 662 { 566 663 struct idetape_bh *bh = pc->bh; 567 664 int count; 568 665 569 666 while (bcount) { 570 667 if (bh == NULL) { 571 - printk(KERN_ERR "ide-tape: bh == NULL in " 572 - "idetape_output_buffers\n"); 668 + printk(KERN_ERR "ide-tape: bh == NULL in %s\n", 669 + __func__); 573 670 return; 574 671 } 575 672 count = min((unsigned int)pc->b_count, (unsigned int)bcount); ··· 579 674 pc->b_data += count; 580 675 pc->b_count -= count; 581 676 if (!pc->b_count) { 582 - pc->bh = bh = bh->b_reqnext; 677 + bh = bh->b_reqnext; 678 + pc->bh = bh; 583 679 if (bh) { 584 680 pc->b_data = bh->b_data; 585 681 pc->b_count = atomic_read(&bh->b_count); ··· 589 683 } 590 684 } 591 685 592 - static void idetape_update_buffers (idetape_pc_t *pc) 686 + static void idetape_update_buffers(idetape_pc_t *pc) 593 687 { 594 688 struct idetape_bh *bh = pc->bh; 595 689 int count; ··· 599 693 return; 600 694 while (bcount) { 601 695 if (bh == NULL) { 602 - printk(KERN_ERR "ide-tape: bh == NULL in " 603 - "idetape_update_buffers\n"); 696 + printk(KERN_ERR "ide-tape: bh == NULL in %s\n", 697 + __func__); 604 698 return; 605 699 } 606 700 count = min((unsigned int)bh->b_size, (unsigned int)bcount); ··· 618 712 * driver. A storage space for a maximum of IDETAPE_PC_STACK packet 619 713 * commands is allocated at initialization time. 620 714 */ 621 - static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive) 715 + static idetape_pc_t *idetape_next_pc_storage(ide_drive_t *drive) 622 716 { 623 717 idetape_tape_t *tape = drive->driver_data; 624 718 625 - #if IDETAPE_DEBUG_LOG 626 - if (tape->debug_level >= 5) 627 - printk(KERN_INFO "ide-tape: pc_stack_index=%d\n", 628 - tape->pc_stack_index); 629 - #endif /* IDETAPE_DEBUG_LOG */ 719 + debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); 720 + 630 721 if (tape->pc_stack_index == IDETAPE_PC_STACK) 631 - tape->pc_stack_index=0; 722 + tape->pc_stack_index = 0; 632 723 return (&tape->pc_stack[tape->pc_stack_index++]); 633 724 } 634 725 ··· 634 731 * Since we queue packet commands in the request queue, we need to 635 732 * allocate a request, along with the allocation of a packet command. 636 733 */ 637 - 734 + 638 735 /************************************************************** 639 736 * * 640 737 * This should get fixed to use kmalloc(.., GFP_ATOMIC) * 641 738 * followed later on by kfree(). -ml * 642 739 * * 643 740 **************************************************************/ 644 - 645 - static struct request *idetape_next_rq_storage (ide_drive_t *drive) 741 + 742 + static struct request *idetape_next_rq_storage(ide_drive_t *drive) 646 743 { 647 744 idetape_tape_t *tape = drive->driver_data; 648 745 649 - #if IDETAPE_DEBUG_LOG 650 - if (tape->debug_level >= 5) 651 - printk(KERN_INFO "ide-tape: rq_stack_index=%d\n", 652 - tape->rq_stack_index); 653 - #endif /* IDETAPE_DEBUG_LOG */ 746 + debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index); 747 + 654 748 if (tape->rq_stack_index == IDETAPE_PC_STACK) 655 - tape->rq_stack_index=0; 749 + tape->rq_stack_index = 0; 656 750 return (&tape->rq_stack[tape->rq_stack_index++]); 657 751 } 658 752 659 - /* 660 - * idetape_init_pc initializes a packet command. 661 - */ 662 - static void idetape_init_pc (idetape_pc_t *pc) 753 + static void idetape_init_pc(idetape_pc_t *pc) 663 754 { 664 755 memset(pc->c, 0, 12); 665 756 pc->retries = 0; ··· 677 780 tape->sense_key = sense[2] & 0xF; 678 781 tape->asc = sense[12]; 679 782 tape->ascq = sense[13]; 680 - #if IDETAPE_DEBUG_LOG 681 - /* 682 - * Without debugging, we only log an error if we decided to give up 683 - * retrying. 684 - */ 685 - if (tape->debug_level >= 1) 686 - printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, " 687 - "asc = %x, ascq = %x\n", 688 - pc->c[0], tape->sense_key, 689 - tape->asc, tape->ascq); 690 - #endif /* IDETAPE_DEBUG_LOG */ 783 + 784 + debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", 785 + pc->c[0], tape->sense_key, tape->asc, tape->ascq); 691 786 692 787 /* Correct pc->actually_transferred by asking the tape. */ 693 788 if (test_bit(PC_DMA_ERROR, &pc->flags)) { 694 789 pc->actually_transferred = pc->request_transfer - 695 - tape->tape_block_size * 790 + tape->blk_size * 696 791 be32_to_cpu(get_unaligned((u32 *)&sense[3])); 697 792 idetape_update_buffers(pc); 698 793 } ··· 732 843 idetape_stage_t *stage = tape->next_stage; 733 844 struct request *rq = &stage->rq; 734 845 735 - #if IDETAPE_DEBUG_LOG 736 - if (tape->debug_level >= 4) 737 - printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n"); 738 - #endif /* IDETAPE_DEBUG_LOG */ 846 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 847 + 739 848 if (stage == NULL) { 740 - printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); 849 + printk(KERN_ERR "ide-tape: bug: Trying to activate a non" 850 + " existing stage\n"); 741 851 return; 742 852 } 743 853 744 854 rq->rq_disk = tape->disk; 745 855 rq->buffer = NULL; 746 856 rq->special = (void *)stage->bh; 747 - tape->active_data_request = rq; 857 + tape->active_data_rq = rq; 748 858 tape->active_stage = stage; 749 859 tape->next_stage = stage->next; 750 860 } 751 861 752 - /* 753 - * idetape_increase_max_pipeline_stages is a part of the feedback 754 - * loop which tries to find the optimum number of stages. In the 755 - * feedback loop, we are starting from a minimum maximum number of 756 - * stages, and if we sense that the pipeline is empty, we try to 757 - * increase it, until we reach the user compile time memory limit. 758 - */ 759 - static void idetape_increase_max_pipeline_stages (ide_drive_t *drive) 760 - { 761 - idetape_tape_t *tape = drive->driver_data; 762 - int increase = (tape->max_pipeline - tape->min_pipeline) / 10; 763 - 764 - #if IDETAPE_DEBUG_LOG 765 - if (tape->debug_level >= 4) 766 - printk (KERN_INFO "ide-tape: Reached idetape_increase_max_pipeline_stages\n"); 767 - #endif /* IDETAPE_DEBUG_LOG */ 768 - 769 - tape->max_stages += max(increase, 1); 770 - tape->max_stages = max(tape->max_stages, tape->min_pipeline); 771 - tape->max_stages = min(tape->max_stages, tape->max_pipeline); 772 - } 773 - 774 - /* 775 - * idetape_kfree_stage calls kfree to completely free a stage, along with 776 - * its related buffers. 777 - */ 778 - static void __idetape_kfree_stage (idetape_stage_t *stage) 862 + /* Free a stage along with its related buffers completely. */ 863 + static void __idetape_kfree_stage(idetape_stage_t *stage) 779 864 { 780 865 struct idetape_bh *prev_bh, *bh = stage->bh; 781 866 int size; ··· 770 907 kfree(stage); 771 908 } 772 909 773 - static void idetape_kfree_stage (idetape_tape_t *tape, idetape_stage_t *stage) 910 + static void idetape_kfree_stage(idetape_tape_t *tape, idetape_stage_t *stage) 774 911 { 775 912 __idetape_kfree_stage(stage); 776 913 } 777 914 778 915 /* 779 - * idetape_remove_stage_head removes tape->first_stage from the pipeline. 780 - * The caller should avoid race conditions. 916 + * Remove tape->first_stage from the pipeline. The caller should avoid race 917 + * conditions. 781 918 */ 782 - static void idetape_remove_stage_head (ide_drive_t *drive) 919 + static void idetape_remove_stage_head(ide_drive_t *drive) 783 920 { 784 921 idetape_tape_t *tape = drive->driver_data; 785 922 idetape_stage_t *stage; 786 - 787 - #if IDETAPE_DEBUG_LOG 788 - if (tape->debug_level >= 4) 789 - printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n"); 790 - #endif /* IDETAPE_DEBUG_LOG */ 923 + 924 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 925 + 791 926 if (tape->first_stage == NULL) { 792 927 printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); 793 928 return; 794 929 } 795 930 if (tape->active_stage == tape->first_stage) { 796 - printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); 931 + printk(KERN_ERR "ide-tape: bug: Trying to free our active " 932 + "pipeline stage\n"); 797 933 return; 798 934 } 799 935 stage = tape->first_stage; ··· 802 940 if (tape->first_stage == NULL) { 803 941 tape->last_stage = NULL; 804 942 if (tape->next_stage != NULL) 805 - printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); 943 + printk(KERN_ERR "ide-tape: bug: tape->next_stage !=" 944 + " NULL\n"); 806 945 if (tape->nr_stages) 807 - printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); 946 + printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 " 947 + "now\n"); 808 948 } 809 949 } 810 950 ··· 821 957 idetape_stage_t *stage = new_last_stage->next; 822 958 idetape_stage_t *nstage; 823 959 824 - #if IDETAPE_DEBUG_LOG 825 - if (tape->debug_level >= 4) 826 - printk(KERN_INFO "ide-tape: %s: idetape_abort_pipeline called\n", tape->name); 827 - #endif 960 + debug_log(DBG_PROCS, "%s: Enter %s\n", tape->name, __func__); 961 + 828 962 while (stage) { 829 963 nstage = stage->next; 830 964 idetape_kfree_stage(tape, stage); ··· 837 975 } 838 976 839 977 /* 840 - * idetape_end_request is used to finish servicing a request, and to 841 - * insert a pending pipeline request into the main device queue. 978 + * Finish servicing a request and insert a pending pipeline request into the 979 + * main device queue. 842 980 */ 843 981 static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) 844 982 { ··· 849 987 int remove_stage = 0; 850 988 idetape_stage_t *active_stage; 851 989 852 - #if IDETAPE_DEBUG_LOG 853 - if (tape->debug_level >= 4) 854 - printk(KERN_INFO "ide-tape: Reached idetape_end_request\n"); 855 - #endif /* IDETAPE_DEBUG_LOG */ 990 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 856 991 857 992 switch (uptodate) { 858 - case 0: error = IDETAPE_ERROR_GENERAL; break; 859 - case 1: error = 0; break; 860 - default: error = uptodate; 993 + case 0: error = IDETAPE_ERROR_GENERAL; break; 994 + case 1: error = 0; break; 995 + default: error = uptodate; 861 996 } 862 997 rq->errors = error; 863 998 if (error) ··· 865 1006 return 0; 866 1007 } 867 1008 868 - spin_lock_irqsave(&tape->spinlock, flags); 1009 + spin_lock_irqsave(&tape->lock, flags); 869 1010 870 1011 /* The request was a pipelined data transfer request */ 871 - if (tape->active_data_request == rq) { 1012 + if (tape->active_data_rq == rq) { 872 1013 active_stage = tape->active_stage; 873 1014 tape->active_stage = NULL; 874 - tape->active_data_request = NULL; 1015 + tape->active_data_rq = NULL; 875 1016 tape->nr_pending_stages--; 876 1017 if (rq->cmd[0] & REQ_IDETAPE_WRITE) { 877 1018 remove_stage = 1; 878 1019 if (error) { 879 1020 set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 880 1021 if (error == IDETAPE_ERROR_EOD) 881 - idetape_abort_pipeline(drive, active_stage); 1022 + idetape_abort_pipeline(drive, 1023 + active_stage); 882 1024 } 883 1025 } else if (rq->cmd[0] & REQ_IDETAPE_READ) { 884 1026 if (error == IDETAPE_ERROR_EOD) { ··· 890 1030 if (tape->next_stage != NULL) { 891 1031 idetape_activate_next_stage(drive); 892 1032 893 - /* 894 - * Insert the next request into the request queue. 895 - */ 896 - (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); 1033 + /* Insert the next request into the request queue. */ 1034 + (void)ide_do_drive_cmd(drive, tape->active_data_rq, 1035 + ide_end); 897 1036 } else if (!error) { 898 - idetape_increase_max_pipeline_stages(drive); 1037 + /* 1038 + * This is a part of the feedback loop which tries to 1039 + * find the optimum number of stages. We are starting 1040 + * from a minimum maximum number of stages, and if we 1041 + * sense that the pipeline is empty, we try to increase 1042 + * it, until we reach the user compile time memory 1043 + * limit. 1044 + */ 1045 + int i = (tape->max_pipeline - tape->min_pipeline) / 10; 1046 + 1047 + tape->max_stages += max(i, 1); 1048 + tape->max_stages = max(tape->max_stages, 1049 + tape->min_pipeline); 1050 + tape->max_stages = min(tape->max_stages, 1051 + tape->max_pipeline); 899 1052 } 900 1053 } 901 1054 ide_end_drive_cmd(drive, 0, 0); 902 - // blkdev_dequeue_request(rq); 903 - // drive->rq = NULL; 904 - // end_that_request_last(rq); 905 1055 906 1056 if (remove_stage) 907 1057 idetape_remove_stage_head(drive); 908 - if (tape->active_data_request == NULL) 1058 + if (tape->active_data_rq == NULL) 909 1059 clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); 910 - spin_unlock_irqrestore(&tape->spinlock, flags); 1060 + spin_unlock_irqrestore(&tape->lock, flags); 911 1061 return 0; 912 1062 } 913 1063 914 - static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) 1064 + static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) 915 1065 { 916 1066 idetape_tape_t *tape = drive->driver_data; 917 1067 918 - #if IDETAPE_DEBUG_LOG 919 - if (tape->debug_level >= 4) 920 - printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n"); 921 - #endif /* IDETAPE_DEBUG_LOG */ 1068 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1069 + 922 1070 if (!tape->pc->error) { 923 1071 idetape_analyze_error(drive, tape->pc->buffer); 924 1072 idetape_end_request(drive, 1, 0); 925 1073 } else { 926 - printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); 1074 + printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " 1075 + "Aborting request!\n"); 927 1076 idetape_end_request(drive, 0, 0); 928 1077 } 929 1078 return ide_stopped; 930 1079 } 931 1080 932 - static void idetape_create_request_sense_cmd (idetape_pc_t *pc) 1081 + static void idetape_create_request_sense_cmd(idetape_pc_t *pc) 933 1082 { 934 - idetape_init_pc(pc); 1083 + idetape_init_pc(pc); 935 1084 pc->c[0] = REQUEST_SENSE; 936 1085 pc->c[4] = 20; 937 1086 pc->request_transfer = 20; ··· 955 1086 } 956 1087 957 1088 /* 958 - * idetape_queue_pc_head generates a new packet command request in front 959 - * of the request queue, before the current request, so that it will be 960 - * processed immediately, on the next pass through the driver. 1089 + * Generate a new packet command request in front of the request queue, before 1090 + * the current request, so that it will be processed immediately, on the next 1091 + * pass through the driver. The function below is called from the request 1092 + * handling part of the driver (the "bottom" part). Safe storage for the request 1093 + * should be allocated with ide_tape_next_{pc,rq}_storage() prior to that. 961 1094 * 962 - * idetape_queue_pc_head is called from the request handling part of 963 - * the driver (the "bottom" part). Safe storage for the request should 964 - * be allocated with idetape_next_pc_storage and idetape_next_rq_storage 965 - * before calling idetape_queue_pc_head. 1095 + * Memory for those requests is pre-allocated at initialization time, and is 1096 + * limited to IDETAPE_PC_STACK requests. We assume that we have enough space for 1097 + * the maximum possible number of inter-dependent packet commands. 966 1098 * 967 - * Memory for those requests is pre-allocated at initialization time, and 968 - * is limited to IDETAPE_PC_STACK requests. We assume that we have enough 969 - * space for the maximum possible number of inter-dependent packet commands. 970 - * 971 - * The higher level of the driver - The ioctl handler and the character 972 - * device handling functions should queue request to the lower level part 973 - * and wait for their completion using idetape_queue_pc_tail or 974 - * idetape_queue_rw_tail. 1099 + * The higher level of the driver - The ioctl handler and the character device 1100 + * handling functions should queue request to the lower level part and wait for 1101 + * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. 975 1102 */ 976 - static void idetape_queue_pc_head (ide_drive_t *drive, idetape_pc_t *pc,struct request *rq) 1103 + static void idetape_queue_pc_head(ide_drive_t *drive, idetape_pc_t *pc, 1104 + struct request *rq) 977 1105 { 978 1106 struct ide_tape_obj *tape = drive->driver_data; 979 1107 ··· 991 1125 idetape_pc_t *pc; 992 1126 struct request *rq; 993 1127 994 - (void)drive->hwif->INB(IDE_ERROR_REG); 1128 + (void)ide_read_error(drive); 995 1129 pc = idetape_next_pc_storage(drive); 996 1130 rq = idetape_next_rq_storage(drive); 997 1131 idetape_create_request_sense_cmd(pc); ··· 1001 1135 } 1002 1136 1003 1137 /* 1004 - * idetape_postpone_request postpones the current request so that 1005 - * ide.c will be able to service requests from another device on 1006 - * the same hwgroup while we are polling for DSC. 1138 + * Postpone the current request so that ide.c will be able to service requests 1139 + * from another device on the same hwgroup while we are polling for DSC. 1007 1140 */ 1008 - static void idetape_postpone_request (ide_drive_t *drive) 1141 + static void idetape_postpone_request(ide_drive_t *drive) 1009 1142 { 1010 1143 idetape_tape_t *tape = drive->driver_data; 1011 1144 1012 - #if IDETAPE_DEBUG_LOG 1013 - if (tape->debug_level >= 4) 1014 - printk(KERN_INFO "ide-tape: idetape_postpone_request\n"); 1015 - #endif 1145 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1146 + 1016 1147 tape->postponed_rq = HWGROUP(drive)->rq; 1017 - ide_stall_queue(drive, tape->dsc_polling_frequency); 1148 + ide_stall_queue(drive, tape->dsc_poll_freq); 1018 1149 } 1019 1150 1151 + typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int); 1152 + 1020 1153 /* 1021 - * idetape_pc_intr is the usual interrupt handler which will be called 1022 - * during a packet command. We will transfer some of the data (as 1023 - * requested by the drive) and will re-point interrupt handler to us. 1024 - * When data transfer is finished, we will act according to the 1025 - * algorithm described before idetape_issue_packet_command. 1026 - * 1154 + * This is the usual interrupt handler which will be called during a packet 1155 + * command. We will transfer some of the data (as requested by the drive) and 1156 + * will re-point interrupt handler to us. When data transfer is finished, we 1157 + * will act according to the algorithm described before 1158 + * idetape_issue_pc. 1027 1159 */ 1028 - static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) 1160 + static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) 1029 1161 { 1030 1162 ide_hwif_t *hwif = drive->hwif; 1031 1163 idetape_tape_t *tape = drive->driver_data; 1032 1164 idetape_pc_t *pc = tape->pc; 1165 + xfer_func_t *xferfunc; 1166 + idetape_io_buf *iobuf; 1033 1167 unsigned int temp; 1034 1168 #if SIMULATE_ERRORS 1035 - static int error_sim_count = 0; 1169 + static int error_sim_count; 1036 1170 #endif 1037 1171 u16 bcount; 1038 1172 u8 stat, ireason; 1039 1173 1040 - #if IDETAPE_DEBUG_LOG 1041 - if (tape->debug_level >= 4) 1042 - printk(KERN_INFO "ide-tape: Reached idetape_pc_intr " 1043 - "interrupt handler\n"); 1044 - #endif /* IDETAPE_DEBUG_LOG */ 1174 + debug_log(DBG_PROCS, "Enter %s - interrupt handler\n", __func__); 1045 1175 1046 1176 /* Clear the interrupt */ 1047 - stat = hwif->INB(IDE_STATUS_REG); 1177 + stat = ide_read_status(drive); 1048 1178 1049 1179 if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { 1050 1180 if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { ··· 1070 1208 pc->actually_transferred = pc->request_transfer; 1071 1209 idetape_update_buffers(pc); 1072 1210 } 1073 - #if IDETAPE_DEBUG_LOG 1074 - if (tape->debug_level >= 4) 1075 - printk(KERN_INFO "ide-tape: DMA finished\n"); 1076 - #endif /* IDETAPE_DEBUG_LOG */ 1211 + debug_log(DBG_PROCS, "DMA finished\n"); 1212 + 1077 1213 } 1078 1214 1079 1215 /* No more interrupts */ 1080 1216 if ((stat & DRQ_STAT) == 0) { 1081 - #if IDETAPE_DEBUG_LOG 1082 - if (tape->debug_level >= 2) 1083 - printk(KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred); 1084 - #endif /* IDETAPE_DEBUG_LOG */ 1085 - clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); 1217 + debug_log(DBG_SENSE, "Packet command completed, %d bytes" 1218 + " transferred\n", pc->actually_transferred); 1086 1219 1220 + clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); 1087 1221 local_irq_enable(); 1088 1222 1089 1223 #if SIMULATE_ERRORS ··· 1094 1236 stat &= ~ERR_STAT; 1095 1237 if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { 1096 1238 /* Error detected */ 1097 - #if IDETAPE_DEBUG_LOG 1098 - if (tape->debug_level >= 1) 1099 - printk(KERN_INFO "ide-tape: %s: I/O error\n", 1100 - tape->name); 1101 - #endif /* IDETAPE_DEBUG_LOG */ 1239 + debug_log(DBG_ERR, "%s: I/O error\n", tape->name); 1240 + 1102 1241 if (pc->c[0] == REQUEST_SENSE) { 1103 - printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); 1242 + printk(KERN_ERR "ide-tape: I/O error in request" 1243 + " sense command\n"); 1104 1244 return ide_do_reset(drive); 1105 1245 } 1106 - #if IDETAPE_DEBUG_LOG 1107 - if (tape->debug_level >= 1) 1108 - printk(KERN_INFO "ide-tape: [cmd %x]: check condition\n", pc->c[0]); 1109 - #endif 1246 + debug_log(DBG_ERR, "[cmd %x]: check condition\n", 1247 + pc->c[0]); 1248 + 1110 1249 /* Retry operation */ 1111 1250 return idetape_retry_pc(drive); 1112 1251 } ··· 1112 1257 (stat & SEEK_STAT) == 0) { 1113 1258 /* Media access command */ 1114 1259 tape->dsc_polling_start = jiffies; 1115 - tape->dsc_polling_frequency = IDETAPE_DSC_MA_FAST; 1260 + tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; 1116 1261 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; 1117 1262 /* Allow ide.c to handle other requests */ 1118 1263 idetape_postpone_request(drive); ··· 1137 1282 ireason = hwif->INB(IDE_IREASON_REG); 1138 1283 1139 1284 if (ireason & CD) { 1140 - printk(KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n"); 1285 + printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); 1141 1286 return ide_do_reset(drive); 1142 1287 } 1143 1288 if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { ··· 1153 1298 temp = pc->actually_transferred + bcount; 1154 1299 if (temp > pc->request_transfer) { 1155 1300 if (temp > pc->buffer_size) { 1156 - printk(KERN_ERR "ide-tape: The tape wants to send us more data than expected - discarding data\n"); 1301 + printk(KERN_ERR "ide-tape: The tape wants to " 1302 + "send us more data than expected " 1303 + "- discarding data\n"); 1157 1304 idetape_discard_data(drive, bcount); 1158 - ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 1305 + ide_set_handler(drive, &idetape_pc_intr, 1306 + IDETAPE_WAIT_CMD, NULL); 1159 1307 return ide_started; 1160 1308 } 1161 - #if IDETAPE_DEBUG_LOG 1162 - if (tape->debug_level >= 2) 1163 - printk(KERN_NOTICE "ide-tape: The tape wants to send us more data than expected - allowing transfer\n"); 1164 - #endif /* IDETAPE_DEBUG_LOG */ 1309 + debug_log(DBG_SENSE, "The tape wants to send us more " 1310 + "data than expected - allowing transfer\n"); 1165 1311 } 1166 - } 1167 - if (test_bit(PC_WRITING, &pc->flags)) { 1168 - if (pc->bh != NULL) 1169 - idetape_output_buffers(drive, pc, bcount); 1170 - else 1171 - /* Write the current buffer */ 1172 - hwif->atapi_output_bytes(drive, pc->current_position, 1173 - bcount); 1312 + iobuf = &idetape_input_buffers; 1313 + xferfunc = hwif->atapi_input_bytes; 1174 1314 } else { 1175 - if (pc->bh != NULL) 1176 - idetape_input_buffers(drive, pc, bcount); 1177 - else 1178 - /* Read the current buffer */ 1179 - hwif->atapi_input_bytes(drive, pc->current_position, 1180 - bcount); 1315 + iobuf = &idetape_output_buffers; 1316 + xferfunc = hwif->atapi_output_bytes; 1181 1317 } 1318 + 1319 + if (pc->bh) 1320 + iobuf(drive, pc, bcount); 1321 + else 1322 + xferfunc(drive, pc->current_position, bcount); 1323 + 1182 1324 /* Update the current position */ 1183 1325 pc->actually_transferred += bcount; 1184 1326 pc->current_position += bcount; 1185 - #if IDETAPE_DEBUG_LOG 1186 - if (tape->debug_level >= 2) 1187 - printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes " 1188 - "on that interrupt\n", pc->c[0], bcount); 1189 - #endif 1327 + 1328 + debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n", 1329 + pc->c[0], bcount); 1330 + 1190 1331 /* And set the interrupt handler again */ 1191 1332 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 1192 1333 return ide_started; 1193 1334 } 1194 1335 1195 1336 /* 1196 - * Packet Command Interface 1337 + * Packet Command Interface 1197 1338 * 1198 - * The current Packet Command is available in tape->pc, and will not 1199 - * change until we finish handling it. Each packet command is associated 1200 - * with a callback function that will be called when the command is 1201 - * finished. 1339 + * The current Packet Command is available in tape->pc, and will not change 1340 + * until we finish handling it. Each packet command is associated with a 1341 + * callback function that will be called when the command is finished. 1202 1342 * 1203 - * The handling will be done in three stages: 1343 + * The handling will be done in three stages: 1204 1344 * 1205 - * 1. idetape_issue_packet_command will send the packet command to the 1206 - * drive, and will set the interrupt handler to idetape_pc_intr. 1345 + * 1. idetape_issue_pc will send the packet command to the drive, and will set 1346 + * the interrupt handler to idetape_pc_intr. 1207 1347 * 1208 - * 2. On each interrupt, idetape_pc_intr will be called. This step 1209 - * will be repeated until the device signals us that no more 1210 - * interrupts will be issued. 1348 + * 2. On each interrupt, idetape_pc_intr will be called. This step will be 1349 + * repeated until the device signals us that no more interrupts will be issued. 1211 1350 * 1212 - * 3. ATAPI Tape media access commands have immediate status with a 1213 - * delayed process. In case of a successful initiation of a 1214 - * media access packet command, the DSC bit will be set when the 1215 - * actual execution of the command is finished. 1216 - * Since the tape drive will not issue an interrupt, we have to 1217 - * poll for this event. In this case, we define the request as 1218 - * "low priority request" by setting rq_status to 1219 - * IDETAPE_RQ_POSTPONED, set a timer to poll for DSC and exit 1220 - * the driver. 1351 + * 3. ATAPI Tape media access commands have immediate status with a delayed 1352 + * process. In case of a successful initiation of a media access packet command, 1353 + * the DSC bit will be set when the actual execution of the command is finished. 1354 + * Since the tape drive will not issue an interrupt, we have to poll for this 1355 + * event. In this case, we define the request as "low priority request" by 1356 + * setting rq_status to IDETAPE_RQ_POSTPONED, set a timer to poll for DSC and 1357 + * exit the driver. 1221 1358 * 1222 - * ide.c will then give higher priority to requests which 1223 - * originate from the other device, until will change rq_status 1224 - * to RQ_ACTIVE. 1359 + * ide.c will then give higher priority to requests which originate from the 1360 + * other device, until will change rq_status to RQ_ACTIVE. 1225 1361 * 1226 - * 4. When the packet command is finished, it will be checked for errors. 1362 + * 4. When the packet command is finished, it will be checked for errors. 1227 1363 * 1228 - * 5. In case an error was found, we queue a request sense packet 1229 - * command in front of the request queue and retry the operation 1230 - * up to IDETAPE_MAX_PC_RETRIES times. 1364 + * 5. In case an error was found, we queue a request sense packet command in 1365 + * front of the request queue and retry the operation up to 1366 + * IDETAPE_MAX_PC_RETRIES times. 1231 1367 * 1232 - * 6. In case no error was found, or we decided to give up and not 1233 - * to retry again, the callback function will be called and then 1234 - * we will handle the next request. 1235 - * 1368 + * 6. In case no error was found, or we decided to give up and not to retry 1369 + * again, the callback function will be called and then we will handle the next 1370 + * request. 1236 1371 */ 1237 1372 static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) 1238 1373 { ··· 1233 1388 ide_startstop_t startstop; 1234 1389 u8 ireason; 1235 1390 1236 - if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { 1237 - printk(KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n"); 1391 + if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { 1392 + printk(KERN_ERR "ide-tape: Strange, packet command initiated " 1393 + "yet DRQ isn't asserted\n"); 1238 1394 return startstop; 1239 1395 } 1240 1396 ireason = hwif->INB(IDE_IREASON_REG); ··· 1268 1422 return ide_started; 1269 1423 } 1270 1424 1271 - static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape_pc_t *pc) 1425 + static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc) 1272 1426 { 1273 1427 ide_hwif_t *hwif = drive->hwif; 1274 1428 idetape_tape_t *tape = drive->driver_data; ··· 1289 1443 if (pc->retries > IDETAPE_MAX_PC_RETRIES || 1290 1444 test_bit(PC_ABORT, &pc->flags)) { 1291 1445 /* 1292 - * We will "abort" retrying a packet command in case 1293 - * a legitimate error code was received (crossing a 1294 - * filemark, or end of the media, for example). 1446 + * We will "abort" retrying a packet command in case legitimate 1447 + * error code was received (crossing a filemark, or end of the 1448 + * media, for example). 1295 1449 */ 1296 1450 if (!test_bit(PC_ABORT, &pc->flags)) { 1297 1451 if (!(pc->c[0] == TEST_UNIT_READY && ··· 1310 1464 tape->failed_pc = NULL; 1311 1465 return pc->callback(drive); 1312 1466 } 1313 - #if IDETAPE_DEBUG_LOG 1314 - if (tape->debug_level >= 2) 1315 - printk(KERN_INFO "ide-tape: Retry number - %d, cmd = %02X\n", pc->retries, pc->c[0]); 1316 - #endif /* IDETAPE_DEBUG_LOG */ 1467 + debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 1317 1468 1318 1469 pc->retries++; 1319 1470 /* We haven't transferred any data yet */ ··· 1342 1499 } 1343 1500 } 1344 1501 1345 - /* 1346 - * General packet command callback function. 1347 - */ 1348 - static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) 1502 + static ide_startstop_t idetape_pc_callback(ide_drive_t *drive) 1349 1503 { 1350 1504 idetape_tape_t *tape = drive->driver_data; 1351 - 1352 - #if IDETAPE_DEBUG_LOG 1353 - if (tape->debug_level >= 4) 1354 - printk(KERN_INFO "ide-tape: Reached idetape_pc_callback\n"); 1355 - #endif /* IDETAPE_DEBUG_LOG */ 1505 + 1506 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1356 1507 1357 1508 idetape_end_request(drive, tape->pc->error ? 0 : 1, 0); 1358 1509 return ide_stopped; 1359 1510 } 1360 1511 1361 - /* 1362 - * A mode sense command is used to "sense" tape parameters. 1363 - */ 1364 - static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) 1512 + /* A mode sense command is used to "sense" tape parameters. */ 1513 + static void idetape_create_mode_sense_cmd(idetape_pc_t *pc, u8 page_code) 1365 1514 { 1366 1515 idetape_init_pc(pc); 1367 1516 pc->c[0] = MODE_SENSE; 1368 1517 if (page_code != IDETAPE_BLOCK_DESCRIPTOR) 1369 - pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ 1518 + /* DBD = 1 - Don't return block descriptors */ 1519 + pc->c[1] = 8; 1370 1520 pc->c[2] = page_code; 1371 1521 /* 1372 1522 * Changed pc->c[3] to 0 (255 will at best return unused info). ··· 1369 1533 * and return an error when 255 is used. 1370 1534 */ 1371 1535 pc->c[3] = 0; 1372 - pc->c[4] = 255; /* (We will just discard data in that case) */ 1536 + /* We will just discard data in that case */ 1537 + pc->c[4] = 255; 1373 1538 if (page_code == IDETAPE_BLOCK_DESCRIPTOR) 1374 1539 pc->request_transfer = 12; 1375 1540 else if (page_code == IDETAPE_CAPABILITIES_PAGE) ··· 1380 1543 pc->callback = &idetape_pc_callback; 1381 1544 } 1382 1545 1383 - static void calculate_speeds(ide_drive_t *drive) 1546 + static void idetape_calculate_speeds(ide_drive_t *drive) 1384 1547 { 1385 1548 idetape_tape_t *tape = drive->driver_data; 1386 - int full = 125, empty = 75; 1387 1549 1388 - if (time_after(jiffies, tape->controlled_pipeline_head_time + 120 * HZ)) { 1389 - tape->controlled_previous_pipeline_head = tape->controlled_last_pipeline_head; 1390 - tape->controlled_previous_head_time = tape->controlled_pipeline_head_time; 1550 + if (time_after(jiffies, 1551 + tape->controlled_pipeline_head_time + 120 * HZ)) { 1552 + tape->controlled_previous_pipeline_head = 1553 + tape->controlled_last_pipeline_head; 1554 + tape->controlled_previous_head_time = 1555 + tape->controlled_pipeline_head_time; 1391 1556 tape->controlled_last_pipeline_head = tape->pipeline_head; 1392 1557 tape->controlled_pipeline_head_time = jiffies; 1393 1558 } 1394 1559 if (time_after(jiffies, tape->controlled_pipeline_head_time + 60 * HZ)) 1395 - tape->controlled_pipeline_head_speed = (tape->pipeline_head - tape->controlled_last_pipeline_head) * 32 * HZ / (jiffies - tape->controlled_pipeline_head_time); 1560 + tape->controlled_pipeline_head_speed = (tape->pipeline_head - 1561 + tape->controlled_last_pipeline_head) * 32 * HZ / 1562 + (jiffies - tape->controlled_pipeline_head_time); 1396 1563 else if (time_after(jiffies, tape->controlled_previous_head_time)) 1397 - tape->controlled_pipeline_head_speed = (tape->pipeline_head - tape->controlled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->controlled_previous_head_time); 1564 + tape->controlled_pipeline_head_speed = (tape->pipeline_head - 1565 + tape->controlled_previous_pipeline_head) * 32 * 1566 + HZ / (jiffies - tape->controlled_previous_head_time); 1398 1567 1399 - if (tape->nr_pending_stages < tape->max_stages /*- 1 */) { 1568 + if (tape->nr_pending_stages < tape->max_stages/*- 1 */) { 1400 1569 /* -1 for read mode error recovery */ 1401 - if (time_after(jiffies, tape->uncontrolled_previous_head_time + 10 * HZ)) { 1570 + if (time_after(jiffies, tape->uncontrolled_previous_head_time + 1571 + 10 * HZ)) { 1402 1572 tape->uncontrolled_pipeline_head_time = jiffies; 1403 - tape->uncontrolled_pipeline_head_speed = (tape->pipeline_head - tape->uncontrolled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->uncontrolled_previous_head_time); 1573 + tape->uncontrolled_pipeline_head_speed = 1574 + (tape->pipeline_head - 1575 + tape->uncontrolled_previous_pipeline_head) * 1576 + 32 * HZ / (jiffies - 1577 + tape->uncontrolled_previous_head_time); 1404 1578 } 1405 1579 } else { 1406 1580 tape->uncontrolled_previous_head_time = jiffies; 1407 1581 tape->uncontrolled_previous_pipeline_head = tape->pipeline_head; 1408 - if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + 30 * HZ)) { 1582 + if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + 1583 + 30 * HZ)) 1409 1584 tape->uncontrolled_pipeline_head_time = jiffies; 1410 - } 1585 + 1411 1586 } 1412 - tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed); 1413 - if (tape->speed_control == 0) { 1414 - tape->max_insert_speed = 5000; 1415 - } else if (tape->speed_control == 1) { 1587 + tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, 1588 + tape->controlled_pipeline_head_speed); 1589 + 1590 + if (tape->speed_control == 1) { 1416 1591 if (tape->nr_pending_stages >= tape->max_stages / 2) 1417 1592 tape->max_insert_speed = tape->pipeline_head_speed + 1418 - (1100 - tape->pipeline_head_speed) * 2 * (tape->nr_pending_stages - tape->max_stages / 2) / tape->max_stages; 1593 + (1100 - tape->pipeline_head_speed) * 2 * 1594 + (tape->nr_pending_stages - tape->max_stages / 2) 1595 + / tape->max_stages; 1419 1596 else 1420 1597 tape->max_insert_speed = 500 + 1421 - (tape->pipeline_head_speed - 500) * 2 * tape->nr_pending_stages / tape->max_stages; 1598 + (tape->pipeline_head_speed - 500) * 2 * 1599 + tape->nr_pending_stages / tape->max_stages; 1600 + 1422 1601 if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) 1423 1602 tape->max_insert_speed = 5000; 1424 - } else if (tape->speed_control == 2) { 1425 - tape->max_insert_speed = tape->pipeline_head_speed * empty / 100 + 1426 - (tape->pipeline_head_speed * full / 100 - tape->pipeline_head_speed * empty / 100) * tape->nr_pending_stages / tape->max_stages; 1427 1603 } else 1428 1604 tape->max_insert_speed = tape->speed_control; 1605 + 1429 1606 tape->max_insert_speed = max(tape->max_insert_speed, 500); 1430 1607 } 1431 1608 1432 - static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) 1609 + static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) 1433 1610 { 1434 1611 idetape_tape_t *tape = drive->driver_data; 1435 1612 idetape_pc_t *pc = tape->pc; 1436 1613 u8 stat; 1437 1614 1438 - stat = drive->hwif->INB(IDE_STATUS_REG); 1615 + stat = ide_read_status(drive); 1616 + 1439 1617 if (stat & SEEK_STAT) { 1440 1618 if (stat & ERR_STAT) { 1441 1619 /* Error detected */ ··· 1470 1618 return pc->callback(drive); 1471 1619 } 1472 1620 1473 - static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) 1621 + static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) 1474 1622 { 1475 1623 idetape_tape_t *tape = drive->driver_data; 1476 1624 struct request *rq = HWGROUP(drive)->rq; 1477 - int blocks = tape->pc->actually_transferred / tape->tape_block_size; 1625 + int blocks = tape->pc->actually_transferred / tape->blk_size; 1478 1626 1479 - tape->avg_size += blocks * tape->tape_block_size; 1480 - tape->insert_size += blocks * tape->tape_block_size; 1627 + tape->avg_size += blocks * tape->blk_size; 1628 + tape->insert_size += blocks * tape->blk_size; 1481 1629 if (tape->insert_size > 1024 * 1024) 1482 1630 tape->measure_insert_time = 1; 1483 1631 if (tape->measure_insert_time) { ··· 1486 1634 tape->insert_size = 0; 1487 1635 } 1488 1636 if (time_after(jiffies, tape->insert_time)) 1489 - tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); 1637 + tape->insert_speed = tape->insert_size / 1024 * HZ / 1638 + (jiffies - tape->insert_time); 1490 1639 if (time_after_eq(jiffies, tape->avg_time + HZ)) { 1491 - tape->avg_speed = tape->avg_size * HZ / (jiffies - tape->avg_time) / 1024; 1640 + tape->avg_speed = tape->avg_size * HZ / 1641 + (jiffies - tape->avg_time) / 1024; 1492 1642 tape->avg_size = 0; 1493 1643 tape->avg_time = jiffies; 1494 1644 } 1645 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1495 1646 1496 - #if IDETAPE_DEBUG_LOG 1497 - if (tape->debug_level >= 4) 1498 - printk(KERN_INFO "ide-tape: Reached idetape_rw_callback\n"); 1499 - #endif /* IDETAPE_DEBUG_LOG */ 1500 - 1501 - tape->first_frame_position += blocks; 1647 + tape->first_frame += blocks; 1502 1648 rq->current_nr_sectors -= blocks; 1503 1649 1504 1650 if (!tape->pc->error) ··· 1506 1656 return ide_stopped; 1507 1657 } 1508 1658 1509 - static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) 1659 + static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, 1660 + unsigned int length, struct idetape_bh *bh) 1510 1661 { 1511 1662 idetape_init_pc(pc); 1512 1663 pc->c[0] = READ_6; ··· 1517 1666 pc->bh = bh; 1518 1667 atomic_set(&bh->b_count, 0); 1519 1668 pc->buffer = NULL; 1520 - pc->request_transfer = pc->buffer_size = length * tape->tape_block_size; 1669 + pc->buffer_size = length * tape->blk_size; 1670 + pc->request_transfer = pc->buffer_size; 1521 1671 if (pc->request_transfer == tape->stage_size) 1522 1672 set_bit(PC_DMA_RECOMMENDED, &pc->flags); 1523 1673 } 1524 1674 1525 - static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) 1675 + static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, 1676 + idetape_pc_t *pc, struct idetape_bh *bh) 1526 1677 { 1527 1678 int size = 32768; 1528 1679 struct idetape_bh *p = bh; ··· 1542 1689 atomic_set(&p->b_count, 0); 1543 1690 p = p->b_reqnext; 1544 1691 } 1545 - pc->request_transfer = pc->buffer_size = size; 1692 + pc->request_transfer = size; 1693 + pc->buffer_size = size; 1546 1694 } 1547 1695 1548 - static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) 1696 + static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, 1697 + unsigned int length, struct idetape_bh *bh) 1549 1698 { 1550 1699 idetape_init_pc(pc); 1551 1700 pc->c[0] = WRITE_6; ··· 1559 1704 pc->b_data = bh->b_data; 1560 1705 pc->b_count = atomic_read(&bh->b_count); 1561 1706 pc->buffer = NULL; 1562 - pc->request_transfer = pc->buffer_size = length * tape->tape_block_size; 1707 + pc->buffer_size = length * tape->blk_size; 1708 + pc->request_transfer = pc->buffer_size; 1563 1709 if (pc->request_transfer == tape->stage_size) 1564 1710 set_bit(PC_DMA_RECOMMENDED, &pc->flags); 1565 1711 } 1566 1712 1567 - /* 1568 - * idetape_do_request is our request handling function. 1569 - */ 1570 1713 static ide_startstop_t idetape_do_request(ide_drive_t *drive, 1571 1714 struct request *rq, sector_t block) 1572 1715 { ··· 1573 1720 struct request *postponed_rq = tape->postponed_rq; 1574 1721 u8 stat; 1575 1722 1576 - #if IDETAPE_DEBUG_LOG 1577 - if (tape->debug_level >= 2) 1578 - printk(KERN_INFO "ide-tape: sector: %ld, " 1579 - "nr_sectors: %ld, current_nr_sectors: %d\n", 1723 + debug_log(DBG_SENSE, "sector: %ld, nr_sectors: %ld," 1724 + " current_nr_sectors: %d\n", 1580 1725 rq->sector, rq->nr_sectors, rq->current_nr_sectors); 1581 - #endif /* IDETAPE_DEBUG_LOG */ 1582 1726 1583 1727 if (!blk_special_request(rq)) { 1584 - /* 1585 - * We do not support buffer cache originated requests. 1586 - */ 1728 + /* We do not support buffer cache originated requests. */ 1587 1729 printk(KERN_NOTICE "ide-tape: %s: Unsupported request in " 1588 1730 "request queue (%d)\n", drive->name, rq->cmd_type); 1589 1731 ide_end_request(drive, 0, 0); 1590 1732 return ide_stopped; 1591 1733 } 1592 1734 1593 - /* 1594 - * Retry a failed packet command 1595 - */ 1596 - if (tape->failed_pc != NULL && 1597 - tape->pc->c[0] == REQUEST_SENSE) { 1598 - return idetape_issue_packet_command(drive, tape->failed_pc); 1599 - } 1735 + /* Retry a failed packet command */ 1736 + if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) 1737 + return idetape_issue_pc(drive, tape->failed_pc); 1738 + 1600 1739 if (postponed_rq != NULL) 1601 1740 if (rq != postponed_rq) { 1602 1741 printk(KERN_ERR "ide-tape: ide-tape.c bug - " ··· 1603 1758 * If the tape is still busy, postpone our request and service 1604 1759 * the other device meanwhile. 1605 1760 */ 1606 - stat = drive->hwif->INB(IDE_STATUS_REG); 1761 + stat = ide_read_status(drive); 1607 1762 1608 1763 if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) 1609 1764 set_bit(IDETAPE_IGNORE_DSC, &tape->flags); ··· 1613 1768 drive->post_reset = 0; 1614 1769 } 1615 1770 1616 - if (tape->tape_still_time > 100 && tape->tape_still_time < 200) 1617 - tape->measure_insert_time = 1; 1618 1771 if (time_after(jiffies, tape->insert_time)) 1619 - tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); 1620 - calculate_speeds(drive); 1772 + tape->insert_speed = tape->insert_size / 1024 * HZ / 1773 + (jiffies - tape->insert_time); 1774 + idetape_calculate_speeds(drive); 1621 1775 if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && 1622 1776 (stat & SEEK_STAT) == 0) { 1623 1777 if (postponed_rq == NULL) { 1624 1778 tape->dsc_polling_start = jiffies; 1625 - tape->dsc_polling_frequency = tape->best_dsc_rw_frequency; 1779 + tape->dsc_poll_freq = tape->best_dsc_rw_freq; 1626 1780 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; 1627 1781 } else if (time_after(jiffies, tape->dsc_timeout)) { 1628 1782 printk(KERN_ERR "ide-tape: %s: DSC timeout\n", ··· 1632 1788 } else { 1633 1789 return ide_do_reset(drive); 1634 1790 } 1635 - } else if (time_after(jiffies, tape->dsc_polling_start + IDETAPE_DSC_MA_THRESHOLD)) 1636 - tape->dsc_polling_frequency = IDETAPE_DSC_MA_SLOW; 1791 + } else if (time_after(jiffies, 1792 + tape->dsc_polling_start + 1793 + IDETAPE_DSC_MA_THRESHOLD)) 1794 + tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 1637 1795 idetape_postpone_request(drive); 1638 1796 return ide_stopped; 1639 1797 } ··· 1643 1797 tape->buffer_head++; 1644 1798 tape->postpone_cnt = 0; 1645 1799 pc = idetape_next_pc_storage(drive); 1646 - idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); 1800 + idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, 1801 + (struct idetape_bh *)rq->special); 1647 1802 goto out; 1648 1803 } 1649 1804 if (rq->cmd[0] & REQ_IDETAPE_WRITE) { 1650 1805 tape->buffer_head++; 1651 1806 tape->postpone_cnt = 0; 1652 1807 pc = idetape_next_pc_storage(drive); 1653 - idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); 1808 + idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, 1809 + (struct idetape_bh *)rq->special); 1654 1810 goto out; 1655 1811 } 1656 1812 if (rq->cmd[0] & REQ_IDETAPE_READ_BUFFER) { 1657 1813 tape->postpone_cnt = 0; 1658 1814 pc = idetape_next_pc_storage(drive); 1659 - idetape_create_read_buffer_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); 1815 + idetape_create_read_buffer_cmd(tape, pc, 1816 + (struct idetape_bh *)rq->special); 1660 1817 goto out; 1661 1818 } 1662 1819 if (rq->cmd[0] & REQ_IDETAPE_PC1) { ··· 1674 1825 } 1675 1826 BUG(); 1676 1827 out: 1677 - return idetape_issue_packet_command(drive, pc); 1828 + return idetape_issue_pc(drive, pc); 1678 1829 } 1679 1830 1680 - /* 1681 - * Pipeline related functions 1682 - */ 1683 - static inline int idetape_pipeline_active (idetape_tape_t *tape) 1831 + /* Pipeline related functions */ 1832 + static inline int idetape_pipeline_active(idetape_tape_t *tape) 1684 1833 { 1685 1834 int rc1, rc2; 1686 1835 1687 1836 rc1 = test_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); 1688 - rc2 = (tape->active_data_request != NULL); 1837 + rc2 = (tape->active_data_rq != NULL); 1689 1838 return rc1; 1690 1839 } 1691 1840 1692 1841 /* 1693 - * idetape_kmalloc_stage uses __get_free_page to allocate a pipeline 1694 - * stage, along with all the necessary small buffers which together make 1695 - * a buffer of size tape->stage_size (or a bit more). We attempt to 1696 - * combine sequential pages as much as possible. 1842 + * The function below uses __get_free_page to allocate a pipeline stage, along 1843 + * with all the necessary small buffers which together make a buffer of size 1844 + * tape->stage_size (or a bit more). We attempt to combine sequential pages as 1845 + * much as possible. 1697 1846 * 1698 - * Returns a pointer to the new allocated stage, or NULL if we 1699 - * can't (or don't want to) allocate a stage. 1847 + * It returns a pointer to the new allocated stage, or NULL if we can't (or 1848 + * don't want to) allocate a stage. 1700 1849 * 1701 - * Pipeline stages are optional and are used to increase performance. 1702 - * If we can't allocate them, we'll manage without them. 1850 + * Pipeline stages are optional and are used to increase performance. If we 1851 + * can't allocate them, we'll manage without them. 1703 1852 */ 1704 - static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, int clear) 1853 + static idetape_stage_t *__idetape_kmalloc_stage(idetape_tape_t *tape, int full, 1854 + int clear) 1705 1855 { 1706 1856 idetape_stage_t *stage; 1707 1857 struct idetape_bh *prev_bh, *bh; 1708 1858 int pages = tape->pages_per_stage; 1709 1859 char *b_data = NULL; 1710 1860 1711 - if ((stage = kmalloc(sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) 1861 + stage = kmalloc(sizeof(idetape_stage_t), GFP_KERNEL); 1862 + if (!stage) 1712 1863 return NULL; 1713 1864 stage->next = NULL; 1714 1865 1715 - bh = stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); 1866 + stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); 1867 + bh = stage->bh; 1716 1868 if (bh == NULL) 1717 1869 goto abort; 1718 1870 bh->b_reqnext = NULL; 1719 - if ((bh->b_data = (char *) __get_free_page (GFP_KERNEL)) == NULL) 1871 + bh->b_data = (char *) __get_free_page(GFP_KERNEL); 1872 + if (!bh->b_data) 1720 1873 goto abort; 1721 1874 if (clear) 1722 1875 memset(bh->b_data, 0, PAGE_SIZE); ··· 1726 1875 atomic_set(&bh->b_count, full ? bh->b_size : 0); 1727 1876 1728 1877 while (--pages) { 1729 - if ((b_data = (char *) __get_free_page (GFP_KERNEL)) == NULL) 1878 + b_data = (char *) __get_free_page(GFP_KERNEL); 1879 + if (!b_data) 1730 1880 goto abort; 1731 1881 if (clear) 1732 1882 memset(b_data, 0, PAGE_SIZE); ··· 1745 1893 continue; 1746 1894 } 1747 1895 prev_bh = bh; 1748 - if ((bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { 1896 + bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); 1897 + if (!bh) { 1749 1898 free_page((unsigned long) b_data); 1750 1899 goto abort; 1751 1900 } ··· 1765 1912 return NULL; 1766 1913 } 1767 1914 1768 - static idetape_stage_t *idetape_kmalloc_stage (idetape_tape_t *tape) 1915 + static idetape_stage_t *idetape_kmalloc_stage(idetape_tape_t *tape) 1769 1916 { 1770 1917 idetape_stage_t *cache_stage = tape->cache_stage; 1771 1918 1772 - #if IDETAPE_DEBUG_LOG 1773 - if (tape->debug_level >= 4) 1774 - printk(KERN_INFO "ide-tape: Reached idetape_kmalloc_stage\n"); 1775 - #endif /* IDETAPE_DEBUG_LOG */ 1919 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1776 1920 1777 1921 if (tape->nr_stages >= tape->max_stages) 1778 1922 return NULL; ··· 1780 1930 return __idetape_kmalloc_stage(tape, 0, 0); 1781 1931 } 1782 1932 1783 - static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t *stage, const char __user *buf, int n) 1933 + static int idetape_copy_stage_from_user(idetape_tape_t *tape, 1934 + idetape_stage_t *stage, const char __user *buf, int n) 1784 1935 { 1785 1936 struct idetape_bh *bh = tape->bh; 1786 1937 int count; ··· 1789 1938 1790 1939 while (n) { 1791 1940 if (bh == NULL) { 1792 - printk(KERN_ERR "ide-tape: bh == NULL in " 1793 - "idetape_copy_stage_from_user\n"); 1941 + printk(KERN_ERR "ide-tape: bh == NULL in %s\n", 1942 + __func__); 1794 1943 return 1; 1795 1944 } 1796 - count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); 1797 - if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) 1945 + count = min((unsigned int) 1946 + (bh->b_size - atomic_read(&bh->b_count)), 1947 + (unsigned int)n); 1948 + if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, 1949 + count)) 1798 1950 ret = 1; 1799 1951 n -= count; 1800 1952 atomic_add(count, &bh->b_count); ··· 1812 1958 return ret; 1813 1959 } 1814 1960 1815 - static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, idetape_stage_t *stage, int n) 1961 + static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, 1962 + idetape_stage_t *stage, int n) 1816 1963 { 1817 1964 struct idetape_bh *bh = tape->bh; 1818 1965 int count; ··· 1821 1966 1822 1967 while (n) { 1823 1968 if (bh == NULL) { 1824 - printk(KERN_ERR "ide-tape: bh == NULL in " 1825 - "idetape_copy_stage_to_user\n"); 1969 + printk(KERN_ERR "ide-tape: bh == NULL in %s\n", 1970 + __func__); 1826 1971 return 1; 1827 1972 } 1828 1973 count = min(tape->b_count, n); ··· 1833 1978 tape->b_count -= count; 1834 1979 buf += count; 1835 1980 if (!tape->b_count) { 1836 - tape->bh = bh = bh->b_reqnext; 1981 + bh = bh->b_reqnext; 1982 + tape->bh = bh; 1837 1983 if (bh) { 1838 1984 tape->b_data = bh->b_data; 1839 1985 tape->b_count = atomic_read(&bh->b_count); ··· 1844 1988 return ret; 1845 1989 } 1846 1990 1847 - static void idetape_init_merge_stage (idetape_tape_t *tape) 1991 + static void idetape_init_merge_stage(idetape_tape_t *tape) 1848 1992 { 1849 1993 struct idetape_bh *bh = tape->merge_stage->bh; 1850 - 1994 + 1851 1995 tape->bh = bh; 1852 - if (tape->chrdev_direction == idetape_direction_write) 1996 + if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 1853 1997 atomic_set(&bh->b_count, 0); 1854 1998 else { 1855 1999 tape->b_data = bh->b_data; ··· 1857 2001 } 1858 2002 } 1859 2003 1860 - static void idetape_switch_buffers (idetape_tape_t *tape, idetape_stage_t *stage) 2004 + static void idetape_switch_buffers(idetape_tape_t *tape, idetape_stage_t *stage) 1861 2005 { 1862 2006 struct idetape_bh *tmp; 1863 2007 ··· 1867 2011 idetape_init_merge_stage(tape); 1868 2012 } 1869 2013 1870 - /* 1871 - * idetape_add_stage_tail adds a new stage at the end of the pipeline. 1872 - */ 1873 - static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) 2014 + /* Add a new stage at the end of the pipeline. */ 2015 + static void idetape_add_stage_tail(ide_drive_t *drive, idetape_stage_t *stage) 1874 2016 { 1875 2017 idetape_tape_t *tape = drive->driver_data; 1876 2018 unsigned long flags; 1877 - 1878 - #if IDETAPE_DEBUG_LOG 1879 - if (tape->debug_level >= 4) 1880 - printk (KERN_INFO "ide-tape: Reached idetape_add_stage_tail\n"); 1881 - #endif /* IDETAPE_DEBUG_LOG */ 1882 - spin_lock_irqsave(&tape->spinlock, flags); 2019 + 2020 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 2021 + 2022 + spin_lock_irqsave(&tape->lock, flags); 1883 2023 stage->next = NULL; 1884 2024 if (tape->last_stage != NULL) 1885 - tape->last_stage->next=stage; 2025 + tape->last_stage->next = stage; 1886 2026 else 1887 - tape->first_stage = tape->next_stage=stage; 2027 + tape->first_stage = stage; 2028 + tape->next_stage = stage; 1888 2029 tape->last_stage = stage; 1889 2030 if (tape->next_stage == NULL) 1890 2031 tape->next_stage = tape->last_stage; 1891 2032 tape->nr_stages++; 1892 2033 tape->nr_pending_stages++; 1893 - spin_unlock_irqrestore(&tape->spinlock, flags); 2034 + spin_unlock_irqrestore(&tape->lock, flags); 1894 2035 } 1895 2036 1896 - /* 1897 - * idetape_wait_for_request installs a completion in a pending request 1898 - * and sleeps until it is serviced. 1899 - * 1900 - * The caller should ensure that the request will not be serviced 1901 - * before we install the completion (usually by disabling interrupts). 2037 + /* Install a completion in a pending request and sleep until it is serviced. The 2038 + * caller should ensure that the request will not be serviced before we install 2039 + * the completion (usually by disabling interrupts). 1902 2040 */ 1903 - static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) 2041 + static void idetape_wait_for_request(ide_drive_t *drive, struct request *rq) 1904 2042 { 1905 2043 DECLARE_COMPLETION_ONSTACK(wait); 1906 2044 idetape_tape_t *tape = drive->driver_data; 1907 2045 1908 2046 if (rq == NULL || !blk_special_request(rq)) { 1909 - printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); 2047 + printk(KERN_ERR "ide-tape: bug: Trying to sleep on non-valid" 2048 + " request\n"); 1910 2049 return; 1911 2050 } 1912 2051 rq->end_io_data = &wait; 1913 2052 rq->end_io = blk_end_sync_rq; 1914 - spin_unlock_irq(&tape->spinlock); 2053 + spin_unlock_irq(&tape->lock); 1915 2054 wait_for_completion(&wait); 1916 2055 /* The stage and its struct request have been deallocated */ 1917 - spin_lock_irq(&tape->spinlock); 2056 + spin_lock_irq(&tape->lock); 1918 2057 } 1919 2058 1920 - static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) 2059 + static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) 1921 2060 { 1922 2061 idetape_tape_t *tape = drive->driver_data; 1923 - idetape_read_position_result_t *result; 1924 - 1925 - #if IDETAPE_DEBUG_LOG 1926 - if (tape->debug_level >= 4) 1927 - printk(KERN_INFO "ide-tape: Reached idetape_read_position_callback\n"); 1928 - #endif /* IDETAPE_DEBUG_LOG */ 2062 + u8 *readpos = tape->pc->buffer; 2063 + 2064 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 1929 2065 1930 2066 if (!tape->pc->error) { 1931 - result = (idetape_read_position_result_t *) tape->pc->buffer; 1932 - #if IDETAPE_DEBUG_LOG 1933 - if (tape->debug_level >= 2) 1934 - printk(KERN_INFO "ide-tape: BOP - %s\n",result->bop ? "Yes":"No"); 1935 - if (tape->debug_level >= 2) 1936 - printk(KERN_INFO "ide-tape: EOP - %s\n",result->eop ? "Yes":"No"); 1937 - #endif /* IDETAPE_DEBUG_LOG */ 1938 - if (result->bpu) { 1939 - printk(KERN_INFO "ide-tape: Block location is unknown to the tape\n"); 2067 + debug_log(DBG_SENSE, "BOP - %s\n", 2068 + (readpos[0] & 0x80) ? "Yes" : "No"); 2069 + debug_log(DBG_SENSE, "EOP - %s\n", 2070 + (readpos[0] & 0x40) ? "Yes" : "No"); 2071 + 2072 + if (readpos[0] & 0x4) { 2073 + printk(KERN_INFO "ide-tape: Block location is unknown" 2074 + "to the tape\n"); 1940 2075 clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags); 1941 2076 idetape_end_request(drive, 0, 0); 1942 2077 } else { 1943 - #if IDETAPE_DEBUG_LOG 1944 - if (tape->debug_level >= 2) 1945 - printk(KERN_INFO "ide-tape: Block Location - %u\n", ntohl(result->first_block)); 1946 - #endif /* IDETAPE_DEBUG_LOG */ 1947 - tape->partition = result->partition; 1948 - tape->first_frame_position = ntohl(result->first_block); 1949 - tape->last_frame_position = ntohl(result->last_block); 1950 - tape->blocks_in_buffer = result->blocks_in_buffer[2]; 2078 + debug_log(DBG_SENSE, "Block Location - %u\n", 2079 + be32_to_cpu(*(u32 *)&readpos[4])); 2080 + 2081 + tape->partition = readpos[1]; 2082 + tape->first_frame = 2083 + be32_to_cpu(*(u32 *)&readpos[4]); 1951 2084 set_bit(IDETAPE_ADDRESS_VALID, &tape->flags); 1952 2085 idetape_end_request(drive, 1, 0); 1953 2086 } ··· 1947 2102 } 1948 2103 1949 2104 /* 1950 - * idetape_create_write_filemark_cmd will: 1951 - * 1952 - * 1. Write a filemark if write_filemark=1. 1953 - * 2. Flush the device buffers without writing a filemark 1954 - * if write_filemark=0. 1955 - * 2105 + * Write a filemark if write_filemark=1. Flush the device buffers without 2106 + * writing a filemark otherwise. 1956 2107 */ 1957 - static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) 2108 + static void idetape_create_write_filemark_cmd(ide_drive_t *drive, 2109 + idetape_pc_t *pc, int write_filemark) 1958 2110 { 1959 2111 idetape_init_pc(pc); 1960 2112 pc->c[0] = WRITE_FILEMARKS; ··· 1968 2126 } 1969 2127 1970 2128 /* 1971 - * idetape_queue_pc_tail is based on the following functions: 2129 + * We add a special packet command request to the tail of the request queue, and 2130 + * wait for it to be serviced. This is not to be called from within the request 2131 + * handling part of the driver! We allocate here data on the stack and it is 2132 + * valid until the request is finished. This is not the case for the bottom part 2133 + * of the driver, where we are always leaving the functions to wait for an 2134 + * interrupt or a timer event. 1972 2135 * 1973 - * ide_do_drive_cmd from ide.c 1974 - * cdrom_queue_request and cdrom_queue_packet_command from ide-cd.c 1975 - * 1976 - * We add a special packet command request to the tail of the request 1977 - * queue, and wait for it to be serviced. 1978 - * 1979 - * This is not to be called from within the request handling part 1980 - * of the driver ! We allocate here data in the stack, and it is valid 1981 - * until the request is finished. This is not the case for the bottom 1982 - * part of the driver, where we are always leaving the functions to wait 1983 - * for an interrupt or a timer event. 1984 - * 1985 - * From the bottom part of the driver, we should allocate safe memory 1986 - * using idetape_next_pc_storage and idetape_next_rq_storage, and add 1987 - * the request to the request list without waiting for it to be serviced ! 1988 - * In that case, we usually use idetape_queue_pc_head. 2136 + * From the bottom part of the driver, we should allocate safe memory using 2137 + * idetape_next_pc_storage() and ide_tape_next_rq_storage(), and add the request 2138 + * to the request list without waiting for it to be serviced! In that case, we 2139 + * usually use idetape_queue_pc_head(). 1989 2140 */ 1990 - static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) 2141 + static int __idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) 1991 2142 { 1992 2143 struct ide_tape_obj *tape = drive->driver_data; 1993 2144 struct request rq; ··· 1991 2156 return ide_do_drive_cmd(drive, &rq, ide_wait); 1992 2157 } 1993 2158 1994 - static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) 2159 + static void idetape_create_load_unload_cmd(ide_drive_t *drive, idetape_pc_t *pc, 2160 + int cmd) 1995 2161 { 1996 2162 idetape_init_pc(pc); 1997 2163 pc->c[0] = START_STOP; ··· 2007 2171 idetape_pc_t pc; 2008 2172 int load_attempted = 0; 2009 2173 2010 - /* 2011 - * Wait for the tape to become ready 2012 - */ 2174 + /* Wait for the tape to become ready */ 2013 2175 set_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); 2014 2176 timeout += jiffies; 2015 2177 while (time_before(jiffies, timeout)) { ··· 2015 2181 if (!__idetape_queue_pc_tail(drive, &pc)) 2016 2182 return 0; 2017 2183 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) 2018 - || (tape->asc == 0x3A)) { /* no media */ 2184 + || (tape->asc == 0x3A)) { 2185 + /* no media */ 2019 2186 if (load_attempted) 2020 2187 return -ENOMEDIUM; 2021 - idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK); 2188 + idetape_create_load_unload_cmd(drive, &pc, 2189 + IDETAPE_LU_LOAD_MASK); 2022 2190 __idetape_queue_pc_tail(drive, &pc); 2023 2191 load_attempted = 1; 2024 2192 /* not about to be ready */ ··· 2032 2196 return -EIO; 2033 2197 } 2034 2198 2035 - static int idetape_queue_pc_tail (ide_drive_t *drive,idetape_pc_t *pc) 2199 + static int idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) 2036 2200 { 2037 2201 return __idetape_queue_pc_tail(drive, pc); 2038 2202 } 2039 2203 2040 - static int idetape_flush_tape_buffers (ide_drive_t *drive) 2204 + static int idetape_flush_tape_buffers(ide_drive_t *drive) 2041 2205 { 2042 2206 idetape_pc_t pc; 2043 2207 int rc; 2044 2208 2045 2209 idetape_create_write_filemark_cmd(drive, &pc, 0); 2046 - if ((rc = idetape_queue_pc_tail(drive, &pc))) 2210 + rc = idetape_queue_pc_tail(drive, &pc); 2211 + if (rc) 2047 2212 return rc; 2048 2213 idetape_wait_ready(drive, 60 * 5 * HZ); 2049 2214 return 0; 2050 2215 } 2051 2216 2052 - static void idetape_create_read_position_cmd (idetape_pc_t *pc) 2217 + static void idetape_create_read_position_cmd(idetape_pc_t *pc) 2053 2218 { 2054 2219 idetape_init_pc(pc); 2055 2220 pc->c[0] = READ_POSITION; ··· 2058 2221 pc->callback = &idetape_read_position_callback; 2059 2222 } 2060 2223 2061 - static int idetape_read_position (ide_drive_t *drive) 2224 + static int idetape_read_position(ide_drive_t *drive) 2062 2225 { 2063 2226 idetape_tape_t *tape = drive->driver_data; 2064 2227 idetape_pc_t pc; 2065 2228 int position; 2066 2229 2067 - #if IDETAPE_DEBUG_LOG 2068 - if (tape->debug_level >= 4) 2069 - printk(KERN_INFO "ide-tape: Reached idetape_read_position\n"); 2070 - #endif /* IDETAPE_DEBUG_LOG */ 2230 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 2071 2231 2072 2232 idetape_create_read_position_cmd(&pc); 2073 2233 if (idetape_queue_pc_tail(drive, &pc)) 2074 2234 return -1; 2075 - position = tape->first_frame_position; 2235 + position = tape->first_frame; 2076 2236 return position; 2077 2237 } 2078 2238 2079 - static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) 2239 + static void idetape_create_locate_cmd(ide_drive_t *drive, idetape_pc_t *pc, 2240 + unsigned int block, u8 partition, int skip) 2080 2241 { 2081 2242 idetape_init_pc(pc); 2082 2243 pc->c[0] = POSITION_TO_ELEMENT; ··· 2085 2250 pc->callback = &idetape_pc_callback; 2086 2251 } 2087 2252 2088 - static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent) 2253 + static int idetape_create_prevent_cmd(ide_drive_t *drive, idetape_pc_t *pc, 2254 + int prevent) 2089 2255 { 2090 2256 idetape_tape_t *tape = drive->driver_data; 2091 2257 ··· 2101 2265 return 1; 2102 2266 } 2103 2267 2104 - static int __idetape_discard_read_pipeline (ide_drive_t *drive) 2268 + static int __idetape_discard_read_pipeline(ide_drive_t *drive) 2105 2269 { 2106 2270 idetape_tape_t *tape = drive->driver_data; 2107 2271 unsigned long flags; 2108 2272 int cnt; 2109 2273 2110 - if (tape->chrdev_direction != idetape_direction_read) 2274 + if (tape->chrdev_dir != IDETAPE_DIR_READ) 2111 2275 return 0; 2112 2276 2113 2277 /* Remove merge stage. */ 2114 - cnt = tape->merge_stage_size / tape->tape_block_size; 2278 + cnt = tape->merge_stage_size / tape->blk_size; 2115 2279 if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) 2116 2280 ++cnt; /* Filemarks count as 1 sector */ 2117 2281 tape->merge_stage_size = 0; ··· 2122 2286 2123 2287 /* Clear pipeline flags. */ 2124 2288 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 2125 - tape->chrdev_direction = idetape_direction_none; 2289 + tape->chrdev_dir = IDETAPE_DIR_NONE; 2126 2290 2127 2291 /* Remove pipeline stages. */ 2128 2292 if (tape->first_stage == NULL) 2129 2293 return 0; 2130 2294 2131 - spin_lock_irqsave(&tape->spinlock, flags); 2295 + spin_lock_irqsave(&tape->lock, flags); 2132 2296 tape->next_stage = NULL; 2133 2297 if (idetape_pipeline_active(tape)) 2134 - idetape_wait_for_request(drive, tape->active_data_request); 2135 - spin_unlock_irqrestore(&tape->spinlock, flags); 2298 + idetape_wait_for_request(drive, tape->active_data_rq); 2299 + spin_unlock_irqrestore(&tape->lock, flags); 2136 2300 2137 2301 while (tape->first_stage != NULL) { 2138 2302 struct request *rq_ptr = &tape->first_stage->rq; 2139 2303 2140 - cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; 2304 + cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; 2141 2305 if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) 2142 2306 ++cnt; 2143 2307 idetape_remove_stage_head(drive); ··· 2148 2312 } 2149 2313 2150 2314 /* 2151 - * idetape_position_tape positions the tape to the requested block 2152 - * using the LOCATE packet command. A READ POSITION command is then 2153 - * issued to check where we are positioned. 2154 - * 2155 - * Like all higher level operations, we queue the commands at the tail 2156 - * of the request queue and wait for their completion. 2157 - * 2315 + * Position the tape to the requested block using the LOCATE packet command. 2316 + * A READ POSITION command is then issued to check where we are positioned. Like 2317 + * all higher level operations, we queue the commands at the tail of the request 2318 + * queue and wait for their completion. 2158 2319 */ 2159 - static int idetape_position_tape (ide_drive_t *drive, unsigned int block, u8 partition, int skip) 2320 + static int idetape_position_tape(ide_drive_t *drive, unsigned int block, 2321 + u8 partition, int skip) 2160 2322 { 2161 2323 idetape_tape_t *tape = drive->driver_data; 2162 2324 int retval; 2163 2325 idetape_pc_t pc; 2164 2326 2165 - if (tape->chrdev_direction == idetape_direction_read) 2327 + if (tape->chrdev_dir == IDETAPE_DIR_READ) 2166 2328 __idetape_discard_read_pipeline(drive); 2167 2329 idetape_wait_ready(drive, 60 * 5 * HZ); 2168 2330 idetape_create_locate_cmd(drive, &pc, block, partition, skip); ··· 2172 2338 return (idetape_queue_pc_tail(drive, &pc)); 2173 2339 } 2174 2340 2175 - static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_position) 2341 + static void idetape_discard_read_pipeline(ide_drive_t *drive, 2342 + int restore_position) 2176 2343 { 2177 2344 idetape_tape_t *tape = drive->driver_data; 2178 2345 int cnt; ··· 2184 2349 position = idetape_read_position(drive); 2185 2350 seek = position > cnt ? position - cnt : 0; 2186 2351 if (idetape_position_tape(drive, seek, 0, 0)) { 2187 - printk(KERN_INFO "ide-tape: %s: position_tape failed in discard_pipeline()\n", tape->name); 2352 + printk(KERN_INFO "ide-tape: %s: position_tape failed in" 2353 + " discard_pipeline()\n", tape->name); 2188 2354 return; 2189 2355 } 2190 2356 } 2191 2357 } 2192 2358 2193 2359 /* 2194 - * idetape_queue_rw_tail generates a read/write request for the block 2195 - * device interface and wait for it to be serviced. 2360 + * Generate a read/write request for the block device interface and wait for it 2361 + * to be serviced. 2196 2362 */ 2197 - static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct idetape_bh *bh) 2363 + static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, 2364 + struct idetape_bh *bh) 2198 2365 { 2199 2366 idetape_tape_t *tape = drive->driver_data; 2200 2367 struct request rq; 2201 2368 2202 - #if IDETAPE_DEBUG_LOG 2203 - if (tape->debug_level >= 2) 2204 - printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd); 2205 - #endif /* IDETAPE_DEBUG_LOG */ 2369 + debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); 2370 + 2206 2371 if (idetape_pipeline_active(tape)) { 2207 - printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); 2372 + printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n", 2373 + __func__); 2208 2374 return (0); 2209 2375 } 2210 2376 2211 2377 idetape_init_rq(&rq, cmd); 2212 2378 rq.rq_disk = tape->disk; 2213 2379 rq.special = (void *)bh; 2214 - rq.sector = tape->first_frame_position; 2215 - rq.nr_sectors = rq.current_nr_sectors = blocks; 2380 + rq.sector = tape->first_frame; 2381 + rq.nr_sectors = blocks; 2382 + rq.current_nr_sectors = blocks; 2216 2383 (void) ide_do_drive_cmd(drive, &rq, ide_wait); 2217 2384 2218 2385 if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) ··· 2224 2387 idetape_init_merge_stage(tape); 2225 2388 if (rq.errors == IDETAPE_ERROR_GENERAL) 2226 2389 return -EIO; 2227 - return (tape->tape_block_size * (blocks-rq.current_nr_sectors)); 2390 + return (tape->blk_size * (blocks-rq.current_nr_sectors)); 2228 2391 } 2229 2392 2230 - /* 2231 - * idetape_insert_pipeline_into_queue is used to start servicing the 2232 - * pipeline stages, starting from tape->next_stage. 2233 - */ 2234 - static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) 2393 + /* start servicing the pipeline stages, starting from tape->next_stage. */ 2394 + static void idetape_plug_pipeline(ide_drive_t *drive) 2235 2395 { 2236 2396 idetape_tape_t *tape = drive->driver_data; 2237 2397 ··· 2237 2403 if (!idetape_pipeline_active(tape)) { 2238 2404 set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); 2239 2405 idetape_activate_next_stage(drive); 2240 - (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); 2406 + (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); 2241 2407 } 2242 2408 } 2243 2409 2244 - static void idetape_create_inquiry_cmd (idetape_pc_t *pc) 2410 + static void idetape_create_inquiry_cmd(idetape_pc_t *pc) 2245 2411 { 2246 2412 idetape_init_pc(pc); 2247 2413 pc->c[0] = INQUIRY; 2248 - pc->c[4] = pc->request_transfer = 254; 2414 + pc->c[4] = 254; 2415 + pc->request_transfer = 254; 2249 2416 pc->callback = &idetape_pc_callback; 2250 2417 } 2251 2418 2252 - static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) 2419 + static void idetape_create_rewind_cmd(ide_drive_t *drive, idetape_pc_t *pc) 2253 2420 { 2254 2421 idetape_init_pc(pc); 2255 2422 pc->c[0] = REZERO_UNIT; ··· 2258 2423 pc->callback = &idetape_pc_callback; 2259 2424 } 2260 2425 2261 - static void idetape_create_erase_cmd (idetape_pc_t *pc) 2426 + static void idetape_create_erase_cmd(idetape_pc_t *pc) 2262 2427 { 2263 2428 idetape_init_pc(pc); 2264 2429 pc->c[0] = ERASE; ··· 2267 2432 pc->callback = &idetape_pc_callback; 2268 2433 } 2269 2434 2270 - static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) 2435 + static void idetape_create_space_cmd(idetape_pc_t *pc, int count, u8 cmd) 2271 2436 { 2272 2437 idetape_init_pc(pc); 2273 2438 pc->c[0] = SPACE; ··· 2277 2442 pc->callback = &idetape_pc_callback; 2278 2443 } 2279 2444 2280 - static void idetape_wait_first_stage (ide_drive_t *drive) 2445 + static void idetape_wait_first_stage(ide_drive_t *drive) 2281 2446 { 2282 2447 idetape_tape_t *tape = drive->driver_data; 2283 2448 unsigned long flags; 2284 2449 2285 2450 if (tape->first_stage == NULL) 2286 2451 return; 2287 - spin_lock_irqsave(&tape->spinlock, flags); 2452 + spin_lock_irqsave(&tape->lock, flags); 2288 2453 if (tape->active_stage == tape->first_stage) 2289 - idetape_wait_for_request(drive, tape->active_data_request); 2290 - spin_unlock_irqrestore(&tape->spinlock, flags); 2454 + idetape_wait_for_request(drive, tape->active_data_rq); 2455 + spin_unlock_irqrestore(&tape->lock, flags); 2291 2456 } 2292 2457 2293 2458 /* 2294 - * idetape_add_chrdev_write_request tries to add a character device 2295 - * originated write request to our pipeline. In case we don't succeed, 2296 - * we revert to non-pipelined operation mode for this request. 2459 + * Try to add a character device originated write request to our pipeline. In 2460 + * case we don't succeed, we revert to non-pipelined operation mode for this 2461 + * request. In order to accomplish that, we 2297 2462 * 2298 - * 1. Try to allocate a new pipeline stage. 2299 - * 2. If we can't, wait for more and more requests to be serviced 2300 - * and try again each time. 2301 - * 3. If we still can't allocate a stage, fallback to 2302 - * non-pipelined operation mode for this request. 2463 + * 1. Try to allocate a new pipeline stage. 2464 + * 2. If we can't, wait for more and more requests to be serviced and try again 2465 + * each time. 2466 + * 3. If we still can't allocate a stage, fallback to non-pipelined operation 2467 + * mode for this request. 2303 2468 */ 2304 - static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) 2469 + static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) 2305 2470 { 2306 2471 idetape_tape_t *tape = drive->driver_data; 2307 2472 idetape_stage_t *new_stage; 2308 2473 unsigned long flags; 2309 2474 struct request *rq; 2310 2475 2311 - #if IDETAPE_DEBUG_LOG 2312 - if (tape->debug_level >= 3) 2313 - printk(KERN_INFO "ide-tape: Reached idetape_add_chrdev_write_request\n"); 2314 - #endif /* IDETAPE_DEBUG_LOG */ 2476 + debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 2315 2477 2316 - /* 2317 - * Attempt to allocate a new stage. 2318 - * Pay special attention to possible race conditions. 2319 - */ 2478 + /* Attempt to allocate a new stage. Beware possible race conditions. */ 2320 2479 while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { 2321 - spin_lock_irqsave(&tape->spinlock, flags); 2480 + spin_lock_irqsave(&tape->lock, flags); 2322 2481 if (idetape_pipeline_active(tape)) { 2323 - idetape_wait_for_request(drive, tape->active_data_request); 2324 - spin_unlock_irqrestore(&tape->spinlock, flags); 2482 + idetape_wait_for_request(drive, tape->active_data_rq); 2483 + spin_unlock_irqrestore(&tape->lock, flags); 2325 2484 } else { 2326 - spin_unlock_irqrestore(&tape->spinlock, flags); 2327 - idetape_insert_pipeline_into_queue(drive); 2485 + spin_unlock_irqrestore(&tape->lock, flags); 2486 + idetape_plug_pipeline(drive); 2328 2487 if (idetape_pipeline_active(tape)) 2329 2488 continue; 2330 2489 /* 2331 - * Linux is short on memory. Fallback to 2332 - * non-pipelined operation mode for this request. 2490 + * The machine is short on memory. Fallback to non- 2491 + * pipelined operation mode for this request. 2333 2492 */ 2334 - return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, tape->merge_stage->bh); 2493 + return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, 2494 + blocks, tape->merge_stage->bh); 2335 2495 } 2336 2496 } 2337 2497 rq = &new_stage->rq; 2338 2498 idetape_init_rq(rq, REQ_IDETAPE_WRITE); 2339 2499 /* Doesn't actually matter - We always assume sequential access */ 2340 - rq->sector = tape->first_frame_position; 2341 - rq->nr_sectors = rq->current_nr_sectors = blocks; 2500 + rq->sector = tape->first_frame; 2501 + rq->current_nr_sectors = blocks; 2502 + rq->nr_sectors = blocks; 2342 2503 2343 2504 idetape_switch_buffers(tape, new_stage); 2344 2505 idetape_add_stage_tail(drive, new_stage); 2345 2506 tape->pipeline_head++; 2346 - calculate_speeds(drive); 2507 + idetape_calculate_speeds(drive); 2347 2508 2348 2509 /* 2349 - * Estimate whether the tape has stopped writing by checking 2350 - * if our write pipeline is currently empty. If we are not 2351 - * writing anymore, wait for the pipeline to be full enough 2352 - * (90%) before starting to service requests, so that we will 2353 - * be able to keep up with the higher speeds of the tape. 2510 + * Estimate whether the tape has stopped writing by checking if our 2511 + * write pipeline is currently empty. If we are not writing anymore, 2512 + * wait for the pipeline to be almost completely full (90%) before 2513 + * starting to service requests, so that we will be able to keep up with 2514 + * the higher speeds of the tape. 2354 2515 */ 2355 2516 if (!idetape_pipeline_active(tape)) { 2356 2517 if (tape->nr_stages >= tape->max_stages * 9 / 10 || 2357 - tape->nr_stages >= tape->max_stages - tape->uncontrolled_pipeline_head_speed * 3 * 1024 / tape->tape_block_size) { 2518 + tape->nr_stages >= tape->max_stages - 2519 + tape->uncontrolled_pipeline_head_speed * 3 * 1024 / 2520 + tape->blk_size) { 2358 2521 tape->measure_insert_time = 1; 2359 2522 tape->insert_time = jiffies; 2360 2523 tape->insert_size = 0; 2361 2524 tape->insert_speed = 0; 2362 - idetape_insert_pipeline_into_queue(drive); 2525 + idetape_plug_pipeline(drive); 2363 2526 } 2364 2527 } 2365 2528 if (test_and_clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) ··· 2367 2534 } 2368 2535 2369 2536 /* 2370 - * idetape_wait_for_pipeline will wait until all pending pipeline 2371 - * requests are serviced. Typically called on device close. 2537 + * Wait until all pending pipeline requests are serviced. Typically called on 2538 + * device close. 2372 2539 */ 2373 - static void idetape_wait_for_pipeline (ide_drive_t *drive) 2540 + static void idetape_wait_for_pipeline(ide_drive_t *drive) 2374 2541 { 2375 2542 idetape_tape_t *tape = drive->driver_data; 2376 2543 unsigned long flags; 2377 2544 2378 2545 while (tape->next_stage || idetape_pipeline_active(tape)) { 2379 - idetape_insert_pipeline_into_queue(drive); 2380 - spin_lock_irqsave(&tape->spinlock, flags); 2546 + idetape_plug_pipeline(drive); 2547 + spin_lock_irqsave(&tape->lock, flags); 2381 2548 if (idetape_pipeline_active(tape)) 2382 - idetape_wait_for_request(drive, tape->active_data_request); 2383 - spin_unlock_irqrestore(&tape->spinlock, flags); 2549 + idetape_wait_for_request(drive, tape->active_data_rq); 2550 + spin_unlock_irqrestore(&tape->lock, flags); 2384 2551 } 2385 2552 } 2386 2553 2387 - static void idetape_empty_write_pipeline (ide_drive_t *drive) 2554 + static void idetape_empty_write_pipeline(ide_drive_t *drive) 2388 2555 { 2389 2556 idetape_tape_t *tape = drive->driver_data; 2390 2557 int blocks, min; 2391 2558 struct idetape_bh *bh; 2392 2559 2393 - if (tape->chrdev_direction != idetape_direction_write) { 2394 - printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); 2560 + if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { 2561 + printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline," 2562 + " but we are not writing.\n"); 2395 2563 return; 2396 2564 } 2397 2565 if (tape->merge_stage_size > tape->stage_size) { ··· 2400 2566 tape->merge_stage_size = tape->stage_size; 2401 2567 } 2402 2568 if (tape->merge_stage_size) { 2403 - blocks = tape->merge_stage_size / tape->tape_block_size; 2404 - if (tape->merge_stage_size % tape->tape_block_size) { 2569 + blocks = tape->merge_stage_size / tape->blk_size; 2570 + if (tape->merge_stage_size % tape->blk_size) { 2405 2571 unsigned int i; 2406 2572 2407 2573 blocks++; 2408 - i = tape->tape_block_size - tape->merge_stage_size % tape->tape_block_size; 2574 + i = tape->blk_size - tape->merge_stage_size % 2575 + tape->blk_size; 2409 2576 bh = tape->bh->b_reqnext; 2410 2577 while (bh) { 2411 2578 atomic_set(&bh->b_count, 0); ··· 2415 2580 bh = tape->bh; 2416 2581 while (i) { 2417 2582 if (bh == NULL) { 2418 - 2419 - printk(KERN_INFO "ide-tape: bug, bh NULL\n"); 2583 + printk(KERN_INFO "ide-tape: bug," 2584 + " bh NULL\n"); 2420 2585 break; 2421 2586 } 2422 - min = min(i, (unsigned int)(bh->b_size - atomic_read(&bh->b_count))); 2423 - memset(bh->b_data + atomic_read(&bh->b_count), 0, min); 2587 + min = min(i, (unsigned int)(bh->b_size - 2588 + atomic_read(&bh->b_count))); 2589 + memset(bh->b_data + atomic_read(&bh->b_count), 2590 + 0, min); 2424 2591 atomic_add(min, &bh->b_count); 2425 2592 i -= min; 2426 2593 bh = bh->b_reqnext; ··· 2437 2600 tape->merge_stage = NULL; 2438 2601 } 2439 2602 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 2440 - tape->chrdev_direction = idetape_direction_none; 2603 + tape->chrdev_dir = IDETAPE_DIR_NONE; 2441 2604 2442 2605 /* 2443 - * On the next backup, perform the feedback loop again. 2444 - * (I don't want to keep sense information between backups, 2445 - * as some systems are constantly on, and the system load 2446 - * can be totally different on the next backup). 2606 + * On the next backup, perform the feedback loop again. (I don't want to 2607 + * keep sense information between backups, as some systems are 2608 + * constantly on, and the system load can be totally different on the 2609 + * next backup). 2447 2610 */ 2448 2611 tape->max_stages = tape->min_pipeline; 2449 2612 if (tape->first_stage != NULL || ··· 2458 2621 } 2459 2622 } 2460 2623 2461 - static void idetape_restart_speed_control (ide_drive_t *drive) 2624 + static void idetape_restart_speed_control(ide_drive_t *drive) 2462 2625 { 2463 2626 idetape_tape_t *tape = drive->driver_data; 2464 2627 2465 2628 tape->restart_speed_control_req = 0; 2466 2629 tape->pipeline_head = 0; 2467 - tape->controlled_last_pipeline_head = tape->uncontrolled_last_pipeline_head = 0; 2468 - tape->controlled_previous_pipeline_head = tape->uncontrolled_previous_pipeline_head = 0; 2469 - tape->pipeline_head_speed = tape->controlled_pipeline_head_speed = 5000; 2630 + tape->controlled_last_pipeline_head = 0; 2631 + tape->controlled_previous_pipeline_head = 0; 2632 + tape->uncontrolled_previous_pipeline_head = 0; 2633 + tape->controlled_pipeline_head_speed = 5000; 2634 + tape->pipeline_head_speed = 5000; 2470 2635 tape->uncontrolled_pipeline_head_speed = 0; 2471 - tape->controlled_pipeline_head_time = tape->uncontrolled_pipeline_head_time = jiffies; 2472 - tape->controlled_previous_head_time = tape->uncontrolled_previous_head_time = jiffies; 2636 + tape->controlled_pipeline_head_time = 2637 + tape->uncontrolled_pipeline_head_time = jiffies; 2638 + tape->controlled_previous_head_time = 2639 + tape->uncontrolled_previous_head_time = jiffies; 2473 2640 } 2474 2641 2475 - static int idetape_initiate_read (ide_drive_t *drive, int max_stages) 2642 + static int idetape_init_read(ide_drive_t *drive, int max_stages) 2476 2643 { 2477 2644 idetape_tape_t *tape = drive->driver_data; 2478 2645 idetape_stage_t *new_stage; ··· 2485 2644 u16 blocks = *(u16 *)&tape->caps[12]; 2486 2645 2487 2646 /* Initialize read operation */ 2488 - if (tape->chrdev_direction != idetape_direction_read) { 2489 - if (tape->chrdev_direction == idetape_direction_write) { 2647 + if (tape->chrdev_dir != IDETAPE_DIR_READ) { 2648 + if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 2490 2649 idetape_empty_write_pipeline(drive); 2491 2650 idetape_flush_tape_buffers(drive); 2492 2651 } 2493 2652 if (tape->merge_stage || tape->merge_stage_size) { 2494 - printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); 2653 + printk(KERN_ERR "ide-tape: merge_stage_size should be" 2654 + " 0 now\n"); 2495 2655 tape->merge_stage_size = 0; 2496 2656 } 2497 - if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) 2657 + tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); 2658 + if (!tape->merge_stage) 2498 2659 return -ENOMEM; 2499 - tape->chrdev_direction = idetape_direction_read; 2660 + tape->chrdev_dir = IDETAPE_DIR_READ; 2500 2661 2501 2662 /* 2502 - * Issue a read 0 command to ensure that DSC handshake 2503 - * is switched from completion mode to buffer available 2504 - * mode. 2505 - * No point in issuing this if DSC overlap isn't supported, 2506 - * some drives (Seagate STT3401A) will return an error. 2663 + * Issue a read 0 command to ensure that DSC handshake is 2664 + * switched from completion mode to buffer available mode. 2665 + * No point in issuing this if DSC overlap isn't supported, some 2666 + * drives (Seagate STT3401A) will return an error. 2507 2667 */ 2508 2668 if (drive->dsc_overlap) { 2509 - bytes_read = idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, 0, tape->merge_stage->bh); 2669 + bytes_read = idetape_queue_rw_tail(drive, 2670 + REQ_IDETAPE_READ, 0, 2671 + tape->merge_stage->bh); 2510 2672 if (bytes_read < 0) { 2511 2673 __idetape_kfree_stage(tape->merge_stage); 2512 2674 tape->merge_stage = NULL; 2513 - tape->chrdev_direction = idetape_direction_none; 2675 + tape->chrdev_dir = IDETAPE_DIR_NONE; 2514 2676 return bytes_read; 2515 2677 } 2516 2678 } ··· 2521 2677 if (tape->restart_speed_control_req) 2522 2678 idetape_restart_speed_control(drive); 2523 2679 idetape_init_rq(&rq, REQ_IDETAPE_READ); 2524 - rq.sector = tape->first_frame_position; 2525 - rq.nr_sectors = rq.current_nr_sectors = blocks; 2680 + rq.sector = tape->first_frame; 2681 + rq.nr_sectors = blocks; 2682 + rq.current_nr_sectors = blocks; 2526 2683 if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && 2527 2684 tape->nr_stages < max_stages) { 2528 2685 new_stage = idetape_kmalloc_stage(tape); ··· 2541 2696 tape->insert_time = jiffies; 2542 2697 tape->insert_size = 0; 2543 2698 tape->insert_speed = 0; 2544 - idetape_insert_pipeline_into_queue(drive); 2699 + idetape_plug_pipeline(drive); 2545 2700 } 2546 2701 } 2547 2702 return 0; 2548 2703 } 2549 2704 2550 2705 /* 2551 - * idetape_add_chrdev_read_request is called from idetape_chrdev_read 2552 - * to service a character device read request and add read-ahead 2553 - * requests to our pipeline. 2706 + * Called from idetape_chrdev_read() to service a character device read request 2707 + * and add read-ahead requests to our pipeline. 2554 2708 */ 2555 - static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) 2709 + static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) 2556 2710 { 2557 2711 idetape_tape_t *tape = drive->driver_data; 2558 2712 unsigned long flags; 2559 2713 struct request *rq_ptr; 2560 2714 int bytes_read; 2561 2715 2562 - #if IDETAPE_DEBUG_LOG 2563 - if (tape->debug_level >= 4) 2564 - printk(KERN_INFO "ide-tape: Reached idetape_add_chrdev_read_request, %d blocks\n", blocks); 2565 - #endif /* IDETAPE_DEBUG_LOG */ 2716 + debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); 2566 2717 2567 - /* 2568 - * If we are at a filemark, return a read length of 0 2569 - */ 2718 + /* If we are at a filemark, return a read length of 0 */ 2570 2719 if (test_bit(IDETAPE_FILEMARK, &tape->flags)) 2571 2720 return 0; 2572 2721 2573 - /* 2574 - * Wait for the next block to be available at the head 2575 - * of the pipeline 2576 - */ 2577 - idetape_initiate_read(drive, tape->max_stages); 2722 + /* Wait for the next block to reach the head of the pipeline. */ 2723 + idetape_init_read(drive, tape->max_stages); 2578 2724 if (tape->first_stage == NULL) { 2579 2725 if (test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) 2580 2726 return 0; 2581 - return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, tape->merge_stage->bh); 2727 + return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, 2728 + tape->merge_stage->bh); 2582 2729 } 2583 2730 idetape_wait_first_stage(drive); 2584 2731 rq_ptr = &tape->first_stage->rq; 2585 - bytes_read = tape->tape_block_size * (rq_ptr->nr_sectors - rq_ptr->current_nr_sectors); 2586 - rq_ptr->nr_sectors = rq_ptr->current_nr_sectors = 0; 2587 - 2732 + bytes_read = tape->blk_size * (rq_ptr->nr_sectors - 2733 + rq_ptr->current_nr_sectors); 2734 + rq_ptr->nr_sectors = 0; 2735 + rq_ptr->current_nr_sectors = 0; 2588 2736 2589 2737 if (rq_ptr->errors == IDETAPE_ERROR_EOD) 2590 2738 return 0; ··· 2585 2747 idetape_switch_buffers(tape, tape->first_stage); 2586 2748 if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) 2587 2749 set_bit(IDETAPE_FILEMARK, &tape->flags); 2588 - spin_lock_irqsave(&tape->spinlock, flags); 2750 + spin_lock_irqsave(&tape->lock, flags); 2589 2751 idetape_remove_stage_head(drive); 2590 - spin_unlock_irqrestore(&tape->spinlock, flags); 2752 + spin_unlock_irqrestore(&tape->lock, flags); 2591 2753 tape->pipeline_head++; 2592 - calculate_speeds(drive); 2754 + idetape_calculate_speeds(drive); 2593 2755 } 2594 - if (bytes_read > blocks * tape->tape_block_size) { 2595 - printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); 2596 - bytes_read = blocks * tape->tape_block_size; 2756 + if (bytes_read > blocks * tape->blk_size) { 2757 + printk(KERN_ERR "ide-tape: bug: trying to return more bytes" 2758 + " than requested\n"); 2759 + bytes_read = blocks * tape->blk_size; 2597 2760 } 2598 2761 return (bytes_read); 2599 2762 } 2600 2763 2601 - static void idetape_pad_zeros (ide_drive_t *drive, int bcount) 2764 + static void idetape_pad_zeros(ide_drive_t *drive, int bcount) 2602 2765 { 2603 2766 idetape_tape_t *tape = drive->driver_data; 2604 2767 struct idetape_bh *bh; 2605 2768 int blocks; 2606 - 2769 + 2607 2770 while (bcount) { 2608 2771 unsigned int count; 2609 2772 2610 2773 bh = tape->merge_stage->bh; 2611 2774 count = min(tape->stage_size, bcount); 2612 2775 bcount -= count; 2613 - blocks = count / tape->tape_block_size; 2776 + blocks = count / tape->blk_size; 2614 2777 while (count) { 2615 - atomic_set(&bh->b_count, min(count, (unsigned int)bh->b_size)); 2778 + atomic_set(&bh->b_count, 2779 + min(count, (unsigned int)bh->b_size)); 2616 2780 memset(bh->b_data, 0, atomic_read(&bh->b_count)); 2617 2781 count -= atomic_read(&bh->b_count); 2618 2782 bh = bh->b_reqnext; 2619 2783 } 2620 - idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, tape->merge_stage->bh); 2784 + idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, 2785 + tape->merge_stage->bh); 2621 2786 } 2622 2787 } 2623 2788 2624 - static int idetape_pipeline_size (ide_drive_t *drive) 2789 + static int idetape_pipeline_size(ide_drive_t *drive) 2625 2790 { 2626 2791 idetape_tape_t *tape = drive->driver_data; 2627 2792 idetape_stage_t *stage; ··· 2635 2794 stage = tape->first_stage; 2636 2795 while (stage != NULL) { 2637 2796 rq = &stage->rq; 2638 - size += tape->tape_block_size * (rq->nr_sectors-rq->current_nr_sectors); 2797 + size += tape->blk_size * (rq->nr_sectors - 2798 + rq->current_nr_sectors); 2639 2799 if (rq->errors == IDETAPE_ERROR_FILEMARK) 2640 - size += tape->tape_block_size; 2800 + size += tape->blk_size; 2641 2801 stage = stage->next; 2642 2802 } 2643 2803 size += tape->merge_stage_size; ··· 2646 2804 } 2647 2805 2648 2806 /* 2649 - * Rewinds the tape to the Beginning Of the current Partition (BOP). 2650 - * 2651 - * We currently support only one partition. 2652 - */ 2653 - static int idetape_rewind_tape (ide_drive_t *drive) 2807 + * Rewinds the tape to the Beginning Of the current Partition (BOP). We 2808 + * currently support only one partition. 2809 + */ 2810 + static int idetape_rewind_tape(ide_drive_t *drive) 2654 2811 { 2655 2812 int retval; 2656 2813 idetape_pc_t pc; 2657 - #if IDETAPE_DEBUG_LOG 2658 - idetape_tape_t *tape = drive->driver_data; 2659 - if (tape->debug_level >= 2) 2660 - printk(KERN_INFO "ide-tape: Reached idetape_rewind_tape\n"); 2661 - #endif /* IDETAPE_DEBUG_LOG */ 2662 - 2814 + idetape_tape_t *tape; 2815 + tape = drive->driver_data; 2816 + 2817 + debug_log(DBG_SENSE, "Enter %s\n", __func__); 2818 + 2663 2819 idetape_create_rewind_cmd(drive, &pc); 2664 2820 retval = idetape_queue_pc_tail(drive, &pc); 2665 2821 if (retval) ··· 2670 2830 return 0; 2671 2831 } 2672 2832 2673 - /* 2674 - * Our special ide-tape ioctl's. 2675 - * 2676 - * Currently there aren't any ioctl's. 2677 - * mtio.h compatible commands should be issued to the character device 2678 - * interface. 2679 - */ 2680 - static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) 2833 + /* mtio.h compatible commands should be issued to the chrdev interface. */ 2834 + static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, 2835 + unsigned long arg) 2681 2836 { 2682 2837 idetape_tape_t *tape = drive->driver_data; 2683 2838 void __user *argp = (void __user *)arg; ··· 2683 2848 int nr_stages; 2684 2849 } config; 2685 2850 2686 - #if IDETAPE_DEBUG_LOG 2687 - if (tape->debug_level >= 4) 2688 - printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n"); 2689 - #endif /* IDETAPE_DEBUG_LOG */ 2851 + debug_log(DBG_PROCS, "Enter %s\n", __func__); 2852 + 2690 2853 switch (cmd) { 2691 - case 0x0340: 2692 - if (copy_from_user(&config, argp, sizeof(config))) 2693 - return -EFAULT; 2694 - tape->best_dsc_rw_frequency = config.dsc_rw_frequency; 2695 - tape->max_stages = config.nr_stages; 2696 - break; 2697 - case 0x0350: 2698 - config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; 2699 - config.nr_stages = tape->max_stages; 2700 - if (copy_to_user(argp, &config, sizeof(config))) 2701 - return -EFAULT; 2702 - break; 2703 - default: 2704 - return -EIO; 2854 + case 0x0340: 2855 + if (copy_from_user(&config, argp, sizeof(config))) 2856 + return -EFAULT; 2857 + tape->best_dsc_rw_freq = config.dsc_rw_frequency; 2858 + tape->max_stages = config.nr_stages; 2859 + break; 2860 + case 0x0350: 2861 + config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; 2862 + config.nr_stages = tape->max_stages; 2863 + if (copy_to_user(argp, &config, sizeof(config))) 2864 + return -EFAULT; 2865 + break; 2866 + default: 2867 + return -EIO; 2705 2868 } 2706 2869 return 0; 2707 2870 } 2708 2871 2709 2872 /* 2710 - * idetape_space_over_filemarks is now a bit more complicated than just 2711 - * passing the command to the tape since we may have crossed some 2712 - * filemarks during our pipelined read-ahead mode. 2713 - * 2714 - * As a minor side effect, the pipeline enables us to support MTFSFM when 2715 - * the filemark is in our internal pipeline even if the tape doesn't 2716 - * support spacing over filemarks in the reverse direction. 2873 + * The function below is now a bit more complicated than just passing the 2874 + * command to the tape since we may have crossed some filemarks during our 2875 + * pipelined read-ahead mode. As a minor side effect, the pipeline enables us to 2876 + * support MTFSFM when the filemark is in our internal pipeline even if the tape 2877 + * doesn't support spacing over filemarks in the reverse direction. 2717 2878 */ 2718 - static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_count) 2879 + static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, 2880 + int mt_count) 2719 2881 { 2720 2882 idetape_tape_t *tape = drive->driver_data; 2721 2883 idetape_pc_t pc; 2722 2884 unsigned long flags; 2723 - int retval,count=0; 2885 + int retval, count = 0; 2724 2886 int sprev = !!(tape->caps[4] & 0x20); 2725 2887 2726 2888 if (mt_count == 0) ··· 2725 2893 if (MTBSF == mt_op || MTBSFM == mt_op) { 2726 2894 if (!sprev) 2727 2895 return -EIO; 2728 - mt_count = - mt_count; 2896 + mt_count = -mt_count; 2729 2897 } 2730 2898 2731 - if (tape->chrdev_direction == idetape_direction_read) { 2732 - /* 2733 - * We have a read-ahead buffer. Scan it for crossed 2734 - * filemarks. 2735 - */ 2899 + if (tape->chrdev_dir == IDETAPE_DIR_READ) { 2900 + /* its a read-ahead buffer, scan it for crossed filemarks. */ 2736 2901 tape->merge_stage_size = 0; 2737 2902 if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) 2738 2903 ++count; ··· 2739 2910 set_bit(IDETAPE_FILEMARK, &tape->flags); 2740 2911 return 0; 2741 2912 } 2742 - spin_lock_irqsave(&tape->spinlock, flags); 2913 + spin_lock_irqsave(&tape->lock, flags); 2743 2914 if (tape->first_stage == tape->active_stage) { 2744 2915 /* 2745 - * We have reached the active stage in the read pipeline. 2746 - * There is no point in allowing the drive to continue 2747 - * reading any farther, so we stop the pipeline. 2916 + * We have reached the active stage in the read 2917 + * pipeline. There is no point in allowing the 2918 + * drive to continue reading any farther, so we 2919 + * stop the pipeline. 2748 2920 * 2749 - * This section should be moved to a separate subroutine, 2750 - * because a similar function is performed in 2751 - * __idetape_discard_read_pipeline(), for example. 2921 + * This section should be moved to a separate 2922 + * subroutine because similar operations are 2923 + * done in __idetape_discard_read_pipeline(), 2924 + * for example. 2752 2925 */ 2753 2926 tape->next_stage = NULL; 2754 - spin_unlock_irqrestore(&tape->spinlock, flags); 2927 + spin_unlock_irqrestore(&tape->lock, flags); 2755 2928 idetape_wait_first_stage(drive); 2756 2929 tape->next_stage = tape->first_stage->next; 2757 2930 } else 2758 - spin_unlock_irqrestore(&tape->spinlock, flags); 2759 - if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) 2931 + spin_unlock_irqrestore(&tape->lock, flags); 2932 + if (tape->first_stage->rq.errors == 2933 + IDETAPE_ERROR_FILEMARK) 2760 2934 ++count; 2761 2935 idetape_remove_stage_head(drive); 2762 2936 } ··· 2767 2935 } 2768 2936 2769 2937 /* 2770 - * The filemark was not found in our internal pipeline. 2771 - * Now we can issue the space command. 2938 + * The filemark was not found in our internal pipeline; now we can issue 2939 + * the space command. 2772 2940 */ 2773 2941 switch (mt_op) { 2774 - case MTFSF: 2775 - case MTBSF: 2776 - idetape_create_space_cmd(&pc,mt_count-count,IDETAPE_SPACE_OVER_FILEMARK); 2777 - return (idetape_queue_pc_tail(drive, &pc)); 2778 - case MTFSFM: 2779 - case MTBSFM: 2780 - if (!sprev) 2781 - return (-EIO); 2782 - retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); 2783 - if (retval) return (retval); 2784 - count = (MTBSFM == mt_op ? 1 : -1); 2785 - return (idetape_space_over_filemarks(drive, MTFSF, count)); 2786 - default: 2787 - printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op); 2788 - return (-EIO); 2942 + case MTFSF: 2943 + case MTBSF: 2944 + idetape_create_space_cmd(&pc, mt_count - count, 2945 + IDETAPE_SPACE_OVER_FILEMARK); 2946 + return idetape_queue_pc_tail(drive, &pc); 2947 + case MTFSFM: 2948 + case MTBSFM: 2949 + if (!sprev) 2950 + return -EIO; 2951 + retval = idetape_space_over_filemarks(drive, MTFSF, 2952 + mt_count - count); 2953 + if (retval) 2954 + return retval; 2955 + count = (MTBSFM == mt_op ? 1 : -1); 2956 + return idetape_space_over_filemarks(drive, MTFSF, count); 2957 + default: 2958 + printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 2959 + mt_op); 2960 + return -EIO; 2789 2961 } 2790 2962 } 2791 2963 2792 - 2793 2964 /* 2794 - * Our character device read / write functions. 2965 + * Our character device read / write functions. 2795 2966 * 2796 - * The tape is optimized to maximize throughput when it is transferring 2797 - * an integral number of the "continuous transfer limit", which is 2798 - * a parameter of the specific tape (26 KB on my particular tape). 2799 - * (32 kB for Onstream) 2967 + * The tape is optimized to maximize throughput when it is transferring an 2968 + * integral number of the "continuous transfer limit", which is a parameter of 2969 + * the specific tape (26kB on my particular tape, 32kB for Onstream). 2800 2970 * 2801 - * As of version 1.3 of the driver, the character device provides an 2802 - * abstract continuous view of the media - any mix of block sizes (even 1 2803 - * byte) on the same backup/restore procedure is supported. The driver 2804 - * will internally convert the requests to the recommended transfer unit, 2805 - * so that an unmatch between the user's block size to the recommended 2806 - * size will only result in a (slightly) increased driver overhead, but 2807 - * will no longer hit performance. 2808 - * This is not applicable to Onstream. 2971 + * As of version 1.3 of the driver, the character device provides an abstract 2972 + * continuous view of the media - any mix of block sizes (even 1 byte) on the 2973 + * same backup/restore procedure is supported. The driver will internally 2974 + * convert the requests to the recommended transfer unit, so that an unmatch 2975 + * between the user's block size to the recommended size will only result in a 2976 + * (slightly) increased driver overhead, but will no longer hit performance. 2977 + * This is not applicable to Onstream. 2809 2978 */ 2810 - static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, 2811 - size_t count, loff_t *ppos) 2979 + static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, 2980 + size_t count, loff_t *ppos) 2812 2981 { 2813 2982 struct ide_tape_obj *tape = ide_tape_f(file); 2814 2983 ide_drive_t *drive = tape->drive; 2815 - ssize_t bytes_read,temp, actually_read = 0, rc; 2984 + ssize_t bytes_read, temp, actually_read = 0, rc; 2816 2985 ssize_t ret = 0; 2817 2986 u16 ctl = *(u16 *)&tape->caps[12]; 2818 2987 2819 - #if IDETAPE_DEBUG_LOG 2820 - if (tape->debug_level >= 3) 2821 - printk(KERN_INFO "ide-tape: Reached idetape_chrdev_read, count %Zd\n", count); 2822 - #endif /* IDETAPE_DEBUG_LOG */ 2988 + debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 2823 2989 2824 - if (tape->chrdev_direction != idetape_direction_read) { 2990 + if (tape->chrdev_dir != IDETAPE_DIR_READ) { 2825 2991 if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) 2826 - if (count > tape->tape_block_size && 2827 - (count % tape->tape_block_size) == 0) 2828 - tape->user_bs_factor = count / tape->tape_block_size; 2992 + if (count > tape->blk_size && 2993 + (count % tape->blk_size) == 0) 2994 + tape->user_bs_factor = count / tape->blk_size; 2829 2995 } 2830 - if ((rc = idetape_initiate_read(drive, tape->max_stages)) < 0) 2996 + rc = idetape_init_read(drive, tape->max_stages); 2997 + if (rc < 0) 2831 2998 return rc; 2832 2999 if (count == 0) 2833 3000 return (0); 2834 3001 if (tape->merge_stage_size) { 2835 - actually_read = min((unsigned int)(tape->merge_stage_size), (unsigned int)count); 2836 - if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, actually_read)) 3002 + actually_read = min((unsigned int)(tape->merge_stage_size), 3003 + (unsigned int)count); 3004 + if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, 3005 + actually_read)) 2837 3006 ret = -EFAULT; 2838 3007 buf += actually_read; 2839 3008 tape->merge_stage_size -= actually_read; ··· 2844 3011 bytes_read = idetape_add_chrdev_read_request(drive, ctl); 2845 3012 if (bytes_read <= 0) 2846 3013 goto finish; 2847 - if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) 3014 + if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, 3015 + bytes_read)) 2848 3016 ret = -EFAULT; 2849 3017 buf += bytes_read; 2850 3018 count -= bytes_read; ··· 2856 3022 if (bytes_read <= 0) 2857 3023 goto finish; 2858 3024 temp = min((unsigned long)count, (unsigned long)bytes_read); 2859 - if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, temp)) 3025 + if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, 3026 + temp)) 2860 3027 ret = -EFAULT; 2861 3028 actually_read += temp; 2862 3029 tape->merge_stage_size = bytes_read-temp; 2863 3030 } 2864 3031 finish: 2865 3032 if (!actually_read && test_bit(IDETAPE_FILEMARK, &tape->flags)) { 2866 - #if IDETAPE_DEBUG_LOG 2867 - if (tape->debug_level >= 2) 2868 - printk(KERN_INFO "ide-tape: %s: spacing over filemark\n", tape->name); 2869 - #endif 3033 + debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); 3034 + 2870 3035 idetape_space_over_filemarks(drive, MTFSF, 1); 2871 3036 return 0; 2872 3037 } 2873 3038 2874 - return (ret) ? ret : actually_read; 3039 + return ret ? ret : actually_read; 2875 3040 } 2876 3041 2877 - static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, 3042 + static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, 2878 3043 size_t count, loff_t *ppos) 2879 3044 { 2880 3045 struct ide_tape_obj *tape = ide_tape_f(file); ··· 2886 3053 if (tape->write_prot) 2887 3054 return -EACCES; 2888 3055 2889 - #if IDETAPE_DEBUG_LOG 2890 - if (tape->debug_level >= 3) 2891 - printk(KERN_INFO "ide-tape: Reached idetape_chrdev_write, " 2892 - "count %Zd\n", count); 2893 - #endif /* IDETAPE_DEBUG_LOG */ 3056 + debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 2894 3057 2895 3058 /* Initialize write operation */ 2896 - if (tape->chrdev_direction != idetape_direction_write) { 2897 - if (tape->chrdev_direction == idetape_direction_read) 3059 + if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { 3060 + if (tape->chrdev_dir == IDETAPE_DIR_READ) 2898 3061 idetape_discard_read_pipeline(drive, 1); 2899 3062 if (tape->merge_stage || tape->merge_stage_size) { 2900 3063 printk(KERN_ERR "ide-tape: merge_stage_size " 2901 3064 "should be 0 now\n"); 2902 3065 tape->merge_stage_size = 0; 2903 3066 } 2904 - if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) 3067 + tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); 3068 + if (!tape->merge_stage) 2905 3069 return -ENOMEM; 2906 - tape->chrdev_direction = idetape_direction_write; 3070 + tape->chrdev_dir = IDETAPE_DIR_WRITE; 2907 3071 idetape_init_merge_stage(tape); 2908 3072 2909 3073 /* 2910 - * Issue a write 0 command to ensure that DSC handshake 2911 - * is switched from completion mode to buffer available 2912 - * mode. 2913 - * No point in issuing this if DSC overlap isn't supported, 2914 - * some drives (Seagate STT3401A) will return an error. 3074 + * Issue a write 0 command to ensure that DSC handshake is 3075 + * switched from completion mode to buffer available mode. No 3076 + * point in issuing this if DSC overlap isn't supported, some 3077 + * drives (Seagate STT3401A) will return an error. 2915 3078 */ 2916 3079 if (drive->dsc_overlap) { 2917 - ssize_t retval = idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, 0, tape->merge_stage->bh); 3080 + ssize_t retval = idetape_queue_rw_tail(drive, 3081 + REQ_IDETAPE_WRITE, 0, 3082 + tape->merge_stage->bh); 2918 3083 if (retval < 0) { 2919 3084 __idetape_kfree_stage(tape->merge_stage); 2920 3085 tape->merge_stage = NULL; 2921 - tape->chrdev_direction = idetape_direction_none; 3086 + tape->chrdev_dir = IDETAPE_DIR_NONE; 2922 3087 return retval; 2923 3088 } 2924 3089 } ··· 2927 3096 idetape_restart_speed_control(drive); 2928 3097 if (tape->merge_stage_size) { 2929 3098 if (tape->merge_stage_size >= tape->stage_size) { 2930 - printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); 3099 + printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); 2931 3100 tape->merge_stage_size = 0; 2932 3101 } 2933 - actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); 2934 - if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) 3102 + actually_written = min((unsigned int) 3103 + (tape->stage_size - tape->merge_stage_size), 3104 + (unsigned int)count); 3105 + if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, 3106 + actually_written)) 2935 3107 ret = -EFAULT; 2936 3108 buf += actually_written; 2937 3109 tape->merge_stage_size += actually_written; ··· 2950 3116 } 2951 3117 while (count >= tape->stage_size) { 2952 3118 ssize_t retval; 2953 - if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, tape->stage_size)) 3119 + if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, 3120 + tape->stage_size)) 2954 3121 ret = -EFAULT; 2955 3122 buf += tape->stage_size; 2956 3123 count -= tape->stage_size; ··· 2962 3127 } 2963 3128 if (count) { 2964 3129 actually_written += count; 2965 - if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, count)) 3130 + if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, 3131 + count)) 2966 3132 ret = -EFAULT; 2967 3133 tape->merge_stage_size += count; 2968 3134 } 2969 - return (ret) ? ret : actually_written; 3135 + return ret ? ret : actually_written; 2970 3136 } 2971 3137 2972 - static int idetape_write_filemark (ide_drive_t *drive) 3138 + static int idetape_write_filemark(ide_drive_t *drive) 2973 3139 { 2974 3140 idetape_pc_t pc; 2975 3141 ··· 3001 3165 { 3002 3166 idetape_tape_t *tape = drive->driver_data; 3003 3167 idetape_pc_t pc; 3004 - int i,retval; 3168 + int i, retval; 3005 3169 3006 - #if IDETAPE_DEBUG_LOG 3007 - if (tape->debug_level >= 1) 3008 - printk(KERN_INFO "ide-tape: Handling MTIOCTOP ioctl: " 3009 - "mt_op=%d, mt_count=%d\n", mt_op, mt_count); 3010 - #endif /* IDETAPE_DEBUG_LOG */ 3011 - /* 3012 - * Commands which need our pipelined read-ahead stages. 3013 - */ 3170 + debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", 3171 + mt_op, mt_count); 3172 + 3173 + /* Commands which need our pipelined read-ahead stages. */ 3014 3174 switch (mt_op) { 3015 - case MTFSF: 3016 - case MTFSFM: 3017 - case MTBSF: 3018 - case MTBSFM: 3019 - if (!mt_count) 3020 - return (0); 3021 - return (idetape_space_over_filemarks(drive,mt_op,mt_count)); 3022 - default: 3023 - break; 3175 + case MTFSF: 3176 + case MTFSFM: 3177 + case MTBSF: 3178 + case MTBSFM: 3179 + if (!mt_count) 3180 + return 0; 3181 + return idetape_space_over_filemarks(drive, mt_op, mt_count); 3182 + default: 3183 + break; 3024 3184 } 3185 + 3025 3186 switch (mt_op) { 3026 - case MTWEOF: 3027 - if (tape->write_prot) 3028 - return -EACCES; 3029 - idetape_discard_read_pipeline(drive, 1); 3030 - for (i = 0; i < mt_count; i++) { 3031 - retval = idetape_write_filemark(drive); 3032 - if (retval) 3033 - return retval; 3034 - } 3035 - return (0); 3036 - case MTREW: 3037 - idetape_discard_read_pipeline(drive, 0); 3038 - if (idetape_rewind_tape(drive)) 3187 + case MTWEOF: 3188 + if (tape->write_prot) 3189 + return -EACCES; 3190 + idetape_discard_read_pipeline(drive, 1); 3191 + for (i = 0; i < mt_count; i++) { 3192 + retval = idetape_write_filemark(drive); 3193 + if (retval) 3194 + return retval; 3195 + } 3196 + return 0; 3197 + case MTREW: 3198 + idetape_discard_read_pipeline(drive, 0); 3199 + if (idetape_rewind_tape(drive)) 3200 + return -EIO; 3201 + return 0; 3202 + case MTLOAD: 3203 + idetape_discard_read_pipeline(drive, 0); 3204 + idetape_create_load_unload_cmd(drive, &pc, 3205 + IDETAPE_LU_LOAD_MASK); 3206 + return idetape_queue_pc_tail(drive, &pc); 3207 + case MTUNLOAD: 3208 + case MTOFFL: 3209 + /* 3210 + * If door is locked, attempt to unlock before 3211 + * attempting to eject. 3212 + */ 3213 + if (tape->door_locked) { 3214 + if (idetape_create_prevent_cmd(drive, &pc, 0)) 3215 + if (!idetape_queue_pc_tail(drive, &pc)) 3216 + tape->door_locked = DOOR_UNLOCKED; 3217 + } 3218 + idetape_discard_read_pipeline(drive, 0); 3219 + idetape_create_load_unload_cmd(drive, &pc, 3220 + !IDETAPE_LU_LOAD_MASK); 3221 + retval = idetape_queue_pc_tail(drive, &pc); 3222 + if (!retval) 3223 + clear_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); 3224 + return retval; 3225 + case MTNOP: 3226 + idetape_discard_read_pipeline(drive, 0); 3227 + return idetape_flush_tape_buffers(drive); 3228 + case MTRETEN: 3229 + idetape_discard_read_pipeline(drive, 0); 3230 + idetape_create_load_unload_cmd(drive, &pc, 3231 + IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); 3232 + return idetape_queue_pc_tail(drive, &pc); 3233 + case MTEOM: 3234 + idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); 3235 + return idetape_queue_pc_tail(drive, &pc); 3236 + case MTERASE: 3237 + (void)idetape_rewind_tape(drive); 3238 + idetape_create_erase_cmd(&pc); 3239 + return idetape_queue_pc_tail(drive, &pc); 3240 + case MTSETBLK: 3241 + if (mt_count) { 3242 + if (mt_count < tape->blk_size || 3243 + mt_count % tape->blk_size) 3039 3244 return -EIO; 3245 + tape->user_bs_factor = mt_count / tape->blk_size; 3246 + clear_bit(IDETAPE_DETECT_BS, &tape->flags); 3247 + } else 3248 + set_bit(IDETAPE_DETECT_BS, &tape->flags); 3249 + return 0; 3250 + case MTSEEK: 3251 + idetape_discard_read_pipeline(drive, 0); 3252 + return idetape_position_tape(drive, 3253 + mt_count * tape->user_bs_factor, tape->partition, 0); 3254 + case MTSETPART: 3255 + idetape_discard_read_pipeline(drive, 0); 3256 + return idetape_position_tape(drive, 0, mt_count, 0); 3257 + case MTFSR: 3258 + case MTBSR: 3259 + case MTLOCK: 3260 + if (!idetape_create_prevent_cmd(drive, &pc, 1)) 3040 3261 return 0; 3041 - case MTLOAD: 3042 - idetape_discard_read_pipeline(drive, 0); 3043 - idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK); 3044 - return (idetape_queue_pc_tail(drive, &pc)); 3045 - case MTUNLOAD: 3046 - case MTOFFL: 3047 - /* 3048 - * If door is locked, attempt to unlock before 3049 - * attempting to eject. 3050 - */ 3051 - if (tape->door_locked) { 3052 - if (idetape_create_prevent_cmd(drive, &pc, 0)) 3053 - if (!idetape_queue_pc_tail(drive, &pc)) 3054 - tape->door_locked = DOOR_UNLOCKED; 3055 - } 3056 - idetape_discard_read_pipeline(drive, 0); 3057 - idetape_create_load_unload_cmd(drive, &pc,!IDETAPE_LU_LOAD_MASK); 3058 - retval = idetape_queue_pc_tail(drive, &pc); 3059 - if (!retval) 3060 - clear_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); 3262 + retval = idetape_queue_pc_tail(drive, &pc); 3263 + if (retval) 3061 3264 return retval; 3062 - case MTNOP: 3063 - idetape_discard_read_pipeline(drive, 0); 3064 - return (idetape_flush_tape_buffers(drive)); 3065 - case MTRETEN: 3066 - idetape_discard_read_pipeline(drive, 0); 3067 - idetape_create_load_unload_cmd(drive, &pc,IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); 3068 - return (idetape_queue_pc_tail(drive, &pc)); 3069 - case MTEOM: 3070 - idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); 3071 - return (idetape_queue_pc_tail(drive, &pc)); 3072 - case MTERASE: 3073 - (void) idetape_rewind_tape(drive); 3074 - idetape_create_erase_cmd(&pc); 3075 - return (idetape_queue_pc_tail(drive, &pc)); 3076 - case MTSETBLK: 3077 - if (mt_count) { 3078 - if (mt_count < tape->tape_block_size || mt_count % tape->tape_block_size) 3079 - return -EIO; 3080 - tape->user_bs_factor = mt_count / tape->tape_block_size; 3081 - clear_bit(IDETAPE_DETECT_BS, &tape->flags); 3082 - } else 3083 - set_bit(IDETAPE_DETECT_BS, &tape->flags); 3265 + tape->door_locked = DOOR_EXPLICITLY_LOCKED; 3266 + return 0; 3267 + case MTUNLOCK: 3268 + if (!idetape_create_prevent_cmd(drive, &pc, 0)) 3084 3269 return 0; 3085 - case MTSEEK: 3086 - idetape_discard_read_pipeline(drive, 0); 3087 - return idetape_position_tape(drive, mt_count * tape->user_bs_factor, tape->partition, 0); 3088 - case MTSETPART: 3089 - idetape_discard_read_pipeline(drive, 0); 3090 - return (idetape_position_tape(drive, 0, mt_count, 0)); 3091 - case MTFSR: 3092 - case MTBSR: 3093 - case MTLOCK: 3094 - if (!idetape_create_prevent_cmd(drive, &pc, 1)) 3095 - return 0; 3096 - retval = idetape_queue_pc_tail(drive, &pc); 3097 - if (retval) return retval; 3098 - tape->door_locked = DOOR_EXPLICITLY_LOCKED; 3099 - return 0; 3100 - case MTUNLOCK: 3101 - if (!idetape_create_prevent_cmd(drive, &pc, 0)) 3102 - return 0; 3103 - retval = idetape_queue_pc_tail(drive, &pc); 3104 - if (retval) return retval; 3105 - tape->door_locked = DOOR_UNLOCKED; 3106 - return 0; 3107 - default: 3108 - printk(KERN_ERR "ide-tape: MTIO operation %d not " 3109 - "supported\n", mt_op); 3110 - return (-EIO); 3270 + retval = idetape_queue_pc_tail(drive, &pc); 3271 + if (retval) 3272 + return retval; 3273 + tape->door_locked = DOOR_UNLOCKED; 3274 + return 0; 3275 + default: 3276 + printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 3277 + mt_op); 3278 + return -EIO; 3111 3279 } 3112 3280 } 3113 3281 ··· 3128 3288 struct mtop mtop; 3129 3289 struct mtget mtget; 3130 3290 struct mtpos mtpos; 3131 - int block_offset = 0, position = tape->first_frame_position; 3291 + int block_offset = 0, position = tape->first_frame; 3132 3292 void __user *argp = (void __user *)arg; 3133 3293 3134 - #if IDETAPE_DEBUG_LOG 3135 - if (tape->debug_level >= 3) 3136 - printk(KERN_INFO "ide-tape: Reached idetape_chrdev_ioctl, " 3137 - "cmd=%u\n", cmd); 3138 - #endif /* IDETAPE_DEBUG_LOG */ 3294 + debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); 3139 3295 3140 3296 tape->restart_speed_control_req = 1; 3141 - if (tape->chrdev_direction == idetape_direction_write) { 3297 + if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 3142 3298 idetape_empty_write_pipeline(drive); 3143 3299 idetape_flush_tape_buffers(drive); 3144 3300 } 3145 3301 if (cmd == MTIOCGET || cmd == MTIOCPOS) { 3146 - block_offset = idetape_pipeline_size(drive) / (tape->tape_block_size * tape->user_bs_factor); 3147 - if ((position = idetape_read_position(drive)) < 0) 3302 + block_offset = idetape_pipeline_size(drive) / 3303 + (tape->blk_size * tape->user_bs_factor); 3304 + position = idetape_read_position(drive); 3305 + if (position < 0) 3148 3306 return -EIO; 3149 3307 } 3150 3308 switch (cmd) { 3151 - case MTIOCTOP: 3152 - if (copy_from_user(&mtop, argp, sizeof (struct mtop))) 3153 - return -EFAULT; 3154 - return (idetape_mtioctop(drive,mtop.mt_op,mtop.mt_count)); 3155 - case MTIOCGET: 3156 - memset(&mtget, 0, sizeof (struct mtget)); 3157 - mtget.mt_type = MT_ISSCSI2; 3158 - mtget.mt_blkno = position / tape->user_bs_factor - block_offset; 3159 - mtget.mt_dsreg = ((tape->tape_block_size * tape->user_bs_factor) << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; 3160 - if (tape->drv_write_prot) { 3161 - mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); 3162 - } 3163 - if (copy_to_user(argp, &mtget, sizeof(struct mtget))) 3164 - return -EFAULT; 3165 - return 0; 3166 - case MTIOCPOS: 3167 - mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; 3168 - if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) 3169 - return -EFAULT; 3170 - return 0; 3171 - default: 3172 - if (tape->chrdev_direction == idetape_direction_read) 3173 - idetape_discard_read_pipeline(drive, 1); 3174 - return idetape_blkdev_ioctl(drive, cmd, arg); 3309 + case MTIOCTOP: 3310 + if (copy_from_user(&mtop, argp, sizeof(struct mtop))) 3311 + return -EFAULT; 3312 + return idetape_mtioctop(drive, mtop.mt_op, mtop.mt_count); 3313 + case MTIOCGET: 3314 + memset(&mtget, 0, sizeof(struct mtget)); 3315 + mtget.mt_type = MT_ISSCSI2; 3316 + mtget.mt_blkno = position / tape->user_bs_factor - block_offset; 3317 + mtget.mt_dsreg = 3318 + ((tape->blk_size * tape->user_bs_factor) 3319 + << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; 3320 + 3321 + if (tape->drv_write_prot) 3322 + mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); 3323 + 3324 + if (copy_to_user(argp, &mtget, sizeof(struct mtget))) 3325 + return -EFAULT; 3326 + return 0; 3327 + case MTIOCPOS: 3328 + mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; 3329 + if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) 3330 + return -EFAULT; 3331 + return 0; 3332 + default: 3333 + if (tape->chrdev_dir == IDETAPE_DIR_READ) 3334 + idetape_discard_read_pipeline(drive, 1); 3335 + return idetape_blkdev_ioctl(drive, cmd, arg); 3175 3336 } 3176 3337 } 3177 3338 ··· 3188 3347 idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); 3189 3348 if (idetape_queue_pc_tail(drive, &pc)) { 3190 3349 printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); 3191 - if (tape->tape_block_size == 0) { 3350 + if (tape->blk_size == 0) { 3192 3351 printk(KERN_WARNING "ide-tape: Cannot deal with zero " 3193 3352 "block size, assuming 32k\n"); 3194 - tape->tape_block_size = 32768; 3353 + tape->blk_size = 32768; 3195 3354 } 3196 3355 return; 3197 3356 } 3198 - tape->tape_block_size = (pc.buffer[4 + 5] << 16) + 3357 + tape->blk_size = (pc.buffer[4 + 5] << 16) + 3199 3358 (pc.buffer[4 + 6] << 8) + 3200 3359 pc.buffer[4 + 7]; 3201 3360 tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; 3202 3361 } 3203 3362 3204 - /* 3205 - * Our character device open function. 3206 - */ 3207 - static int idetape_chrdev_open (struct inode *inode, struct file *filp) 3363 + static int idetape_chrdev_open(struct inode *inode, struct file *filp) 3208 3364 { 3209 3365 unsigned int minor = iminor(inode), i = minor & ~0xc0; 3210 3366 ide_drive_t *drive; ··· 3209 3371 idetape_pc_t pc; 3210 3372 int retval; 3211 3373 3374 + if (i >= MAX_HWIFS * MAX_DRIVES) 3375 + return -ENXIO; 3376 + 3377 + tape = ide_tape_chrdev_get(i); 3378 + if (!tape) 3379 + return -ENXIO; 3380 + 3381 + debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 3382 + 3212 3383 /* 3213 3384 * We really want to do nonseekable_open(inode, filp); here, but some 3214 3385 * versions of tar incorrectly call lseek on tapes and bail out if that 3215 3386 * fails. So we disallow pread() and pwrite(), but permit lseeks. 3216 3387 */ 3217 3388 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 3218 - 3219 - #if IDETAPE_DEBUG_LOG 3220 - printk(KERN_INFO "ide-tape: Reached idetape_chrdev_open\n"); 3221 - #endif /* IDETAPE_DEBUG_LOG */ 3222 - 3223 - if (i >= MAX_HWIFS * MAX_DRIVES) 3224 - return -ENXIO; 3225 - 3226 - if (!(tape = ide_tape_chrdev_get(i))) 3227 - return -ENXIO; 3228 3389 3229 3390 drive = tape->drive; 3230 3391 ··· 3245 3408 if (!test_bit(IDETAPE_ADDRESS_VALID, &tape->flags)) 3246 3409 (void)idetape_rewind_tape(drive); 3247 3410 3248 - if (tape->chrdev_direction != idetape_direction_read) 3411 + if (tape->chrdev_dir != IDETAPE_DIR_READ) 3249 3412 clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); 3250 3413 3251 3414 /* Read block size and write protect status from drive. */ ··· 3267 3430 } 3268 3431 } 3269 3432 3270 - /* 3271 - * Lock the tape drive door so user can't eject. 3272 - */ 3273 - if (tape->chrdev_direction == idetape_direction_none) { 3433 + /* Lock the tape drive door so user can't eject. */ 3434 + if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 3274 3435 if (idetape_create_prevent_cmd(drive, &pc, 1)) { 3275 3436 if (!idetape_queue_pc_tail(drive, &pc)) { 3276 3437 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) ··· 3285 3450 return retval; 3286 3451 } 3287 3452 3288 - static void idetape_write_release (ide_drive_t *drive, unsigned int minor) 3453 + static void idetape_write_release(ide_drive_t *drive, unsigned int minor) 3289 3454 { 3290 3455 idetape_tape_t *tape = drive->driver_data; 3291 3456 3292 3457 idetape_empty_write_pipeline(drive); 3293 3458 tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0); 3294 3459 if (tape->merge_stage != NULL) { 3295 - idetape_pad_zeros(drive, tape->tape_block_size * (tape->user_bs_factor - 1)); 3460 + idetape_pad_zeros(drive, tape->blk_size * 3461 + (tape->user_bs_factor - 1)); 3296 3462 __idetape_kfree_stage(tape->merge_stage); 3297 3463 tape->merge_stage = NULL; 3298 3464 } ··· 3302 3466 idetape_flush_tape_buffers(drive); 3303 3467 } 3304 3468 3305 - /* 3306 - * Our character device release function. 3307 - */ 3308 - static int idetape_chrdev_release (struct inode *inode, struct file *filp) 3469 + static int idetape_chrdev_release(struct inode *inode, struct file *filp) 3309 3470 { 3310 3471 struct ide_tape_obj *tape = ide_tape_f(filp); 3311 3472 ide_drive_t *drive = tape->drive; ··· 3311 3478 3312 3479 lock_kernel(); 3313 3480 tape = drive->driver_data; 3314 - #if IDETAPE_DEBUG_LOG 3315 - if (tape->debug_level >= 3) 3316 - printk(KERN_INFO "ide-tape: Reached idetape_chrdev_release\n"); 3317 - #endif /* IDETAPE_DEBUG_LOG */ 3318 3481 3319 - if (tape->chrdev_direction == idetape_direction_write) 3482 + debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 3483 + 3484 + if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 3320 3485 idetape_write_release(drive, minor); 3321 - if (tape->chrdev_direction == idetape_direction_read) { 3486 + if (tape->chrdev_dir == IDETAPE_DIR_READ) { 3322 3487 if (minor < 128) 3323 3488 idetape_discard_read_pipeline(drive, 1); 3324 3489 else ··· 3328 3497 } 3329 3498 if (minor < 128 && test_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags)) 3330 3499 (void) idetape_rewind_tape(drive); 3331 - if (tape->chrdev_direction == idetape_direction_none) { 3500 + if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 3332 3501 if (tape->door_locked == DOOR_LOCKED) { 3333 3502 if (idetape_create_prevent_cmd(drive, &pc, 0)) { 3334 3503 if (!idetape_queue_pc_tail(drive, &pc)) ··· 3343 3512 } 3344 3513 3345 3514 /* 3346 - * idetape_identify_device is called to check the contents of the 3347 - * ATAPI IDENTIFY command results. We return: 3515 + * check the contents of the ATAPI IDENTIFY command results. We return: 3348 3516 * 3349 - * 1 If the tape can be supported by us, based on the information 3350 - * we have so far. 3517 + * 1 - If the tape can be supported by us, based on the information we have so 3518 + * far. 3351 3519 * 3352 - * 0 If this tape driver is not currently supported by us. 3520 + * 0 - If this tape driver is not currently supported by us. 3353 3521 */ 3354 - static int idetape_identify_device (ide_drive_t *drive) 3522 + static int idetape_identify_device(ide_drive_t *drive) 3355 3523 { 3356 - struct idetape_id_gcw gcw; 3357 - struct hd_driveid *id = drive->id; 3524 + u8 gcw[2], protocol, device_type, removable, packet_size; 3358 3525 3359 3526 if (drive->id_read == 0) 3360 3527 return 1; 3361 3528 3362 - *((unsigned short *) &gcw) = id->config; 3529 + *((unsigned short *) &gcw) = drive->id->config; 3530 + 3531 + protocol = (gcw[1] & 0xC0) >> 6; 3532 + device_type = gcw[1] & 0x1F; 3533 + removable = !!(gcw[0] & 0x80); 3534 + packet_size = gcw[0] & 0x3; 3363 3535 3364 3536 /* Check that we can support this device */ 3365 - 3366 - if (gcw.protocol != 2) 3537 + if (protocol != 2) 3367 3538 printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n", 3368 - gcw.protocol); 3369 - else if (gcw.device_type != 1) 3539 + protocol); 3540 + else if (device_type != 1) 3370 3541 printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set " 3371 - "to tape\n", gcw.device_type); 3372 - else if (!gcw.removable) 3542 + "to tape\n", device_type); 3543 + else if (!removable) 3373 3544 printk(KERN_ERR "ide-tape: The removable flag is not set\n"); 3374 - else if (gcw.packet_size != 0) { 3375 - printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 " 3376 - "bytes long\n", gcw.packet_size); 3545 + else if (packet_size != 0) { 3546 + printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12" 3547 + " bytes\n", packet_size); 3377 3548 } else 3378 3549 return 1; 3379 3550 return 0; ··· 3383 3550 3384 3551 static void idetape_get_inquiry_results(ide_drive_t *drive) 3385 3552 { 3386 - char *r; 3387 3553 idetape_tape_t *tape = drive->driver_data; 3388 3554 idetape_pc_t pc; 3555 + char fw_rev[6], vendor_id[10], product_id[18]; 3389 3556 3390 3557 idetape_create_inquiry_cmd(&pc); 3391 3558 if (idetape_queue_pc_tail(drive, &pc)) { ··· 3393 3560 tape->name); 3394 3561 return; 3395 3562 } 3396 - memcpy(tape->vendor_id, &pc.buffer[8], 8); 3397 - memcpy(tape->product_id, &pc.buffer[16], 16); 3398 - memcpy(tape->firmware_revision, &pc.buffer[32], 4); 3563 + memcpy(vendor_id, &pc.buffer[8], 8); 3564 + memcpy(product_id, &pc.buffer[16], 16); 3565 + memcpy(fw_rev, &pc.buffer[32], 4); 3399 3566 3400 - ide_fixstring(tape->vendor_id, 10, 0); 3401 - ide_fixstring(tape->product_id, 18, 0); 3402 - ide_fixstring(tape->firmware_revision, 6, 0); 3403 - r = tape->firmware_revision; 3404 - if (*(r + 1) == '.') 3405 - tape->firmware_revision_num = (*r - '0') * 100 + 3406 - (*(r + 2) - '0') * 10 + *(r + 3) - '0'; 3567 + ide_fixstring(vendor_id, 10, 0); 3568 + ide_fixstring(product_id, 18, 0); 3569 + ide_fixstring(fw_rev, 6, 0); 3570 + 3407 3571 printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", 3408 - drive->name, tape->name, tape->vendor_id, 3409 - tape->product_id, tape->firmware_revision); 3572 + drive->name, tape->name, vendor_id, product_id, fw_rev); 3410 3573 } 3411 3574 3412 3575 /* 3413 3576 * Ask the tape about its various parameters. In particular, we will adjust our 3414 3577 * data transfer buffer size to the recommended value as returned by the tape. 3415 3578 */ 3416 - static void idetape_get_mode_sense_results (ide_drive_t *drive) 3579 + static void idetape_get_mode_sense_results(ide_drive_t *drive) 3417 3580 { 3418 3581 idetape_tape_t *tape = drive->driver_data; 3419 3582 idetape_pc_t pc; ··· 3420 3591 if (idetape_queue_pc_tail(drive, &pc)) { 3421 3592 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" 3422 3593 " some default values\n"); 3423 - tape->tape_block_size = 512; 3594 + tape->blk_size = 512; 3424 3595 put_unaligned(52, (u16 *)&tape->caps[12]); 3425 3596 put_unaligned(540, (u16 *)&tape->caps[14]); 3426 3597 put_unaligned(6*52, (u16 *)&tape->caps[16]); ··· 3450 3621 3451 3622 memcpy(&tape->caps, caps, 20); 3452 3623 if (caps[7] & 0x02) 3453 - tape->tape_block_size = 512; 3624 + tape->blk_size = 512; 3454 3625 else if (caps[7] & 0x04) 3455 - tape->tape_block_size = 1024; 3626 + tape->blk_size = 1024; 3456 3627 } 3457 3628 3458 3629 #ifdef CONFIG_IDE_PROC_FS 3459 - static void idetape_add_settings (ide_drive_t *drive) 3630 + static void idetape_add_settings(ide_drive_t *drive) 3460 3631 { 3461 3632 idetape_tape_t *tape = drive->driver_data; 3462 3633 3463 - /* 3464 - * drive setting name read/write data type min max mul_factor div_factor data pointer set function 3465 - */ 3466 3634 ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, 3467 3635 1, 2, (u16 *)&tape->caps[16], NULL); 3468 - ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); 3469 - ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); 3470 - ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); 3471 - ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); 3472 - ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); 3636 + ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, 3637 + tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); 3638 + ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, 3639 + tape->stage_size / 1024, 1, &tape->max_stages, NULL); 3640 + ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, 3641 + tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); 3642 + ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 3643 + 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, 3644 + NULL); 3645 + ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 3646 + 0xffff, tape->stage_size / 1024, 1, 3647 + &tape->nr_pending_stages, NULL); 3473 3648 ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, 3474 3649 1, 1, (u16 *)&tape->caps[14], NULL); 3475 - ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); 3476 - ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); 3477 - ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); 3478 - ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); 3479 - ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL); 3480 - ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL); 3481 - ide_add_setting(drive, "debug_level", SETTING_RW, TYPE_INT, 0, 0xffff, 1, 1, &tape->debug_level, NULL); 3650 + ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 3651 + 1024, &tape->stage_size, NULL); 3652 + ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, 3653 + IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, 3654 + NULL); 3655 + ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 3656 + 1, &drive->dsc_overlap, NULL); 3657 + ide_add_setting(drive, "pipeline_head_speed_c", SETTING_READ, TYPE_INT, 3658 + 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, 3659 + NULL); 3660 + ide_add_setting(drive, "pipeline_head_speed_u", SETTING_READ, TYPE_INT, 3661 + 0, 0xffff, 1, 1, 3662 + &tape->uncontrolled_pipeline_head_speed, NULL); 3663 + ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 3664 + 1, 1, &tape->avg_speed, NULL); 3665 + ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, 3666 + 1, &tape->debug_mask, NULL); 3482 3667 } 3483 3668 #else 3484 3669 static inline void idetape_add_settings(ide_drive_t *drive) { ; } 3485 3670 #endif 3486 3671 3487 3672 /* 3488 - * ide_setup is called to: 3673 + * The function below is called to: 3489 3674 * 3490 - * 1. Initialize our various state variables. 3491 - * 2. Ask the tape for its capabilities. 3492 - * 3. Allocate a buffer which will be used for data 3493 - * transfer. The buffer size is chosen based on 3494 - * the recommendation which we received in step (2). 3675 + * 1. Initialize our various state variables. 3676 + * 2. Ask the tape for its capabilities. 3677 + * 3. Allocate a buffer which will be used for data transfer. The buffer size 3678 + * is chosen based on the recommendation which we received in step 2. 3495 3679 * 3496 - * Note that at this point ide.c already assigned us an irq, so that 3497 - * we can queue requests here and wait for their completion. 3680 + * Note that at this point ide.c already assigned us an irq, so that we can 3681 + * queue requests here and wait for their completion. 3498 3682 */ 3499 - static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) 3683 + static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) 3500 3684 { 3501 3685 unsigned long t1, tmid, tn, t; 3502 3686 int speed; 3503 - struct idetape_id_gcw gcw; 3504 3687 int stage_size; 3688 + u8 gcw[2]; 3505 3689 struct sysinfo si; 3506 3690 u16 *ctl = (u16 *)&tape->caps[12]; 3507 3691 3508 - spin_lock_init(&tape->spinlock); 3692 + spin_lock_init(&tape->lock); 3509 3693 drive->dsc_overlap = 1; 3510 3694 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 3511 3695 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", ··· 3532 3690 tape->name[0] = 'h'; 3533 3691 tape->name[1] = 't'; 3534 3692 tape->name[2] = '0' + minor; 3535 - tape->chrdev_direction = idetape_direction_none; 3693 + tape->chrdev_dir = IDETAPE_DIR_NONE; 3536 3694 tape->pc = tape->pc_stack; 3537 3695 tape->max_insert_speed = 10000; 3538 3696 tape->speed_control = 1; 3539 3697 *((unsigned short *) &gcw) = drive->id->config; 3540 - if (gcw.drq_type == 1) 3698 + 3699 + /* Command packet DRQ type */ 3700 + if (((gcw[0] & 0x60) >> 5) == 1) 3541 3701 set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags); 3542 3702 3543 - tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10; 3544 - 3703 + tape->min_pipeline = 10; 3704 + tape->max_pipeline = 10; 3705 + tape->max_stages = 10; 3706 + 3545 3707 idetape_get_inquiry_results(drive); 3546 3708 idetape_get_mode_sense_results(drive); 3547 3709 ide_tape_get_bsize_from_bdesc(drive); 3548 3710 tape->user_bs_factor = 1; 3549 - tape->stage_size = *ctl * tape->tape_block_size; 3711 + tape->stage_size = *ctl * tape->blk_size; 3550 3712 while (tape->stage_size > 0xffff) { 3551 3713 printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); 3552 3714 *ctl /= 2; 3553 - tape->stage_size = *ctl * tape->tape_block_size; 3715 + tape->stage_size = *ctl * tape->blk_size; 3554 3716 } 3555 3717 stage_size = tape->stage_size; 3556 3718 tape->pages_per_stage = stage_size / PAGE_SIZE; ··· 3568 3722 3569 3723 tape->max_stages = speed * 1000 * 10 / tape->stage_size; 3570 3724 3571 - /* 3572 - * Limit memory use for pipeline to 10% of physical memory 3573 - */ 3725 + /* Limit memory use for pipeline to 10% of physical memory */ 3574 3726 si_meminfo(&si); 3575 - if (tape->max_stages * tape->stage_size > si.totalram * si.mem_unit / 10) 3576 - tape->max_stages = si.totalram * si.mem_unit / (10 * tape->stage_size); 3727 + if (tape->max_stages * tape->stage_size > 3728 + si.totalram * si.mem_unit / 10) 3729 + tape->max_stages = 3730 + si.totalram * si.mem_unit / (10 * tape->stage_size); 3731 + 3577 3732 tape->max_stages = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES); 3578 3733 tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES); 3579 - tape->max_pipeline = min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); 3580 - if (tape->max_stages == 0) 3581 - tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; 3734 + tape->max_pipeline = 3735 + min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); 3736 + if (tape->max_stages == 0) { 3737 + tape->max_stages = 1; 3738 + tape->min_pipeline = 1; 3739 + tape->max_pipeline = 1; 3740 + } 3582 3741 3583 3742 t1 = (tape->stage_size * HZ) / (speed * 1000); 3584 3743 tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); ··· 3595 3744 t = t1; 3596 3745 3597 3746 /* 3598 - * Ensure that the number we got makes sense; limit 3599 - * it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. 3747 + * Ensure that the number we got makes sense; limit it within 3748 + * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. 3600 3749 */ 3601 - tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); 3750 + tape->best_dsc_rw_freq = max_t(unsigned long, 3751 + min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), 3752 + IDETAPE_DSC_RW_MIN); 3602 3753 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " 3603 3754 "%dkB pipeline, %lums tDSC%s\n", 3604 3755 drive->name, tape->name, *(u16 *)&tape->caps[14], 3605 3756 (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, 3606 3757 tape->stage_size / 1024, 3607 3758 tape->max_stages * tape->stage_size / 1024, 3608 - tape->best_dsc_rw_frequency * 1000 / HZ, 3759 + tape->best_dsc_rw_freq * 1000 / HZ, 3609 3760 drive->using_dma ? ", DMA":""); 3610 3761 3611 3762 idetape_add_settings(drive); ··· 3635 3782 drive->dsc_overlap = 0; 3636 3783 drive->driver_data = NULL; 3637 3784 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); 3638 - device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor + 128)); 3785 + device_destroy(idetape_sysfs_class, 3786 + MKDEV(IDETAPE_MAJOR, tape->minor + 128)); 3639 3787 idetape_devs[tape->minor] = NULL; 3640 3788 g->private_data = NULL; 3641 3789 put_disk(g); ··· 3685 3831 #endif 3686 3832 }; 3687 3833 3688 - /* 3689 - * Our character device supporting functions, passed to register_chrdev. 3690 - */ 3834 + /* Our character device supporting functions, passed to register_chrdev. */ 3691 3835 static const struct file_operations idetape_fops = { 3692 3836 .owner = THIS_MODULE, 3693 3837 .read = idetape_chrdev_read, ··· 3700 3848 struct gendisk *disk = inode->i_bdev->bd_disk; 3701 3849 struct ide_tape_obj *tape; 3702 3850 3703 - if (!(tape = ide_tape_get(disk))) 3851 + tape = ide_tape_get(disk); 3852 + if (!tape) 3704 3853 return -ENXIO; 3705 3854 3706 3855 return 0; ··· 3748 3895 goto failed; 3749 3896 if (drive->media != ide_tape) 3750 3897 goto failed; 3751 - if (!idetape_identify_device (drive)) { 3752 - printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name); 3898 + if (!idetape_identify_device(drive)) { 3899 + printk(KERN_ERR "ide-tape: %s: not supported by this version of" 3900 + " the driver\n", drive->name); 3753 3901 goto failed; 3754 3902 } 3755 3903 if (drive->scsi) { 3756 - printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name); 3904 + printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi" 3905 + " emulation.\n", drive->name); 3757 3906 goto failed; 3758 3907 } 3759 - if (strstr(drive->id->model, "OnStream DI-")) { 3760 - printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); 3761 - printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); 3762 - } 3763 - tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL); 3908 + tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); 3764 3909 if (tape == NULL) { 3765 - printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); 3910 + printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", 3911 + drive->name); 3766 3912 goto failed; 3767 3913 } 3768 3914 ··· 3807 3955 return -ENODEV; 3808 3956 } 3809 3957 3810 - MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); 3811 - MODULE_LICENSE("GPL"); 3812 - 3813 - static void __exit idetape_exit (void) 3958 + static void __exit idetape_exit(void) 3814 3959 { 3815 3960 driver_unregister(&idetape_driver.gen_driver); 3816 3961 class_destroy(idetape_sysfs_class); ··· 3826 3977 } 3827 3978 3828 3979 if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { 3829 - printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); 3980 + printk(KERN_ERR "ide-tape: Failed to register chrdev" 3981 + " interface\n"); 3830 3982 error = -EBUSY; 3831 3983 goto out_free_class; 3832 3984 } ··· 3850 4000 module_init(idetape_init); 3851 4001 module_exit(idetape_exit); 3852 4002 MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR); 4003 + MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); 4004 + MODULE_LICENSE("GPL");
+17 -18
drivers/ide/ide-taskfile.c
··· 189 189 */ 190 190 static ide_startstop_t set_multmode_intr(ide_drive_t *drive) 191 191 { 192 - ide_hwif_t *hwif = HWIF(drive); 193 - u8 stat; 192 + u8 stat = ide_read_status(drive); 194 193 195 - if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { 194 + if (OK_STAT(stat, READY_STAT, BAD_STAT)) 196 195 drive->mult_count = drive->mult_req; 197 - } else { 196 + else { 198 197 drive->mult_req = drive->mult_count = 0; 199 198 drive->special.b.recalibrate = 1; 200 199 (void) ide_dump_status(drive, "set_multmode", stat); ··· 206 207 */ 207 208 static ide_startstop_t set_geometry_intr(ide_drive_t *drive) 208 209 { 209 - ide_hwif_t *hwif = HWIF(drive); 210 210 int retries = 5; 211 211 u8 stat; 212 212 213 - while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) 213 + while (((stat = ide_read_status(drive)) & BUSY_STAT) && retries--) 214 214 udelay(10); 215 215 216 216 if (OK_STAT(stat, READY_STAT, BAD_STAT)) ··· 228 230 */ 229 231 static ide_startstop_t recal_intr(ide_drive_t *drive) 230 232 { 231 - ide_hwif_t *hwif = HWIF(drive); 232 - u8 stat; 233 + u8 stat = ide_read_status(drive); 233 234 234 - if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT)) 235 + if (!OK_STAT(stat, READY_STAT, BAD_STAT)) 235 236 return ide_error(drive, "recal_intr", stat); 236 237 return ide_stopped; 237 238 } ··· 241 244 static ide_startstop_t task_no_data_intr(ide_drive_t *drive) 242 245 { 243 246 ide_task_t *args = HWGROUP(drive)->rq->special; 244 - ide_hwif_t *hwif = HWIF(drive); 245 247 u8 stat; 246 248 247 249 local_irq_enable_in_hardirq(); 248 - if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) { 250 + stat = ide_read_status(drive); 251 + 252 + if (!OK_STAT(stat, READY_STAT, BAD_STAT)) 249 253 return ide_error(drive, "task_no_data_intr", stat); 250 254 /* calls ide_end_drive_cmd */ 251 - } 255 + 252 256 if (args) 253 - ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG)); 257 + ide_end_drive_cmd(drive, stat, ide_read_error(drive)); 254 258 255 259 return ide_stopped; 256 260 } 257 261 258 262 static u8 wait_drive_not_busy(ide_drive_t *drive) 259 263 { 260 - ide_hwif_t *hwif = HWIF(drive); 261 264 int retries; 262 265 u8 stat; 263 266 ··· 266 269 * This can take up to 10 usec, but we will wait max 1 ms. 267 270 */ 268 271 for (retries = 0; retries < 100; retries++) { 269 - if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) 272 + stat = ide_read_status(drive); 273 + 274 + if (stat & BUSY_STAT) 270 275 udelay(10); 271 276 else 272 277 break; ··· 407 408 void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) 408 409 { 409 410 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { 410 - u8 err = drive->hwif->INB(IDE_ERROR_REG); 411 + u8 err = ide_read_error(drive); 411 412 412 413 ide_end_drive_cmd(drive, stat, err); 413 414 return; ··· 429 430 { 430 431 ide_hwif_t *hwif = drive->hwif; 431 432 struct request *rq = HWGROUP(drive)->rq; 432 - u8 stat = hwif->INB(IDE_STATUS_REG); 433 + u8 stat = ide_read_status(drive); 433 434 434 435 /* new way for dealing with premature shared PCI interrupts */ 435 436 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { ··· 464 465 { 465 466 ide_hwif_t *hwif = drive->hwif; 466 467 struct request *rq = HWGROUP(drive)->rq; 467 - u8 stat = hwif->INB(IDE_STATUS_REG); 468 + u8 stat = ide_read_status(drive); 468 469 469 470 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) 470 471 return task_error(drive, rq, __FUNCTION__, stat);
-54
drivers/ide/ide.c
··· 618 618 619 619 EXPORT_SYMBOL(ide_unregister); 620 620 621 - 622 - /** 623 - * ide_setup_ports - set up IDE interface ports 624 - * @hw: register descriptions 625 - * @base: base register 626 - * @offsets: table of register offsets 627 - * @ctrl: control register 628 - * @ack_irq: IRQ ack 629 - * @irq: interrupt lie 630 - * 631 - * Setup hw_regs_t structure described by parameters. You 632 - * may set up the hw structure yourself OR use this routine to 633 - * do it for you. This is basically a helper 634 - * 635 - */ 636 - 637 - void ide_setup_ports ( hw_regs_t *hw, 638 - unsigned long base, int *offsets, 639 - unsigned long ctrl, unsigned long intr, 640 - ide_ack_intr_t *ack_intr, 641 - /* 642 - * ide_io_ops_t *iops, 643 - */ 644 - int irq) 645 - { 646 - int i; 647 - 648 - memset(hw, 0, sizeof(hw_regs_t)); 649 - for (i = 0; i < IDE_NR_PORTS; i++) { 650 - if (offsets[i] == -1) { 651 - switch(i) { 652 - case IDE_CONTROL_OFFSET: 653 - hw->io_ports[i] = ctrl; 654 - break; 655 - #if defined(CONFIG_AMIGA) || defined(CONFIG_MAC) 656 - case IDE_IRQ_OFFSET: 657 - hw->io_ports[i] = intr; 658 - break; 659 - #endif /* (CONFIG_AMIGA) || (CONFIG_MAC) */ 660 - default: 661 - hw->io_ports[i] = 0; 662 - break; 663 - } 664 - } else { 665 - hw->io_ports[i] = base + offsets[i]; 666 - } 667 - } 668 - hw->irq = irq; 669 - hw->ack_intr = ack_intr; 670 - /* 671 - * hw->iops = iops; 672 - */ 673 - } 674 - 675 621 void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) 676 622 { 677 623 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
+37 -35
drivers/ide/legacy/buddha.c
··· 56 56 XSURF_BASE1, XSURF_BASE2 57 57 }; 58 58 59 - 60 59 /* 61 60 * Offsets from one of the above bases 62 61 */ 63 62 64 - #define BUDDHA_DATA 0x00 65 - #define BUDDHA_ERROR 0x06 /* see err-bits */ 66 - #define BUDDHA_NSECTOR 0x0a /* nr of sectors to read/write */ 67 - #define BUDDHA_SECTOR 0x0e /* starting sector */ 68 - #define BUDDHA_LCYL 0x12 /* starting cylinder */ 69 - #define BUDDHA_HCYL 0x16 /* high byte of starting cyl */ 70 - #define BUDDHA_SELECT 0x1a /* 101dhhhh , d=drive, hhhh=head */ 71 - #define BUDDHA_STATUS 0x1e /* see status-bits */ 72 63 #define BUDDHA_CONTROL 0x11a 73 - #define XSURF_CONTROL -1 /* X-Surf has no CS1* (Control/AltStat) */ 74 - 75 - static int buddha_offsets[IDE_NR_PORTS] __initdata = { 76 - BUDDHA_DATA, BUDDHA_ERROR, BUDDHA_NSECTOR, BUDDHA_SECTOR, BUDDHA_LCYL, 77 - BUDDHA_HCYL, BUDDHA_SELECT, BUDDHA_STATUS, BUDDHA_CONTROL, -1 78 - }; 79 - 80 - static int xsurf_offsets[IDE_NR_PORTS] __initdata = { 81 - BUDDHA_DATA, BUDDHA_ERROR, BUDDHA_NSECTOR, BUDDHA_SECTOR, BUDDHA_LCYL, 82 - BUDDHA_HCYL, BUDDHA_SELECT, BUDDHA_STATUS, XSURF_CONTROL, -1 83 - }; 84 64 85 65 /* 86 66 * Other registers ··· 118 138 if (!(ch & 0x80)) 119 139 return 0; 120 140 return 1; 141 + } 142 + 143 + static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, 144 + unsigned long ctl, unsigned long irq_port, 145 + ide_ack_intr_t *ack_intr) 146 + { 147 + int i; 148 + 149 + memset(hw, 0, sizeof(*hw)); 150 + 151 + hw->io_ports[IDE_DATA_OFFSET] = base; 152 + 153 + for (i = 1; i < 8; i++) 154 + hw->io_ports[i] = base + 2 + i * 4; 155 + 156 + hw->io_ports[IDE_CONTROL_OFFSET] = ctl; 157 + hw->io_ports[IDE_IRQ_OFFSET] = irq_port; 158 + 159 + hw->irq = IRQ_AMIGA_PORTS; 160 + hw->ack_intr = ack_intr; 121 161 } 122 162 123 163 /* ··· 202 202 printk(KERN_INFO "ide: %s IDE controller\n", 203 203 buddha_board_name[type]); 204 204 205 - for(i=0;i<buddha_num_hwifs;i++) { 206 - if(type != BOARD_XSURF) { 207 - ide_setup_ports(&hw, (buddha_board+buddha_bases[i]), 208 - buddha_offsets, 0, 209 - (buddha_board+buddha_irqports[i]), 210 - buddha_ack_intr, 211 - // budda_iops, 212 - IRQ_AMIGA_PORTS); 205 + for (i = 0; i < buddha_num_hwifs; i++) { 206 + unsigned long base, ctl, irq_port; 207 + ide_ack_intr_t *ack_intr; 208 + 209 + if (type != BOARD_XSURF) { 210 + base = buddha_board + buddha_bases[i]; 211 + ctl = base + BUDDHA_CONTROL; 212 + irq_port = buddha_board + buddha_irqports[i]; 213 + ack_intr = buddha_ack_intr; 213 214 } else { 214 - ide_setup_ports(&hw, (buddha_board+xsurf_bases[i]), 215 - xsurf_offsets, 0, 216 - (buddha_board+xsurf_irqports[i]), 217 - xsurf_ack_intr, 218 - // xsurf_iops, 219 - IRQ_AMIGA_PORTS); 220 - } 215 + base = buddha_board + xsurf_bases[i]; 216 + /* X-Surf has no CS1* (Control/AltStat) */ 217 + ctl = 0; 218 + irq_port = buddha_board + xsurf_irqports[i]; 219 + ack_intr = xsurf_ack_intr; 220 + } 221 + 222 + buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); 221 223 222 224 hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); 223 225 if (hwif) {
+21 -21
drivers/ide/legacy/falconide.c
··· 33 33 * Offsets from the above base 34 34 */ 35 35 36 - #define ATA_HD_DATA 0x00 37 - #define ATA_HD_ERROR 0x05 /* see err-bits */ 38 - #define ATA_HD_NSECTOR 0x09 /* nr of sectors to read/write */ 39 - #define ATA_HD_SECTOR 0x0d /* starting sector */ 40 - #define ATA_HD_LCYL 0x11 /* starting cylinder */ 41 - #define ATA_HD_HCYL 0x15 /* high byte of starting cyl */ 42 - #define ATA_HD_SELECT 0x19 /* 101dhhhh , d=drive, hhhh=head */ 43 - #define ATA_HD_STATUS 0x1d /* see status-bits */ 44 36 #define ATA_HD_CONTROL 0x39 45 - 46 - static int falconide_offsets[IDE_NR_PORTS] __initdata = { 47 - ATA_HD_DATA, ATA_HD_ERROR, ATA_HD_NSECTOR, ATA_HD_SECTOR, ATA_HD_LCYL, 48 - ATA_HD_HCYL, ATA_HD_SELECT, ATA_HD_STATUS, ATA_HD_CONTROL, -1 49 - }; 50 - 51 37 52 38 /* 53 39 * falconide_intr_lock is used to obtain access to the IDE interrupt, ··· 43 57 int falconide_intr_lock; 44 58 EXPORT_SYMBOL(falconide_intr_lock); 45 59 60 + static void __init falconide_setup_ports(hw_regs_t *hw) 61 + { 62 + int i; 63 + 64 + memset(hw, 0, sizeof(*hw)); 65 + 66 + hw->io_ports[IDE_DATA_OFFSET] = ATA_HD_BASE; 67 + 68 + for (i = 1; i < 8; i++) 69 + hw->io_ports[i] = ATA_HD_BASE + 1 + i * 4; 70 + 71 + hw->io_ports[IDE_CONTROL_OFFSET] = ATA_HD_CONTROL; 72 + 73 + hw->irq = IRQ_MFP_IDE; 74 + hw->ack_intr = NULL; 75 + } 46 76 47 77 /* 48 78 * Probe for a Falcon IDE interface ··· 66 64 67 65 static int __init falconide_init(void) 68 66 { 69 - if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) { 70 67 hw_regs_t hw; 71 68 ide_hwif_t *hwif; 72 69 70 + if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE)) 71 + return 0; 72 + 73 73 printk(KERN_INFO "ide: Falcon IDE controller\n"); 74 74 75 - ide_setup_ports(&hw, ATA_HD_BASE, falconide_offsets, 76 - 0, 0, NULL, 77 - // falconide_iops, 78 - IRQ_MFP_IDE); 75 + falconide_setup_ports(&hw); 79 76 80 77 hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); 81 78 if (hwif) { ··· 86 85 87 86 ide_device_add(idx, NULL); 88 87 } 89 - } 90 88 91 - return 0; 89 + return 0; 92 90 } 93 91 94 92 module_init(falconide_init);
+21 -18
drivers/ide/legacy/gayle.c
··· 34 34 * Offsets from one of the above bases 35 35 */ 36 36 37 - #define GAYLE_DATA 0x00 38 - #define GAYLE_ERROR 0x06 /* see err-bits */ 39 - #define GAYLE_NSECTOR 0x0a /* nr of sectors to read/write */ 40 - #define GAYLE_SECTOR 0x0e /* starting sector */ 41 - #define GAYLE_LCYL 0x12 /* starting cylinder */ 42 - #define GAYLE_HCYL 0x16 /* high byte of starting cyl */ 43 - #define GAYLE_SELECT 0x1a /* 101dhhhh , d=drive, hhhh=head */ 44 - #define GAYLE_STATUS 0x1e /* see status-bits */ 45 37 #define GAYLE_CONTROL 0x101a 46 - 47 - static int gayle_offsets[IDE_NR_PORTS] __initdata = { 48 - GAYLE_DATA, GAYLE_ERROR, GAYLE_NSECTOR, GAYLE_SECTOR, GAYLE_LCYL, 49 - GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, -1, -1 50 - }; 51 - 52 38 53 39 /* 54 40 * These are at different offsets from the base ··· 90 104 (void)z_readb(hwif->io_ports[IDE_STATUS_OFFSET]); 91 105 z_writeb(0x7c, hwif->io_ports[IDE_IRQ_OFFSET]); 92 106 return 1; 107 + } 108 + 109 + static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base, 110 + unsigned long ctl, unsigned long irq_port, 111 + ide_ack_intr_t *ack_intr); 112 + { 113 + int i; 114 + 115 + memset(hw, 0, sizeof(*hw)); 116 + 117 + hw->io_ports[IDE_DATA_OFFSET] = base; 118 + 119 + for (i = 1; i < 8; i++) 120 + hw->io_ports[i] = base + 2 + i * 4; 121 + 122 + hw->io_ports[IDE_CONTROL_OFFSET] = ctl; 123 + hw->io_ports[IDE_IRQ_OFFSET] = irq_port; 124 + 125 + hw->irq = IRQ_AMIGA_PORTS; 126 + hw->ack_intr = ack_intr; 93 127 } 94 128 95 129 /* ··· 173 167 base = (unsigned long)ZTWO_VADDR(phys_base); 174 168 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; 175 169 176 - ide_setup_ports(&hw, base, gayle_offsets, 177 - ctrlport, irqport, ack_intr, 178 - // &gayle_iops, 179 - IRQ_AMIGA_PORTS); 170 + gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); 180 171 181 172 hwif = ide_find_port(base); 182 173 if (hwif) {
+6 -3
drivers/ide/legacy/hd.c
··· 421 421 422 422 static inline int wait_DRQ(void) 423 423 { 424 - int retries = 100000, stat; 424 + int retries; 425 + int stat; 425 426 426 - while (--retries > 0) 427 - if ((stat = inb_p(HD_STATUS)) & DRQ_STAT) 427 + for (retries = 0; retries < 100000; retries++) { 428 + stat = inb_p(HD_STATUS); 429 + if (stat & DRQ_STAT) 428 430 return 0; 431 + } 429 432 dump_status("wait_DRQ", stat); 430 433 return -1; 431 434 }
+31 -26
drivers/ide/legacy/macide.c
··· 31 31 * These match MkLinux so they should be correct. 32 32 */ 33 33 34 - #define IDE_DATA 0x00 35 - #define IDE_ERROR 0x04 /* see err-bits */ 36 - #define IDE_NSECTOR 0x08 /* nr of sectors to read/write */ 37 - #define IDE_SECTOR 0x0c /* starting sector */ 38 - #define IDE_LCYL 0x10 /* starting cylinder */ 39 - #define IDE_HCYL 0x14 /* high byte of starting cyl */ 40 - #define IDE_SELECT 0x18 /* 101dhhhh , d=drive, hhhh=head */ 41 - #define IDE_STATUS 0x1c /* see status-bits */ 42 34 #define IDE_CONTROL 0x38 /* control/altstatus */ 43 35 44 36 /* ··· 55 63 56 64 volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR); 57 65 58 - static int macide_offsets[IDE_NR_PORTS] = { 59 - IDE_DATA, IDE_ERROR, IDE_NSECTOR, IDE_SECTOR, IDE_LCYL, 60 - IDE_HCYL, IDE_SELECT, IDE_STATUS, IDE_CONTROL 61 - }; 62 - 63 66 int macide_ack_intr(ide_hwif_t* hwif) 64 67 { 65 68 if (*ide_ifr & 0x20) { ··· 62 75 return 1; 63 76 } 64 77 return 0; 78 + } 79 + 80 + static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base, 81 + int irq, ide_ack_intr_t *ack_intr) 82 + { 83 + int i; 84 + 85 + memset(hw, 0, sizeof(*hw)); 86 + 87 + for (i = 0; i < 8; i++) 88 + hw->io_ports[i] = base + i * 4; 89 + 90 + hw->io_ports[IDE_CONTROL_OFFSET] = IDE_CONTROL; 91 + 92 + hw->irq = irq; 93 + hw->ack_intr = ack_intr; 65 94 } 66 95 67 96 static const char *mac_ide_name[] = ··· 89 86 90 87 static int __init macide_init(void) 91 88 { 92 - hw_regs_t hw; 93 89 ide_hwif_t *hwif; 90 + ide_ack_intr_t *ack_intr; 91 + unsigned long base; 92 + int irq; 93 + hw_regs_t hw; 94 94 95 95 switch (macintosh_config->ide_type) { 96 96 case MAC_IDE_QUADRA: 97 - ide_setup_ports(&hw, IDE_BASE, macide_offsets, 98 - 0, 0, macide_ack_intr, 99 - // quadra_ide_iops, 100 - IRQ_NUBUS_F); 97 + base = IDE_BASE; 98 + ack_intr = macide_ack_intr; 99 + irq = IRQ_NUBUS_F; 101 100 break; 102 101 case MAC_IDE_PB: 103 - ide_setup_ports(&hw, IDE_BASE, macide_offsets, 104 - 0, 0, macide_ack_intr, 105 - // macide_pb_iops, 106 - IRQ_NUBUS_C); 102 + base = IDE_BASE; 103 + ack_intr = macide_ack_intr; 104 + irq = IRQ_NUBUS_C; 107 105 break; 108 106 case MAC_IDE_BABOON: 109 - ide_setup_ports(&hw, BABOON_BASE, macide_offsets, 110 - 0, 0, NULL, 111 - // macide_baboon_iops, 112 - IRQ_BABOON_1); 107 + base = BABOON_BASE; 108 + ack_intr = NULL; 109 + irq = IRQ_BABOON_1; 113 110 break; 114 111 default: 115 112 return -ENODEV; ··· 117 114 118 115 printk(KERN_INFO "ide: Macintosh %s IDE controller\n", 119 116 mac_ide_name[macintosh_config->ide_type - 1]); 117 + 118 + macide_setup_ports(&hw, base, irq, ack_intr); 120 119 121 120 hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); 122 121 if (hwif) {
+1 -8
drivers/ide/legacy/q40ide.c
··· 66 66 67 67 68 68 /* 69 - * This is very similar to ide_setup_ports except that addresses 70 - * are pretranslated for q40 ISA access 69 + * Addresses are pretranslated for Q40 ISA access. 71 70 */ 72 71 void q40_ide_setup_ports ( hw_regs_t *hw, 73 72 unsigned long base, int *offsets, 74 73 unsigned long ctrl, unsigned long intr, 75 74 ide_ack_intr_t *ack_intr, 76 - /* 77 - * ide_io_ops_t *iops, 78 - */ 79 75 int irq) 80 76 { 81 77 int i; ··· 88 92 89 93 hw->irq = irq; 90 94 hw->ack_intr = ack_intr; 91 - /* 92 - * hw->iops = iops; 93 - */ 94 95 } 95 96 96 97
+2 -1
drivers/ide/pci/Makefile
··· 34 34 obj-$(CONFIG_BLK_DEV_VIA82CXXX) += via82cxxx.o 35 35 36 36 # Must appear at the end of the block 37 - obj-$(CONFIG_BLK_DEV_GENERIC) += generic.o 37 + obj-$(CONFIG_BLK_DEV_GENERIC) += ide-pci-generic.o 38 + ide-pci-generic-y += generic.o 38 39 39 40 ifeq ($(CONFIG_BLK_DEV_CMD640), m) 40 41 obj-m += cmd640.o
-13
drivers/ide/pci/generic.c
··· 29 29 30 30 static int ide_generic_all; /* Set to claim all devices */ 31 31 32 - /* 33 - * the module_param_named() was added for the modular case 34 - * the __setup() is left as compatibility for existing setups 35 - */ 36 - #ifndef MODULE 37 - static int __init ide_generic_all_on(char *unused) 38 - { 39 - ide_generic_all = 1; 40 - printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); 41 - return 1; 42 - } 43 - const __setup("all-generic-ide", ide_generic_all_on); 44 - #endif 45 32 module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 46 33 MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); 47 34
-3
drivers/ide/pci/siimage.c
··· 704 704 hwif->sata_scr[SATA_STATUS_OFFSET] = base + 0x104; 705 705 hwif->sata_scr[SATA_ERROR_OFFSET] = base + 0x108; 706 706 hwif->sata_scr[SATA_CONTROL_OFFSET] = base + 0x100; 707 - hwif->sata_misc[SATA_MISC_OFFSET] = base + 0x140; 708 - hwif->sata_misc[SATA_PHY_OFFSET] = base + 0x144; 709 - hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148; 710 707 } 711 708 712 709 memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports));
+21 -25
drivers/macintosh/mediabay.c
··· 78 78 int cached_gpio; 79 79 int sleeping; 80 80 struct semaphore lock; 81 - #ifdef CONFIG_BLK_DEV_IDE 81 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 82 82 void __iomem *cd_base; 83 - int cd_index; 84 83 int cd_irq; 85 84 int cd_retry; 85 + #endif 86 + #if defined(CONFIG_BLK_DEV_IDE_PMAC) || defined(CONFIG_MAC_FLOPPY) 87 + int cd_index; 86 88 #endif 87 89 }; 88 90 ··· 93 91 static struct media_bay_info media_bays[MAX_BAYS]; 94 92 int media_bay_count = 0; 95 93 96 - #ifdef CONFIG_BLK_DEV_IDE 94 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 97 95 /* check the busy bit in the media-bay ide interface 98 96 (assumes the media-bay contains an ide device) */ 99 97 #define MB_IDE_READY(i) ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0) ··· 403 401 set_mb_power(bay, id != MB_NO); 404 402 bay->content_id = id; 405 403 if (id == MB_NO) { 406 - #ifdef CONFIG_BLK_DEV_IDE 404 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 407 405 bay->cd_retry = 0; 408 406 #endif 409 407 printk(KERN_INFO "media bay %d is empty\n", bay->index); ··· 416 414 } 417 415 } 418 416 417 + #ifdef CONFIG_MAC_FLOPPY 419 418 int check_media_bay(struct device_node *which_bay, int what) 420 419 { 421 - #ifdef CONFIG_BLK_DEV_IDE 422 420 int i; 423 421 424 422 for (i=0; i<media_bay_count; i++) ··· 428 426 media_bays[i].cd_index = -1; 429 427 return -EINVAL; 430 428 } 431 - #endif /* CONFIG_BLK_DEV_IDE */ 432 429 return -ENODEV; 433 430 } 434 431 EXPORT_SYMBOL(check_media_bay); 432 + #endif /* CONFIG_MAC_FLOPPY */ 435 433 434 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 436 435 int check_media_bay_by_base(unsigned long base, int what) 437 436 { 438 - #ifdef CONFIG_BLK_DEV_IDE 439 437 int i; 440 438 441 439 for (i=0; i<media_bay_count; i++) ··· 445 443 media_bays[i].cd_index = -1; 446 444 return -EINVAL; 447 445 } 448 - #endif 449 - 446 + 450 447 return -ENODEV; 451 448 } 452 449 453 450 int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base, 454 - int irq, int index) 451 + int irq, int index) 455 452 { 456 - #ifdef CONFIG_BLK_DEV_IDE 457 453 int i; 458 454 459 455 for (i=0; i<media_bay_count; i++) { ··· 483 483 return -ENODEV; 484 484 } 485 485 } 486 - #endif /* CONFIG_BLK_DEV_IDE */ 487 - 486 + 488 487 return -ENODEV; 489 488 } 489 + #endif /* CONFIG_BLK_DEV_IDE_PMAC */ 490 490 491 491 static void media_bay_step(int i) 492 492 { ··· 521 521 bay->state = mb_resetting; 522 522 MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id); 523 523 break; 524 - 525 524 case mb_resetting: 526 525 if (bay->content_id != MB_CD) { 527 526 MBDBG("mediabay%d: bay is up (kind:%d)\n", i, bay->content_id); 528 527 bay->state = mb_up; 529 528 break; 530 529 } 531 - #ifdef CONFIG_BLK_DEV_IDE 530 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 532 531 MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id); 533 532 bay->ops->un_reset_ide(bay); 534 533 bay->timer = msecs_to_jiffies(MB_IDE_WAIT); ··· 535 536 #else 536 537 printk(KERN_DEBUG "media-bay %d is ide (not compiled in kernel)\n", i); 537 538 set_mb_power(bay, 0); 538 - #endif /* CONFIG_BLK_DEV_IDE */ 539 + #endif /* CONFIG_BLK_DEV_IDE_PMAC */ 539 540 break; 540 - 541 - #ifdef CONFIG_BLK_DEV_IDE 541 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 542 542 case mb_ide_resetting: 543 543 bay->timer = msecs_to_jiffies(MB_IDE_TIMEOUT); 544 544 bay->state = mb_ide_waiting; 545 545 MBDBG("mediabay%d: waiting IDE ready (kind:%d)\n", i, bay->content_id); 546 546 break; 547 - 548 547 case mb_ide_waiting: 549 548 if (bay->cd_base == NULL) { 550 549 bay->timer = 0; ··· 584 587 bay->timer = 0; 585 588 } 586 589 break; 587 - #endif /* CONFIG_BLK_DEV_IDE */ 588 - 590 + #endif /* CONFIG_BLK_DEV_IDE_PMAC */ 589 591 case mb_powering_down: 590 592 bay->state = mb_empty; 591 - #ifdef CONFIG_BLK_DEV_IDE 593 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 592 594 if (bay->cd_index >= 0) { 593 595 printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i, 594 596 bay->cd_index); ··· 603 607 bay->content_id = MB_NO; 604 608 } 605 609 } 606 - #endif /* CONFIG_BLK_DEV_IDE */ 610 + #endif /* CONFIG_BLK_DEV_IDE_PMAC */ 607 611 MBDBG("mediabay%d: end of power down\n", i); 608 612 break; 609 613 } ··· 735 739 bay->last_value = bay->content_id; 736 740 bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY); 737 741 bay->timer = msecs_to_jiffies(MB_POWER_DELAY); 738 - #ifdef CONFIG_BLK_DEV_IDE 742 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 739 743 bay->cd_retry = 0; 740 744 #endif 741 745 do { ··· 825 829 for (i=0; i<MAX_BAYS; i++) { 826 830 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info)); 827 831 media_bays[i].content_id = -1; 828 - #ifdef CONFIG_BLK_DEV_IDE 832 + #ifdef CONFIG_BLK_DEV_IDE_PMAC 829 833 media_bays[i].cd_index = -1; 830 834 #endif 831 835 }
+2 -2
drivers/scsi/ide-scsi.c
··· 287 287 static ide_startstop_t 288 288 idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) 289 289 { 290 - if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 290 + if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 291 291 /* force an abort */ 292 292 HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); 293 293 ··· 423 423 } 424 424 425 425 /* Clear the interrupt */ 426 - stat = drive->hwif->INB(IDE_STATUS_REG); 426 + stat = ide_read_status(drive); 427 427 428 428 if ((stat & DRQ_STAT) == 0) { 429 429 /* No more interrupts */
+4 -4
include/asm-powerpc/mediabay.h
··· 18 18 #define MB_NO 7 /* media bay contains nothing */ 19 19 20 20 int check_media_bay(struct device_node *which_bay, int what); 21 - int check_media_bay_by_base(unsigned long base, int what); 22 21 23 22 /* Number of bays in the machine or 0 */ 24 23 extern int media_bay_count; 25 24 26 - /* called by pmac-ide.c to register IDE controller for media bay */ 27 - extern int media_bay_set_ide_infos(struct device_node* which_bay, 28 - unsigned long base, int irq, int index); 25 + int check_media_bay_by_base(unsigned long base, int what); 26 + /* called by IDE PMAC host driver to register IDE controller for media bay */ 27 + int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long base, 28 + int irq, int index); 29 29 30 30 #endif /* __KERNEL__ */ 31 31 #endif /* _PPC_MEDIABAY_H */
+24 -18
include/linux/ide.h
··· 115 115 #define SATA_ERROR_OFFSET (1) 116 116 #define SATA_CONTROL_OFFSET (2) 117 117 118 - #define SATA_MISC_OFFSET (0) 119 - #define SATA_PHY_OFFSET (1) 120 - #define SATA_IEN_OFFSET (2) 121 - 122 118 /* 123 119 * Our Physical Region Descriptor (PRD) table should be large enough 124 120 * to handle the biggest I/O request we are likely to see. Since requests ··· 169 173 ide_rz1000, ide_trm290, 170 174 ide_cmd646, ide_cy82c693, ide_4drives, 171 175 ide_pmac, ide_etrax100, ide_acorn, 172 - ide_au1xxx, ide_forced 176 + ide_au1xxx, ide_palm3710, ide_forced 173 177 }; 174 178 175 179 typedef u8 hwif_chipset_t; ··· 193 197 struct ide_drive_s; 194 198 int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *), 195 199 struct hwif_s **); 196 - 197 - void ide_setup_ports( hw_regs_t *hw, 198 - unsigned long base, 199 - int *offsets, 200 - unsigned long ctrl, 201 - unsigned long intr, 202 - ide_ack_intr_t *ack_intr, 203 - #if 0 204 - ide_io_ops_t *iops, 205 - #endif 206 - int irq); 207 200 208 201 static inline void ide_std_init_ports(hw_regs_t *hw, 209 202 unsigned long io_addr, ··· 458 473 /* task file registers for pata and sata */ 459 474 unsigned long io_ports[IDE_NR_PORTS]; 460 475 unsigned long sata_scr[SATA_NR_PORTS]; 461 - unsigned long sata_misc[SATA_NR_PORTS]; 462 476 463 477 ide_drive_t drives[MAX_DRIVES]; /* drive info */ 464 478 ··· 998 1014 void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 999 1015 void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1000 1016 1001 - #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1017 + /* FIXME: palm_bk3710 uses BLK_DEV_IDEDMA_PCI without BLK_DEV_IDEPCI! */ 1018 + #if defined(CONFIG_BLK_DEV_IDEPCI) && defined(CONFIG_BLK_DEV_IDEDMA_PCI) 1002 1019 void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1003 1020 #else 1004 1021 static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, ··· 1307 1322 static inline void ide_set_irq(ide_drive_t *drive, int on) 1308 1323 { 1309 1324 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); 1325 + } 1326 + 1327 + static inline u8 ide_read_status(ide_drive_t *drive) 1328 + { 1329 + ide_hwif_t *hwif = drive->hwif; 1330 + 1331 + return hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); 1332 + } 1333 + 1334 + static inline u8 ide_read_altstatus(ide_drive_t *drive) 1335 + { 1336 + ide_hwif_t *hwif = drive->hwif; 1337 + 1338 + return hwif->INB(hwif->io_ports[IDE_CONTROL_OFFSET]); 1339 + } 1340 + 1341 + static inline u8 ide_read_error(ide_drive_t *drive) 1342 + { 1343 + ide_hwif_t *hwif = drive->hwif; 1344 + 1345 + return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]); 1310 1346 } 1311 1347 1312 1348 #endif /* _IDE_H */