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/davem/ide-next-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-next-2.6:
ide: fixup for fujitsu disk
ide: convert to ->proc_fops
at91_ide: remove headers specific for at91sam9263
IDE: palm_bk3710: convert clock usage after clkdev conversion
ide: fix races in handling of user-space SET XFER commands
ide: allow ide_dev_read_id() to be called from the IRQ context
ide: ide-taskfile.c fix style problems
drivers/ide/ide-cd.c: Use DIV_ROUND_CLOSEST
ide-tape: fix handling of postponed rqs
ide-tape: convert to ide_debug_log macro
ide-tape: fix debug call
ide: Fix annoying warning in ide_pio_bytes().
IDE: Save a call to PageHighMem()

+529 -392
-2
drivers/ide/at91_ide.c
··· 29 29 30 30 #include <mach/board.h> 31 31 #include <mach/gpio.h> 32 - #include <mach/at91sam9263.h> 33 32 #include <mach/at91sam9_smc.h> 34 - #include <mach/at91sam9263_matrix.h> 35 33 36 34 #define DRV_NAME "at91_ide" 37 35
+22 -10
drivers/ide/ide-cd.c
··· 30 30 #include <linux/kernel.h> 31 31 #include <linux/delay.h> 32 32 #include <linux/timer.h> 33 + #include <linux/seq_file.h> 33 34 #include <linux/slab.h> 34 35 #include <linux/interrupt.h> 35 36 #include <linux/errno.h> ··· 1147 1146 ide_debug_log(IDE_DBG_PROBE, "curspeed: %u, maxspeed: %u", 1148 1147 curspeed, maxspeed); 1149 1148 1150 - cd->current_speed = (curspeed + (176/2)) / 176; 1151 - cd->max_speed = (maxspeed + (176/2)) / 176; 1149 + cd->current_speed = DIV_ROUND_CLOSEST(curspeed, 176); 1150 + cd->max_speed = DIV_ROUND_CLOSEST(maxspeed, 176); 1152 1151 } 1153 1152 1154 1153 #define IDE_CD_CAPABILITIES \ ··· 1390 1389 return capacity * sectors_per_frame; 1391 1390 } 1392 1391 1393 - static int proc_idecd_read_capacity(char *page, char **start, off_t off, 1394 - int count, int *eof, void *data) 1392 + static int idecd_capacity_proc_show(struct seq_file *m, void *v) 1395 1393 { 1396 - ide_drive_t *drive = data; 1397 - int len; 1394 + ide_drive_t *drive = m->private; 1398 1395 1399 - len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1400 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1396 + seq_printf(m, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1397 + return 0; 1401 1398 } 1402 1399 1400 + static int idecd_capacity_proc_open(struct inode *inode, struct file *file) 1401 + { 1402 + return single_open(file, idecd_capacity_proc_show, PDE(inode)->data); 1403 + } 1404 + 1405 + static const struct file_operations idecd_capacity_proc_fops = { 1406 + .owner = THIS_MODULE, 1407 + .open = idecd_capacity_proc_open, 1408 + .read = seq_read, 1409 + .llseek = seq_lseek, 1410 + .release = single_release, 1411 + }; 1412 + 1403 1413 static ide_proc_entry_t idecd_proc[] = { 1404 - { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 1405 - { NULL, 0, NULL, NULL } 1414 + { "capacity", S_IFREG|S_IRUGO, &idecd_capacity_proc_fops }, 1415 + {} 1406 1416 }; 1407 1417 1408 1418 static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
+88 -47
drivers/ide/ide-disk_proc.c
··· 1 1 #include <linux/kernel.h> 2 2 #include <linux/ide.h> 3 + #include <linux/seq_file.h> 3 4 4 5 #include "ide-disk.h" 5 6 ··· 38 37 return ide_raw_taskfile(drive, &cmd, buf, 1); 39 38 } 40 39 41 - static int proc_idedisk_read_cache 42 - (char *page, char **start, off_t off, int count, int *eof, void *data) 40 + static int idedisk_cache_proc_show(struct seq_file *m, void *v) 43 41 { 44 - ide_drive_t *drive = (ide_drive_t *) data; 45 - char *out = page; 46 - int len; 42 + ide_drive_t *drive = (ide_drive_t *) m->private; 47 43 48 44 if (drive->dev_flags & IDE_DFLAG_ID_READ) 49 - len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 45 + seq_printf(m, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 50 46 else 51 - len = sprintf(out, "(none)\n"); 52 - 53 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 47 + seq_printf(m, "(none)\n"); 48 + return 0; 54 49 } 55 50 56 - static int proc_idedisk_read_capacity 57 - (char *page, char **start, off_t off, int count, int *eof, void *data) 51 + static int idedisk_cache_proc_open(struct inode *inode, struct file *file) 58 52 { 59 - ide_drive_t*drive = (ide_drive_t *)data; 60 - int len; 61 - 62 - len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); 63 - 64 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 53 + return single_open(file, idedisk_cache_proc_show, PDE(inode)->data); 65 54 } 66 55 67 - static int proc_idedisk_read_smart(char *page, char **start, off_t off, 68 - int count, int *eof, void *data, u8 sub_cmd) 56 + static const struct file_operations idedisk_cache_proc_fops = { 57 + .owner = THIS_MODULE, 58 + .open = idedisk_cache_proc_open, 59 + .read = seq_read, 60 + .llseek = seq_lseek, 61 + .release = single_release, 62 + }; 63 + 64 + static int idedisk_capacity_proc_show(struct seq_file *m, void *v) 69 65 { 70 - ide_drive_t *drive = (ide_drive_t *)data; 71 - int len = 0, i = 0; 66 + ide_drive_t*drive = (ide_drive_t *)m->private; 67 + 68 + seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive)); 69 + return 0; 70 + } 71 + 72 + static int idedisk_capacity_proc_open(struct inode *inode, struct file *file) 73 + { 74 + return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data); 75 + } 76 + 77 + static const struct file_operations idedisk_capacity_proc_fops = { 78 + .owner = THIS_MODULE, 79 + .open = idedisk_capacity_proc_open, 80 + .read = seq_read, 81 + .llseek = seq_lseek, 82 + .release = single_release, 83 + }; 84 + 85 + static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd) 86 + { 87 + u8 *buf; 88 + 89 + buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); 90 + if (!buf) 91 + return -ENOMEM; 72 92 73 93 (void)smart_enable(drive); 74 94 75 - if (get_smart_data(drive, page, sub_cmd) == 0) { 76 - unsigned short *val = (unsigned short *) page; 77 - char *out = (char *)val + SECTOR_SIZE; 95 + if (get_smart_data(drive, buf, sub_cmd) == 0) { 96 + __le16 *val = (__le16 *)buf; 97 + int i; 78 98 79 - page = out; 80 - do { 81 - out += sprintf(out, "%04x%c", le16_to_cpu(*val), 82 - (++i & 7) ? ' ' : '\n'); 83 - val += 1; 84 - } while (i < SECTOR_SIZE / 2); 85 - len = out - page; 99 + for (i = 0; i < SECTOR_SIZE / 2; i++) { 100 + seq_printf(m, "%04x%c", le16_to_cpu(val[i]), 101 + (i % 8) == 7 ? '\n' : ' '); 102 + } 86 103 } 87 - 88 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 104 + kfree(buf); 105 + return 0; 89 106 } 90 107 91 - static int proc_idedisk_read_sv 92 - (char *page, char **start, off_t off, int count, int *eof, void *data) 108 + static int idedisk_sv_proc_show(struct seq_file *m, void *v) 93 109 { 94 - return proc_idedisk_read_smart(page, start, off, count, eof, data, 95 - ATA_SMART_READ_VALUES); 110 + return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES); 96 111 } 97 112 98 - static int proc_idedisk_read_st 99 - (char *page, char **start, off_t off, int count, int *eof, void *data) 113 + static int idedisk_sv_proc_open(struct inode *inode, struct file *file) 100 114 { 101 - return proc_idedisk_read_smart(page, start, off, count, eof, data, 102 - ATA_SMART_READ_THRESHOLDS); 115 + return single_open(file, idedisk_sv_proc_show, PDE(inode)->data); 103 116 } 117 + 118 + static const struct file_operations idedisk_sv_proc_fops = { 119 + .owner = THIS_MODULE, 120 + .open = idedisk_sv_proc_open, 121 + .read = seq_read, 122 + .llseek = seq_lseek, 123 + .release = single_release, 124 + }; 125 + 126 + static int idedisk_st_proc_show(struct seq_file *m, void *v) 127 + { 128 + return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS); 129 + } 130 + 131 + static int idedisk_st_proc_open(struct inode *inode, struct file *file) 132 + { 133 + return single_open(file, idedisk_st_proc_show, PDE(inode)->data); 134 + } 135 + 136 + static const struct file_operations idedisk_st_proc_fops = { 137 + .owner = THIS_MODULE, 138 + .open = idedisk_st_proc_open, 139 + .read = seq_read, 140 + .llseek = seq_lseek, 141 + .release = single_release, 142 + }; 104 143 105 144 ide_proc_entry_t ide_disk_proc[] = { 106 - { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, 107 - { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, 108 - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 109 - { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, 110 - { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, 111 - { NULL, 0, NULL, NULL } 145 + { "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops }, 146 + { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops }, 147 + { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, 148 + { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops }, 149 + { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops }, 150 + {} 112 151 }; 113 152 114 153 ide_devset_rw_field(bios_cyl, bios_cyl);
+21 -9
drivers/ide/ide-floppy_proc.c
··· 1 1 #include <linux/kernel.h> 2 2 #include <linux/ide.h> 3 + #include <linux/seq_file.h> 3 4 4 5 #include "ide-floppy.h" 5 6 6 - static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, 7 - int count, int *eof, void *data) 7 + static int idefloppy_capacity_proc_show(struct seq_file *m, void *v) 8 8 { 9 - ide_drive_t*drive = (ide_drive_t *)data; 10 - int len; 9 + ide_drive_t*drive = (ide_drive_t *)m->private; 11 10 12 - len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); 13 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 11 + seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive)); 12 + return 0; 14 13 } 15 14 15 + static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file) 16 + { 17 + return single_open(file, idefloppy_capacity_proc_show, PDE(inode)->data); 18 + } 19 + 20 + static const struct file_operations idefloppy_capacity_proc_fops = { 21 + .owner = THIS_MODULE, 22 + .open = idefloppy_capacity_proc_open, 23 + .read = seq_read, 24 + .llseek = seq_lseek, 25 + .release = single_release, 26 + }; 27 + 16 28 ide_proc_entry_t ide_floppy_proc[] = { 17 - { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, 18 - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 19 - { NULL, 0, NULL, NULL } 29 + { "capacity", S_IFREG|S_IRUGO, &idefloppy_capacity_proc_fops }, 30 + { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, 31 + {} 20 32 }; 21 33 22 34 ide_devset_rw_field(bios_cyl, bios_cyl);
+2 -6
drivers/ide/ide-ioctls.c
··· 167 167 err = -EINVAL; 168 168 goto abort; 169 169 } 170 + 171 + cmd.tf_flags |= IDE_TFLAG_SET_XFER; 170 172 } 171 173 172 174 err = ide_raw_taskfile(drive, &cmd, buf, args[3]); ··· 176 174 args[0] = tf->status; 177 175 args[1] = tf->error; 178 176 args[2] = tf->nsect; 179 - 180 - if (!err && xfer_rate) { 181 - /* active-retuning-calls future */ 182 - ide_set_xfer_rate(drive, xfer_rate); 183 - ide_driveid_update(drive); 184 - } 185 177 abort: 186 178 if (copy_to_user((void __user *)arg, &args, 4)) 187 179 err = -EFAULT;
+4 -13
drivers/ide/ide-iops.c
··· 102 102 * setting a timer to wake up at half second intervals thereafter, 103 103 * until timeout is achieved, before timing out. 104 104 */ 105 - static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, 106 - unsigned long timeout, u8 *rstat) 105 + int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, 106 + unsigned long timeout, u8 *rstat) 107 107 { 108 108 ide_hwif_t *hwif = drive->hwif; 109 109 const struct ide_tp_ops *tp_ops = hwif->tp_ops; ··· 292 292 "QUANTUM FIREBALLP KX27.3", 293 293 "QUANTUM FIREBALLP LM20.4", 294 294 "QUANTUM FIREBALLP LM20.5", 295 + "FUJITSU MHZ2160BH G2", 295 296 NULL 296 297 }; 297 298 ··· 317 316 return 0; 318 317 319 318 SELECT_MASK(drive, 1); 320 - rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id); 319 + rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id, 1); 321 320 SELECT_MASK(drive, 0); 322 321 323 322 if (rc) ··· 364 363 * this point (lost interrupt). 365 364 */ 366 365 367 - /* 368 - * FIXME: we race against the running IRQ here if 369 - * this is called from non IRQ context. If we use 370 - * disable_irq() we hang on the error path. Work 371 - * is needed. 372 - */ 373 - disable_irq_nosync(hwif->irq); 374 - 375 366 udelay(1); 376 367 tp_ops->dev_select(drive); 377 368 SELECT_MASK(drive, 1); ··· 386 393 WAIT_CMD, &stat); 387 394 388 395 SELECT_MASK(drive, 0); 389 - 390 - enable_irq(hwif->irq); 391 396 392 397 if (error) { 393 398 (void) ide_dump_status(drive, "set_drive_speed_status", stat);
+21 -10
drivers/ide/ide-probe.c
··· 238 238 * @drive: drive to identify 239 239 * @cmd: command to use 240 240 * @id: buffer for IDENTIFY data 241 + * @irq_ctx: flag set when called from the IRQ context 241 242 * 242 243 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response. 243 244 * ··· 247 246 * 2 device aborted the command (refused to identify itself) 248 247 */ 249 248 250 - int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) 249 + int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id, int irq_ctx) 251 250 { 252 251 ide_hwif_t *hwif = drive->hwif; 253 252 struct ide_io_ports *io_ports = &hwif->io_ports; ··· 264 263 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); 265 264 266 265 /* take a deep breath */ 267 - msleep(50); 266 + if (irq_ctx) 267 + mdelay(50); 268 + else 269 + msleep(50); 268 270 269 271 if (io_ports->ctl_addr && 270 272 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { ··· 299 295 300 296 timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 301 297 302 - if (ide_busy_sleep(drive, timeout, use_altstatus)) 303 - return 1; 304 - 305 298 /* wait for IRQ and ATA_DRQ */ 306 - msleep(50); 307 - s = tp_ops->read_status(hwif); 299 + if (irq_ctx) { 300 + rc = __ide_wait_stat(drive, ATA_DRQ, BAD_R_STAT, timeout, &s); 301 + if (rc) 302 + return 1; 303 + } else { 304 + rc = ide_busy_sleep(drive, timeout, use_altstatus); 305 + if (rc) 306 + return 1; 307 + 308 + msleep(50); 309 + s = tp_ops->read_status(hwif); 310 + } 308 311 309 312 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { 310 313 /* drive returned ID */ ··· 417 406 418 407 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 419 408 present || cmd == ATA_CMD_ID_ATAPI) { 420 - rc = ide_dev_read_id(drive, cmd, id); 409 + rc = ide_dev_read_id(drive, cmd, id, 0); 421 410 if (rc) 422 411 /* failed: try again */ 423 - rc = ide_dev_read_id(drive, cmd, id); 412 + rc = ide_dev_read_id(drive, cmd, id, 0); 424 413 425 414 stat = tp_ops->read_status(hwif); 426 415 ··· 435 424 msleep(50); 436 425 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 437 426 (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0); 438 - rc = ide_dev_read_id(drive, cmd, id); 427 + rc = ide_dev_read_id(drive, cmd, id, 0); 439 428 } 440 429 441 430 /* ensure drive IRQ is clear */
+221 -127
drivers/ide/ide-proc.c
··· 30 30 31 31 static struct proc_dir_entry *proc_ide_root; 32 32 33 - static int proc_ide_read_imodel 34 - (char *page, char **start, off_t off, int count, int *eof, void *data) 33 + static int ide_imodel_proc_show(struct seq_file *m, void *v) 35 34 { 36 - ide_hwif_t *hwif = (ide_hwif_t *) data; 37 - int len; 35 + ide_hwif_t *hwif = (ide_hwif_t *) m->private; 38 36 const char *name; 39 37 40 38 switch (hwif->chipset) { ··· 51 53 case ide_acorn: name = "acorn"; break; 52 54 default: name = "(unknown)"; break; 53 55 } 54 - len = sprintf(page, "%s\n", name); 55 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 56 + seq_printf(m, "%s\n", name); 57 + return 0; 56 58 } 57 59 58 - static int proc_ide_read_mate 59 - (char *page, char **start, off_t off, int count, int *eof, void *data) 60 + static int ide_imodel_proc_open(struct inode *inode, struct file *file) 60 61 { 61 - ide_hwif_t *hwif = (ide_hwif_t *) data; 62 - int len; 62 + return single_open(file, ide_imodel_proc_show, PDE(inode)->data); 63 + } 64 + 65 + static const struct file_operations ide_imodel_proc_fops = { 66 + .owner = THIS_MODULE, 67 + .open = ide_imodel_proc_open, 68 + .read = seq_read, 69 + .llseek = seq_lseek, 70 + .release = single_release, 71 + }; 72 + 73 + static int ide_mate_proc_show(struct seq_file *m, void *v) 74 + { 75 + ide_hwif_t *hwif = (ide_hwif_t *) m->private; 63 76 64 77 if (hwif && hwif->mate) 65 - len = sprintf(page, "%s\n", hwif->mate->name); 78 + seq_printf(m, "%s\n", hwif->mate->name); 66 79 else 67 - len = sprintf(page, "(none)\n"); 68 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 80 + seq_printf(m, "(none)\n"); 81 + return 0; 69 82 } 70 83 71 - static int proc_ide_read_channel 72 - (char *page, char **start, off_t off, int count, int *eof, void *data) 84 + static int ide_mate_proc_open(struct inode *inode, struct file *file) 73 85 { 74 - ide_hwif_t *hwif = (ide_hwif_t *) data; 75 - int len; 76 - 77 - page[0] = hwif->channel ? '1' : '0'; 78 - page[1] = '\n'; 79 - len = 2; 80 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 86 + return single_open(file, ide_mate_proc_show, PDE(inode)->data); 81 87 } 82 88 83 - static int proc_ide_read_identify 84 - (char *page, char **start, off_t off, int count, int *eof, void *data) 89 + static const struct file_operations ide_mate_proc_fops = { 90 + .owner = THIS_MODULE, 91 + .open = ide_mate_proc_open, 92 + .read = seq_read, 93 + .llseek = seq_lseek, 94 + .release = single_release, 95 + }; 96 + 97 + static int ide_channel_proc_show(struct seq_file *m, void *v) 85 98 { 86 - ide_drive_t *drive = (ide_drive_t *)data; 87 - int len = 0, i = 0; 88 - int err = 0; 99 + ide_hwif_t *hwif = (ide_hwif_t *) m->private; 89 100 90 - len = sprintf(page, "\n"); 101 + seq_printf(m, "%c\n", hwif->channel ? '1' : '0'); 102 + return 0; 103 + } 91 104 92 - if (drive) { 93 - __le16 *val = (__le16 *)page; 105 + static int ide_channel_proc_open(struct inode *inode, struct file *file) 106 + { 107 + return single_open(file, ide_channel_proc_show, PDE(inode)->data); 108 + } 94 109 95 - err = taskfile_lib_get_identify(drive, page); 96 - if (!err) { 97 - char *out = (char *)page + SECTOR_SIZE; 110 + static const struct file_operations ide_channel_proc_fops = { 111 + .owner = THIS_MODULE, 112 + .open = ide_channel_proc_open, 113 + .read = seq_read, 114 + .llseek = seq_lseek, 115 + .release = single_release, 116 + }; 98 117 99 - page = out; 100 - do { 101 - out += sprintf(out, "%04x%c", 102 - le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); 103 - val += 1; 104 - } while (i < SECTOR_SIZE / 2); 105 - len = out - page; 106 - } 118 + static int ide_identify_proc_show(struct seq_file *m, void *v) 119 + { 120 + ide_drive_t *drive = (ide_drive_t *)m->private; 121 + u8 *buf; 122 + 123 + if (!drive) { 124 + seq_putc(m, '\n'); 125 + return 0; 107 126 } 108 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 127 + 128 + buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); 129 + if (!buf) 130 + return -ENOMEM; 131 + if (taskfile_lib_get_identify(drive, buf) == 0) { 132 + __le16 *val = (__le16 *)buf; 133 + int i; 134 + 135 + for (i = 0; i < SECTOR_SIZE / 2; i++) { 136 + seq_printf(m, "%04x%c", le16_to_cpu(val[i]), 137 + (i % 8) == 7 ? '\n' : ' '); 138 + } 139 + } else 140 + seq_putc(m, buf[0]); 141 + kfree(buf); 142 + return 0; 109 143 } 144 + 145 + static int ide_identify_proc_open(struct inode *inode, struct file *file) 146 + { 147 + return single_open(file, ide_identify_proc_show, PDE(inode)->data); 148 + } 149 + 150 + static const struct file_operations ide_identify_proc_fops = { 151 + .owner = THIS_MODULE, 152 + .open = ide_identify_proc_open, 153 + .read = seq_read, 154 + .llseek = seq_lseek, 155 + .release = single_release, 156 + }; 110 157 111 158 /** 112 159 * ide_find_setting - find a specific setting ··· 238 195 static int set_xfer_rate (ide_drive_t *drive, int arg) 239 196 { 240 197 struct ide_cmd cmd; 241 - int err; 242 198 243 199 if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) 244 200 return -EINVAL; ··· 248 206 cmd.tf.nsect = (u8)arg; 249 207 cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; 250 208 cmd.valid.in.tf = IDE_VALID_NSECT; 209 + cmd.tf_flags = IDE_TFLAG_SET_XFER; 251 210 252 - err = ide_no_data_taskfile(drive, &cmd); 253 - 254 - if (!err) { 255 - ide_set_xfer_rate(drive, (u8) arg); 256 - ide_driveid_update(drive); 257 - } 258 - return err; 211 + return ide_no_data_taskfile(drive, &cmd); 259 212 } 260 213 261 214 ide_devset_rw(current_speed, xfer_rate); ··· 283 246 warned = 1; 284 247 } 285 248 286 - static int proc_ide_read_settings 287 - (char *page, char **start, off_t off, int count, int *eof, void *data) 249 + static int ide_settings_proc_show(struct seq_file *m, void *v) 288 250 { 289 251 const struct ide_proc_devset *setting, *g, *d; 290 252 const struct ide_devset *ds; 291 - ide_drive_t *drive = (ide_drive_t *) data; 292 - char *out = page; 293 - int len, rc, mul_factor, div_factor; 253 + ide_drive_t *drive = (ide_drive_t *) m->private; 254 + int rc, mul_factor, div_factor; 294 255 295 256 proc_ide_settings_warn(); 296 257 297 258 mutex_lock(&ide_setting_mtx); 298 259 g = ide_generic_settings; 299 260 d = drive->settings; 300 - out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); 301 - out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); 261 + seq_printf(m, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); 262 + seq_printf(m, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); 302 263 while (g->name || (d && d->name)) { 303 264 /* read settings in the alphabetical order */ 304 265 if (g->name && d && d->name) { ··· 310 275 setting = g++; 311 276 mul_factor = setting->mulf ? setting->mulf(drive) : 1; 312 277 div_factor = setting->divf ? setting->divf(drive) : 1; 313 - out += sprintf(out, "%-24s", setting->name); 278 + seq_printf(m, "%-24s", setting->name); 314 279 rc = ide_read_setting(drive, setting); 315 280 if (rc >= 0) 316 - out += sprintf(out, "%-16d", rc * mul_factor / div_factor); 281 + seq_printf(m, "%-16d", rc * mul_factor / div_factor); 317 282 else 318 - out += sprintf(out, "%-16s", "write-only"); 319 - out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); 283 + seq_printf(m, "%-16s", "write-only"); 284 + seq_printf(m, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); 320 285 ds = setting->setting; 321 286 if (ds->get) 322 - out += sprintf(out, "r"); 287 + seq_printf(m, "r"); 323 288 if (ds->set) 324 - out += sprintf(out, "w"); 325 - out += sprintf(out, "\n"); 289 + seq_printf(m, "w"); 290 + seq_printf(m, "\n"); 326 291 } 327 - len = out - page; 328 292 mutex_unlock(&ide_setting_mtx); 329 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 293 + return 0; 294 + } 295 + 296 + static int ide_settings_proc_open(struct inode *inode, struct file *file) 297 + { 298 + return single_open(file, ide_settings_proc_show, PDE(inode)->data); 330 299 } 331 300 332 301 #define MAX_LEN 30 333 302 334 - static int proc_ide_write_settings(struct file *file, const char __user *buffer, 335 - unsigned long count, void *data) 303 + static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer, 304 + size_t count, loff_t *pos) 336 305 { 337 - ide_drive_t *drive = (ide_drive_t *) data; 306 + ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; 338 307 char name[MAX_LEN + 1]; 339 308 int for_real = 0, mul_factor, div_factor; 340 309 unsigned long n; ··· 433 394 return count; 434 395 parse_error: 435 396 free_page((unsigned long)buf); 436 - printk("proc_ide_write_settings(): parse error\n"); 397 + printk("%s(): parse error\n", __func__); 437 398 return -EINVAL; 438 399 } 439 400 440 - int proc_ide_read_capacity 441 - (char *page, char **start, off_t off, int count, int *eof, void *data) 401 + static const struct file_operations ide_settings_proc_fops = { 402 + .owner = THIS_MODULE, 403 + .open = ide_settings_proc_open, 404 + .read = seq_read, 405 + .llseek = seq_lseek, 406 + .release = single_release, 407 + .write = ide_settings_proc_write, 408 + }; 409 + 410 + static int ide_capacity_proc_show(struct seq_file *m, void *v) 442 411 { 443 - int len = sprintf(page, "%llu\n", (long long)0x7fffffff); 444 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 412 + seq_printf(m, "%llu\n", (long long)0x7fffffff); 413 + return 0; 445 414 } 446 415 447 - EXPORT_SYMBOL_GPL(proc_ide_read_capacity); 448 - 449 - int proc_ide_read_geometry 450 - (char *page, char **start, off_t off, int count, int *eof, void *data) 416 + static int ide_capacity_proc_open(struct inode *inode, struct file *file) 451 417 { 452 - ide_drive_t *drive = (ide_drive_t *) data; 453 - char *out = page; 454 - int len; 418 + return single_open(file, ide_capacity_proc_show, NULL); 419 + } 455 420 456 - out += sprintf(out, "physical %d/%d/%d\n", 421 + const struct file_operations ide_capacity_proc_fops = { 422 + .owner = THIS_MODULE, 423 + .open = ide_capacity_proc_open, 424 + .read = seq_read, 425 + .llseek = seq_lseek, 426 + .release = single_release, 427 + }; 428 + EXPORT_SYMBOL_GPL(ide_capacity_proc_fops); 429 + 430 + static int ide_geometry_proc_show(struct seq_file *m, void *v) 431 + { 432 + ide_drive_t *drive = (ide_drive_t *) m->private; 433 + 434 + seq_printf(m, "physical %d/%d/%d\n", 457 435 drive->cyl, drive->head, drive->sect); 458 - out += sprintf(out, "logical %d/%d/%d\n", 436 + seq_printf(m, "logical %d/%d/%d\n", 459 437 drive->bios_cyl, drive->bios_head, drive->bios_sect); 460 - 461 - len = out - page; 462 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 438 + return 0; 463 439 } 464 440 465 - EXPORT_SYMBOL(proc_ide_read_geometry); 466 - 467 - static int proc_ide_read_dmodel 468 - (char *page, char **start, off_t off, int count, int *eof, void *data) 441 + static int ide_geometry_proc_open(struct inode *inode, struct file *file) 469 442 { 470 - ide_drive_t *drive = (ide_drive_t *) data; 443 + return single_open(file, ide_geometry_proc_show, PDE(inode)->data); 444 + } 445 + 446 + const struct file_operations ide_geometry_proc_fops = { 447 + .owner = THIS_MODULE, 448 + .open = ide_geometry_proc_open, 449 + .read = seq_read, 450 + .llseek = seq_lseek, 451 + .release = single_release, 452 + }; 453 + EXPORT_SYMBOL(ide_geometry_proc_fops); 454 + 455 + static int ide_dmodel_proc_show(struct seq_file *seq, void *v) 456 + { 457 + ide_drive_t *drive = (ide_drive_t *) seq->private; 471 458 char *m = (char *)&drive->id[ATA_ID_PROD]; 472 - int len; 473 459 474 - len = sprintf(page, "%.40s\n", m[0] ? m : "(none)"); 475 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 460 + seq_printf(seq, "%.40s\n", m[0] ? m : "(none)"); 461 + return 0; 476 462 } 477 463 478 - static int proc_ide_read_driver 479 - (char *page, char **start, off_t off, int count, int *eof, void *data) 464 + static int ide_dmodel_proc_open(struct inode *inode, struct file *file) 480 465 { 481 - ide_drive_t *drive = (ide_drive_t *)data; 466 + return single_open(file, ide_dmodel_proc_show, PDE(inode)->data); 467 + } 468 + 469 + static const struct file_operations ide_dmodel_proc_fops = { 470 + .owner = THIS_MODULE, 471 + .open = ide_dmodel_proc_open, 472 + .read = seq_read, 473 + .llseek = seq_lseek, 474 + .release = single_release, 475 + }; 476 + 477 + static int ide_driver_proc_show(struct seq_file *m, void *v) 478 + { 479 + ide_drive_t *drive = (ide_drive_t *)m->private; 482 480 struct device *dev = &drive->gendev; 483 481 struct ide_driver *ide_drv; 484 - int len; 485 482 486 483 if (dev->driver) { 487 484 ide_drv = to_ide_driver(dev->driver); 488 - len = sprintf(page, "%s version %s\n", 485 + seq_printf(m, "%s version %s\n", 489 486 dev->driver->name, ide_drv->version); 490 487 } else 491 - len = sprintf(page, "ide-default version 0.9.newide\n"); 492 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 488 + seq_printf(m, "ide-default version 0.9.newide\n"); 489 + return 0; 490 + } 491 + 492 + static int ide_driver_proc_open(struct inode *inode, struct file *file) 493 + { 494 + return single_open(file, ide_driver_proc_show, PDE(inode)->data); 493 495 } 494 496 495 497 static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) ··· 560 480 return ret; 561 481 } 562 482 563 - static int proc_ide_write_driver 564 - (struct file *file, const char __user *buffer, unsigned long count, void *data) 483 + static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer, 484 + size_t count, loff_t *pos) 565 485 { 566 - ide_drive_t *drive = (ide_drive_t *) data; 486 + ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data; 567 487 char name[32]; 568 488 569 489 if (!capable(CAP_SYS_ADMIN)) ··· 578 498 return count; 579 499 } 580 500 581 - static int proc_ide_read_media 582 - (char *page, char **start, off_t off, int count, int *eof, void *data) 501 + static const struct file_operations ide_driver_proc_fops = { 502 + .owner = THIS_MODULE, 503 + .open = ide_driver_proc_open, 504 + .read = seq_read, 505 + .llseek = seq_lseek, 506 + .release = single_release, 507 + .write = ide_driver_proc_write, 508 + }; 509 + 510 + static int ide_media_proc_show(struct seq_file *m, void *v) 583 511 { 584 - ide_drive_t *drive = (ide_drive_t *) data; 512 + ide_drive_t *drive = (ide_drive_t *) m->private; 585 513 const char *media; 586 - int len; 587 514 588 515 switch (drive->media) { 589 516 case ide_disk: media = "disk\n"; break; ··· 600 513 case ide_optical: media = "optical\n"; break; 601 514 default: media = "UNKNOWN\n"; break; 602 515 } 603 - strcpy(page, media); 604 - len = strlen(media); 605 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 516 + seq_puts(m, media); 517 + return 0; 606 518 } 607 519 520 + static int ide_media_proc_open(struct inode *inode, struct file *file) 521 + { 522 + return single_open(file, ide_media_proc_show, PDE(inode)->data); 523 + } 524 + 525 + static const struct file_operations ide_media_proc_fops = { 526 + .owner = THIS_MODULE, 527 + .open = ide_media_proc_open, 528 + .read = seq_read, 529 + .llseek = seq_lseek, 530 + .release = single_release, 531 + }; 532 + 608 533 static ide_proc_entry_t generic_drive_entries[] = { 609 - { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, 610 - proc_ide_write_driver }, 611 - { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, 612 - { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, 613 - { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, 614 - { "settings", S_IFREG|S_IRUSR|S_IWUSR, proc_ide_read_settings, 615 - proc_ide_write_settings }, 616 - { NULL, 0, NULL, NULL } 534 + { "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops }, 535 + { "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops}, 536 + { "media", S_IFREG|S_IRUGO, &ide_media_proc_fops }, 537 + { "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops }, 538 + { "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops}, 539 + {} 617 540 }; 618 541 619 542 static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data) ··· 633 536 if (!dir || !p) 634 537 return; 635 538 while (p->name != NULL) { 636 - ent = create_proc_entry(p->name, p->mode, dir); 539 + ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data); 637 540 if (!ent) return; 638 - ent->data = data; 639 - ent->read_proc = p->read_proc; 640 - ent->write_proc = p->write_proc; 641 541 p++; 642 542 } 643 543 } ··· 717 623 } 718 624 719 625 static ide_proc_entry_t hwif_entries[] = { 720 - { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL }, 721 - { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL }, 722 - { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL }, 723 - { NULL, 0, NULL, NULL } 626 + { "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops }, 627 + { "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops }, 628 + { "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops }, 629 + {} 724 630 }; 725 631 726 632 void ide_proc_register_port(ide_hwif_t *hwif)
+78 -82
drivers/ide/ide-tape.c
··· 31 31 #include <linux/major.h> 32 32 #include <linux/errno.h> 33 33 #include <linux/genhd.h> 34 + #include <linux/seq_file.h> 34 35 #include <linux/slab.h> 35 36 #include <linux/pci.h> 36 37 #include <linux/ide.h> ··· 48 47 #include <asm/unaligned.h> 49 48 #include <linux/mtio.h> 50 49 51 - enum { 52 - /* output errors only */ 53 - DBG_ERR = (1 << 0), 54 - /* output all sense key/asc */ 55 - DBG_SENSE = (1 << 1), 56 - /* info regarding all chrdev-related procedures */ 57 - DBG_CHRDEV = (1 << 2), 58 - /* all remaining procedures */ 59 - DBG_PROCS = (1 << 3), 60 - }; 61 - 62 50 /* define to see debug info */ 63 - #define IDETAPE_DEBUG_LOG 0 51 + #undef IDETAPE_DEBUG_LOG 64 52 65 - #if IDETAPE_DEBUG_LOG 66 - #define debug_log(lvl, fmt, args...) \ 67 - { \ 68 - if (tape->debug_mask & lvl) \ 69 - printk(KERN_INFO "ide-tape: " fmt, ## args); \ 70 - } 53 + #ifdef IDETAPE_DEBUG_LOG 54 + #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 71 55 #else 72 - #define debug_log(lvl, fmt, args...) do {} while (0) 56 + #define ide_debug_log(lvl, fmt, args...) do {} while (0) 73 57 #endif 74 58 75 59 /**************************** Tunable parameters *****************************/ ··· 156 170 * other device. Note that at most we will have only one DSC (usually 157 171 * data transfer) request in the device request queue. 158 172 */ 159 - struct request *postponed_rq; 173 + bool postponed_rq; 174 + 160 175 /* The time in which we started polling for DSC */ 161 176 unsigned long dsc_polling_start; 162 177 /* Timer used to poll for dsc */ ··· 217 230 char drv_write_prot; 218 231 /* the tape is write protected (hardware or opened as read-only) */ 219 232 char write_prot; 220 - 221 - u32 debug_mask; 222 233 } idetape_tape_t; 223 234 224 235 static DEFINE_MUTEX(idetape_ref_mutex); ··· 275 290 tape->asc = sense[12]; 276 291 tape->ascq = sense[13]; 277 292 278 - debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", 279 - pc->c[0], tape->sense_key, tape->asc, tape->ascq); 293 + ide_debug_log(IDE_DBG_FUNC, 294 + "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x", 295 + rq->cmd[0], tape->sense_key, tape->asc, tape->ascq); 280 296 281 297 /* correct remaining bytes to transfer */ 282 298 if (pc->flags & PC_FLAG_DMA_ERROR) ··· 330 344 int uptodate = pc->error ? 0 : 1; 331 345 int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; 332 346 333 - debug_log(DBG_PROCS, "Enter %s\n", __func__); 347 + ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0], 348 + dsc, err); 334 349 335 350 if (dsc) 336 351 ide_tape_handle_dsc(drive); ··· 374 387 * Postpone the current request so that ide.c will be able to service requests 375 388 * from another device on the same port while we are polling for DSC. 376 389 */ 377 - static void idetape_postpone_request(ide_drive_t *drive) 390 + static void ide_tape_stall_queue(ide_drive_t *drive) 378 391 { 379 392 idetape_tape_t *tape = drive->driver_data; 380 393 381 - debug_log(DBG_PROCS, "Enter %s\n", __func__); 394 + ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu", 395 + drive->hwif->rq->cmd[0], tape->dsc_poll_freq); 382 396 383 - tape->postponed_rq = drive->hwif->rq; 397 + tape->postponed_rq = true; 384 398 385 399 ide_stall_queue(drive, tape->dsc_poll_freq); 386 400 } ··· 395 407 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; 396 408 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; 397 409 /* Allow ide.c to handle other requests */ 398 - idetape_postpone_request(drive); 410 + ide_tape_stall_queue(drive); 399 411 } 400 412 401 413 /* ··· 476 488 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); 477 489 return ide_stopped; 478 490 } 479 - debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 491 + ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries, 492 + pc->c[0]); 480 493 481 494 pc->retries++; 482 495 ··· 568 579 ide_hwif_t *hwif = drive->hwif; 569 580 idetape_tape_t *tape = drive->driver_data; 570 581 struct ide_atapi_pc *pc = NULL; 571 - struct request *postponed_rq = tape->postponed_rq; 572 582 struct ide_cmd cmd; 573 583 u8 stat; 574 584 575 - debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" 576 - (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); 585 + ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", 586 + rq->cmd[0], (unsigned long long)blk_rq_pos(rq), 587 + blk_rq_sectors(rq)); 577 588 578 589 BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); 579 590 ··· 582 593 pc = drive->failed_pc; 583 594 goto out; 584 595 } 585 - 586 - if (postponed_rq != NULL) 587 - if (rq != postponed_rq) { 588 - printk(KERN_ERR "ide-tape: ide-tape.c bug - " 589 - "Two DSC requests were queued\n"); 590 - drive->failed_pc = NULL; 591 - rq->errors = 0; 592 - ide_complete_rq(drive, 0, blk_rq_bytes(rq)); 593 - return ide_stopped; 594 - } 595 - 596 - tape->postponed_rq = NULL; 597 596 598 597 /* 599 598 * If the tape is still busy, postpone our request and service ··· 600 623 601 624 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && 602 625 !(stat & ATA_DSC)) { 603 - if (postponed_rq == NULL) { 626 + if (!tape->postponed_rq) { 604 627 tape->dsc_polling_start = jiffies; 605 628 tape->dsc_poll_freq = tape->best_dsc_rw_freq; 606 629 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; ··· 617 640 tape->dsc_polling_start + 618 641 IDETAPE_DSC_MA_THRESHOLD)) 619 642 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 620 - idetape_postpone_request(drive); 643 + ide_tape_stall_queue(drive); 621 644 return ide_stopped; 622 - } else 645 + } else { 623 646 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; 647 + tape->postponed_rq = false; 648 + } 624 649 625 650 if (rq->cmd[13] & REQ_IDETAPE_READ) { 626 651 pc = &tape->queued_pc; ··· 724 745 struct ide_atapi_pc pc; 725 746 u8 buf[20]; 726 747 727 - debug_log(DBG_PROCS, "Enter %s\n", __func__); 748 + ide_debug_log(IDE_DBG_FUNC, "enter"); 728 749 729 750 /* prep cmd */ 730 751 ide_init_pc(&pc); ··· 735 756 return -1; 736 757 737 758 if (!pc.error) { 738 - debug_log(DBG_SENSE, "BOP - %s\n", 759 + ide_debug_log(IDE_DBG_FUNC, "BOP - %s", 739 760 (buf[0] & 0x80) ? "Yes" : "No"); 740 - debug_log(DBG_SENSE, "EOP - %s\n", 761 + ide_debug_log(IDE_DBG_FUNC, "EOP - %s", 741 762 (buf[0] & 0x40) ? "Yes" : "No"); 742 763 743 764 if (buf[0] & 0x4) { ··· 747 768 &drive->atapi_flags); 748 769 return -1; 749 770 } else { 750 - debug_log(DBG_SENSE, "Block Location - %u\n", 751 - be32_to_cpup((__be32 *)&buf[4])); 771 + ide_debug_log(IDE_DBG_FUNC, "Block Location: %u", 772 + be32_to_cpup((__be32 *)&buf[4])); 752 773 753 774 tape->partition = buf[1]; 754 775 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); ··· 845 866 struct request *rq; 846 867 int ret; 847 868 848 - debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); 869 + ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size); 870 + 849 871 BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); 850 872 BUG_ON(size < 0 || size % tape->blk_size); 851 873 ··· 1009 1029 struct ide_atapi_pc pc; 1010 1030 int ret; 1011 1031 1012 - debug_log(DBG_SENSE, "Enter %s\n", __func__); 1032 + ide_debug_log(IDE_DBG_FUNC, "enter"); 1013 1033 1014 1034 idetape_create_rewind_cmd(drive, &pc); 1015 1035 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); ··· 1035 1055 int nr_stages; 1036 1056 } config; 1037 1057 1038 - debug_log(DBG_PROCS, "Enter %s\n", __func__); 1058 + ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd); 1039 1059 1040 1060 switch (cmd) { 1041 1061 case 0x0340: ··· 1064 1084 struct ide_atapi_pc pc; 1065 1085 int retval, count = 0; 1066 1086 int sprev = !!(tape->caps[4] & 0x20); 1087 + 1088 + 1089 + ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count); 1067 1090 1068 1091 if (mt_count == 0) 1069 1092 return 0; ··· 1131 1148 ssize_t ret = 0; 1132 1149 int rc; 1133 1150 1134 - debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 1151 + ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1135 1152 1136 1153 if (tape->chrdev_dir != IDETAPE_DIR_READ) { 1137 1154 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) ··· 1170 1187 } 1171 1188 1172 1189 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { 1173 - debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); 1174 - 1175 1190 idetape_space_over_filemarks(drive, MTFSF, 1); 1176 1191 return 0; 1177 1192 } ··· 1190 1209 if (tape->write_prot) 1191 1210 return -EACCES; 1192 1211 1193 - debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 1212 + ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1194 1213 1195 1214 /* Initialize write operation */ 1196 1215 rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); ··· 1254 1273 struct ide_atapi_pc pc; 1255 1274 int i, retval; 1256 1275 1257 - debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", 1258 - mt_op, mt_count); 1276 + ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d", 1277 + mt_op, mt_count); 1259 1278 1260 1279 switch (mt_op) { 1261 1280 case MTFSF: ··· 1374 1393 int block_offset = 0, position = tape->first_frame; 1375 1394 void __user *argp = (void __user *)arg; 1376 1395 1377 - debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); 1396 + ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd); 1378 1397 1379 1398 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 1380 1399 ide_tape_flush_merge_buffer(drive); ··· 1442 1461 (buf[4 + 6] << 8) + 1443 1462 buf[4 + 7]; 1444 1463 tape->drv_write_prot = (buf[2] & 0x80) >> 7; 1464 + 1465 + ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d", 1466 + tape->blk_size, tape->drv_write_prot); 1445 1467 } 1446 1468 1447 1469 static int idetape_chrdev_open(struct inode *inode, struct file *filp) ··· 1464 1480 return -ENXIO; 1465 1481 } 1466 1482 1467 - debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 1483 + drive = tape->drive; 1484 + filp->private_data = tape; 1485 + 1486 + ide_debug_log(IDE_DBG_FUNC, "enter"); 1468 1487 1469 1488 /* 1470 1489 * We really want to do nonseekable_open(inode, filp); here, but some ··· 1476 1489 */ 1477 1490 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1478 1491 1479 - drive = tape->drive; 1480 - 1481 - filp->private_data = tape; 1482 1492 1483 1493 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { 1484 1494 retval = -EBUSY; ··· 1554 1570 lock_kernel(); 1555 1571 tape = drive->driver_data; 1556 1572 1557 - debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 1573 + ide_debug_log(IDE_DBG_FUNC, "enter"); 1558 1574 1559 1575 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 1560 1576 idetape_write_release(drive, minor); ··· 1691 1707 1692 1708 ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 1693 1709 1694 - ide_tape_devset_rw_field(debug_mask, debug_mask); 1695 1710 ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); 1696 1711 1697 1712 ide_tape_devset_r_field(avg_speed, avg_speed); ··· 1702 1719 __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), 1703 1720 __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), 1704 1721 __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), 1705 - __IDE_PROC_DEVSET(debug_mask, 0, 0xffff, NULL, NULL), 1706 1722 __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), 1707 1723 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), 1708 1724 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, ··· 1728 1746 int buffer_size; 1729 1747 u16 *ctl = (u16 *)&tape->caps[12]; 1730 1748 1731 - drive->pc_callback = ide_tape_callback; 1749 + ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor); 1750 + 1751 + drive->pc_callback = ide_tape_callback; 1732 1752 1733 1753 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 1734 1754 ··· 1817 1833 } 1818 1834 1819 1835 #ifdef CONFIG_IDE_PROC_FS 1820 - static int proc_idetape_read_name 1821 - (char *page, char **start, off_t off, int count, int *eof, void *data) 1836 + static int idetape_name_proc_show(struct seq_file *m, void *v) 1822 1837 { 1823 - ide_drive_t *drive = (ide_drive_t *) data; 1838 + ide_drive_t *drive = (ide_drive_t *) m->private; 1824 1839 idetape_tape_t *tape = drive->driver_data; 1825 - char *out = page; 1826 - int len; 1827 1840 1828 - len = sprintf(out, "%s\n", tape->name); 1829 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1841 + seq_printf(m, "%s\n", tape->name); 1842 + return 0; 1830 1843 } 1831 1844 1845 + static int idetape_name_proc_open(struct inode *inode, struct file *file) 1846 + { 1847 + return single_open(file, idetape_name_proc_show, PDE(inode)->data); 1848 + } 1849 + 1850 + static const struct file_operations idetape_name_proc_fops = { 1851 + .owner = THIS_MODULE, 1852 + .open = idetape_name_proc_open, 1853 + .read = seq_read, 1854 + .llseek = seq_lseek, 1855 + .release = single_release, 1856 + }; 1857 + 1832 1858 static ide_proc_entry_t idetape_proc[] = { 1833 - { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL }, 1834 - { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, 1835 - { NULL, 0, NULL, NULL } 1859 + { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops }, 1860 + { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops }, 1861 + {} 1836 1862 }; 1837 1863 1838 1864 static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) ··· 1926 1932 struct gendisk *g; 1927 1933 int minor; 1928 1934 1929 - if (!strstr("ide-tape", drive->driver_req)) 1935 + ide_debug_log(IDE_DBG_FUNC, "enter"); 1936 + 1937 + if (!strstr(DRV_NAME, drive->driver_req)) 1930 1938 goto failed; 1931 1939 1932 1940 if (drive->media != ide_tape)
+64 -62
drivers/ide/ide-taskfile.c
··· 19 19 #include <linux/hdreg.h> 20 20 #include <linux/ide.h> 21 21 #include <linux/scatterlist.h> 22 + #include <linux/uaccess.h> 22 23 23 - #include <asm/uaccess.h> 24 24 #include <asm/io.h> 25 25 26 26 void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd) ··· 53 53 #endif 54 54 } 55 55 56 - int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) 56 + int taskfile_lib_get_identify(ide_drive_t *drive, u8 *buf) 57 57 { 58 58 struct ide_cmd cmd; 59 59 ··· 86 86 if (orig_cmd->protocol == ATA_PROT_PIO && 87 87 (orig_cmd->tf_flags & IDE_TFLAG_MULTI_PIO) && 88 88 drive->mult_count == 0) { 89 - printk(KERN_ERR "%s: multimode not set!\n", drive->name); 89 + pr_err("%s: multimode not set!\n", drive->name); 90 90 return ide_stopped; 91 91 } 92 92 ··· 214 214 } 215 215 216 216 if (stat & ATA_BUSY) 217 - printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); 217 + pr_err("%s: drive still BUSY!\n", drive->name); 218 218 219 219 return stat; 220 220 } ··· 225 225 ide_hwif_t *hwif = drive->hwif; 226 226 struct scatterlist *sg = hwif->sg_table; 227 227 struct scatterlist *cursg = cmd->cursg; 228 + unsigned long uninitialized_var(flags); 228 229 struct page *page; 229 - unsigned long flags; 230 230 unsigned int offset; 231 231 u8 *buf; 232 232 ··· 236 236 237 237 while (len) { 238 238 unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs); 239 + int page_is_high; 239 240 240 241 if (nr_bytes > PAGE_SIZE) 241 242 nr_bytes = PAGE_SIZE; ··· 248 247 page = nth_page(page, (offset >> PAGE_SHIFT)); 249 248 offset %= PAGE_SIZE; 250 249 251 - if (PageHighMem(page)) 250 + page_is_high = PageHighMem(page); 251 + if (page_is_high) 252 252 local_irq_save(flags); 253 253 254 254 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset; ··· 270 268 271 269 kunmap_atomic(buf, KM_BIO_SRC_IRQ); 272 270 273 - if (PageHighMem(page)) 271 + if (page_is_high) 274 272 local_irq_restore(flags); 275 273 276 274 len -= nr_bytes; ··· 324 322 void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat) 325 323 { 326 324 struct request *rq = drive->hwif->rq; 327 - u8 err = ide_read_error(drive); 325 + u8 err = ide_read_error(drive), nsect = cmd->tf.nsect; 326 + u8 set_xfer = !!(cmd->tf_flags & IDE_TFLAG_SET_XFER); 328 327 329 328 ide_complete_cmd(drive, cmd, stat, err); 330 329 rq->errors = err; 330 + 331 + if (err == 0 && set_xfer) { 332 + ide_set_xfer_rate(drive, nsect); 333 + ide_driveid_update(drive); 334 + } 335 + 331 336 ide_complete_rq(drive, err ? -EIO : 0, blk_rq_bytes(rq)); 332 337 } 333 338 ··· 407 398 408 399 if (ide_wait_stat(&startstop, drive, ATA_DRQ, 409 400 drive->bad_wstat, WAIT_DRQ)) { 410 - printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", 411 - drive->name, 401 + pr_err("%s: no DRQ after issuing %sWRITE%s\n", drive->name, 412 402 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "", 413 403 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : ""); 414 404 return startstop; ··· 457 449 blk_put_request(rq); 458 450 return error; 459 451 } 460 - 461 452 EXPORT_SYMBOL(ide_raw_taskfile); 462 453 463 454 int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd) ··· 482 475 u16 nsect = 0; 483 476 char __user *buf = (char __user *)arg; 484 477 485 - // printk("IDE Taskfile ...\n"); 486 - 487 478 req_task = kzalloc(tasksize, GFP_KERNEL); 488 - if (req_task == NULL) return -ENOMEM; 479 + if (req_task == NULL) 480 + return -ENOMEM; 489 481 if (copy_from_user(req_task, buf, tasksize)) { 490 482 kfree(req_task); 491 483 return -EFAULT; ··· 492 486 493 487 taskout = req_task->out_size; 494 488 taskin = req_task->in_size; 495 - 489 + 496 490 if (taskin > 65536 || taskout > 65536) { 497 491 err = -EINVAL; 498 492 goto abort; ··· 582 576 cmd.protocol = ATA_PROT_DMA; 583 577 584 578 switch (req_task->data_phase) { 585 - case TASKFILE_MULTI_OUT: 586 - if (!drive->mult_count) { 587 - /* (hs): give up if multcount is not set */ 588 - printk(KERN_ERR "%s: %s Multimode Write " \ 589 - "multcount is not set\n", 590 - drive->name, __func__); 591 - err = -EPERM; 592 - goto abort; 593 - } 594 - cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; 595 - /* fall through */ 596 - case TASKFILE_OUT: 597 - cmd.protocol = ATA_PROT_PIO; 598 - /* fall through */ 599 - case TASKFILE_OUT_DMAQ: 600 - case TASKFILE_OUT_DMA: 601 - cmd.tf_flags |= IDE_TFLAG_WRITE; 602 - nsect = taskout / SECTOR_SIZE; 603 - data_buf = outbuf; 604 - break; 605 - case TASKFILE_MULTI_IN: 606 - if (!drive->mult_count) { 607 - /* (hs): give up if multcount is not set */ 608 - printk(KERN_ERR "%s: %s Multimode Read failure " \ 609 - "multcount is not set\n", 610 - drive->name, __func__); 611 - err = -EPERM; 612 - goto abort; 613 - } 614 - cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; 615 - /* fall through */ 616 - case TASKFILE_IN: 617 - cmd.protocol = ATA_PROT_PIO; 618 - /* fall through */ 619 - case TASKFILE_IN_DMAQ: 620 - case TASKFILE_IN_DMA: 621 - nsect = taskin / SECTOR_SIZE; 622 - data_buf = inbuf; 623 - break; 624 - case TASKFILE_NO_DATA: 625 - cmd.protocol = ATA_PROT_NODATA; 626 - break; 627 - default: 628 - err = -EFAULT; 579 + case TASKFILE_MULTI_OUT: 580 + if (!drive->mult_count) { 581 + /* (hs): give up if multcount is not set */ 582 + pr_err("%s: %s Multimode Write multcount is not set\n", 583 + drive->name, __func__); 584 + err = -EPERM; 629 585 goto abort; 586 + } 587 + cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; 588 + /* fall through */ 589 + case TASKFILE_OUT: 590 + cmd.protocol = ATA_PROT_PIO; 591 + /* fall through */ 592 + case TASKFILE_OUT_DMAQ: 593 + case TASKFILE_OUT_DMA: 594 + cmd.tf_flags |= IDE_TFLAG_WRITE; 595 + nsect = taskout / SECTOR_SIZE; 596 + data_buf = outbuf; 597 + break; 598 + case TASKFILE_MULTI_IN: 599 + if (!drive->mult_count) { 600 + /* (hs): give up if multcount is not set */ 601 + pr_err("%s: %s Multimode Read multcount is not set\n", 602 + drive->name, __func__); 603 + err = -EPERM; 604 + goto abort; 605 + } 606 + cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; 607 + /* fall through */ 608 + case TASKFILE_IN: 609 + cmd.protocol = ATA_PROT_PIO; 610 + /* fall through */ 611 + case TASKFILE_IN_DMAQ: 612 + case TASKFILE_IN_DMA: 613 + nsect = taskin / SECTOR_SIZE; 614 + data_buf = inbuf; 615 + break; 616 + case TASKFILE_NO_DATA: 617 + cmd.protocol = ATA_PROT_NODATA; 618 + break; 619 + default: 620 + err = -EFAULT; 621 + goto abort; 630 622 } 631 623 632 624 if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA) ··· 633 629 nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect; 634 630 635 631 if (!nsect) { 636 - printk(KERN_ERR "%s: in/out command without data\n", 632 + pr_err("%s: in/out command without data\n", 637 633 drive->name); 638 634 err = -EFAULT; 639 635 goto abort; ··· 674 670 kfree(req_task); 675 671 kfree(outbuf); 676 672 kfree(inbuf); 677 - 678 - // printk("IDE Taskfile ioctl ended. rc = %i\n", err); 679 673 680 674 return err; 681 675 }
+1 -1
drivers/ide/palm_bk3710.c
··· 318 318 int i, rc; 319 319 struct ide_hw hw, *hws[] = { &hw }; 320 320 321 - clk = clk_get(&pdev->dev, "IDECLK"); 321 + clk = clk_get(&pdev->dev, NULL); 322 322 if (IS_ERR(clk)) 323 323 return -ENODEV; 324 324
+7 -23
include/linux/ide.h
··· 258 258 IDE_TFLAG_DYN = (1 << 5), 259 259 IDE_TFLAG_FS = (1 << 6), 260 260 IDE_TFLAG_MULTI_PIO = (1 << 7), 261 + IDE_TFLAG_SET_XFER = (1 << 8), 261 262 }; 262 263 263 264 enum { ··· 295 294 } out, in; 296 295 } valid; 297 296 298 - u8 tf_flags; 297 + u16 tf_flags; 299 298 u8 ftf_flags; /* for TASKFILE ioctl */ 300 299 int protocol; 301 300 ··· 919 918 typedef struct { 920 919 const char *name; 921 920 mode_t mode; 922 - read_proc_t *read_proc; 923 - write_proc_t *write_proc; 921 + const struct file_operations *proc_fops; 924 922 } ide_proc_entry_t; 925 923 926 924 void proc_ide_create(void); ··· 931 931 void ide_proc_register_driver(ide_drive_t *, struct ide_driver *); 932 932 void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *); 933 933 934 - read_proc_t proc_ide_read_capacity; 935 - read_proc_t proc_ide_read_geometry; 936 - 937 - /* 938 - * Standard exit stuff: 939 - */ 940 - #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \ 941 - { \ 942 - len -= off; \ 943 - if (len < count) { \ 944 - *eof = 1; \ 945 - if (len <= 0) \ 946 - return 0; \ 947 - } else \ 948 - len = count; \ 949 - *start = page + off; \ 950 - return len; \ 951 - } 934 + extern const struct file_operations ide_capacity_proc_fops; 935 + extern const struct file_operations ide_geometry_proc_fops; 952 936 #else 953 937 static inline void proc_ide_create(void) { ; } 954 938 static inline void proc_ide_destroy(void) { ; } ··· 944 960 struct ide_driver *driver) { ; } 945 961 static inline void ide_proc_unregister_driver(ide_drive_t *drive, 946 962 struct ide_driver *driver) { ; } 947 - #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 948 963 #endif 949 964 950 965 enum { ··· 1064 1081 1065 1082 int ide_busy_sleep(ide_drive_t *, unsigned long, int); 1066 1083 1084 + int __ide_wait_stat(ide_drive_t *, u8, u8, unsigned long, u8 *); 1067 1085 int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1068 1086 1069 1087 ide_startstop_t ide_do_park_unpark(ide_drive_t *, struct request *); ··· 1153 1169 1154 1170 int ide_taskfile_ioctl(ide_drive_t *, unsigned long); 1155 1171 1156 - int ide_dev_read_id(ide_drive_t *, u8, u16 *); 1172 + int ide_dev_read_id(ide_drive_t *, u8, u16 *, int); 1157 1173 1158 1174 extern int ide_driveid_update(ide_drive_t *); 1159 1175 extern int ide_config_drive_speed(ide_drive_t *, u8);