diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:32:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:32:18 -0500 |
commit | 2640c9a90fa596871e142f42052608864335f102 (patch) | |
tree | bf0fb0e59b324963d650a7e82f83c1a4f993aa69 /drivers/ide/ide-floppy_ioctl.c | |
parent | 80618fa83a34a26199fa99cfd06476a81ddf57df (diff) | |
parent | b16aabc9374217fa2d28e72fd9a6e6d60905e1b9 (diff) |
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: (32 commits)
ide-atapi: start dma in a drive-specific way
ide-atapi: put the rest of non-ide-cd code into the else-clause of ide_transfer_pc
ide-atapi: remove timeout arg to ide_issue_pc
ide-cd: remove handler wrappers
ide-cd: remove xferlen arg to cdrom_start_packet_command
ide-atapi: split drive-specific functionality in ide_issue_pc
ide-atapi: assign expiry and timeout based on device type
ide-atapi: compute cmd_len based on device type in ide_transfer_pc
ide: remove the last ide-scsi remnants
ide-atapi: remove ide-scsi remnants from ide_pc_intr()
ide-atapi: remove ide-scsi remnants from ide_transfer_pc()
ide-atapi: remove ide-scsi remnants from ide_issue_pc
ide-cd: move cdrom_timer_expiry to ide-atapi.c
ide-atapi: teach ide atapi about drive->waiting_for_dma
ide-atapi: accomodate transfer length calculation for ide-cd
ide-atapi: setup dma for ide-cd
ide-atapi: combine drive-specific assignments
ide-atapi: add a dev_is_idecd-inline
remove ide-scsi
ide-floppy: allocate only toplevel packet commands
...
Diffstat (limited to 'drivers/ide/ide-floppy_ioctl.c')
-rw-r--r-- | drivers/ide/ide-floppy_ioctl.c | 58 |
1 files changed, 30 insertions, 28 deletions
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 | ||
34 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | 34 | static 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 | ||
114 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) | 115 | static 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 | ||
133 | static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) | 133 | static 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 | ||
175 | out: | 175 | out: |
@@ -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 | ||
191 | static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 191 | static 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 | ||
244 | static int ide_floppy_format_ioctl(ide_drive_t *drive, fmode_t mode, | 245 | static 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 | ||