aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:23 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:23 -0500
commit972560fb9d9ea7bc7082c0c79c99c24e3f56606c (patch)
treec7ca8212cc0dc85e22e04d9faf8744972fc62a93 /drivers/ide/ide-cd.c
parent89d13ec7c8b85f3c62a4a12034e65d3d2d3273a8 (diff)
ide-cd: move VERBOSE_IDE_CD_ERRORS code to ide-cd_verbose.c
* Rename ide-cd kernel module to ide-cd_mod in preparation to moving code out from ide-cd.[c,h]. Add MODULE_ALIAS("ide-cd") to preserve compatibility. * Move VERBOSE_IDE_CD_ERRORS code from ide-cd.[c,h] to ide-cd_verbose.c. ide-cd_verbose.c is IDE subsystem independent and may be easily converted into generic library usable by other drivers (i.e. libata) if needed. * Add CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS config option to drivers/ide/Kconfig replacing VERBOSE_IDE_CD_ERRORS define. Make this config option enabled by default and visible only if CONFIG_EMBEDDED is defined. before the patch: text data bss dec hex filename 22841 360 1056 24257 5ec1 drivers/ide/ide-cd.o after the patch w/ CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y: text data bss dec hex filename 22857 360 1056 24273 5ed1 drivers/ide/ide-cd_mod.o after the patch w/ CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=n: text data bss dec hex filename 15091 360 1056 16507 407b drivers/ide/ide-cd_mod.o Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c124
1 files changed, 2 insertions, 122 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 02488b48fa7a..f4a0264bea6d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -199,129 +199,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
199 } 199 }
200 } 200 }
201 } 201 }
202#if VERBOSE_IDE_CD_ERRORS
203 {
204 int i;
205 const char *s = "bad sense key!";
206 char buf[80];
207
208 printk(KERN_ERR "ATAPI device %s:\n", drive->name);
209 if (sense->error_code == 0x70)
210 printk(KERN_CONT " Error: ");
211 else if (sense->error_code == 0x71)
212 printk(" Deferred Error: ");
213 else if (sense->error_code == 0x7f)
214 printk(KERN_CONT " Vendor-specific Error: ");
215 else
216 printk(KERN_CONT " Unknown Error Type: ");
217
218 if (sense->sense_key < ARRAY_SIZE(sense_key_texts))
219 s = sense_key_texts[sense->sense_key];
220
221 printk(KERN_CONT "%s -- (Sense key=0x%02x)\n",
222 s, sense->sense_key);
223
224 if (sense->asc == 0x40) {
225 sprintf(buf, "Diagnostic failure on component 0x%02x",
226 sense->ascq);
227 s = buf;
228 } else {
229 int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts);
230 unsigned long key = (sense->sense_key << 16);
231
232 key |= (sense->asc << 8);
233 if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd))
234 key |= sense->ascq;
235 s = NULL;
236
237 while (hi > lo) {
238 mid = (lo + hi) / 2;
239 if (sense_data_texts[mid].asc_ascq == key ||
240 sense_data_texts[mid].asc_ascq == (0xff0000|key)) {
241 s = sense_data_texts[mid].text;
242 break;
243 } else if (sense_data_texts[mid].asc_ascq > key)
244 hi = mid;
245 else
246 lo = mid + 1;
247 }
248 }
249
250 if (s == NULL) {
251 if (sense->asc > 0x80)
252 s = "(vendor-specific error)";
253 else
254 s = "(reserved error code)";
255 }
256
257 printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n",
258 s, sense->asc, sense->ascq);
259
260 if (failed_command != NULL) {
261 int lo = 0, mid, hi = ARRAY_SIZE(packet_command_texts);
262 s = NULL;
263
264 while (hi > lo) {
265 mid = (lo + hi) / 2;
266 if (packet_command_texts[mid].packet_command ==
267 failed_command->cmd[0]) {
268 s = packet_command_texts[mid].text;
269 break;
270 }
271 if (packet_command_texts[mid].packet_command >
272 failed_command->cmd[0])
273 hi = mid;
274 else
275 lo = mid + 1;
276 }
277
278 printk(KERN_ERR " The failed \"%s\" packet command "
279 "was: \n \"", s);
280 for (i = 0; i < sizeof(failed_command->cmd); i++)
281 printk(KERN_CONT "%02x ",
282 failed_command->cmd[i]);
283 printk(KERN_CONT "\"\n");
284 }
285
286 /* The SKSV bit specifies validity of the sense_key_specific
287 * in the next two commands. It is bit 7 of the first byte.
288 * In the case of NOT_READY, if SKSV is set the drive can
289 * give us nice ETA readings.
290 */
291 if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) {
292 int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100;
293
294 printk(KERN_ERR " Command is %02d%% complete\n",
295 progress / 0xffff);
296 }
297
298 if (sense->sense_key == ILLEGAL_REQUEST &&
299 (sense->sks[0] & 0x80) != 0) {
300 printk(KERN_ERR " Error in %s byte %d",
301 (sense->sks[0] & 0x40) != 0 ?
302 "command packet" : "command data",
303 (sense->sks[1] << 8) + sense->sks[2]);
304
305 if ((sense->sks[0] & 0x40) != 0)
306 printk(KERN_CONT " bit %d",
307 sense->sks[0] & 0x07);
308
309 printk(KERN_CONT "\n");
310 }
311 }
312#else /* not VERBOSE_IDE_CD_ERRORS */
313 /* Suppress printing unit attention and `in progress of becoming ready'
314 errors when we're not being verbose. */
315 if (sense->sense_key == UNIT_ATTENTION ||
316 (sense->sense_key == NOT_READY && (sense->asc == 4 ||
317 sense->asc == 0x3a)))
318 return;
319 202
320 printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x " 203 ide_cd_log_error(drive->name, failed_command, sense);
321 "asc: 0x%02x ascq: 0x%02x\n",
322 drive->name, sense->error_code, sense->sense_key,
323 sense->asc, sense->ascq);
324#endif /* not VERBOSE_IDE_CD_ERRORS */
325} 204}
326 205
327/* 206/*
@@ -3189,6 +3068,7 @@ static int __init ide_cdrom_init(void)
3189} 3068}
3190 3069
3191MODULE_ALIAS("ide:*m-cdrom*"); 3070MODULE_ALIAS("ide:*m-cdrom*");
3071MODULE_ALIAS("ide-cd");
3192module_init(ide_cdrom_init); 3072module_init(ide_cdrom_init);
3193module_exit(ide_cdrom_exit); 3073module_exit(ide_cdrom_exit);
3194MODULE_LICENSE("GPL"); 3074MODULE_LICENSE("GPL");