diff options
Diffstat (limited to 'drivers/ide/ide-floppy_ioctl.c')
-rw-r--r-- | drivers/ide/ide-floppy_ioctl.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index cd8a42027ede..9c2288234dea 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c | |||
@@ -47,15 +47,13 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
47 | return -EINVAL; | 47 | return -EINVAL; |
48 | 48 | ||
49 | ide_floppy_create_read_capacity_cmd(pc); | 49 | ide_floppy_create_read_capacity_cmd(pc); |
50 | pc->buf = &pc_buf[0]; | ||
51 | pc->buf_size = sizeof(pc_buf); | ||
52 | 50 | ||
53 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) { | 51 | if (ide_queue_pc_tail(drive, floppy->disk, pc, pc_buf, pc->req_xfer)) { |
54 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 52 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
55 | return -EIO; | 53 | return -EIO; |
56 | } | 54 | } |
57 | 55 | ||
58 | header_len = pc->buf[3]; | 56 | header_len = pc_buf[3]; |
59 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | 57 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
60 | 58 | ||
61 | u_index = 0; | 59 | u_index = 0; |
@@ -72,8 +70,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
72 | if (u_index >= u_array_size) | 70 | if (u_index >= u_array_size) |
73 | break; /* User-supplied buffer too small */ | 71 | break; /* User-supplied buffer too small */ |
74 | 72 | ||
75 | blocks = be32_to_cpup((__be32 *)&pc->buf[desc_start]); | 73 | blocks = be32_to_cpup((__be32 *)&pc_buf[desc_start]); |
76 | length = be16_to_cpup((__be16 *)&pc->buf[desc_start + 6]); | 74 | length = be16_to_cpup((__be16 *)&pc_buf[desc_start + 6]); |
77 | 75 | ||
78 | if (put_user(blocks, argp)) | 76 | if (put_user(blocks, argp)) |
79 | return -EFAULT; | 77 | return -EFAULT; |
@@ -94,40 +92,42 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
94 | return 0; | 92 | return 0; |
95 | } | 93 | } |
96 | 94 | ||
97 | static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b, | 95 | static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, |
98 | int l, int flags) | 96 | u8 *buf, int b, int l, |
97 | int flags) | ||
99 | { | 98 | { |
100 | ide_init_pc(pc); | 99 | ide_init_pc(pc); |
101 | pc->c[0] = GPCMD_FORMAT_UNIT; | 100 | pc->c[0] = GPCMD_FORMAT_UNIT; |
102 | pc->c[1] = 0x17; | 101 | pc->c[1] = 0x17; |
103 | 102 | ||
104 | memset(pc->buf, 0, 12); | 103 | memset(buf, 0, 12); |
105 | pc->buf[1] = 0xA2; | 104 | buf[1] = 0xA2; |
106 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ | 105 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ |
107 | 106 | ||
108 | if (flags & 1) /* Verify bit on... */ | 107 | if (flags & 1) /* Verify bit on... */ |
109 | pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */ | 108 | buf[1] ^= 0x20; /* ... turn off DCRT bit */ |
110 | pc->buf[3] = 8; | 109 | buf[3] = 8; |
111 | 110 | ||
112 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4])); | 111 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&buf[4])); |
113 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8])); | 112 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&buf[8])); |
114 | pc->buf_size = 12; | 113 | pc->req_xfer = 12; |
115 | pc->flags |= PC_FLAG_WRITING; | 114 | pc->flags |= PC_FLAG_WRITING; |
116 | } | 115 | } |
117 | 116 | ||
118 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) | 117 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) |
119 | { | 118 | { |
120 | struct ide_disk_obj *floppy = drive->driver_data; | 119 | struct ide_disk_obj *floppy = drive->driver_data; |
120 | u8 buf[20]; | ||
121 | 121 | ||
122 | drive->atapi_flags &= ~IDE_AFLAG_SRFP; | 122 | drive->atapi_flags &= ~IDE_AFLAG_SRFP; |
123 | 123 | ||
124 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE); | 124 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE); |
125 | pc->flags |= PC_FLAG_SUPPRESS_ERROR; | 125 | pc->flags |= PC_FLAG_SUPPRESS_ERROR; |
126 | 126 | ||
127 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 127 | if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) |
128 | return 1; | 128 | return 1; |
129 | 129 | ||
130 | if (pc->buf[8 + 2] & 0x40) | 130 | if (buf[8 + 2] & 0x40) |
131 | drive->atapi_flags |= IDE_AFLAG_SRFP; | 131 | drive->atapi_flags |= IDE_AFLAG_SRFP; |
132 | 132 | ||
133 | return 0; | 133 | return 0; |
@@ -137,6 +137,7 @@ static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
137 | int __user *arg) | 137 | int __user *arg) |
138 | { | 138 | { |
139 | struct ide_disk_obj *floppy = drive->driver_data; | 139 | struct ide_disk_obj *floppy = drive->driver_data; |
140 | u8 buf[12]; | ||
140 | int blocks, length, flags, err = 0; | 141 | int blocks, length, flags, err = 0; |
141 | 142 | ||
142 | if (floppy->openers > 1) { | 143 | if (floppy->openers > 1) { |
@@ -170,9 +171,9 @@ static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
170 | } | 171 | } |
171 | 172 | ||
172 | ide_floppy_get_sfrp_bit(drive, pc); | 173 | ide_floppy_get_sfrp_bit(drive, pc); |
173 | ide_floppy_create_format_unit_cmd(pc, blocks, length, flags); | 174 | ide_floppy_create_format_unit_cmd(pc, buf, blocks, length, flags); |
174 | 175 | ||
175 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 176 | if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) |
176 | err = -EIO; | 177 | err = -EIO; |
177 | 178 | ||
178 | out: | 179 | out: |
@@ -196,11 +197,13 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, | |||
196 | int __user *arg) | 197 | int __user *arg) |
197 | { | 198 | { |
198 | struct ide_disk_obj *floppy = drive->driver_data; | 199 | struct ide_disk_obj *floppy = drive->driver_data; |
200 | u8 sense_buf[18]; | ||
199 | int progress_indication = 0x10000; | 201 | int progress_indication = 0x10000; |
200 | 202 | ||
201 | if (drive->atapi_flags & IDE_AFLAG_SRFP) { | 203 | if (drive->atapi_flags & IDE_AFLAG_SRFP) { |
202 | ide_create_request_sense_cmd(drive, pc); | 204 | ide_create_request_sense_cmd(drive, pc); |
203 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 205 | if (ide_queue_pc_tail(drive, floppy->disk, pc, sense_buf, |
206 | pc->req_xfer)) | ||
204 | return -EIO; | 207 | return -EIO; |
205 | 208 | ||
206 | if (floppy->sense_key == 2 && | 209 | if (floppy->sense_key == 2 && |