aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-02-05 20:57:51 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:51 -0500
commit8004a8c9744842a5a32b71d3a8093c652972bb23 (patch)
treed39926bdd1e54a05dcf8a67d833c8a1d931302ee /drivers/ide/ide-tape.c
parent64a57fe4393bae920d03c253173f59d8a7ec8e25 (diff)
ide-tape: refactor the debug logging facility
Teach the debug logging macro to differentiate between log levels based on the type of debug level enabled specifically instead of a threshold-based one. Thus, convert tape->debug_level to a bitmask that is written to over /proc. Also, - cleanup and simplify the debug macro thus removing a lot of code lines, - get rid of unused debug levels, - adjust the loglevel at several places where it was simply missing (e.g. idetape_chrdev_open()) - move the tape ptr initialization up in idetape_chrdev_open() so that we can use it in the debug_log macro earlier in the function. Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c344
1 files changed, 122 insertions, 222 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 401731302c5c..64d46fef2602 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -45,6 +45,32 @@
45#include <asm/unaligned.h> 45#include <asm/unaligned.h>
46#include <linux/mtio.h> 46#include <linux/mtio.h>
47 47
48enum {
49 /* output errors only */
50 DBG_ERR = (1 << 0),
51 /* output all sense key/asc */
52 DBG_SENSE = (1 << 1),
53 /* info regarding all chrdev-related procedures */
54 DBG_CHRDEV = (1 << 2),
55 /* all remaining procedures */
56 DBG_PROCS = (1 << 3),
57 /* buffer alloc info (pc_stack & rq_stack) */
58 DBG_PCRQ_STACK = (1 << 4),
59};
60
61/* define to see debug info */
62#define IDETAPE_DEBUG_LOG 0
63
64#if IDETAPE_DEBUG_LOG
65#define debug_log(lvl, fmt, args...) \
66{ \
67 if (tape->debug_mask & lvl) \
68 printk(KERN_INFO "ide-tape: " fmt, ## args); \
69}
70#else
71#define debug_log(lvl, fmt, args...) do {} while (0)
72#endif
73
48/**************************** Tunable parameters *****************************/ 74/**************************** Tunable parameters *****************************/
49 75
50 76
@@ -68,23 +94,6 @@
68#define IDETAPE_INCREASE_STAGES_RATE 20 94#define IDETAPE_INCREASE_STAGES_RATE 20
69 95
70/* 96/*
71 * The following are used to debug the driver:
72 *
73 * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control.
74 *
75 * Setting them to 0 will restore normal operation mode:
76 *
77 * 1. Disable logging normal successful operations.
78 * 2. Disable self-sanity checks.
79 * 3. Errors will still be logged, of course.
80 *
81 * All the #if DEBUG code will be removed some day, when the driver
82 * is verified to be stable enough. This will make it much more
83 * esthetic.
84 */
85#define IDETAPE_DEBUG_LOG 0
86
87/*
88 * After each failed packet command we issue a request sense command 97 * After each failed packet command we issue a request sense command
89 * and retry the packet command IDETAPE_MAX_PC_RETRIES times. 98 * and retry the packet command IDETAPE_MAX_PC_RETRIES times.
90 * 99 *
@@ -451,18 +460,7 @@ typedef struct ide_tape_obj {
451 unsigned long uncontrolled_previous_head_time; 460 unsigned long uncontrolled_previous_head_time;
452 int restart_speed_control_req; 461 int restart_speed_control_req;
453 462
454 /* 463 u32 debug_mask;
455 * Debug_level determines amount of debugging output;
456 * can be changed using /proc/ide/hdx/settings
457 * 0 : almost no debugging output
458 * 1 : 0+output errors only
459 * 2 : 1+output all sensekey/asc
460 * 3 : 2+follow all chrdev related procedures
461 * 4 : 3+follow all procedures
462 * 5 : 4+include pc_stack rq_stack info
463 * 6 : 5+USE_COUNT updates
464 */
465 int debug_level;
466} idetape_tape_t; 464} idetape_tape_t;
467 465
468static DEFINE_MUTEX(idetape_ref_mutex); 466static DEFINE_MUTEX(idetape_ref_mutex);
@@ -716,11 +714,8 @@ static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive)
716{ 714{
717 idetape_tape_t *tape = drive->driver_data; 715 idetape_tape_t *tape = drive->driver_data;
718 716
719#if IDETAPE_DEBUG_LOG 717 debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);
720 if (tape->debug_level >= 5) 718
721 printk(KERN_INFO "ide-tape: pc_stack_index=%d\n",
722 tape->pc_stack_index);
723#endif /* IDETAPE_DEBUG_LOG */
724 if (tape->pc_stack_index == IDETAPE_PC_STACK) 719 if (tape->pc_stack_index == IDETAPE_PC_STACK)
725 tape->pc_stack_index=0; 720 tape->pc_stack_index=0;
726 return (&tape->pc_stack[tape->pc_stack_index++]); 721 return (&tape->pc_stack[tape->pc_stack_index++]);
@@ -743,11 +738,8 @@ static struct request *idetape_next_rq_storage (ide_drive_t *drive)
743{ 738{
744 idetape_tape_t *tape = drive->driver_data; 739 idetape_tape_t *tape = drive->driver_data;
745 740
746#if IDETAPE_DEBUG_LOG 741 debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index);
747 if (tape->debug_level >= 5) 742
748 printk(KERN_INFO "ide-tape: rq_stack_index=%d\n",
749 tape->rq_stack_index);
750#endif /* IDETAPE_DEBUG_LOG */
751 if (tape->rq_stack_index == IDETAPE_PC_STACK) 743 if (tape->rq_stack_index == IDETAPE_PC_STACK)
752 tape->rq_stack_index=0; 744 tape->rq_stack_index=0;
753 return (&tape->rq_stack[tape->rq_stack_index++]); 745 return (&tape->rq_stack[tape->rq_stack_index++]);
@@ -780,17 +772,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
780 tape->sense_key = sense[2] & 0xF; 772 tape->sense_key = sense[2] & 0xF;
781 tape->asc = sense[12]; 773 tape->asc = sense[12];
782 tape->ascq = sense[13]; 774 tape->ascq = sense[13];
783#if IDETAPE_DEBUG_LOG 775
784 /* 776 debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
785 * Without debugging, we only log an error if we decided to give up 777 pc->c[0], tape->sense_key, tape->asc, tape->ascq);
786 * retrying.
787 */
788 if (tape->debug_level >= 1)
789 printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, "
790 "asc = %x, ascq = %x\n",
791 pc->c[0], tape->sense_key,
792 tape->asc, tape->ascq);
793#endif /* IDETAPE_DEBUG_LOG */
794 778
795 /* Correct pc->actually_transferred by asking the tape. */ 779 /* Correct pc->actually_transferred by asking the tape. */
796 if (test_bit(PC_DMA_ERROR, &pc->flags)) { 780 if (test_bit(PC_DMA_ERROR, &pc->flags)) {
@@ -843,12 +827,11 @@ static void idetape_activate_next_stage(ide_drive_t *drive)
843 idetape_stage_t *stage = tape->next_stage; 827 idetape_stage_t *stage = tape->next_stage;
844 struct request *rq = &stage->rq; 828 struct request *rq = &stage->rq;
845 829
846#if IDETAPE_DEBUG_LOG 830 debug_log(DBG_PROCS, "Enter %s\n", __func__);
847 if (tape->debug_level >= 4) 831
848 printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n");
849#endif /* IDETAPE_DEBUG_LOG */
850 if (stage == NULL) { 832 if (stage == NULL) {
851 printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); 833 printk(KERN_ERR "ide-tape: bug: Trying to activate a non"
834 " existing stage\n");
852 return; 835 return;
853 } 836 }
854 837
@@ -871,11 +854,8 @@ static void idetape_increase_max_pipeline_stages (ide_drive_t *drive)
871{ 854{
872 idetape_tape_t *tape = drive->driver_data; 855 idetape_tape_t *tape = drive->driver_data;
873 int increase = (tape->max_pipeline - tape->min_pipeline) / 10; 856 int increase = (tape->max_pipeline - tape->min_pipeline) / 10;
874 857
875#if IDETAPE_DEBUG_LOG 858 debug_log(DBG_PROCS, "Enter %s\n", __func__);
876 if (tape->debug_level >= 4)
877 printk (KERN_INFO "ide-tape: Reached idetape_increase_max_pipeline_stages\n");
878#endif /* IDETAPE_DEBUG_LOG */
879 859
880 tape->max_stages += max(increase, 1); 860 tape->max_stages += max(increase, 1);
881 tape->max_stages = max(tape->max_stages, tape->min_pipeline); 861 tape->max_stages = max(tape->max_stages, tape->min_pipeline);
@@ -920,17 +900,16 @@ static void idetape_remove_stage_head (ide_drive_t *drive)
920{ 900{
921 idetape_tape_t *tape = drive->driver_data; 901 idetape_tape_t *tape = drive->driver_data;
922 idetape_stage_t *stage; 902 idetape_stage_t *stage;
923 903
924#if IDETAPE_DEBUG_LOG 904 debug_log(DBG_PROCS, "Enter %s\n", __func__);
925 if (tape->debug_level >= 4) 905
926 printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n");
927#endif /* IDETAPE_DEBUG_LOG */
928 if (tape->first_stage == NULL) { 906 if (tape->first_stage == NULL) {
929 printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); 907 printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n");
930 return; 908 return;
931 } 909 }
932 if (tape->active_stage == tape->first_stage) { 910 if (tape->active_stage == tape->first_stage) {
933 printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); 911 printk(KERN_ERR "ide-tape: bug: Trying to free our active "
912 "pipeline stage\n");
934 return; 913 return;
935 } 914 }
936 stage = tape->first_stage; 915 stage = tape->first_stage;
@@ -957,10 +936,8 @@ static void idetape_abort_pipeline(ide_drive_t *drive,
957 idetape_stage_t *stage = new_last_stage->next; 936 idetape_stage_t *stage = new_last_stage->next;
958 idetape_stage_t *nstage; 937 idetape_stage_t *nstage;
959 938
960#if IDETAPE_DEBUG_LOG 939 debug_log(DBG_PROCS, "%s: Enter %s\n", tape->name, __func__);
961 if (tape->debug_level >= 4) 940
962 printk(KERN_INFO "ide-tape: %s: idetape_abort_pipeline called\n", tape->name);
963#endif
964 while (stage) { 941 while (stage) {
965 nstage = stage->next; 942 nstage = stage->next;
966 idetape_kfree_stage(tape, stage); 943 idetape_kfree_stage(tape, stage);
@@ -987,10 +964,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
987 int remove_stage = 0; 964 int remove_stage = 0;
988 idetape_stage_t *active_stage; 965 idetape_stage_t *active_stage;
989 966
990#if IDETAPE_DEBUG_LOG 967 debug_log(DBG_PROCS, "Enter %s\n", __func__);
991 if (tape->debug_level >= 4)
992 printk(KERN_INFO "ide-tape: Reached idetape_end_request\n");
993#endif /* IDETAPE_DEBUG_LOG */
994 968
995 switch (uptodate) { 969 switch (uptodate) {
996 case 0: error = IDETAPE_ERROR_GENERAL; break; 970 case 0: error = IDETAPE_ERROR_GENERAL; break;
@@ -1055,10 +1029,8 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
1055{ 1029{
1056 idetape_tape_t *tape = drive->driver_data; 1030 idetape_tape_t *tape = drive->driver_data;
1057 1031
1058#if IDETAPE_DEBUG_LOG 1032 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1059 if (tape->debug_level >= 4) 1033
1060 printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n");
1061#endif /* IDETAPE_DEBUG_LOG */
1062 if (!tape->pc->error) { 1034 if (!tape->pc->error) {
1063 idetape_analyze_error(drive, tape->pc->buffer); 1035 idetape_analyze_error(drive, tape->pc->buffer);
1064 idetape_end_request(drive, 1, 0); 1036 idetape_end_request(drive, 1, 0);
@@ -1143,10 +1115,8 @@ static void idetape_postpone_request (ide_drive_t *drive)
1143{ 1115{
1144 idetape_tape_t *tape = drive->driver_data; 1116 idetape_tape_t *tape = drive->driver_data;
1145 1117
1146#if IDETAPE_DEBUG_LOG 1118 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1147 if (tape->debug_level >= 4) 1119
1148 printk(KERN_INFO "ide-tape: idetape_postpone_request\n");
1149#endif
1150 tape->postponed_rq = HWGROUP(drive)->rq; 1120 tape->postponed_rq = HWGROUP(drive)->rq;
1151 ide_stall_queue(drive, tape->dsc_polling_frequency); 1121 ide_stall_queue(drive, tape->dsc_polling_frequency);
1152} 1122}
@@ -1171,11 +1141,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1171 u16 bcount; 1141 u16 bcount;
1172 u8 stat, ireason; 1142 u8 stat, ireason;
1173 1143
1174#if IDETAPE_DEBUG_LOG 1144 debug_log(DBG_PROCS, "Enter %s - interrupt handler\n", __func__);
1175 if (tape->debug_level >= 4)
1176 printk(KERN_INFO "ide-tape: Reached idetape_pc_intr "
1177 "interrupt handler\n");
1178#endif /* IDETAPE_DEBUG_LOG */
1179 1145
1180 /* Clear the interrupt */ 1146 /* Clear the interrupt */
1181 stat = ide_read_status(drive); 1147 stat = ide_read_status(drive);
@@ -1208,20 +1174,16 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1208 pc->actually_transferred = pc->request_transfer; 1174 pc->actually_transferred = pc->request_transfer;
1209 idetape_update_buffers(pc); 1175 idetape_update_buffers(pc);
1210 } 1176 }
1211#if IDETAPE_DEBUG_LOG 1177 debug_log(DBG_PROCS, "DMA finished\n");
1212 if (tape->debug_level >= 4) 1178
1213 printk(KERN_INFO "ide-tape: DMA finished\n");
1214#endif /* IDETAPE_DEBUG_LOG */
1215 } 1179 }
1216 1180
1217 /* No more interrupts */ 1181 /* No more interrupts */
1218 if ((stat & DRQ_STAT) == 0) { 1182 if ((stat & DRQ_STAT) == 0) {
1219#if IDETAPE_DEBUG_LOG 1183 debug_log(DBG_SENSE, "Packet command completed, %d bytes"
1220 if (tape->debug_level >= 2) 1184 " transferred\n", pc->actually_transferred);
1221 printk(KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred);
1222#endif /* IDETAPE_DEBUG_LOG */
1223 clear_bit(PC_DMA_IN_PROGRESS, &pc->flags);
1224 1185
1186 clear_bit(PC_DMA_IN_PROGRESS, &pc->flags);
1225 local_irq_enable(); 1187 local_irq_enable();
1226 1188
1227#if SIMULATE_ERRORS 1189#if SIMULATE_ERRORS
@@ -1236,19 +1198,15 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1236 stat &= ~ERR_STAT; 1198 stat &= ~ERR_STAT;
1237 if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { 1199 if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) {
1238 /* Error detected */ 1200 /* Error detected */
1239#if IDETAPE_DEBUG_LOG 1201 debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
1240 if (tape->debug_level >= 1) 1202
1241 printk(KERN_INFO "ide-tape: %s: I/O error\n",
1242 tape->name);
1243#endif /* IDETAPE_DEBUG_LOG */
1244 if (pc->c[0] == REQUEST_SENSE) { 1203 if (pc->c[0] == REQUEST_SENSE) {
1245 printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); 1204 printk(KERN_ERR "ide-tape: I/O error in request sense command\n");
1246 return ide_do_reset(drive); 1205 return ide_do_reset(drive);
1247 } 1206 }
1248#if IDETAPE_DEBUG_LOG 1207 debug_log(DBG_ERR, "[cmd %x]: check condition\n",
1249 if (tape->debug_level >= 1) 1208 pc->c[0]);
1250 printk(KERN_INFO "ide-tape: [cmd %x]: check condition\n", pc->c[0]); 1209
1251#endif
1252 /* Retry operation */ 1210 /* Retry operation */
1253 return idetape_retry_pc(drive); 1211 return idetape_retry_pc(drive);
1254 } 1212 }
@@ -1303,10 +1261,9 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1303 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 1261 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
1304 return ide_started; 1262 return ide_started;
1305 } 1263 }
1306#if IDETAPE_DEBUG_LOG 1264 debug_log(DBG_SENSE, "The tape wants to send us more "
1307 if (tape->debug_level >= 2) 1265 "data than expected - allowing transfer\n");
1308 printk(KERN_NOTICE "ide-tape: The tape wants to send us more data than expected - allowing transfer\n"); 1266
1309#endif /* IDETAPE_DEBUG_LOG */
1310 } 1267 }
1311 } 1268 }
1312 if (test_bit(PC_WRITING, &pc->flags)) { 1269 if (test_bit(PC_WRITING, &pc->flags)) {
@@ -1327,11 +1284,10 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1327 /* Update the current position */ 1284 /* Update the current position */
1328 pc->actually_transferred += bcount; 1285 pc->actually_transferred += bcount;
1329 pc->current_position += bcount; 1286 pc->current_position += bcount;
1330#if IDETAPE_DEBUG_LOG 1287
1331 if (tape->debug_level >= 2) 1288 debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n",
1332 printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes " 1289 pc->c[0], bcount);
1333 "on that interrupt\n", pc->c[0], bcount); 1290
1334#endif
1335 /* And set the interrupt handler again */ 1291 /* And set the interrupt handler again */
1336 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 1292 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
1337 return ide_started; 1293 return ide_started;
@@ -1464,10 +1420,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
1464 tape->failed_pc = NULL; 1420 tape->failed_pc = NULL;
1465 return pc->callback(drive); 1421 return pc->callback(drive);
1466 } 1422 }
1467#if IDETAPE_DEBUG_LOG 1423 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]);
1468 if (tape->debug_level >= 2)
1469 printk(KERN_INFO "ide-tape: Retry number - %d, cmd = %02X\n", pc->retries, pc->c[0]);
1470#endif /* IDETAPE_DEBUG_LOG */
1471 1424
1472 pc->retries++; 1425 pc->retries++;
1473 /* We haven't transferred any data yet */ 1426 /* We haven't transferred any data yet */
@@ -1505,11 +1458,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
1505static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) 1458static ide_startstop_t idetape_pc_callback (ide_drive_t *drive)
1506{ 1459{
1507 idetape_tape_t *tape = drive->driver_data; 1460 idetape_tape_t *tape = drive->driver_data;
1508 1461
1509#if IDETAPE_DEBUG_LOG 1462 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1510 if (tape->debug_level >= 4)
1511 printk(KERN_INFO "ide-tape: Reached idetape_pc_callback\n");
1512#endif /* IDETAPE_DEBUG_LOG */
1513 1463
1514 idetape_end_request(drive, tape->pc->error ? 0 : 1, 0); 1464 idetape_end_request(drive, tape->pc->error ? 0 : 1, 0);
1515 return ide_stopped; 1465 return ide_stopped;
@@ -1641,11 +1591,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
1641 tape->avg_size = 0; 1591 tape->avg_size = 0;
1642 tape->avg_time = jiffies; 1592 tape->avg_time = jiffies;
1643 } 1593 }
1644 1594 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1645#if IDETAPE_DEBUG_LOG
1646 if (tape->debug_level >= 4)
1647 printk(KERN_INFO "ide-tape: Reached idetape_rw_callback\n");
1648#endif /* IDETAPE_DEBUG_LOG */
1649 1595
1650 tape->first_frame_position += blocks; 1596 tape->first_frame_position += blocks;
1651 rq->current_nr_sectors -= blocks; 1597 rq->current_nr_sectors -= blocks;
@@ -1721,12 +1667,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1721 struct request *postponed_rq = tape->postponed_rq; 1667 struct request *postponed_rq = tape->postponed_rq;
1722 u8 stat; 1668 u8 stat;
1723 1669
1724#if IDETAPE_DEBUG_LOG 1670 debug_log(DBG_SENSE, "sector: %ld, nr_sectors: %ld,"
1725 if (tape->debug_level >= 2) 1671 " current_nr_sectors: %d\n",
1726 printk(KERN_INFO "ide-tape: sector: %ld, "
1727 "nr_sectors: %ld, current_nr_sectors: %d\n",
1728 rq->sector, rq->nr_sectors, rq->current_nr_sectors); 1672 rq->sector, rq->nr_sectors, rq->current_nr_sectors);
1729#endif /* IDETAPE_DEBUG_LOG */
1730 1673
1731 if (!blk_special_request(rq)) { 1674 if (!blk_special_request(rq)) {
1732 /* 1675 /*
@@ -1917,10 +1860,7 @@ static idetape_stage_t *idetape_kmalloc_stage (idetape_tape_t *tape)
1917{ 1860{
1918 idetape_stage_t *cache_stage = tape->cache_stage; 1861 idetape_stage_t *cache_stage = tape->cache_stage;
1919 1862
1920#if IDETAPE_DEBUG_LOG 1863 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1921 if (tape->debug_level >= 4)
1922 printk(KERN_INFO "ide-tape: Reached idetape_kmalloc_stage\n");
1923#endif /* IDETAPE_DEBUG_LOG */
1924 1864
1925 if (tape->nr_stages >= tape->max_stages) 1865 if (tape->nr_stages >= tape->max_stages)
1926 return NULL; 1866 return NULL;
@@ -2019,11 +1959,9 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage)
2019{ 1959{
2020 idetape_tape_t *tape = drive->driver_data; 1960 idetape_tape_t *tape = drive->driver_data;
2021 unsigned long flags; 1961 unsigned long flags;
2022 1962
2023#if IDETAPE_DEBUG_LOG 1963 debug_log(DBG_PROCS, "Enter %s\n", __func__);
2024 if (tape->debug_level >= 4) 1964
2025 printk (KERN_INFO "ide-tape: Reached idetape_add_stage_tail\n");
2026#endif /* IDETAPE_DEBUG_LOG */
2027 spin_lock_irqsave(&tape->spinlock, flags); 1965 spin_lock_irqsave(&tape->spinlock, flags);
2028 stage->next = NULL; 1966 stage->next = NULL;
2029 if (tape->last_stage != NULL) 1967 if (tape->last_stage != NULL)
@@ -2066,29 +2004,22 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
2066{ 2004{
2067 idetape_tape_t *tape = drive->driver_data; 2005 idetape_tape_t *tape = drive->driver_data;
2068 idetape_read_position_result_t *result; 2006 idetape_read_position_result_t *result;
2069 2007
2070#if IDETAPE_DEBUG_LOG 2008 debug_log(DBG_PROCS, "Enter %s\n", __func__);
2071 if (tape->debug_level >= 4)
2072 printk(KERN_INFO "ide-tape: Reached idetape_read_position_callback\n");
2073#endif /* IDETAPE_DEBUG_LOG */
2074 2009
2075 if (!tape->pc->error) { 2010 if (!tape->pc->error) {
2076 result = (idetape_read_position_result_t *) tape->pc->buffer; 2011 result = (idetape_read_position_result_t *) tape->pc->buffer;
2077#if IDETAPE_DEBUG_LOG 2012 debug_log(DBG_SENSE, "BOP - %s\n", result->bop ? "Yes" : "No");
2078 if (tape->debug_level >= 2) 2013 debug_log(DBG_SENSE, "EOP - %s\n", result->eop ? "Yes" : "No");
2079 printk(KERN_INFO "ide-tape: BOP - %s\n",result->bop ? "Yes":"No"); 2014
2080 if (tape->debug_level >= 2)
2081 printk(KERN_INFO "ide-tape: EOP - %s\n",result->eop ? "Yes":"No");
2082#endif /* IDETAPE_DEBUG_LOG */
2083 if (result->bpu) { 2015 if (result->bpu) {
2084 printk(KERN_INFO "ide-tape: Block location is unknown to the tape\n"); 2016 printk(KERN_INFO "ide-tape: Block location is unknown to the tape\n");
2085 clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags); 2017 clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
2086 idetape_end_request(drive, 0, 0); 2018 idetape_end_request(drive, 0, 0);
2087 } else { 2019 } else {
2088#if IDETAPE_DEBUG_LOG 2020 debug_log(DBG_SENSE, "Block Location - %u\n",
2089 if (tape->debug_level >= 2) 2021 ntohl(result->first_block));
2090 printk(KERN_INFO "ide-tape: Block Location - %u\n", ntohl(result->first_block)); 2022
2091#endif /* IDETAPE_DEBUG_LOG */
2092 tape->partition = result->partition; 2023 tape->partition = result->partition;
2093 tape->first_frame_position = ntohl(result->first_block); 2024 tape->first_frame_position = ntohl(result->first_block);
2094 tape->last_frame_position = ntohl(result->last_block); 2025 tape->last_frame_position = ntohl(result->last_block);
@@ -2228,10 +2159,7 @@ static int idetape_read_position (ide_drive_t *drive)
2228 idetape_pc_t pc; 2159 idetape_pc_t pc;
2229 int position; 2160 int position;
2230 2161
2231#if IDETAPE_DEBUG_LOG 2162 debug_log(DBG_PROCS, "Enter %s\n", __func__);
2232 if (tape->debug_level >= 4)
2233 printk(KERN_INFO "ide-tape: Reached idetape_read_position\n");
2234#endif /* IDETAPE_DEBUG_LOG */
2235 2163
2236 idetape_create_read_position_cmd(&pc); 2164 idetape_create_read_position_cmd(&pc);
2237 if (idetape_queue_pc_tail(drive, &pc)) 2165 if (idetape_queue_pc_tail(drive, &pc))
@@ -2365,12 +2293,11 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct
2365 idetape_tape_t *tape = drive->driver_data; 2293 idetape_tape_t *tape = drive->driver_data;
2366 struct request rq; 2294 struct request rq;
2367 2295
2368#if IDETAPE_DEBUG_LOG 2296 debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd);
2369 if (tape->debug_level >= 2) 2297
2370 printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd);
2371#endif /* IDETAPE_DEBUG_LOG */
2372 if (idetape_pipeline_active(tape)) { 2298 if (idetape_pipeline_active(tape)) {
2373 printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); 2299 printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n",
2300 __func__);
2374 return (0); 2301 return (0);
2375 } 2302 }
2376 2303
@@ -2474,10 +2401,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
2474 unsigned long flags; 2401 unsigned long flags;
2475 struct request *rq; 2402 struct request *rq;
2476 2403
2477#if IDETAPE_DEBUG_LOG 2404 debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
2478 if (tape->debug_level >= 3)
2479 printk(KERN_INFO "ide-tape: Reached idetape_add_chrdev_write_request\n");
2480#endif /* IDETAPE_DEBUG_LOG */
2481 2405
2482 /* 2406 /*
2483 * Attempt to allocate a new stage. 2407 * Attempt to allocate a new stage.
@@ -2715,10 +2639,7 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks)
2715 struct request *rq_ptr; 2639 struct request *rq_ptr;
2716 int bytes_read; 2640 int bytes_read;
2717 2641
2718#if IDETAPE_DEBUG_LOG 2642 debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks);
2719 if (tape->debug_level >= 4)
2720 printk(KERN_INFO "ide-tape: Reached idetape_add_chrdev_read_request, %d blocks\n", blocks);
2721#endif /* IDETAPE_DEBUG_LOG */
2722 2643
2723 /* 2644 /*
2724 * If we are at a filemark, return a read length of 0 2645 * If we are at a filemark, return a read length of 0
@@ -2813,12 +2734,11 @@ static int idetape_rewind_tape (ide_drive_t *drive)
2813{ 2734{
2814 int retval; 2735 int retval;
2815 idetape_pc_t pc; 2736 idetape_pc_t pc;
2816#if IDETAPE_DEBUG_LOG 2737 idetape_tape_t *tape;
2817 idetape_tape_t *tape = drive->driver_data; 2738 tape = drive->driver_data;
2818 if (tape->debug_level >= 2) 2739
2819 printk(KERN_INFO "ide-tape: Reached idetape_rewind_tape\n"); 2740 debug_log(DBG_SENSE, "Enter %s\n", __func__);
2820#endif /* IDETAPE_DEBUG_LOG */ 2741
2821
2822 idetape_create_rewind_cmd(drive, &pc); 2742 idetape_create_rewind_cmd(drive, &pc);
2823 retval = idetape_queue_pc_tail(drive, &pc); 2743 retval = idetape_queue_pc_tail(drive, &pc);
2824 if (retval) 2744 if (retval)
@@ -2849,10 +2769,8 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l
2849 int nr_stages; 2769 int nr_stages;
2850 } config; 2770 } config;
2851 2771
2852#if IDETAPE_DEBUG_LOG 2772 debug_log(DBG_PROCS, "Enter %s\n", __func__);
2853 if (tape->debug_level >= 4) 2773
2854 printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n");
2855#endif /* IDETAPE_DEBUG_LOG */
2856 switch (cmd) { 2774 switch (cmd) {
2857 case 0x0340: 2775 case 0x0340:
2858 if (copy_from_user(&config, argp, sizeof(config))) 2776 if (copy_from_user(&config, argp, sizeof(config)))
@@ -2985,10 +2903,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf,
2985 ssize_t ret = 0; 2903 ssize_t ret = 0;
2986 u16 ctl = *(u16 *)&tape->caps[12]; 2904 u16 ctl = *(u16 *)&tape->caps[12];
2987 2905
2988#if IDETAPE_DEBUG_LOG 2906 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
2989 if (tape->debug_level >= 3)
2990 printk(KERN_INFO "ide-tape: Reached idetape_chrdev_read, count %Zd\n", count);
2991#endif /* IDETAPE_DEBUG_LOG */
2992 2907
2993 if (tape->chrdev_direction != idetape_direction_read) { 2908 if (tape->chrdev_direction != idetape_direction_read) {
2994 if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) 2909 if (test_bit(IDETAPE_DETECT_BS, &tape->flags))
@@ -3030,10 +2945,8 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf,
3030 } 2945 }
3031finish: 2946finish:
3032 if (!actually_read && test_bit(IDETAPE_FILEMARK, &tape->flags)) { 2947 if (!actually_read && test_bit(IDETAPE_FILEMARK, &tape->flags)) {
3033#if IDETAPE_DEBUG_LOG 2948 debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
3034 if (tape->debug_level >= 2) 2949
3035 printk(KERN_INFO "ide-tape: %s: spacing over filemark\n", tape->name);
3036#endif
3037 idetape_space_over_filemarks(drive, MTFSF, 1); 2950 idetape_space_over_filemarks(drive, MTFSF, 1);
3038 return 0; 2951 return 0;
3039 } 2952 }
@@ -3054,11 +2967,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf,
3054 if (tape->write_prot) 2967 if (tape->write_prot)
3055 return -EACCES; 2968 return -EACCES;
3056 2969
3057#if IDETAPE_DEBUG_LOG 2970 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count);
3058 if (tape->debug_level >= 3)
3059 printk(KERN_INFO "ide-tape: Reached idetape_chrdev_write, "
3060 "count %Zd\n", count);
3061#endif /* IDETAPE_DEBUG_LOG */
3062 2971
3063 /* Initialize write operation */ 2972 /* Initialize write operation */
3064 if (tape->chrdev_direction != idetape_direction_write) { 2973 if (tape->chrdev_direction != idetape_direction_write) {
@@ -3168,11 +3077,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
3168 idetape_pc_t pc; 3077 idetape_pc_t pc;
3169 int i,retval; 3078 int i,retval;
3170 3079
3171#if IDETAPE_DEBUG_LOG 3080 debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n",
3172 if (tape->debug_level >= 1) 3081 mt_op, mt_count);
3173 printk(KERN_INFO "ide-tape: Handling MTIOCTOP ioctl: "
3174 "mt_op=%d, mt_count=%d\n", mt_op, mt_count);
3175#endif /* IDETAPE_DEBUG_LOG */
3176 /* 3082 /*
3177 * Commands which need our pipelined read-ahead stages. 3083 * Commands which need our pipelined read-ahead stages.
3178 */ 3084 */
@@ -3292,11 +3198,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
3292 int block_offset = 0, position = tape->first_frame_position; 3198 int block_offset = 0, position = tape->first_frame_position;
3293 void __user *argp = (void __user *)arg; 3199 void __user *argp = (void __user *)arg;
3294 3200
3295#if IDETAPE_DEBUG_LOG 3201 debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd);
3296 if (tape->debug_level >= 3)
3297 printk(KERN_INFO "ide-tape: Reached idetape_chrdev_ioctl, "
3298 "cmd=%u\n", cmd);
3299#endif /* IDETAPE_DEBUG_LOG */
3300 3202
3301 tape->restart_speed_control_req = 1; 3203 tape->restart_speed_control_req = 1;
3302 if (tape->chrdev_direction == idetape_direction_write) { 3204 if (tape->chrdev_direction == idetape_direction_write) {
@@ -3372,6 +3274,15 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp)
3372 idetape_pc_t pc; 3274 idetape_pc_t pc;
3373 int retval; 3275 int retval;
3374 3276
3277 if (i >= MAX_HWIFS * MAX_DRIVES)
3278 return -ENXIO;
3279
3280 tape = ide_tape_chrdev_get(i);
3281 if (!tape)
3282 return -ENXIO;
3283
3284 debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
3285
3375 /* 3286 /*
3376 * We really want to do nonseekable_open(inode, filp); here, but some 3287 * We really want to do nonseekable_open(inode, filp); here, but some
3377 * versions of tar incorrectly call lseek on tapes and bail out if that 3288 * versions of tar incorrectly call lseek on tapes and bail out if that
@@ -3379,16 +3290,6 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp)
3379 */ 3290 */
3380 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 3291 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
3381 3292
3382#if IDETAPE_DEBUG_LOG
3383 printk(KERN_INFO "ide-tape: Reached idetape_chrdev_open\n");
3384#endif /* IDETAPE_DEBUG_LOG */
3385
3386 if (i >= MAX_HWIFS * MAX_DRIVES)
3387 return -ENXIO;
3388
3389 if (!(tape = ide_tape_chrdev_get(i)))
3390 return -ENXIO;
3391
3392 drive = tape->drive; 3293 drive = tape->drive;
3393 3294
3394 filp->private_data = tape; 3295 filp->private_data = tape;
@@ -3479,10 +3380,8 @@ static int idetape_chrdev_release (struct inode *inode, struct file *filp)
3479 3380
3480 lock_kernel(); 3381 lock_kernel();
3481 tape = drive->driver_data; 3382 tape = drive->driver_data;
3482#if IDETAPE_DEBUG_LOG 3383
3483 if (tape->debug_level >= 3) 3384 debug_log(DBG_CHRDEV, "Enter %s\n", __func__);
3484 printk(KERN_INFO "ide-tape: Reached idetape_chrdev_release\n");
3485#endif /* IDETAPE_DEBUG_LOG */
3486 3385
3487 if (tape->chrdev_direction == idetape_direction_write) 3386 if (tape->chrdev_direction == idetape_direction_write)
3488 idetape_write_release(drive, minor); 3387 idetape_write_release(drive, minor);
@@ -3650,7 +3549,8 @@ static void idetape_add_settings (ide_drive_t *drive)
3650 ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); 3549 ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL);
3651 ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL); 3550 ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL);
3652 ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL); 3551 ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL);
3653 ide_add_setting(drive, "debug_level", SETTING_RW, TYPE_INT, 0, 0xffff, 1, 1, &tape->debug_level, NULL); 3552 ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1,
3553 1, &tape->debug_mask, NULL);
3654} 3554}
3655#else 3555#else
3656static inline void idetape_add_settings(ide_drive_t *drive) { ; } 3556static inline void idetape_add_settings(ide_drive_t *drive) { ; }