Merge branch 'drm-ttm-unmappable' into drm-core-next
[pandora-kernel.git] / drivers / s390 / char / tape_34xx.c
1 /*
2  *  drivers/s390/char/tape_34xx.c
3  *    tape device discipline for 3480/3490 tapes.
4  *
5  *    Copyright IBM Corp. 2001, 2009
6  *    Author(s): Carsten Otte <cotte@de.ibm.com>
7  *               Tuan Ngo-Anh <ngoanh@de.ibm.com>
8  *               Martin Schwidefsky <schwidefsky@de.ibm.com>
9  */
10
11 #define KMSG_COMPONENT "tape_34xx"
12 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/bio.h>
17 #include <linux/workqueue.h>
18 #include <linux/slab.h>
19
20 #define TAPE_DBF_AREA   tape_34xx_dbf
21
22 #include "tape.h"
23 #include "tape_std.h"
24
25 /*
26  * Pointer to debug area.
27  */
28 debug_info_t *TAPE_DBF_AREA = NULL;
29 EXPORT_SYMBOL(TAPE_DBF_AREA);
30
31 #define TAPE34XX_FMT_3480       0
32 #define TAPE34XX_FMT_3480_2_XF  1
33 #define TAPE34XX_FMT_3480_XF    2
34
35 struct tape_34xx_block_id {
36         unsigned int    wrap            : 1;
37         unsigned int    segment         : 7;
38         unsigned int    format          : 2;
39         unsigned int    block           : 22;
40 };
41
42 /*
43  * A list of block ID's is used to faster seek blocks.
44  */
45 struct tape_34xx_sbid {
46         struct list_head                list;
47         struct tape_34xx_block_id       bid;
48 };
49
50 static void tape_34xx_delete_sbid_from(struct tape_device *, int);
51
52 /*
53  * Medium sense for 34xx tapes. There is no 'real' medium sense call.
54  * So we just do a normal sense.
55  */
56 static int
57 tape_34xx_medium_sense(struct tape_device *device)
58 {
59         struct tape_request *request;
60         unsigned char       *sense;
61         int                  rc;
62
63         request = tape_alloc_request(1, 32);
64         if (IS_ERR(request)) {
65                 DBF_EXCEPTION(6, "MSEN fail\n");
66                 return PTR_ERR(request);
67         }
68
69         request->op = TO_MSEN;
70         tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata);
71
72         rc = tape_do_io_interruptible(device, request);
73         if (request->rc == 0) {
74                 sense = request->cpdata;
75
76                 /*
77                  * This isn't quite correct. But since INTERVENTION_REQUIRED
78                  * means that the drive is 'neither ready nor on-line' it is
79                  * only slightly inaccurate to say there is no tape loaded if
80                  * the drive isn't online...
81                  */
82                 if (sense[0] & SENSE_INTERVENTION_REQUIRED)
83                         tape_med_state_set(device, MS_UNLOADED);
84                 else
85                         tape_med_state_set(device, MS_LOADED);
86
87                 if (sense[1] & SENSE_WRITE_PROTECT)
88                         device->tape_generic_status |= GMT_WR_PROT(~0);
89                 else
90                         device->tape_generic_status &= ~GMT_WR_PROT(~0);
91         } else {
92                 DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n",
93                         request->rc);
94         }
95         tape_free_request(request);
96
97         return rc;
98 }
99
100 struct tape_34xx_work {
101         struct tape_device      *device;
102         enum tape_op             op;
103         struct work_struct       work;
104 };
105
106 /*
107  * These functions are currently used only to schedule a medium_sense for
108  * later execution. This is because we get an interrupt whenever a medium
109  * is inserted but cannot call tape_do_io* from an interrupt context.
110  * Maybe that's useful for other actions we want to start from the
111  * interrupt handler.
112  */
113 static void
114 tape_34xx_work_handler(struct work_struct *work)
115 {
116         struct tape_34xx_work *p =
117                 container_of(work, struct tape_34xx_work, work);
118         struct tape_device *device = p->device;
119
120         switch(p->op) {
121                 case TO_MSEN:
122                         tape_34xx_medium_sense(device);
123                         break;
124                 default:
125                         DBF_EVENT(3, "T34XX: internal error: unknown work\n");
126         }
127         tape_put_device(device);
128         kfree(p);
129 }
130
131 static int
132 tape_34xx_schedule_work(struct tape_device *device, enum tape_op op)
133 {
134         struct tape_34xx_work *p;
135
136         if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
137                 return -ENOMEM;
138
139         INIT_WORK(&p->work, tape_34xx_work_handler);
140
141         p->device = tape_get_device(device);
142         p->op     = op;
143
144         schedule_work(&p->work);
145         return 0;
146 }
147
148 /*
149  * Done Handler is called when dev stat = DEVICE-END (successful operation)
150  */
151 static inline int
152 tape_34xx_done(struct tape_request *request)
153 {
154         DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
155
156         switch (request->op) {
157                 case TO_DSE:
158                 case TO_RUN:
159                 case TO_WRI:
160                 case TO_WTM:
161                 case TO_ASSIGN:
162                 case TO_UNASSIGN:
163                         tape_34xx_delete_sbid_from(request->device, 0);
164                         break;
165                 default:
166                         ;
167         }
168         return TAPE_IO_SUCCESS;
169 }
170
171 static inline int
172 tape_34xx_erp_failed(struct tape_request *request, int rc)
173 {
174         DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n",
175                   tape_op_verbose[request->op], rc);
176         return rc;
177 }
178
179 static inline int
180 tape_34xx_erp_succeeded(struct tape_request *request)
181 {
182         DBF_EVENT(3, "Error Recovery successful for %s\n",
183                   tape_op_verbose[request->op]);
184         return tape_34xx_done(request);
185 }
186
187 static inline int
188 tape_34xx_erp_retry(struct tape_request *request)
189 {
190         DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]);
191         return TAPE_IO_RETRY;
192 }
193
194 /*
195  * This function is called, when no request is outstanding and we get an
196  * interrupt
197  */
198 static int
199 tape_34xx_unsolicited_irq(struct tape_device *device, struct irb *irb)
200 {
201         if (irb->scsw.cmd.dstat == 0x85) { /* READY */
202                 /* A medium was inserted in the drive. */
203                 DBF_EVENT(6, "xuud med\n");
204                 tape_34xx_delete_sbid_from(device, 0);
205                 tape_34xx_schedule_work(device, TO_MSEN);
206         } else {
207                 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
208                 tape_dump_sense_dbf(device, NULL, irb);
209         }
210         return TAPE_IO_SUCCESS;
211 }
212
213 /*
214  * Read Opposite Error Recovery Function:
215  * Used, when Read Forward does not work
216  */
217 static int
218 tape_34xx_erp_read_opposite(struct tape_device *device,
219                             struct tape_request *request)
220 {
221         if (request->op == TO_RFO) {
222                 /*
223                  * We did read forward, but the data could not be read
224                  * *correctly*. We transform the request to a read backward
225                  * and try again.
226                  */
227                 tape_std_read_backward(device, request);
228                 return tape_34xx_erp_retry(request);
229         }
230
231         /*
232          * We tried to read forward and backward, but hat no
233          * success -> failed.
234          */
235         return tape_34xx_erp_failed(request, -EIO);
236 }
237
238 static int
239 tape_34xx_erp_bug(struct tape_device *device, struct tape_request *request,
240                   struct irb *irb, int no)
241 {
242         if (request->op != TO_ASSIGN) {
243                 dev_err(&device->cdev->dev, "An unexpected condition %d "
244                         "occurred in tape error recovery\n", no);
245                 tape_dump_sense_dbf(device, request, irb);
246         }
247         return tape_34xx_erp_failed(request, -EIO);
248 }
249
250 /*
251  * Handle data overrun between cu and drive. The channel speed might
252  * be too slow.
253  */
254 static int
255 tape_34xx_erp_overrun(struct tape_device *device, struct tape_request *request,
256                       struct irb *irb)
257 {
258         if (irb->ecw[3] == 0x40) {
259                 dev_warn (&device->cdev->dev, "A data overrun occurred between"
260                         " the control unit and tape unit\n");
261                 return tape_34xx_erp_failed(request, -EIO);
262         }
263         return tape_34xx_erp_bug(device, request, irb, -1);
264 }
265
266 /*
267  * Handle record sequence error.
268  */
269 static int
270 tape_34xx_erp_sequence(struct tape_device *device,
271                        struct tape_request *request, struct irb *irb)
272 {
273         if (irb->ecw[3] == 0x41) {
274                 /*
275                  * cu detected incorrect block-id sequence on tape.
276                  */
277                 dev_warn (&device->cdev->dev, "The block ID sequence on the "
278                         "tape is incorrect\n");
279                 return tape_34xx_erp_failed(request, -EIO);
280         }
281         /*
282          * Record sequence error bit is set, but erpa does not
283          * show record sequence error.
284          */
285         return tape_34xx_erp_bug(device, request, irb, -2);
286 }
287
288 /*
289  * This function analyses the tape's sense-data in case of a unit-check.
290  * If possible, it tries to recover from the error. Else the user is
291  * informed about the problem.
292  */
293 static int
294 tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
295                      struct irb *irb)
296 {
297         int inhibit_cu_recovery;
298         __u8* sense;
299
300         inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0;
301         sense = irb->ecw;
302
303 #ifdef CONFIG_S390_TAPE_BLOCK
304         if (request->op == TO_BLOCK) {
305                 /*
306                  * Recovery for block device requests. Set the block_position
307                  * to something invalid and retry.
308                  */
309                 device->blk_data.block_position = -1;
310                 if (request->retries-- <= 0)
311                         return tape_34xx_erp_failed(request, -EIO);
312                 else
313                         return tape_34xx_erp_retry(request);
314         }
315 #endif
316
317         if (
318                 sense[0] & SENSE_COMMAND_REJECT &&
319                 sense[1] & SENSE_WRITE_PROTECT
320         ) {
321                 if (
322                         request->op == TO_DSE ||
323                         request->op == TO_WRI ||
324                         request->op == TO_WTM
325                 ) {
326                         /* medium is write protected */
327                         return tape_34xx_erp_failed(request, -EACCES);
328                 } else {
329                         return tape_34xx_erp_bug(device, request, irb, -3);
330                 }
331         }
332
333         /*
334          * Special cases for various tape-states when reaching
335          * end of recorded area
336          *
337          * FIXME: Maybe a special case of the special case:
338          *        sense[0] == SENSE_EQUIPMENT_CHECK &&
339          *        sense[1] == SENSE_DRIVE_ONLINE    &&
340          *        sense[3] == 0x47 (Volume Fenced)
341          *
342          *        This was caused by continued FSF or FSR after an
343          *        'End Of Data'.
344          */
345         if ((
346                 sense[0] == SENSE_DATA_CHECK      ||
347                 sense[0] == SENSE_EQUIPMENT_CHECK ||
348                 sense[0] == SENSE_EQUIPMENT_CHECK + SENSE_DEFERRED_UNIT_CHECK
349         ) && (
350                 sense[1] == SENSE_DRIVE_ONLINE ||
351                 sense[1] == SENSE_BEGINNING_OF_TAPE + SENSE_WRITE_MODE
352         )) {
353                 switch (request->op) {
354                 /*
355                  * sense[0] == SENSE_DATA_CHECK   &&
356                  * sense[1] == SENSE_DRIVE_ONLINE
357                  * sense[3] == 0x36 (End Of Data)
358                  *
359                  * Further seeks might return a 'Volume Fenced'.
360                  */
361                 case TO_FSF:
362                 case TO_FSB:
363                         /* Trying to seek beyond end of recorded area */
364                         return tape_34xx_erp_failed(request, -ENOSPC);
365                 case TO_BSB:
366                         return tape_34xx_erp_retry(request);
367
368                 /*
369                  * sense[0] == SENSE_DATA_CHECK   &&
370                  * sense[1] == SENSE_DRIVE_ONLINE &&
371                  * sense[3] == 0x36 (End Of Data)
372                  */
373                 case TO_LBL:
374                         /* Block could not be located. */
375                         tape_34xx_delete_sbid_from(device, 0);
376                         return tape_34xx_erp_failed(request, -EIO);
377
378                 case TO_RFO:
379                         /* Read beyond end of recorded area -> 0 bytes read */
380                         return tape_34xx_erp_failed(request, 0);
381
382                 /*
383                  * sense[0] == SENSE_EQUIPMENT_CHECK &&
384                  * sense[1] == SENSE_DRIVE_ONLINE    &&
385                  * sense[3] == 0x38 (Physical End Of Volume)
386                  */
387                 case TO_WRI:
388                         /* Writing at physical end of volume */
389                         return tape_34xx_erp_failed(request, -ENOSPC);
390                 default:
391                         return tape_34xx_erp_failed(request, 0);
392                 }
393         }
394
395         /* Sensing special bits */
396         if (sense[0] & SENSE_BUS_OUT_CHECK)
397                 return tape_34xx_erp_retry(request);
398
399         if (sense[0] & SENSE_DATA_CHECK) {
400                 /*
401                  * hardware failure, damaged tape or improper
402                  * operating conditions
403                  */
404                 switch (sense[3]) {
405                 case 0x23:
406                         /* a read data check occurred */
407                         if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
408                             inhibit_cu_recovery)
409                                 // data check is not permanent, may be
410                                 // recovered. We always use async-mode with
411                                 // cu-recovery, so this should *never* happen.
412                                 return tape_34xx_erp_bug(device, request,
413                                                          irb, -4);
414
415                         /* data check is permanent, CU recovery has failed */
416                         dev_warn (&device->cdev->dev, "A read error occurred "
417                                 "that cannot be recovered\n");
418                         return tape_34xx_erp_failed(request, -EIO);
419                 case 0x25:
420                         // a write data check occurred
421                         if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
422                             inhibit_cu_recovery)
423                                 // data check is not permanent, may be
424                                 // recovered. We always use async-mode with
425                                 // cu-recovery, so this should *never* happen.
426                                 return tape_34xx_erp_bug(device, request,
427                                                          irb, -5);
428
429                         // data check is permanent, cu-recovery has failed
430                         dev_warn (&device->cdev->dev, "A write error on the "
431                                 "tape cannot be recovered\n");
432                         return tape_34xx_erp_failed(request, -EIO);
433                 case 0x26:
434                         /* Data Check (read opposite) occurred. */
435                         return tape_34xx_erp_read_opposite(device, request);
436                 case 0x28:
437                         /* ID-Mark at tape start couldn't be written */
438                         dev_warn (&device->cdev->dev, "Writing the ID-mark "
439                                 "failed\n");
440                         return tape_34xx_erp_failed(request, -EIO);
441                 case 0x31:
442                         /* Tape void. Tried to read beyond end of device. */
443                         dev_warn (&device->cdev->dev, "Reading the tape beyond"
444                                 " the end of the recorded area failed\n");
445                         return tape_34xx_erp_failed(request, -ENOSPC);
446                 case 0x41:
447                         /* Record sequence error. */
448                         dev_warn (&device->cdev->dev, "The tape contains an "
449                                 "incorrect block ID sequence\n");
450                         return tape_34xx_erp_failed(request, -EIO);
451                 default:
452                         /* all data checks for 3480 should result in one of
453                          * the above erpa-codes. For 3490, other data-check
454                          * conditions do exist. */
455                         if (device->cdev->id.driver_info == tape_3480)
456                                 return tape_34xx_erp_bug(device, request,
457                                                          irb, -6);
458                 }
459         }
460
461         if (sense[0] & SENSE_OVERRUN)
462                 return tape_34xx_erp_overrun(device, request, irb);
463
464         if (sense[1] & SENSE_RECORD_SEQUENCE_ERR)
465                 return tape_34xx_erp_sequence(device, request, irb);
466
467         /* Sensing erpa codes */
468         switch (sense[3]) {
469         case 0x00:
470                 /* Unit check with erpa code 0. Report and ignore. */
471                 return TAPE_IO_SUCCESS;
472         case 0x21:
473                 /*
474                  * Data streaming not operational. CU will switch to
475                  * interlock mode. Reissue the command.
476                  */
477                 return tape_34xx_erp_retry(request);
478         case 0x22:
479                 /*
480                  * Path equipment check. Might be drive adapter error, buffer
481                  * error on the lower interface, internal path not usable,
482                  * or error during cartridge load.
483                  */
484                 dev_warn (&device->cdev->dev, "A path equipment check occurred"
485                         " for the tape device\n");
486                 return tape_34xx_erp_failed(request, -EIO);
487         case 0x24:
488                 /*
489                  * Load display check. Load display was command was issued,
490                  * but the drive is displaying a drive check message. Can
491                  * be threated as "device end".
492                  */
493                 return tape_34xx_erp_succeeded(request);
494         case 0x27:
495                 /*
496                  * Command reject. May indicate illegal channel program or
497                  * buffer over/underrun. Since all channel programs are
498                  * issued by this driver and ought be correct, we assume a
499                  * over/underrun situation and retry the channel program.
500                  */
501                 return tape_34xx_erp_retry(request);
502         case 0x29:
503                 /*
504                  * Function incompatible. Either the tape is idrc compressed
505                  * but the hardware isn't capable to do idrc, or a perform
506                  * subsystem func is issued and the CU is not on-line.
507                  */
508                 return tape_34xx_erp_failed(request, -EIO);
509         case 0x2a:
510                 /*
511                  * Unsolicited environmental data. An internal counter
512                  * overflows, we can ignore this and reissue the cmd.
513                  */
514                 return tape_34xx_erp_retry(request);
515         case 0x2b:
516                 /*
517                  * Environmental data present. Indicates either unload
518                  * completed ok or read buffered log command completed ok.
519                  */
520                 if (request->op == TO_RUN) {
521                         /* Rewind unload completed ok. */
522                         tape_med_state_set(device, MS_UNLOADED);
523                         return tape_34xx_erp_succeeded(request);
524                 }
525                 /* tape_34xx doesn't use read buffered log commands. */
526                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
527         case 0x2c:
528                 /*
529                  * Permanent equipment check. CU has tried recovery, but
530                  * did not succeed.
531                  */
532                 return tape_34xx_erp_failed(request, -EIO);
533         case 0x2d:
534                 /* Data security erase failure. */
535                 if (request->op == TO_DSE)
536                         return tape_34xx_erp_failed(request, -EIO);
537                 /* Data security erase failure, but no such command issued. */
538                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
539         case 0x2e:
540                 /*
541                  * Not capable. This indicates either that the drive fails
542                  * reading the format id mark or that that format specified
543                  * is not supported by the drive.
544                  */
545                 dev_warn (&device->cdev->dev, "The tape unit cannot process "
546                         "the tape format\n");
547                 return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
548         case 0x30:
549                 /* The medium is write protected. */
550                 dev_warn (&device->cdev->dev, "The tape medium is write-"
551                         "protected\n");
552                 return tape_34xx_erp_failed(request, -EACCES);
553         case 0x32:
554                 // Tension loss. We cannot recover this, it's an I/O error.
555                 dev_warn (&device->cdev->dev, "The tape does not have the "
556                         "required tape tension\n");
557                 return tape_34xx_erp_failed(request, -EIO);
558         case 0x33:
559                 /*
560                  * Load Failure. The cartridge was not inserted correctly or
561                  * the tape is not threaded correctly.
562                  */
563                 dev_warn (&device->cdev->dev, "The tape unit failed to load"
564                         " the cartridge\n");
565                 tape_34xx_delete_sbid_from(device, 0);
566                 return tape_34xx_erp_failed(request, -EIO);
567         case 0x34:
568                 /*
569                  * Unload failure. The drive cannot maintain tape tension
570                  * and control tape movement during an unload operation.
571                  */
572                 dev_warn (&device->cdev->dev, "Automatic unloading of the tape"
573                         " cartridge failed\n");
574                 if (request->op == TO_RUN)
575                         return tape_34xx_erp_failed(request, -EIO);
576                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
577         case 0x35:
578                 /*
579                  * Drive equipment check. One of the following:
580                  * - cu cannot recover from a drive detected error
581                  * - a check code message is shown on drive display
582                  * - the cartridge loader does not respond correctly
583                  * - a failure occurs during an index, load, or unload cycle
584                  */
585                 dev_warn (&device->cdev->dev, "An equipment check has occurred"
586                         " on the tape unit\n");
587                 return tape_34xx_erp_failed(request, -EIO);
588         case 0x36:
589                 if (device->cdev->id.driver_info == tape_3490)
590                         /* End of data. */
591                         return tape_34xx_erp_failed(request, -EIO);
592                 /* This erpa is reserved for 3480 */
593                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
594         case 0x37:
595                 /*
596                  * Tape length error. The tape is shorter than reported in
597                  * the beginning-of-tape data.
598                  */
599                 dev_warn (&device->cdev->dev, "The tape information states an"
600                         " incorrect length\n");
601                 return tape_34xx_erp_failed(request, -EIO);
602         case 0x38:
603                 /*
604                  * Physical end of tape. A read/write operation reached
605                  * the physical end of tape.
606                  */
607                 if (request->op==TO_WRI ||
608                     request->op==TO_DSE ||
609                     request->op==TO_WTM)
610                         return tape_34xx_erp_failed(request, -ENOSPC);
611                 return tape_34xx_erp_failed(request, -EIO);
612         case 0x39:
613                 /* Backward at Beginning of tape. */
614                 return tape_34xx_erp_failed(request, -EIO);
615         case 0x3a:
616                 /* Drive switched to not ready. */
617                 dev_warn (&device->cdev->dev, "The tape unit is not ready\n");
618                 return tape_34xx_erp_failed(request, -EIO);
619         case 0x3b:
620                 /* Manual rewind or unload. This causes an I/O error. */
621                 dev_warn (&device->cdev->dev, "The tape medium has been "
622                         "rewound or unloaded manually\n");
623                 tape_34xx_delete_sbid_from(device, 0);
624                 return tape_34xx_erp_failed(request, -EIO);
625         case 0x42:
626                 /*
627                  * Degraded mode. A condition that can cause degraded
628                  * performance is detected.
629                  */
630                 dev_warn (&device->cdev->dev, "The tape subsystem is running "
631                         "in degraded mode\n");
632                 return tape_34xx_erp_retry(request);
633         case 0x43:
634                 /* Drive not ready. */
635                 tape_34xx_delete_sbid_from(device, 0);
636                 tape_med_state_set(device, MS_UNLOADED);
637                 /* Some commands commands are successful even in this case */
638                 if (sense[1] & SENSE_DRIVE_ONLINE) {
639                         switch(request->op) {
640                                 case TO_ASSIGN:
641                                 case TO_UNASSIGN:
642                                 case TO_DIS:
643                                 case TO_NOP:
644                                         return tape_34xx_done(request);
645                                         break;
646                                 default:
647                                         break;
648                         }
649                 }
650                 return tape_34xx_erp_failed(request, -ENOMEDIUM);
651         case 0x44:
652                 /* Locate Block unsuccessful. */
653                 if (request->op != TO_BLOCK && request->op != TO_LBL)
654                         /* No locate block was issued. */
655                         return tape_34xx_erp_bug(device, request,
656                                                  irb, sense[3]);
657                 return tape_34xx_erp_failed(request, -EIO);
658         case 0x45:
659                 /* The drive is assigned to a different channel path. */
660                 dev_warn (&device->cdev->dev, "The tape unit is already "
661                         "assigned\n");
662                 return tape_34xx_erp_failed(request, -EIO);
663         case 0x46:
664                 /*
665                  * Drive not on-line. Drive may be switched offline,
666                  * the power supply may be switched off or
667                  * the drive address may not be set correctly.
668                  */
669                 dev_warn (&device->cdev->dev, "The tape unit is not online\n");
670                 return tape_34xx_erp_failed(request, -EIO);
671         case 0x47:
672                 /* Volume fenced. CU reports volume integrity is lost. */
673                 dev_warn (&device->cdev->dev, "The control unit has fenced "
674                         "access to the tape volume\n");
675                 tape_34xx_delete_sbid_from(device, 0);
676                 return tape_34xx_erp_failed(request, -EIO);
677         case 0x48:
678                 /* Log sense data and retry request. */
679                 return tape_34xx_erp_retry(request);
680         case 0x49:
681                 /* Bus out check. A parity check error on the bus was found. */
682                 dev_warn (&device->cdev->dev, "A parity error occurred on the "
683                         "tape bus\n");
684                 return tape_34xx_erp_failed(request, -EIO);
685         case 0x4a:
686                 /* Control unit erp failed. */
687                 dev_warn (&device->cdev->dev, "I/O error recovery failed on "
688                         "the tape control unit\n");
689                 return tape_34xx_erp_failed(request, -EIO);
690         case 0x4b:
691                 /*
692                  * CU and drive incompatible. The drive requests micro-program
693                  * patches, which are not available on the CU.
694                  */
695                 dev_warn (&device->cdev->dev, "The tape unit requires a "
696                         "firmware update\n");
697                 return tape_34xx_erp_failed(request, -EIO);
698         case 0x4c:
699                 /*
700                  * Recovered Check-One failure. Cu develops a hardware error,
701                  * but is able to recover.
702                  */
703                 return tape_34xx_erp_retry(request);
704         case 0x4d:
705                 if (device->cdev->id.driver_info == tape_3490)
706                         /*
707                          * Resetting event received. Since the driver does
708                          * not support resetting event recovery (which has to
709                          * be handled by the I/O Layer), retry our command.
710                          */
711                         return tape_34xx_erp_retry(request);
712                 /* This erpa is reserved for 3480. */
713                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
714         case 0x4e:
715                 if (device->cdev->id.driver_info == tape_3490) {
716                         /*
717                          * Maximum block size exceeded. This indicates, that
718                          * the block to be written is larger than allowed for
719                          * buffered mode.
720                          */
721                         dev_warn (&device->cdev->dev, "The maximum block size"
722                                 " for buffered mode is exceeded\n");
723                         return tape_34xx_erp_failed(request, -ENOBUFS);
724                 }
725                 /* This erpa is reserved for 3480. */
726                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
727         case 0x50:
728                 /*
729                  * Read buffered log (Overflow). CU is running in extended
730                  * buffered log mode, and a counter overflows. This should
731                  * never happen, since we're never running in extended
732                  * buffered log mode.
733                  */
734                 return tape_34xx_erp_retry(request);
735         case 0x51:
736                 /*
737                  * Read buffered log (EOV). EOF processing occurs while the
738                  * CU is in extended buffered log mode. This should never
739                  * happen, since we're never running in extended buffered
740                  * log mode.
741                  */
742                 return tape_34xx_erp_retry(request);
743         case 0x52:
744                 /* End of Volume complete. Rewind unload completed ok. */
745                 if (request->op == TO_RUN) {
746                         tape_med_state_set(device, MS_UNLOADED);
747                         tape_34xx_delete_sbid_from(device, 0);
748                         return tape_34xx_erp_succeeded(request);
749                 }
750                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
751         case 0x53:
752                 /* Global command intercept. */
753                 return tape_34xx_erp_retry(request);
754         case 0x54:
755                 /* Channel interface recovery (temporary). */
756                 return tape_34xx_erp_retry(request);
757         case 0x55:
758                 /* Channel interface recovery (permanent). */
759                 dev_warn (&device->cdev->dev, "A channel interface error cannot be"
760                         " recovered\n");
761                 return tape_34xx_erp_failed(request, -EIO);
762         case 0x56:
763                 /* Channel protocol error. */
764                 dev_warn (&device->cdev->dev, "A channel protocol error "
765                         "occurred\n");
766                 return tape_34xx_erp_failed(request, -EIO);
767         case 0x57:
768                 if (device->cdev->id.driver_info == tape_3480) {
769                         /* Attention intercept. */
770                         return tape_34xx_erp_retry(request);
771                 } else {
772                         /* Global status intercept. */
773                         return tape_34xx_erp_retry(request);
774                 }
775         case 0x5a:
776                 /*
777                  * Tape length incompatible. The tape inserted is too long,
778                  * which could cause damage to the tape or the drive.
779                  */
780                 dev_warn (&device->cdev->dev, "The tape unit does not support "
781                         "the tape length\n");
782                 return tape_34xx_erp_failed(request, -EIO);
783         case 0x5b:
784                 /* Format 3480 XF incompatible */
785                 if (sense[1] & SENSE_BEGINNING_OF_TAPE)
786                         /* The tape will get overwritten. */
787                         return tape_34xx_erp_retry(request);
788                 dev_warn (&device->cdev->dev, "The tape unit does not support"
789                         " format 3480 XF\n");
790                 return tape_34xx_erp_failed(request, -EIO);
791         case 0x5c:
792                 /* Format 3480-2 XF incompatible */
793                 dev_warn (&device->cdev->dev, "The tape unit does not support tape "
794                         "format 3480-2 XF\n");
795                 return tape_34xx_erp_failed(request, -EIO);
796         case 0x5d:
797                 /* Tape length violation. */
798                 dev_warn (&device->cdev->dev, "The tape unit does not support"
799                         " the current tape length\n");
800                 return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
801         case 0x5e:
802                 /* Compaction algorithm incompatible. */
803                 dev_warn (&device->cdev->dev, "The tape unit does not support"
804                         " the compaction algorithm\n");
805                 return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
806
807                 /* The following erpas should have been covered earlier. */
808         case 0x23: /* Read data check. */
809         case 0x25: /* Write data check. */
810         case 0x26: /* Data check (read opposite). */
811         case 0x28: /* Write id mark check. */
812         case 0x31: /* Tape void. */
813         case 0x40: /* Overrun error. */
814         case 0x41: /* Record sequence error. */
815                 /* All other erpas are reserved for future use. */
816         default:
817                 return tape_34xx_erp_bug(device, request, irb, sense[3]);
818         }
819 }
820
821 /*
822  * 3480/3490 interrupt handler
823  */
824 static int
825 tape_34xx_irq(struct tape_device *device, struct tape_request *request,
826               struct irb *irb)
827 {
828         if (request == NULL)
829                 return tape_34xx_unsolicited_irq(device, irb);
830
831         if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) &&
832             (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) &&
833             (request->op == TO_WRI)) {
834                 /* Write at end of volume */
835                 return tape_34xx_erp_failed(request, -ENOSPC);
836         }
837
838         if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK)
839                 return tape_34xx_unit_check(device, request, irb);
840
841         if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) {
842                 /*
843                  * A unit exception occurs on skipping over a tapemark block.
844                  */
845                 if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) {
846                         if (request->op == TO_BSB || request->op == TO_FSB)
847                                 request->rescnt++;
848                         else
849                                 DBF_EVENT(5, "Unit Exception!\n");
850                 }
851                 return tape_34xx_done(request);
852         }
853
854         DBF_EVENT(6, "xunknownirq\n");
855         tape_dump_sense_dbf(device, request, irb);
856         return TAPE_IO_STOP;
857 }
858
859 /*
860  * ioctl_overload
861  */
862 static int
863 tape_34xx_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
864 {
865         if (cmd == TAPE390_DISPLAY) {
866                 struct display_struct disp;
867
868                 if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)) != 0)
869                         return -EFAULT;
870
871                 return tape_std_display(device, &disp);
872         } else
873                 return -EINVAL;
874 }
875
876 static inline void
877 tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l)
878 {
879         struct tape_34xx_sbid * new_sbid;
880
881         new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC);
882         if (!new_sbid)
883                 return;
884
885         new_sbid->bid = bid;
886         list_add(&new_sbid->list, l);
887 }
888
889 /*
890  * Build up the search block ID list. The block ID consists of a logical
891  * block number and a hardware specific part. The hardware specific part
892  * helps the tape drive to speed up searching for a specific block.
893  */
894 static void
895 tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid)
896 {
897         struct list_head *      sbid_list;
898         struct tape_34xx_sbid * sbid;
899         struct list_head *      l;
900
901         /*
902          * immediately return if there is no list at all or the block to add
903          * is located in segment 1 of wrap 0 because this position is used
904          * if no hardware position data is supplied.
905          */
906         sbid_list = (struct list_head *) device->discdata;
907         if (!sbid_list || (bid.segment < 2 && bid.wrap == 0))
908                 return;
909
910         /*
911          * Search the position where to insert the new entry. Hardware
912          * acceleration uses only the segment and wrap number. So we
913          * need only one entry for a specific wrap/segment combination.
914          * If there is a block with a lower number but the same hard-
915          * ware position data we just update the block number in the
916          * existing entry.
917          */
918         list_for_each(l, sbid_list) {
919                 sbid = list_entry(l, struct tape_34xx_sbid, list);
920
921                 if (
922                         (sbid->bid.segment == bid.segment) &&
923                         (sbid->bid.wrap    == bid.wrap)
924                 ) {
925                         if (bid.block < sbid->bid.block)
926                                 sbid->bid = bid;
927                         else return;
928                         break;
929                 }
930
931                 /* Sort in according to logical block number. */
932                 if (bid.block < sbid->bid.block) {
933                         tape_34xx_append_new_sbid(bid, l->prev);
934                         break;
935                 }
936         }
937         /* List empty or new block bigger than last entry. */
938         if (l == sbid_list)
939                 tape_34xx_append_new_sbid(bid, l->prev);
940
941         DBF_LH(4, "Current list is:\n");
942         list_for_each(l, sbid_list) {
943                 sbid = list_entry(l, struct tape_34xx_sbid, list);
944                 DBF_LH(4, "%d:%03d@%05d\n",
945                         sbid->bid.wrap,
946                         sbid->bid.segment,
947                         sbid->bid.block
948                 );
949         }
950 }
951
952 /*
953  * Delete all entries from the search block ID list that belong to tape blocks
954  * equal or higher than the given number.
955  */
956 static void
957 tape_34xx_delete_sbid_from(struct tape_device *device, int from)
958 {
959         struct list_head *      sbid_list;
960         struct tape_34xx_sbid * sbid;
961         struct list_head *      l;
962         struct list_head *      n;
963
964         sbid_list = (struct list_head *) device->discdata;
965         if (!sbid_list)
966                 return;
967
968         list_for_each_safe(l, n, sbid_list) {
969                 sbid = list_entry(l, struct tape_34xx_sbid, list);
970                 if (sbid->bid.block >= from) {
971                         DBF_LH(4, "Delete sbid %d:%03d@%05d\n",
972                                 sbid->bid.wrap,
973                                 sbid->bid.segment,
974                                 sbid->bid.block
975                         );
976                         list_del(l);
977                         kfree(sbid);
978                 }
979         }
980 }
981
982 /*
983  * Merge hardware position data into a block id.
984  */
985 static void
986 tape_34xx_merge_sbid(
987         struct tape_device *            device,
988         struct tape_34xx_block_id *     bid
989 ) {
990         struct tape_34xx_sbid * sbid;
991         struct tape_34xx_sbid * sbid_to_use;
992         struct list_head *      sbid_list;
993         struct list_head *      l;
994
995         sbid_list = (struct list_head *) device->discdata;
996         bid->wrap    = 0;
997         bid->segment = 1;
998
999         if (!sbid_list || list_empty(sbid_list))
1000                 return;
1001
1002         sbid_to_use = NULL;
1003         list_for_each(l, sbid_list) {
1004                 sbid = list_entry(l, struct tape_34xx_sbid, list);
1005
1006                 if (sbid->bid.block >= bid->block)
1007                         break;
1008                 sbid_to_use = sbid;
1009         }
1010         if (sbid_to_use) {
1011                 bid->wrap    = sbid_to_use->bid.wrap;
1012                 bid->segment = sbid_to_use->bid.segment;
1013                 DBF_LH(4, "Use %d:%03d@%05d for %05d\n",
1014                         sbid_to_use->bid.wrap,
1015                         sbid_to_use->bid.segment,
1016                         sbid_to_use->bid.block,
1017                         bid->block
1018                 );
1019         }
1020 }
1021
1022 static int
1023 tape_34xx_setup_device(struct tape_device * device)
1024 {
1025         int                     rc;
1026         struct list_head *      discdata;
1027
1028         DBF_EVENT(6, "34xx device setup\n");
1029         if ((rc = tape_std_assign(device)) == 0) {
1030                 if ((rc = tape_34xx_medium_sense(device)) != 0) {
1031                         DBF_LH(3, "34xx medium sense returned %d\n", rc);
1032                 }
1033         }
1034         discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL);
1035         if (discdata) {
1036                         INIT_LIST_HEAD(discdata);
1037                         device->discdata = discdata;
1038         }
1039
1040         return rc;
1041 }
1042
1043 static void
1044 tape_34xx_cleanup_device(struct tape_device *device)
1045 {
1046         tape_std_unassign(device);
1047         
1048         if (device->discdata) {
1049                 tape_34xx_delete_sbid_from(device, 0);
1050                 kfree(device->discdata);
1051                 device->discdata = NULL;
1052         }
1053 }
1054
1055
1056 /*
1057  * MTTELL: Tell block. Return the number of block relative to current file.
1058  */
1059 static int
1060 tape_34xx_mttell(struct tape_device *device, int mt_count)
1061 {
1062         struct {
1063                 struct tape_34xx_block_id       cbid;
1064                 struct tape_34xx_block_id       dbid;
1065         } __attribute__ ((packed)) block_id;
1066         int rc;
1067
1068         rc = tape_std_read_block_id(device, (__u64 *) &block_id);
1069         if (rc)
1070                 return rc;
1071
1072         tape_34xx_add_sbid(device, block_id.cbid);
1073         return block_id.cbid.block;
1074 }
1075
1076 /*
1077  * MTSEEK: seek to the specified block.
1078  */
1079 static int
1080 tape_34xx_mtseek(struct tape_device *device, int mt_count)
1081 {
1082         struct tape_request *request;
1083         struct tape_34xx_block_id *     bid;
1084
1085         if (mt_count > 0x3fffff) {
1086                 DBF_EXCEPTION(6, "xsee parm\n");
1087                 return -EINVAL;
1088         }
1089         request = tape_alloc_request(3, 4);
1090         if (IS_ERR(request))
1091                 return PTR_ERR(request);
1092
1093         /* setup ccws */
1094         request->op = TO_LBL;
1095         bid         = (struct tape_34xx_block_id *) request->cpdata;
1096         bid->format = (*device->modeset_byte & 0x08) ?
1097                         TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480;
1098         bid->block  = mt_count;
1099         tape_34xx_merge_sbid(device, bid);
1100
1101         tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
1102         tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
1103         tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
1104
1105         /* execute it */
1106         return tape_do_io_free(device, request);
1107 }
1108
1109 #ifdef CONFIG_S390_TAPE_BLOCK
1110 /*
1111  * Tape block read for 34xx.
1112  */
1113 static struct tape_request *
1114 tape_34xx_bread(struct tape_device *device, struct request *req)
1115 {
1116         struct tape_request *request;
1117         struct ccw1 *ccw;
1118         int count = 0;
1119         unsigned off;
1120         char *dst;
1121         struct bio_vec *bv;
1122         struct req_iterator iter;
1123         struct tape_34xx_block_id *     start_block;
1124
1125         DBF_EVENT(6, "xBREDid:");
1126
1127         /* Count the number of blocks for the request. */
1128         rq_for_each_segment(bv, req, iter)
1129                 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
1130
1131         /* Allocate the ccw request. */
1132         request = tape_alloc_request(3+count+1, 8);
1133         if (IS_ERR(request))
1134                 return request;
1135
1136         /* Setup ccws. */
1137         request->op = TO_BLOCK;
1138         start_block = (struct tape_34xx_block_id *) request->cpdata;
1139         start_block->block = blk_rq_pos(req) >> TAPEBLOCK_HSEC_S2B;
1140         DBF_EVENT(6, "start_block = %i\n", start_block->block);
1141
1142         ccw = request->cpaddr;
1143         ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
1144
1145         /*
1146          * We always setup a nop after the mode set ccw. This slot is
1147          * used in tape_std_check_locate to insert a locate ccw if the
1148          * current tape position doesn't match the start block to be read.
1149          * The second nop will be filled with a read block id which is in
1150          * turn used by tape_34xx_free_bread to populate the segment bid
1151          * table.
1152          */
1153         ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
1154         ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
1155
1156         rq_for_each_segment(bv, req, iter) {
1157                 dst = kmap(bv->bv_page) + bv->bv_offset;
1158                 for (off = 0; off < bv->bv_len; off += TAPEBLOCK_HSEC_SIZE) {
1159                         ccw->flags = CCW_FLAG_CC;
1160                         ccw->cmd_code = READ_FORWARD;
1161                         ccw->count = TAPEBLOCK_HSEC_SIZE;
1162                         set_normalized_cda(ccw, (void*) __pa(dst));
1163                         ccw++;
1164                         dst += TAPEBLOCK_HSEC_SIZE;
1165                 }
1166         }
1167
1168         ccw = tape_ccw_end(ccw, NOP, 0, NULL);
1169         DBF_EVENT(6, "xBREDccwg\n");
1170         return request;
1171 }
1172
1173 static void
1174 tape_34xx_free_bread (struct tape_request *request)
1175 {
1176         struct ccw1* ccw;
1177
1178         ccw = request->cpaddr;
1179         if ((ccw + 2)->cmd_code == READ_BLOCK_ID) {
1180                 struct {
1181                         struct tape_34xx_block_id       cbid;
1182                         struct tape_34xx_block_id       dbid;
1183                 } __attribute__ ((packed)) *rbi_data;
1184
1185                 rbi_data = request->cpdata;
1186
1187                 if (request->device)
1188                         tape_34xx_add_sbid(request->device, rbi_data->cbid);
1189         }
1190
1191         /* Last ccw is a nop and doesn't need clear_normalized_cda */
1192         for (; ccw->flags & CCW_FLAG_CC; ccw++)
1193                 if (ccw->cmd_code == READ_FORWARD)
1194                         clear_normalized_cda(ccw);
1195         tape_free_request(request);
1196 }
1197
1198 /*
1199  * check_locate is called just before the tape request is passed to
1200  * the common io layer for execution. It has to check the current
1201  * tape position and insert a locate ccw if it doesn't match the
1202  * start block for the request.
1203  */
1204 static void
1205 tape_34xx_check_locate(struct tape_device *device, struct tape_request *request)
1206 {
1207         struct tape_34xx_block_id *     start_block;
1208
1209         start_block = (struct tape_34xx_block_id *) request->cpdata;
1210         if (start_block->block == device->blk_data.block_position)
1211                 return;
1212
1213         DBF_LH(4, "Block seek(%06d+%06d)\n", start_block->block, device->bof);
1214         start_block->wrap    = 0;
1215         start_block->segment = 1;
1216         start_block->format  = (*device->modeset_byte & 0x08) ?
1217                                 TAPE34XX_FMT_3480_XF :
1218                                 TAPE34XX_FMT_3480;
1219         start_block->block   = start_block->block + device->bof;
1220         tape_34xx_merge_sbid(device, start_block);
1221         tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
1222         tape_ccw_cc(request->cpaddr + 2, READ_BLOCK_ID, 8, request->cpdata);
1223 }
1224 #endif
1225
1226 /*
1227  * List of 3480/3490 magnetic tape commands.
1228  */
1229 static tape_mtop_fn tape_34xx_mtop[TAPE_NR_MTOPS] = {
1230         [MTRESET]        = tape_std_mtreset,
1231         [MTFSF]          = tape_std_mtfsf,
1232         [MTBSF]          = tape_std_mtbsf,
1233         [MTFSR]          = tape_std_mtfsr,
1234         [MTBSR]          = tape_std_mtbsr,
1235         [MTWEOF]         = tape_std_mtweof,
1236         [MTREW]          = tape_std_mtrew,
1237         [MTOFFL]         = tape_std_mtoffl,
1238         [MTNOP]          = tape_std_mtnop,
1239         [MTRETEN]        = tape_std_mtreten,
1240         [MTBSFM]         = tape_std_mtbsfm,
1241         [MTFSFM]         = tape_std_mtfsfm,
1242         [MTEOM]          = tape_std_mteom,
1243         [MTERASE]        = tape_std_mterase,
1244         [MTRAS1]         = NULL,
1245         [MTRAS2]         = NULL,
1246         [MTRAS3]         = NULL,
1247         [MTSETBLK]       = tape_std_mtsetblk,
1248         [MTSETDENSITY]   = NULL,
1249         [MTSEEK]         = tape_34xx_mtseek,
1250         [MTTELL]         = tape_34xx_mttell,
1251         [MTSETDRVBUFFER] = NULL,
1252         [MTFSS]          = NULL,
1253         [MTBSS]          = NULL,
1254         [MTWSM]          = NULL,
1255         [MTLOCK]         = NULL,
1256         [MTUNLOCK]       = NULL,
1257         [MTLOAD]         = tape_std_mtload,
1258         [MTUNLOAD]       = tape_std_mtunload,
1259         [MTCOMPRESSION]  = tape_std_mtcompression,
1260         [MTSETPART]      = NULL,
1261         [MTMKPART]       = NULL
1262 };
1263
1264 /*
1265  * Tape discipline structure for 3480 and 3490.
1266  */
1267 static struct tape_discipline tape_discipline_34xx = {
1268         .owner = THIS_MODULE,
1269         .setup_device = tape_34xx_setup_device,
1270         .cleanup_device = tape_34xx_cleanup_device,
1271         .process_eov = tape_std_process_eov,
1272         .irq = tape_34xx_irq,
1273         .read_block = tape_std_read_block,
1274         .write_block = tape_std_write_block,
1275 #ifdef CONFIG_S390_TAPE_BLOCK
1276         .bread = tape_34xx_bread,
1277         .free_bread = tape_34xx_free_bread,
1278         .check_locate = tape_34xx_check_locate,
1279 #endif
1280         .ioctl_fn = tape_34xx_ioctl,
1281         .mtop_array = tape_34xx_mtop
1282 };
1283
1284 static struct ccw_device_id tape_34xx_ids[] = {
1285         { CCW_DEVICE_DEVTYPE(0x3480, 0, 0x3480, 0), .driver_info = tape_3480},
1286         { CCW_DEVICE_DEVTYPE(0x3490, 0, 0x3490, 0), .driver_info = tape_3490},
1287         { /* end of list */ },
1288 };
1289
1290 static int
1291 tape_34xx_online(struct ccw_device *cdev)
1292 {
1293         return tape_generic_online(
1294                 dev_get_drvdata(&cdev->dev),
1295                 &tape_discipline_34xx
1296         );
1297 }
1298
1299 static struct ccw_driver tape_34xx_driver = {
1300         .name = "tape_34xx",
1301         .owner = THIS_MODULE,
1302         .ids = tape_34xx_ids,
1303         .probe = tape_generic_probe,
1304         .remove = tape_generic_remove,
1305         .set_online = tape_34xx_online,
1306         .set_offline = tape_generic_offline,
1307         .freeze = tape_generic_pm_suspend,
1308 };
1309
1310 static int
1311 tape_34xx_init (void)
1312 {
1313         int rc;
1314
1315         TAPE_DBF_AREA = debug_register ( "tape_34xx", 2, 2, 4*sizeof(long));
1316         debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
1317 #ifdef DBF_LIKE_HELL
1318         debug_set_level(TAPE_DBF_AREA, 6);
1319 #endif
1320
1321         DBF_EVENT(3, "34xx init\n");
1322         /* Register driver for 3480/3490 tapes. */
1323         rc = ccw_driver_register(&tape_34xx_driver);
1324         if (rc)
1325                 DBF_EVENT(3, "34xx init failed\n");
1326         else
1327                 DBF_EVENT(3, "34xx registered\n");
1328         return rc;
1329 }
1330
1331 static void
1332 tape_34xx_exit(void)
1333 {
1334         ccw_driver_unregister(&tape_34xx_driver);
1335
1336         debug_unregister(TAPE_DBF_AREA);
1337 }
1338
1339 MODULE_DEVICE_TABLE(ccw, tape_34xx_ids);
1340 MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");
1341 MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver");
1342 MODULE_LICENSE("GPL");
1343
1344 module_init(tape_34xx_init);
1345 module_exit(tape_34xx_exit);