aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-floppy.c26
-rw-r--r--drivers/ide/ide-floppy_ioctl.c58
2 files changed, 43 insertions, 41 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index aeb1ad782f54..1f07f3818938 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -342,38 +342,38 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
342 * Look at the flexible disk page parameters. We ignore the CHS capacity 342 * Look at the flexible disk page parameters. We ignore the CHS capacity
343 * parameters and use the LBA parameters instead. 343 * parameters and use the LBA parameters instead.
344 */ 344 */
345static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) 345static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive,
346 struct ide_atapi_pc *pc)
346{ 347{
347 struct ide_disk_obj *floppy = drive->driver_data; 348 struct ide_disk_obj *floppy = drive->driver_data;
348 struct gendisk *disk = floppy->disk; 349 struct gendisk *disk = floppy->disk;
349 struct ide_atapi_pc pc;
350 u8 *page; 350 u8 *page;
351 int capacity, lba_capacity; 351 int capacity, lba_capacity;
352 u16 transfer_rate, sector_size, cyls, rpm; 352 u16 transfer_rate, sector_size, cyls, rpm;
353 u8 heads, sectors; 353 u8 heads, sectors;
354 354
355 ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 355 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE);
356 356
357 if (ide_queue_pc_tail(drive, disk, &pc)) { 357 if (ide_queue_pc_tail(drive, disk, pc)) {
358 printk(KERN_ERR PFX "Can't get flexible disk page params\n"); 358 printk(KERN_ERR PFX "Can't get flexible disk page params\n");
359 return 1; 359 return 1;
360 } 360 }
361 361
362 if (pc.buf[3] & 0x80) 362 if (pc->buf[3] & 0x80)
363 drive->dev_flags |= IDE_DFLAG_WP; 363 drive->dev_flags |= IDE_DFLAG_WP;
364 else 364 else
365 drive->dev_flags &= ~IDE_DFLAG_WP; 365 drive->dev_flags &= ~IDE_DFLAG_WP;
366 366
367 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); 367 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP));
368 368
369 page = &pc.buf[8]; 369 page = &pc->buf[8];
370 370
371 transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); 371 transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]);
372 sector_size = be16_to_cpup((__be16 *)&pc.buf[8 + 6]); 372 sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]);
373 cyls = be16_to_cpup((__be16 *)&pc.buf[8 + 8]); 373 cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]);
374 rpm = be16_to_cpup((__be16 *)&pc.buf[8 + 28]); 374 rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]);
375 heads = pc.buf[8 + 4]; 375 heads = pc->buf[8 + 4];
376 sectors = pc.buf[8 + 5]; 376 sectors = pc->buf[8 + 5];
377 377
378 capacity = cyls * heads * sectors * sector_size; 378 capacity = cyls * heads * sectors * sector_size;
379 379
@@ -499,7 +499,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
499 499
500 /* Clik! disk does not support get_flexible_disk_page */ 500 /* Clik! disk does not support get_flexible_disk_page */
501 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 501 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
502 (void) ide_floppy_get_flexible_disk_page(drive); 502 (void) ide_floppy_get_flexible_disk_page(drive, &pc);
503 503
504 return rc; 504 return rc;
505} 505}
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index 2bc51ff73fee..8f8be8546038 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -31,10 +31,11 @@
31 * On exit we set nformats to the number of records we've actually initialized. 31 * On exit we set nformats to the number of records we've actually initialized.
32 */ 32 */
33 33
34static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) 34static int ide_floppy_get_format_capacities(ide_drive_t *drive,
35 struct ide_atapi_pc *pc,
36 int __user *arg)
35{ 37{
36 struct ide_disk_obj *floppy = drive->driver_data; 38 struct ide_disk_obj *floppy = drive->driver_data;
37 struct ide_atapi_pc pc;
38 u8 header_len, desc_cnt; 39 u8 header_len, desc_cnt;
39 int i, blocks, length, u_array_size, u_index; 40 int i, blocks, length, u_array_size, u_index;
40 int __user *argp; 41 int __user *argp;
@@ -45,13 +46,13 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
45 if (u_array_size <= 0) 46 if (u_array_size <= 0)
46 return -EINVAL; 47 return -EINVAL;
47 48
48 ide_floppy_create_read_capacity_cmd(&pc); 49 ide_floppy_create_read_capacity_cmd(pc);
49 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) { 50 if (ide_queue_pc_tail(drive, floppy->disk, pc)) {
50 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); 51 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n");
51 return -EIO; 52 return -EIO;
52 } 53 }
53 54
54 header_len = pc.buf[3]; 55 header_len = pc->buf[3];
55 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 56 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
56 57
57 u_index = 0; 58 u_index = 0;
@@ -68,8 +69,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
68 if (u_index >= u_array_size) 69 if (u_index >= u_array_size)
69 break; /* User-supplied buffer too small */ 70 break; /* User-supplied buffer too small */
70 71
71 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); 72 blocks = be32_to_cpup((__be32 *)&pc->buf[desc_start]);
72 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); 73 length = be16_to_cpup((__be16 *)&pc->buf[desc_start + 6]);
73 74
74 if (put_user(blocks, argp)) 75 if (put_user(blocks, argp))
75 return -EFAULT; 76 return -EFAULT;
@@ -111,29 +112,28 @@ static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b,
111 pc->flags |= PC_FLAG_WRITING; 112 pc->flags |= PC_FLAG_WRITING;
112} 113}
113 114
114static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) 115static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc)
115{ 116{
116 struct ide_disk_obj *floppy = drive->driver_data; 117 struct ide_disk_obj *floppy = drive->driver_data;
117 struct ide_atapi_pc pc;
118 118
119 drive->atapi_flags &= ~IDE_AFLAG_SRFP; 119 drive->atapi_flags &= ~IDE_AFLAG_SRFP;
120 120
121 ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); 121 ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE);
122 pc.flags |= PC_FLAG_SUPPRESS_ERROR; 122 pc->flags |= PC_FLAG_SUPPRESS_ERROR;
123 123
124 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 124 if (ide_queue_pc_tail(drive, floppy->disk, pc))
125 return 1; 125 return 1;
126 126
127 if (pc.buf[8 + 2] & 0x40) 127 if (pc->buf[8 + 2] & 0x40)
128 drive->atapi_flags |= IDE_AFLAG_SRFP; 128 drive->atapi_flags |= IDE_AFLAG_SRFP;
129 129
130 return 0; 130 return 0;
131} 131}
132 132
133static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) 133static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc,
134 int __user *arg)
134{ 135{
135 struct ide_disk_obj *floppy = drive->driver_data; 136 struct ide_disk_obj *floppy = drive->driver_data;
136 struct ide_atapi_pc pc;
137 int blocks, length, flags, err = 0; 137 int blocks, length, flags, err = 0;
138 138
139 if (floppy->openers > 1) { 139 if (floppy->openers > 1) {
@@ -166,10 +166,10 @@ static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
166 goto out; 166 goto out;
167 } 167 }
168 168
169 (void)ide_floppy_get_sfrp_bit(drive); 169 ide_floppy_get_sfrp_bit(drive, pc);
170 ide_floppy_create_format_unit_cmd(&pc, blocks, length, flags); 170 ide_floppy_create_format_unit_cmd(pc, blocks, length, flags);
171 171
172 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 172 if (ide_queue_pc_tail(drive, floppy->disk, pc))
173 err = -EIO; 173 err = -EIO;
174 174
175out: 175out:
@@ -188,15 +188,16 @@ out:
188 * the dsc bit, and return either 0 or 65536. 188 * the dsc bit, and return either 0 or 65536.
189 */ 189 */
190 190
191static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) 191static int ide_floppy_get_format_progress(ide_drive_t *drive,
192 struct ide_atapi_pc *pc,
193 int __user *arg)
192{ 194{
193 struct ide_disk_obj *floppy = drive->driver_data; 195 struct ide_disk_obj *floppy = drive->driver_data;
194 struct ide_atapi_pc pc;
195 int progress_indication = 0x10000; 196 int progress_indication = 0x10000;
196 197
197 if (drive->atapi_flags & IDE_AFLAG_SRFP) { 198 if (drive->atapi_flags & IDE_AFLAG_SRFP) {
198 ide_create_request_sense_cmd(drive, &pc); 199 ide_create_request_sense_cmd(drive, pc);
199 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 200 if (ide_queue_pc_tail(drive, floppy->disk, pc))
200 return -EIO; 201 return -EIO;
201 202
202 if (floppy->sense_key == 2 && 203 if (floppy->sense_key == 2 &&
@@ -241,20 +242,21 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
241 return 0; 242 return 0;
242} 243}
243 244
244static int ide_floppy_format_ioctl(ide_drive_t *drive, fmode_t mode, 245static int ide_floppy_format_ioctl(ide_drive_t *drive, struct ide_atapi_pc *pc,
245 unsigned int cmd, void __user *argp) 246 fmode_t mode, unsigned int cmd,
247 void __user *argp)
246{ 248{
247 switch (cmd) { 249 switch (cmd) {
248 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: 250 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
249 return 0; 251 return 0;
250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: 252 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
251 return ide_floppy_get_format_capacities(drive, argp); 253 return ide_floppy_get_format_capacities(drive, pc, argp);
252 case IDEFLOPPY_IOCTL_FORMAT_START: 254 case IDEFLOPPY_IOCTL_FORMAT_START:
253 if (!(mode & FMODE_WRITE)) 255 if (!(mode & FMODE_WRITE))
254 return -EPERM; 256 return -EPERM;
255 return ide_floppy_format_unit(drive, (int __user *)argp); 257 return ide_floppy_format_unit(drive, pc, (int __user *)argp);
256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: 258 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
257 return ide_floppy_get_format_progress(drive, argp); 259 return ide_floppy_get_format_progress(drive, pc, argp);
258 default: 260 default:
259 return -ENOTTY; 261 return -ENOTTY;
260 } 262 }
@@ -270,7 +272,7 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
270 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) 272 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
271 return ide_floppy_lockdoor(drive, &pc, arg, cmd); 273 return ide_floppy_lockdoor(drive, &pc, arg, cmd);
272 274
273 err = ide_floppy_format_ioctl(drive, mode, cmd, argp); 275 err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp);
274 if (err != -ENOTTY) 276 if (err != -ENOTTY)
275 return err; 277 return err;
276 278