ide-floppy.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  1. /*
  2. * IDE ATAPI floppy driver.
  3. *
  4. * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il>
  5. * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net>
  6. * Copyright (C) 2005 Bartlomiej Zolnierkiewicz
  7. *
  8. * This driver supports the following IDE floppy drives:
  9. *
  10. * LS-120/240 SuperDisk
  11. * Iomega Zip 100/250
  12. * Iomega PC Card Clik!/PocketZip
  13. *
  14. * For a historical changelog see
  15. * Documentation/ide/ChangeLog.ide-floppy.1996-2002
  16. */
  17. #define IDEFLOPPY_VERSION "1.00"
  18. #include <linux/module.h>
  19. #include <linux/types.h>
  20. #include <linux/string.h>
  21. #include <linux/kernel.h>
  22. #include <linux/delay.h>
  23. #include <linux/timer.h>
  24. #include <linux/mm.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/major.h>
  27. #include <linux/errno.h>
  28. #include <linux/genhd.h>
  29. #include <linux/slab.h>
  30. #include <linux/cdrom.h>
  31. #include <linux/ide.h>
  32. #include <linux/bitops.h>
  33. #include <linux/mutex.h>
  34. #include <scsi/scsi_ioctl.h>
  35. #include <asm/byteorder.h>
  36. #include <linux/irq.h>
  37. #include <linux/uaccess.h>
  38. #include <linux/io.h>
  39. #include <asm/unaligned.h>
  40. /* define to see debug info */
  41. #define IDEFLOPPY_DEBUG_LOG 0
  42. /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */
  43. #define IDEFLOPPY_DEBUG(fmt, args...)
  44. #if IDEFLOPPY_DEBUG_LOG
  45. #define debug_log(fmt, args...) \
  46. printk(KERN_INFO "ide-floppy: " fmt, ## args)
  47. #else
  48. #define debug_log(fmt, args...) do {} while (0)
  49. #endif
  50. /* Some drives require a longer irq timeout. */
  51. #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD)
  52. /*
  53. * After each failed packet command we issue a request sense command and retry
  54. * the packet command IDEFLOPPY_MAX_PC_RETRIES times.
  55. */
  56. #define IDEFLOPPY_MAX_PC_RETRIES 3
  57. /*
  58. * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE
  59. * bytes.
  60. */
  61. #define IDEFLOPPY_PC_BUFFER_SIZE 256
  62. /*
  63. * In various places in the driver, we need to allocate storage for packet
  64. * commands and requests, which will remain valid while we leave the driver to
  65. * wait for an interrupt or a timeout event.
  66. */
  67. #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
  68. typedef struct idefloppy_packet_command_s {
  69. u8 c[12]; /* Actual packet bytes */
  70. int retries; /* On each retry, we increment
  71. retries */
  72. int error; /* Error code */
  73. int request_transfer; /* Bytes to transfer */
  74. int actually_transferred; /* Bytes actually transferred */
  75. int buffer_size; /* Size of our data buffer */
  76. int b_count; /* Missing/Available data on
  77. the current buffer */
  78. struct request *rq; /* The corresponding request */
  79. u8 *buffer; /* Data buffer */
  80. u8 *current_position; /* Pointer into above buffer */
  81. void (*callback) (ide_drive_t *); /* Called when this packet
  82. command is completed */
  83. u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
  84. unsigned long flags; /* Status/Action bit flags: long
  85. for set_bit */
  86. } idefloppy_pc_t;
  87. /* Packet command flag bits. */
  88. enum {
  89. /* 1 when we prefer to use DMA if possible */
  90. PC_FLAG_DMA_RECOMMENDED = (1 << 0),
  91. /* 1 while DMA in progress */
  92. PC_FLAG_DMA_IN_PROGRESS = (1 << 1),
  93. /* 1 when encountered problem during DMA */
  94. PC_FLAG_DMA_ERROR = (1 << 2),
  95. /* Data direction */
  96. PC_FLAG_WRITING = (1 << 3),
  97. /* Suppress error reporting */
  98. PC_FLAG_SUPPRESS_ERROR = (1 << 4),
  99. };
  100. /* format capacities descriptor codes */
  101. #define CAPACITY_INVALID 0x00
  102. #define CAPACITY_UNFORMATTED 0x01
  103. #define CAPACITY_CURRENT 0x02
  104. #define CAPACITY_NO_CARTRIDGE 0x03
  105. /*
  106. * Most of our global data which we need to save even as we leave the driver
  107. * due to an interrupt or a timer event is stored in a variable of type
  108. * idefloppy_floppy_t, defined below.
  109. */
  110. typedef struct ide_floppy_obj {
  111. ide_drive_t *drive;
  112. ide_driver_t *driver;
  113. struct gendisk *disk;
  114. struct kref kref;
  115. unsigned int openers; /* protected by BKL for now */
  116. /* Current packet command */
  117. idefloppy_pc_t *pc;
  118. /* Last failed packet command */
  119. idefloppy_pc_t *failed_pc;
  120. /* Packet command stack */
  121. idefloppy_pc_t pc_stack[IDEFLOPPY_PC_STACK];
  122. /* Next free packet command storage space */
  123. int pc_stack_index;
  124. struct request rq_stack[IDEFLOPPY_PC_STACK];
  125. /* We implement a circular array */
  126. int rq_stack_index;
  127. /* Last error information */
  128. u8 sense_key, asc, ascq;
  129. /* delay this long before sending packet command */
  130. u8 ticks;
  131. int progress_indication;
  132. /* Device information */
  133. /* Current format */
  134. int blocks, block_size, bs_factor;
  135. /* Last format capacity descriptor */
  136. u8 cap_desc[8];
  137. /* Copy of the flexible disk page */
  138. u8 flexible_disk_page[32];
  139. /* Write protect */
  140. int wp;
  141. /* Supports format progress report */
  142. int srfp;
  143. /* Status/Action flags */
  144. unsigned long flags;
  145. } idefloppy_floppy_t;
  146. #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */
  147. /* Floppy flag bits values. */
  148. enum {
  149. /* DRQ interrupt device */
  150. IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0),
  151. /* Media may have changed */
  152. IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1),
  153. /* Format in progress */
  154. IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2),
  155. /* Avoid commands not supported in Clik drive */
  156. IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3),
  157. /* Requires BH algorithm for packets */
  158. IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4),
  159. };
  160. /* Defines for the MODE SENSE command */
  161. #define MODE_SENSE_CURRENT 0x00
  162. #define MODE_SENSE_CHANGEABLE 0x01
  163. #define MODE_SENSE_DEFAULT 0x02
  164. #define MODE_SENSE_SAVED 0x03
  165. /* IOCTLs used in low-level formatting. */
  166. #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600
  167. #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601
  168. #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602
  169. #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603
  170. /* Error code returned in rq->errors to the higher part of the driver. */
  171. #define IDEFLOPPY_ERROR_GENERAL 101
  172. /*
  173. * Pages of the SELECT SENSE / MODE SENSE packet commands.
  174. * See SFF-8070i spec.
  175. */
  176. #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b
  177. #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05
  178. static DEFINE_MUTEX(idefloppy_ref_mutex);
  179. #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)
  180. #define ide_floppy_g(disk) \
  181. container_of((disk)->private_data, struct ide_floppy_obj, driver)
  182. static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
  183. {
  184. struct ide_floppy_obj *floppy = NULL;
  185. mutex_lock(&idefloppy_ref_mutex);
  186. floppy = ide_floppy_g(disk);
  187. if (floppy)
  188. kref_get(&floppy->kref);
  189. mutex_unlock(&idefloppy_ref_mutex);
  190. return floppy;
  191. }
  192. static void idefloppy_cleanup_obj(struct kref *);
  193. static void ide_floppy_put(struct ide_floppy_obj *floppy)
  194. {
  195. mutex_lock(&idefloppy_ref_mutex);
  196. kref_put(&floppy->kref, idefloppy_cleanup_obj);
  197. mutex_unlock(&idefloppy_ref_mutex);
  198. }
  199. /*
  200. * Too bad. The drive wants to send us data which we are not ready to accept.
  201. * Just throw it away.
  202. */
  203. static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount)
  204. {
  205. while (bcount--)
  206. (void) HWIF(drive)->INB(IDE_DATA_REG);
  207. }
  208. static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount)
  209. {
  210. while (bcount--)
  211. HWIF(drive)->OUTB(0, IDE_DATA_REG);
  212. }
  213. /*
  214. * Used to finish servicing a request. For read/write requests, we will call
  215. * ide_end_request to pass to the next buffer.
  216. */
  217. static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs)
  218. {
  219. idefloppy_floppy_t *floppy = drive->driver_data;
  220. struct request *rq = HWGROUP(drive)->rq;
  221. int error;
  222. debug_log("Reached %s\n", __func__);
  223. switch (uptodate) {
  224. case 0: error = IDEFLOPPY_ERROR_GENERAL; break;
  225. case 1: error = 0; break;
  226. default: error = uptodate;
  227. }
  228. if (error)
  229. floppy->failed_pc = NULL;
  230. /* Why does this happen? */
  231. if (!rq)
  232. return 0;
  233. if (!blk_special_request(rq)) {
  234. /* our real local end request function */
  235. ide_end_request(drive, uptodate, nsecs);
  236. return 0;
  237. }
  238. rq->errors = error;
  239. /* fixme: need to move this local also */
  240. ide_end_drive_cmd(drive, 0, 0);
  241. return 0;
  242. }
  243. static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
  244. unsigned int bcount, int direction)
  245. {
  246. struct request *rq = pc->rq;
  247. struct req_iterator iter;
  248. struct bio_vec *bvec;
  249. unsigned long flags;
  250. int count, done = 0;
  251. char *data;
  252. rq_for_each_segment(bvec, rq, iter) {
  253. if (!bcount)
  254. break;
  255. count = min(bvec->bv_len, bcount);
  256. data = bvec_kmap_irq(bvec, &flags);
  257. if (direction)
  258. drive->hwif->atapi_output_bytes(drive, data, count);
  259. else
  260. drive->hwif->atapi_input_bytes(drive, data, count);
  261. bvec_kunmap_irq(data, &flags);
  262. bcount -= count;
  263. pc->b_count += count;
  264. done += count;
  265. }
  266. idefloppy_do_end_request(drive, 1, done >> 9);
  267. if (bcount) {
  268. printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
  269. drive->name, __func__, bcount);
  270. if (direction)
  271. idefloppy_write_zeros(drive, bcount);
  272. else
  273. idefloppy_discard_data(drive, bcount);
  274. }
  275. }
  276. static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc)
  277. {
  278. struct request *rq = pc->rq;
  279. struct bio *bio = rq->bio;
  280. while ((bio = rq->bio) != NULL)
  281. idefloppy_do_end_request(drive, 1, 0);
  282. }
  283. /*
  284. * Generate a new packet command request in front of the request queue, before
  285. * the current request so that it will be processed immediately, on the next
  286. * pass through the driver.
  287. */
  288. static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc,
  289. struct request *rq)
  290. {
  291. struct ide_floppy_obj *floppy = drive->driver_data;
  292. ide_init_drive_cmd(rq);
  293. rq->buffer = (char *) pc;
  294. rq->cmd_type = REQ_TYPE_SPECIAL;
  295. rq->rq_disk = floppy->disk;
  296. (void) ide_do_drive_cmd(drive, rq, ide_preempt);
  297. }
  298. static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive)
  299. {
  300. idefloppy_floppy_t *floppy = drive->driver_data;
  301. if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK)
  302. floppy->pc_stack_index = 0;
  303. return (&floppy->pc_stack[floppy->pc_stack_index++]);
  304. }
  305. static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
  306. {
  307. idefloppy_floppy_t *floppy = drive->driver_data;
  308. if (floppy->rq_stack_index == IDEFLOPPY_PC_STACK)
  309. floppy->rq_stack_index = 0;
  310. return (&floppy->rq_stack[floppy->rq_stack_index++]);
  311. }
  312. static void idefloppy_request_sense_callback(ide_drive_t *drive)
  313. {
  314. idefloppy_floppy_t *floppy = drive->driver_data;
  315. u8 *buf = floppy->pc->buffer;
  316. debug_log("Reached %s\n", __func__);
  317. if (!floppy->pc->error) {
  318. floppy->sense_key = buf[2] & 0x0F;
  319. floppy->asc = buf[12];
  320. floppy->ascq = buf[13];
  321. floppy->progress_indication = buf[15] & 0x80 ?
  322. (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
  323. if (floppy->failed_pc)
  324. debug_log("pc = %x, sense key = %x, asc = %x,"
  325. " ascq = %x\n",
  326. floppy->failed_pc->c[0],
  327. floppy->sense_key,
  328. floppy->asc,
  329. floppy->ascq);
  330. else
  331. debug_log("sense key = %x, asc = %x, ascq = %x\n",
  332. floppy->sense_key,
  333. floppy->asc,
  334. floppy->ascq);
  335. idefloppy_do_end_request(drive, 1, 0);
  336. } else {
  337. printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
  338. " request!\n");
  339. idefloppy_do_end_request(drive, 0, 0);
  340. }
  341. }
  342. /* General packet command callback function. */
  343. static void idefloppy_pc_callback(ide_drive_t *drive)
  344. {
  345. idefloppy_floppy_t *floppy = drive->driver_data;
  346. debug_log("Reached %s\n", __func__);
  347. idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0);
  348. }
  349. static void idefloppy_init_pc(idefloppy_pc_t *pc)
  350. {
  351. memset(pc->c, 0, 12);
  352. pc->retries = 0;
  353. pc->flags = 0;
  354. pc->request_transfer = 0;
  355. pc->buffer = pc->pc_buffer;
  356. pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
  357. pc->callback = &idefloppy_pc_callback;
  358. }
  359. static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc)
  360. {
  361. idefloppy_init_pc(pc);
  362. pc->c[0] = GPCMD_REQUEST_SENSE;
  363. pc->c[4] = 255;
  364. pc->request_transfer = 18;
  365. pc->callback = &idefloppy_request_sense_callback;
  366. }
  367. /*
  368. * Called when an error was detected during the last packet command. We queue a
  369. * request sense packet command in the head of the request list.
  370. */
  371. static void idefloppy_retry_pc(ide_drive_t *drive)
  372. {
  373. idefloppy_pc_t *pc;
  374. struct request *rq;
  375. (void)ide_read_error(drive);
  376. pc = idefloppy_next_pc_storage(drive);
  377. rq = idefloppy_next_rq_storage(drive);
  378. idefloppy_create_request_sense_cmd(pc);
  379. idefloppy_queue_pc_head(drive, pc, rq);
  380. }
  381. /* The usual interrupt handler called during a packet command. */
  382. static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
  383. {
  384. idefloppy_floppy_t *floppy = drive->driver_data;
  385. ide_hwif_t *hwif = drive->hwif;
  386. idefloppy_pc_t *pc = floppy->pc;
  387. struct request *rq = pc->rq;
  388. xfer_func_t *xferfunc;
  389. unsigned int temp;
  390. int dma_error = 0;
  391. u16 bcount;
  392. u8 stat, ireason;
  393. debug_log("Reached %s interrupt handler\n", __func__);
  394. if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
  395. dma_error = hwif->ide_dma_end(drive);
  396. if (dma_error) {
  397. printk(KERN_ERR "%s: DMA %s error\n", drive->name,
  398. rq_data_dir(rq) ? "write" : "read");
  399. pc->flags |= PC_FLAG_DMA_ERROR;
  400. } else {
  401. pc->actually_transferred = pc->request_transfer;
  402. idefloppy_update_buffers(drive, pc);
  403. }
  404. debug_log("DMA finished\n");
  405. }
  406. /* Clear the interrupt */
  407. stat = ide_read_status(drive);
  408. /* No more interrupts */
  409. if ((stat & DRQ_STAT) == 0) {
  410. debug_log("Packet command completed, %d bytes transferred\n",
  411. pc->actually_transferred);
  412. pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
  413. local_irq_enable_in_hardirq();
  414. if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
  415. /* Error detected */
  416. debug_log("%s: I/O error\n", drive->name);
  417. rq->errors++;
  418. if (pc->c[0] == GPCMD_REQUEST_SENSE) {
  419. printk(KERN_ERR "ide-floppy: I/O error in "
  420. "request sense command\n");
  421. return ide_do_reset(drive);
  422. }
  423. /* Retry operation */
  424. idefloppy_retry_pc(drive);
  425. /* queued, but not started */
  426. return ide_stopped;
  427. }
  428. pc->error = 0;
  429. if (floppy->failed_pc == pc)
  430. floppy->failed_pc = NULL;
  431. /* Command finished - Call the callback function */
  432. pc->callback(drive);
  433. return ide_stopped;
  434. }
  435. if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
  436. pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
  437. printk(KERN_ERR "ide-floppy: The floppy wants to issue "
  438. "more interrupts in DMA mode\n");
  439. ide_dma_off(drive);
  440. return ide_do_reset(drive);
  441. }
  442. /* Get the number of bytes to transfer */
  443. bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) |
  444. hwif->INB(IDE_BCOUNTL_REG);
  445. /* on this interrupt */
  446. ireason = hwif->INB(IDE_IREASON_REG);
  447. if (ireason & CD) {
  448. printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
  449. return ide_do_reset(drive);
  450. }
  451. if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
  452. /* Hopefully, we will never get here */
  453. printk(KERN_ERR "ide-floppy: We wanted to %s, ",
  454. (ireason & IO) ? "Write" : "Read");
  455. printk(KERN_ERR "but the floppy wants us to %s !\n",
  456. (ireason & IO) ? "Read" : "Write");
  457. return ide_do_reset(drive);
  458. }
  459. if (!(pc->flags & PC_FLAG_WRITING)) {
  460. /* Reading - Check that we have enough space */
  461. temp = pc->actually_transferred + bcount;
  462. if (temp > pc->request_transfer) {
  463. if (temp > pc->buffer_size) {
  464. printk(KERN_ERR "ide-floppy: The floppy wants "
  465. "to send us more data than expected "
  466. "- discarding data\n");
  467. idefloppy_discard_data(drive, bcount);
  468. ide_set_handler(drive,
  469. &idefloppy_pc_intr,
  470. IDEFLOPPY_WAIT_CMD,
  471. NULL);
  472. return ide_started;
  473. }
  474. debug_log("The floppy wants to send us more data than"
  475. " expected - allowing transfer\n");
  476. }
  477. }
  478. if (pc->flags & PC_FLAG_WRITING)
  479. xferfunc = hwif->atapi_output_bytes;
  480. else
  481. xferfunc = hwif->atapi_input_bytes;
  482. if (pc->buffer)
  483. xferfunc(drive, pc->current_position, bcount);
  484. else
  485. ide_floppy_io_buffers(drive, pc, bcount,
  486. !!(pc->flags & PC_FLAG_WRITING));
  487. /* Update the current position */
  488. pc->actually_transferred += bcount;
  489. pc->current_position += bcount;
  490. /* And set the interrupt handler again */
  491. ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
  492. return ide_started;
  493. }
  494. /*
  495. * This is the original routine that did the packet transfer.
  496. * It fails at high speeds on the Iomega ZIP drive, so there's a slower version
  497. * for that drive below. The algorithm is chosen based on drive type
  498. */
  499. static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
  500. {
  501. ide_startstop_t startstop;
  502. idefloppy_floppy_t *floppy = drive->driver_data;
  503. u8 ireason;
  504. if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
  505. printk(KERN_ERR "ide-floppy: Strange, packet command "
  506. "initiated yet DRQ isn't asserted\n");
  507. return startstop;
  508. }
  509. ireason = drive->hwif->INB(IDE_IREASON_REG);
  510. if ((ireason & CD) == 0 || (ireason & IO)) {
  511. printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
  512. "issuing a packet command\n");
  513. return ide_do_reset(drive);
  514. }
  515. /* Set the interrupt routine */
  516. ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
  517. /* Send the actual packet */
  518. HWIF(drive)->atapi_output_bytes(drive, floppy->pc->c, 12);
  519. return ide_started;
  520. }
  521. /*
  522. * What we have here is a classic case of a top half / bottom half interrupt
  523. * service routine. In interrupt mode, the device sends an interrupt to signal
  524. * that it is ready to receive a packet. However, we need to delay about 2-3
  525. * ticks before issuing the packet or we gets in trouble.
  526. *
  527. * So, follow carefully. transfer_pc1 is called as an interrupt (or directly).
  528. * In either case, when the device says it's ready for a packet, we schedule
  529. * the packet transfer to occur about 2-3 ticks later in transfer_pc2.
  530. */
  531. static int idefloppy_transfer_pc2(ide_drive_t *drive)
  532. {
  533. idefloppy_floppy_t *floppy = drive->driver_data;
  534. /* Send the actual packet */
  535. HWIF(drive)->atapi_output_bytes(drive, floppy->pc->c, 12);
  536. /* Timeout for the packet command */
  537. return IDEFLOPPY_WAIT_CMD;
  538. }
  539. static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
  540. {
  541. idefloppy_floppy_t *floppy = drive->driver_data;
  542. ide_startstop_t startstop;
  543. u8 ireason;
  544. if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
  545. printk(KERN_ERR "ide-floppy: Strange, packet command "
  546. "initiated yet DRQ isn't asserted\n");
  547. return startstop;
  548. }
  549. ireason = drive->hwif->INB(IDE_IREASON_REG);
  550. if ((ireason & CD) == 0 || (ireason & IO)) {
  551. printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
  552. "while issuing a packet command\n");
  553. return ide_do_reset(drive);
  554. }
  555. /*
  556. * The following delay solves a problem with ATAPI Zip 100 drives
  557. * where the Busy flag was apparently being deasserted before the
  558. * unit was ready to receive data. This was happening on a
  559. * 1200 MHz Athlon system. 10/26/01 25msec is too short,
  560. * 40 and 50msec work well. idefloppy_pc_intr will not be actually
  561. * used until after the packet is moved in about 50 msec.
  562. */
  563. ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks,
  564. &idefloppy_transfer_pc2);
  565. return ide_started;
  566. }
  567. static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
  568. idefloppy_pc_t *pc)
  569. {
  570. /* supress error messages resulting from Medium not present */
  571. if (floppy->sense_key == 0x02 &&
  572. floppy->asc == 0x3a &&
  573. floppy->ascq == 0x00)
  574. return;
  575. printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, "
  576. "asc = %2x, ascq = %2x\n",
  577. floppy->drive->name, pc->c[0], floppy->sense_key,
  578. floppy->asc, floppy->ascq);
  579. }
  580. static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
  581. idefloppy_pc_t *pc)
  582. {
  583. idefloppy_floppy_t *floppy = drive->driver_data;
  584. ide_hwif_t *hwif = drive->hwif;
  585. ide_handler_t *pkt_xfer_routine;
  586. u16 bcount;
  587. u8 dma;
  588. if (floppy->failed_pc == NULL &&
  589. pc->c[0] != GPCMD_REQUEST_SENSE)
  590. floppy->failed_pc = pc;
  591. /* Set the current packet command */
  592. floppy->pc = pc;
  593. if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) {
  594. if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR))
  595. ide_floppy_report_error(floppy, pc);
  596. /* Giving up */
  597. pc->error = IDEFLOPPY_ERROR_GENERAL;
  598. floppy->failed_pc = NULL;
  599. pc->callback(drive);
  600. return ide_stopped;
  601. }
  602. debug_log("Retry number - %d\n", pc->retries);
  603. pc->retries++;
  604. /* We haven't transferred any data yet */
  605. pc->actually_transferred = 0;
  606. pc->current_position = pc->buffer;
  607. bcount = min(pc->request_transfer, 63 * 1024);
  608. if (pc->flags & PC_FLAG_DMA_ERROR) {
  609. pc->flags &= ~PC_FLAG_DMA_ERROR;
  610. ide_dma_off(drive);
  611. }
  612. dma = 0;
  613. if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma)
  614. dma = !hwif->dma_setup(drive);
  615. ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
  616. IDE_TFLAG_OUT_DEVICE, bcount, dma);
  617. if (dma) {
  618. /* Begin DMA, if necessary */
  619. pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
  620. hwif->dma_start(drive);
  621. }
  622. /* Can we transfer the packet when we get the interrupt or wait? */
  623. if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) {
  624. /* wait */
  625. pkt_xfer_routine = &idefloppy_transfer_pc1;
  626. } else {
  627. /* immediate */
  628. pkt_xfer_routine = &idefloppy_transfer_pc;
  629. }
  630. if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) {
  631. /* Issue the packet command */
  632. ide_execute_command(drive, WIN_PACKETCMD,
  633. pkt_xfer_routine,
  634. IDEFLOPPY_WAIT_CMD,
  635. NULL);
  636. return ide_started;
  637. } else {
  638. /* Issue the packet command */
  639. HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
  640. return (*pkt_xfer_routine) (drive);
  641. }
  642. }
  643. static void idefloppy_rw_callback(ide_drive_t *drive)
  644. {
  645. debug_log("Reached %s\n", __func__);
  646. idefloppy_do_end_request(drive, 1, 0);
  647. return;
  648. }
  649. static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent)
  650. {
  651. debug_log("creating prevent removal command, prevent = %d\n", prevent);
  652. idefloppy_init_pc(pc);
  653. pc->c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
  654. pc->c[4] = prevent;
  655. }
  656. static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc)
  657. {
  658. idefloppy_init_pc(pc);
  659. pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES;
  660. pc->c[7] = 255;
  661. pc->c[8] = 255;
  662. pc->request_transfer = 255;
  663. }
  664. static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l,
  665. int flags)
  666. {
  667. idefloppy_init_pc(pc);
  668. pc->c[0] = GPCMD_FORMAT_UNIT;
  669. pc->c[1] = 0x17;
  670. memset(pc->buffer, 0, 12);
  671. pc->buffer[1] = 0xA2;
  672. /* Default format list header, u8 1: FOV/DCRT/IMM bits set */
  673. if (flags & 1) /* Verify bit on... */
  674. pc->buffer[1] ^= 0x20; /* ... turn off DCRT bit */
  675. pc->buffer[3] = 8;
  676. put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4]));
  677. put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8]));
  678. pc->buffer_size = 12;
  679. pc->flags |= PC_FLAG_WRITING;
  680. }
  681. /* A mode sense command is used to "sense" floppy parameters. */
  682. static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code,
  683. u8 type)
  684. {
  685. u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */
  686. idefloppy_init_pc(pc);
  687. pc->c[0] = GPCMD_MODE_SENSE_10;
  688. pc->c[1] = 0;
  689. pc->c[2] = page_code + (type << 6);
  690. switch (page_code) {
  691. case IDEFLOPPY_CAPABILITIES_PAGE:
  692. length += 12;
  693. break;
  694. case IDEFLOPPY_FLEXIBLE_DISK_PAGE:
  695. length += 32;
  696. break;
  697. default:
  698. printk(KERN_ERR "ide-floppy: unsupported page code "
  699. "in create_mode_sense_cmd\n");
  700. }
  701. put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]);
  702. pc->request_transfer = length;
  703. }
  704. static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start)
  705. {
  706. idefloppy_init_pc(pc);
  707. pc->c[0] = GPCMD_START_STOP_UNIT;
  708. pc->c[4] = start;
  709. }
  710. static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc)
  711. {
  712. idefloppy_init_pc(pc);
  713. pc->c[0] = GPCMD_TEST_UNIT_READY;
  714. }
  715. static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
  716. idefloppy_pc_t *pc, struct request *rq,
  717. unsigned long sector)
  718. {
  719. int block = sector / floppy->bs_factor;
  720. int blocks = rq->nr_sectors / floppy->bs_factor;
  721. int cmd = rq_data_dir(rq);
  722. debug_log("create_rw10_cmd: block == %d, blocks == %d\n",
  723. block, blocks);
  724. idefloppy_init_pc(pc);
  725. pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10;
  726. put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
  727. put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
  728. pc->callback = &idefloppy_rw_callback;
  729. pc->rq = rq;
  730. pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
  731. if (rq->cmd_flags & REQ_RW)
  732. pc->flags |= PC_FLAG_WRITING;
  733. pc->buffer = NULL;
  734. pc->request_transfer = pc->buffer_size = blocks * floppy->block_size;
  735. pc->flags |= PC_FLAG_DMA_RECOMMENDED;
  736. }
  737. static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
  738. idefloppy_pc_t *pc, struct request *rq)
  739. {
  740. idefloppy_init_pc(pc);
  741. pc->callback = &idefloppy_rw_callback;
  742. memcpy(pc->c, rq->cmd, sizeof(pc->c));
  743. pc->rq = rq;
  744. pc->b_count = rq->data_len;
  745. if (rq->data_len && rq_data_dir(rq) == WRITE)
  746. pc->flags |= PC_FLAG_WRITING;
  747. pc->buffer = rq->data;
  748. if (rq->bio)
  749. pc->flags |= PC_FLAG_DMA_RECOMMENDED;
  750. /*
  751. * possibly problematic, doesn't look like ide-floppy correctly
  752. * handled scattered requests if dma fails...
  753. */
  754. pc->request_transfer = pc->buffer_size = rq->data_len;
  755. }
  756. static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
  757. struct request *rq, sector_t block_s)
  758. {
  759. idefloppy_floppy_t *floppy = drive->driver_data;
  760. idefloppy_pc_t *pc;
  761. unsigned long block = (unsigned long)block_s;
  762. debug_log("dev: %s, cmd_type: %x, errors: %d\n",
  763. rq->rq_disk ? rq->rq_disk->disk_name : "?",
  764. rq->cmd_type, rq->errors);
  765. debug_log("sector: %ld, nr_sectors: %ld, "
  766. "current_nr_sectors: %d\n", (long)rq->sector,
  767. rq->nr_sectors, rq->current_nr_sectors);
  768. if (rq->errors >= ERROR_MAX) {
  769. if (floppy->failed_pc)
  770. ide_floppy_report_error(floppy, floppy->failed_pc);
  771. else
  772. printk(KERN_ERR "ide-floppy: %s: I/O error\n",
  773. drive->name);
  774. idefloppy_do_end_request(drive, 0, 0);
  775. return ide_stopped;
  776. }
  777. if (blk_fs_request(rq)) {
  778. if (((long)rq->sector % floppy->bs_factor) ||
  779. (rq->nr_sectors % floppy->bs_factor)) {
  780. printk(KERN_ERR "%s: unsupported r/w request size\n",
  781. drive->name);
  782. idefloppy_do_end_request(drive, 0, 0);
  783. return ide_stopped;
  784. }
  785. pc = idefloppy_next_pc_storage(drive);
  786. idefloppy_create_rw_cmd(floppy, pc, rq, block);
  787. } else if (blk_special_request(rq)) {
  788. pc = (idefloppy_pc_t *) rq->buffer;
  789. } else if (blk_pc_request(rq)) {
  790. pc = idefloppy_next_pc_storage(drive);
  791. idefloppy_blockpc_cmd(floppy, pc, rq);
  792. } else {
  793. blk_dump_rq_flags(rq,
  794. "ide-floppy: unsupported command in queue");
  795. idefloppy_do_end_request(drive, 0, 0);
  796. return ide_stopped;
  797. }
  798. pc->rq = rq;
  799. return idefloppy_issue_pc(drive, pc);
  800. }
  801. /*
  802. * Add a special packet command request to the tail of the request queue,
  803. * and wait for it to be serviced.
  804. */
  805. static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc)
  806. {
  807. struct ide_floppy_obj *floppy = drive->driver_data;
  808. struct request rq;
  809. ide_init_drive_cmd(&rq);
  810. rq.buffer = (char *) pc;
  811. rq.cmd_type = REQ_TYPE_SPECIAL;
  812. rq.rq_disk = floppy->disk;
  813. return ide_do_drive_cmd(drive, &rq, ide_wait);
  814. }
  815. /*
  816. * Look at the flexible disk page parameters. We ignore the CHS capacity
  817. * parameters and use the LBA parameters instead.
  818. */
  819. static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
  820. {
  821. idefloppy_floppy_t *floppy = drive->driver_data;
  822. idefloppy_pc_t pc;
  823. u8 *page;
  824. int capacity, lba_capacity;
  825. u16 transfer_rate, sector_size, cyls, rpm;
  826. u8 heads, sectors;
  827. idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE,
  828. MODE_SENSE_CURRENT);
  829. if (idefloppy_queue_pc_tail(drive, &pc)) {
  830. printk(KERN_ERR "ide-floppy: Can't get flexible disk page"
  831. " parameters\n");
  832. return 1;
  833. }
  834. floppy->wp = !!(pc.buffer[3] & 0x80);
  835. set_disk_ro(floppy->disk, floppy->wp);
  836. page = &pc.buffer[8];
  837. transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]);
  838. sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]);
  839. cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]);
  840. rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]);
  841. heads = pc.buffer[8 + 4];
  842. sectors = pc.buffer[8 + 5];
  843. capacity = cyls * heads * sectors * sector_size;
  844. if (memcmp(page, &floppy->flexible_disk_page, 32))
  845. printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, "
  846. "%d sector size, %d rpm\n",
  847. drive->name, capacity / 1024, cyls, heads,
  848. sectors, transfer_rate / 8, sector_size, rpm);
  849. memcpy(&floppy->flexible_disk_page, page, 32);
  850. drive->bios_cyl = cyls;
  851. drive->bios_head = heads;
  852. drive->bios_sect = sectors;
  853. lba_capacity = floppy->blocks * floppy->block_size;
  854. if (capacity < lba_capacity) {
  855. printk(KERN_NOTICE "%s: The disk reports a capacity of %d "
  856. "bytes, but the drive only handles %d\n",
  857. drive->name, lba_capacity, capacity);
  858. floppy->blocks = floppy->block_size ?
  859. capacity / floppy->block_size : 0;
  860. }
  861. return 0;
  862. }
  863. static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
  864. {
  865. idefloppy_floppy_t *floppy = drive->driver_data;
  866. idefloppy_pc_t pc;
  867. floppy->srfp = 0;
  868. idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE,
  869. MODE_SENSE_CURRENT);
  870. pc.flags |= PC_FLAG_SUPPRESS_ERROR;
  871. if (idefloppy_queue_pc_tail(drive, &pc))
  872. return 1;
  873. floppy->srfp = pc.buffer[8 + 2] & 0x40;
  874. return (0);
  875. }
  876. /*
  877. * Determine if a media is present in the floppy drive, and if so, its LBA
  878. * capacity.
  879. */
  880. static int ide_floppy_get_capacity(ide_drive_t *drive)
  881. {
  882. idefloppy_floppy_t *floppy = drive->driver_data;
  883. idefloppy_pc_t pc;
  884. u8 *cap_desc;
  885. u8 header_len, desc_cnt;
  886. int i, rc = 1, blocks, length;
  887. drive->bios_cyl = 0;
  888. drive->bios_head = drive->bios_sect = 0;
  889. floppy->blocks = 0;
  890. floppy->bs_factor = 1;
  891. set_capacity(floppy->disk, 0);
  892. idefloppy_create_read_capacity_cmd(&pc);
  893. if (idefloppy_queue_pc_tail(drive, &pc)) {
  894. printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n");
  895. return 1;
  896. }
  897. header_len = pc.buffer[3];
  898. cap_desc = &pc.buffer[4];
  899. desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
  900. for (i = 0; i < desc_cnt; i++) {
  901. unsigned int desc_start = 4 + i*8;
  902. blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]);
  903. length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]);
  904. debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n",
  905. i, blocks * length / 1024, blocks, length);
  906. if (i)
  907. continue;
  908. /*
  909. * the code below is valid only for the 1st descriptor, ie i=0
  910. */
  911. switch (pc.buffer[desc_start + 4] & 0x03) {
  912. /* Clik! drive returns this instead of CAPACITY_CURRENT */
  913. case CAPACITY_UNFORMATTED:
  914. if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE))
  915. /*
  916. * If it is not a clik drive, break out
  917. * (maintains previous driver behaviour)
  918. */
  919. break;
  920. case CAPACITY_CURRENT:
  921. /* Normal Zip/LS-120 disks */
  922. if (memcmp(cap_desc, &floppy->cap_desc, 8))
  923. printk(KERN_INFO "%s: %dkB, %d blocks, %d "
  924. "sector size\n", drive->name,
  925. blocks * length / 1024, blocks, length);
  926. memcpy(&floppy->cap_desc, cap_desc, 8);
  927. if (!length || length % 512) {
  928. printk(KERN_NOTICE "%s: %d bytes block size "
  929. "not supported\n", drive->name, length);
  930. } else {
  931. floppy->blocks = blocks;
  932. floppy->block_size = length;
  933. floppy->bs_factor = length / 512;
  934. if (floppy->bs_factor != 1)
  935. printk(KERN_NOTICE "%s: warning: non "
  936. "512 bytes block size not "
  937. "fully supported\n",
  938. drive->name);
  939. rc = 0;
  940. }
  941. break;
  942. case CAPACITY_NO_CARTRIDGE:
  943. /*
  944. * This is a KERN_ERR so it appears on screen
  945. * for the user to see
  946. */
  947. printk(KERN_ERR "%s: No disk in drive\n", drive->name);
  948. break;
  949. case CAPACITY_INVALID:
  950. printk(KERN_ERR "%s: Invalid capacity for disk "
  951. "in drive\n", drive->name);
  952. break;
  953. }
  954. debug_log("Descriptor 0 Code: %d\n",
  955. pc.buffer[desc_start + 4] & 0x03);
  956. }
  957. /* Clik! disk does not support get_flexible_disk_page */
  958. if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE))
  959. (void) ide_floppy_get_flexible_disk_page(drive);
  960. set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor);
  961. return rc;
  962. }
  963. /*
  964. * Obtain the list of formattable capacities.
  965. * Very similar to ide_floppy_get_capacity, except that we push the capacity
  966. * descriptors to userland, instead of our own structures.
  967. *
  968. * Userland gives us the following structure:
  969. *
  970. * struct idefloppy_format_capacities {
  971. * int nformats;
  972. * struct {
  973. * int nblocks;
  974. * int blocksize;
  975. * } formats[];
  976. * };
  977. *
  978. * userland initializes nformats to the number of allocated formats[] records.
  979. * On exit we set nformats to the number of records we've actually initialized.
  980. */
  981. static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
  982. {
  983. idefloppy_pc_t pc;
  984. u8 header_len, desc_cnt;
  985. int i, blocks, length, u_array_size, u_index;
  986. int __user *argp;
  987. if (get_user(u_array_size, arg))
  988. return (-EFAULT);
  989. if (u_array_size <= 0)
  990. return (-EINVAL);
  991. idefloppy_create_read_capacity_cmd(&pc);
  992. if (idefloppy_queue_pc_tail(drive, &pc)) {
  993. printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n");
  994. return (-EIO);
  995. }
  996. header_len = pc.buffer[3];
  997. desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
  998. u_index = 0;
  999. argp = arg + 1;
  1000. /*
  1001. * We always skip the first capacity descriptor. That's the current
  1002. * capacity. We are interested in the remaining descriptors, the
  1003. * formattable capacities.
  1004. */
  1005. for (i = 1; i < desc_cnt; i++) {
  1006. unsigned int desc_start = 4 + i*8;
  1007. if (u_index >= u_array_size)
  1008. break; /* User-supplied buffer too small */
  1009. blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]);
  1010. length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]);
  1011. if (put_user(blocks, argp))
  1012. return(-EFAULT);
  1013. ++argp;
  1014. if (put_user(length, argp))
  1015. return (-EFAULT);
  1016. ++argp;
  1017. ++u_index;
  1018. }
  1019. if (put_user(u_index, arg))
  1020. return (-EFAULT);
  1021. return (0);
  1022. }
  1023. /*
  1024. * Get ATAPI_FORMAT_UNIT progress indication.
  1025. *
  1026. * Userland gives a pointer to an int. The int is set to a progress
  1027. * indicator 0-65536, with 65536=100%.
  1028. *
  1029. * If the drive does not support format progress indication, we just check
  1030. * the dsc bit, and return either 0 or 65536.
  1031. */
  1032. static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
  1033. {
  1034. idefloppy_floppy_t *floppy = drive->driver_data;
  1035. idefloppy_pc_t pc;
  1036. int progress_indication = 0x10000;
  1037. if (floppy->srfp) {
  1038. idefloppy_create_request_sense_cmd(&pc);
  1039. if (idefloppy_queue_pc_tail(drive, &pc))
  1040. return (-EIO);
  1041. if (floppy->sense_key == 2 &&
  1042. floppy->asc == 4 &&
  1043. floppy->ascq == 4)
  1044. progress_indication = floppy->progress_indication;
  1045. /* Else assume format_unit has finished, and we're at 0x10000 */
  1046. } else {
  1047. unsigned long flags;
  1048. u8 stat;
  1049. local_irq_save(flags);
  1050. stat = ide_read_status(drive);
  1051. local_irq_restore(flags);
  1052. progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
  1053. }
  1054. if (put_user(progress_indication, arg))
  1055. return (-EFAULT);
  1056. return (0);
  1057. }
  1058. static sector_t idefloppy_capacity(ide_drive_t *drive)
  1059. {
  1060. idefloppy_floppy_t *floppy = drive->driver_data;
  1061. unsigned long capacity = floppy->blocks * floppy->bs_factor;
  1062. return capacity;
  1063. }
  1064. /*
  1065. * Check whether we can support a drive, based on the ATAPI IDENTIFY command
  1066. * results.
  1067. */
  1068. static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id)
  1069. {
  1070. u8 gcw[2];
  1071. u8 device_type, protocol, removable, drq_type, packet_size;
  1072. *((u16 *) &gcw) = id->config;
  1073. device_type = gcw[1] & 0x1F;
  1074. removable = (gcw[0] & 0x80) >> 7;
  1075. protocol = (gcw[1] & 0xC0) >> 6;
  1076. drq_type = (gcw[0] & 0x60) >> 5;
  1077. packet_size = gcw[0] & 0x03;
  1078. #ifdef CONFIG_PPC
  1079. /* kludge for Apple PowerBook internal zip */
  1080. if (device_type == 5 &&
  1081. !strstr(id->model, "CD-ROM") && strstr(id->model, "ZIP"))
  1082. device_type = 0;
  1083. #endif
  1084. if (protocol != 2)
  1085. printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n",
  1086. protocol);
  1087. else if (device_type != 0)
  1088. printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set "
  1089. "to floppy\n", device_type);
  1090. else if (!removable)
  1091. printk(KERN_ERR "ide-floppy: The removable flag is not set\n");
  1092. else if (drq_type == 3)
  1093. printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not "
  1094. "supported\n", drq_type);
  1095. else if (packet_size != 0)
  1096. printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 "
  1097. "bytes\n", packet_size);
  1098. else
  1099. return 1;
  1100. return 0;
  1101. }
  1102. #ifdef CONFIG_IDE_PROC_FS
  1103. static void idefloppy_add_settings(ide_drive_t *drive)
  1104. {
  1105. idefloppy_floppy_t *floppy = drive->driver_data;
  1106. ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1,
  1107. &drive->bios_cyl, NULL);
  1108. ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1,
  1109. &drive->bios_head, NULL);
  1110. ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1,
  1111. &drive->bios_sect, NULL);
  1112. ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1,
  1113. &floppy->ticks, NULL);
  1114. }
  1115. #else
  1116. static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
  1117. #endif
  1118. static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
  1119. {
  1120. u8 gcw[2];
  1121. *((u16 *) &gcw) = drive->id->config;
  1122. floppy->pc = floppy->pc_stack;
  1123. if (((gcw[0] & 0x60) >> 5) == 1)
  1124. floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT;
  1125. /*
  1126. * We used to check revisions here. At this point however I'm giving up.
  1127. * Just assume they are all broken, its easier.
  1128. *
  1129. * The actual reason for the workarounds was likely a driver bug after
  1130. * all rather than a firmware bug, and the workaround below used to hide
  1131. * it. It should be fixed as of version 1.9, but to be on the safe side
  1132. * we'll leave the limitation below for the 2.2.x tree.
  1133. */
  1134. if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) {
  1135. floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE;
  1136. /* This value will be visible in the /proc/ide/hdx/settings */
  1137. floppy->ticks = IDEFLOPPY_TICKS_DELAY;
  1138. blk_queue_max_sectors(drive->queue, 64);
  1139. }
  1140. /*
  1141. * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes
  1142. * nasty clicking noises without it, so please don't remove this.
  1143. */
  1144. if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) {
  1145. blk_queue_max_sectors(drive->queue, 64);
  1146. floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE;
  1147. }
  1148. (void) ide_floppy_get_capacity(drive);
  1149. idefloppy_add_settings(drive);
  1150. }
  1151. static void ide_floppy_remove(ide_drive_t *drive)
  1152. {
  1153. idefloppy_floppy_t *floppy = drive->driver_data;
  1154. struct gendisk *g = floppy->disk;
  1155. ide_proc_unregister_driver(drive, floppy->driver);
  1156. del_gendisk(g);
  1157. ide_floppy_put(floppy);
  1158. }
  1159. static void idefloppy_cleanup_obj(struct kref *kref)
  1160. {
  1161. struct ide_floppy_obj *floppy = to_ide_floppy(kref);
  1162. ide_drive_t *drive = floppy->drive;
  1163. struct gendisk *g = floppy->disk;
  1164. drive->driver_data = NULL;
  1165. g->private_data = NULL;
  1166. put_disk(g);
  1167. kfree(floppy);
  1168. }
  1169. #ifdef CONFIG_IDE_PROC_FS
  1170. static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
  1171. int count, int *eof, void *data)
  1172. {
  1173. ide_drive_t*drive = (ide_drive_t *)data;
  1174. int len;
  1175. len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive));
  1176. PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
  1177. }
  1178. static ide_proc_entry_t idefloppy_proc[] = {
  1179. { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL },
  1180. { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
  1181. { NULL, 0, NULL, NULL }
  1182. };
  1183. #endif /* CONFIG_IDE_PROC_FS */
  1184. static int ide_floppy_probe(ide_drive_t *);
  1185. static ide_driver_t idefloppy_driver = {
  1186. .gen_driver = {
  1187. .owner = THIS_MODULE,
  1188. .name = "ide-floppy",
  1189. .bus = &ide_bus_type,
  1190. },
  1191. .probe = ide_floppy_probe,
  1192. .remove = ide_floppy_remove,
  1193. .version = IDEFLOPPY_VERSION,
  1194. .media = ide_floppy,
  1195. .supports_dsc_overlap = 0,
  1196. .do_request = idefloppy_do_request,
  1197. .end_request = idefloppy_do_end_request,
  1198. .error = __ide_error,
  1199. .abort = __ide_abort,
  1200. #ifdef CONFIG_IDE_PROC_FS
  1201. .proc = idefloppy_proc,
  1202. #endif
  1203. };
  1204. static int idefloppy_open(struct inode *inode, struct file *filp)
  1205. {
  1206. struct gendisk *disk = inode->i_bdev->bd_disk;
  1207. struct ide_floppy_obj *floppy;
  1208. ide_drive_t *drive;
  1209. idefloppy_pc_t pc;
  1210. int ret = 0;
  1211. debug_log("Reached %s\n", __func__);
  1212. floppy = ide_floppy_get(disk);
  1213. if (!floppy)
  1214. return -ENXIO;
  1215. drive = floppy->drive;
  1216. floppy->openers++;
  1217. if (floppy->openers == 1) {
  1218. floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
  1219. /* Just in case */
  1220. idefloppy_create_test_unit_ready_cmd(&pc);
  1221. if (idefloppy_queue_pc_tail(drive, &pc)) {
  1222. idefloppy_create_start_stop_cmd(&pc, 1);
  1223. (void) idefloppy_queue_pc_tail(drive, &pc);
  1224. }
  1225. if (ide_floppy_get_capacity(drive)
  1226. && (filp->f_flags & O_NDELAY) == 0
  1227. /*
  1228. * Allow O_NDELAY to open a drive without a disk, or with an
  1229. * unreadable disk, so that we can get the format capacity
  1230. * of the drive or begin the format - Sam
  1231. */
  1232. ) {
  1233. ret = -EIO;
  1234. goto out_put_floppy;
  1235. }
  1236. if (floppy->wp && (filp->f_mode & 2)) {
  1237. ret = -EROFS;
  1238. goto out_put_floppy;
  1239. }
  1240. floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED;
  1241. /* IOMEGA Clik! drives do not support lock/unlock commands */
  1242. if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
  1243. idefloppy_create_prevent_cmd(&pc, 1);
  1244. (void) idefloppy_queue_pc_tail(drive, &pc);
  1245. }
  1246. check_disk_change(inode->i_bdev);
  1247. } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) {
  1248. ret = -EBUSY;
  1249. goto out_put_floppy;
  1250. }
  1251. return 0;
  1252. out_put_floppy:
  1253. floppy->openers--;
  1254. ide_floppy_put(floppy);
  1255. return ret;
  1256. }
  1257. static int idefloppy_release(struct inode *inode, struct file *filp)
  1258. {
  1259. struct gendisk *disk = inode->i_bdev->bd_disk;
  1260. struct ide_floppy_obj *floppy = ide_floppy_g(disk);
  1261. ide_drive_t *drive = floppy->drive;
  1262. idefloppy_pc_t pc;
  1263. debug_log("Reached %s\n", __func__);
  1264. if (floppy->openers == 1) {
  1265. /* IOMEGA Clik! drives do not support lock/unlock commands */
  1266. if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
  1267. idefloppy_create_prevent_cmd(&pc, 0);
  1268. (void) idefloppy_queue_pc_tail(drive, &pc);
  1269. }
  1270. floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
  1271. }
  1272. floppy->openers--;
  1273. ide_floppy_put(floppy);
  1274. return 0;
  1275. }
  1276. static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  1277. {
  1278. struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
  1279. ide_drive_t *drive = floppy->drive;
  1280. geo->heads = drive->bios_head;
  1281. geo->sectors = drive->bios_sect;
  1282. geo->cylinders = (u16)drive->bios_cyl; /* truncate */
  1283. return 0;
  1284. }
  1285. static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc,
  1286. unsigned long arg, unsigned int cmd)
  1287. {
  1288. if (floppy->openers > 1)
  1289. return -EBUSY;
  1290. /* The IOMEGA Clik! Drive doesn't support this command -
  1291. * no room for an eject mechanism */
  1292. if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) {
  1293. int prevent = arg ? 1 : 0;
  1294. if (cmd == CDROMEJECT)
  1295. prevent = 0;
  1296. idefloppy_create_prevent_cmd(pc, prevent);
  1297. (void) idefloppy_queue_pc_tail(floppy->drive, pc);
  1298. }
  1299. if (cmd == CDROMEJECT) {
  1300. idefloppy_create_start_stop_cmd(pc, 2);
  1301. (void) idefloppy_queue_pc_tail(floppy->drive, pc);
  1302. }
  1303. return 0;
  1304. }
  1305. static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
  1306. int __user *arg)
  1307. {
  1308. int blocks, length, flags, err = 0;
  1309. idefloppy_pc_t pc;
  1310. if (floppy->openers > 1) {
  1311. /* Don't format if someone is using the disk */
  1312. floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
  1313. return -EBUSY;
  1314. }
  1315. floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
  1316. /*
  1317. * Send ATAPI_FORMAT_UNIT to the drive.
  1318. *
  1319. * Userland gives us the following structure:
  1320. *
  1321. * struct idefloppy_format_command {
  1322. * int nblocks;
  1323. * int blocksize;
  1324. * int flags;
  1325. * } ;
  1326. *
  1327. * flags is a bitmask, currently, the only defined flag is:
  1328. *
  1329. * 0x01 - verify media after format.
  1330. */
  1331. if (get_user(blocks, arg) ||
  1332. get_user(length, arg+1) ||
  1333. get_user(flags, arg+2)) {
  1334. err = -EFAULT;
  1335. goto out;
  1336. }
  1337. (void) idefloppy_get_sfrp_bit(floppy->drive);
  1338. idefloppy_create_format_unit_cmd(&pc, blocks, length, flags);
  1339. if (idefloppy_queue_pc_tail(floppy->drive, &pc))
  1340. err = -EIO;
  1341. out:
  1342. if (err)
  1343. floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
  1344. return err;
  1345. }
  1346. static int idefloppy_ioctl(struct inode *inode, struct file *file,
  1347. unsigned int cmd, unsigned long arg)
  1348. {
  1349. struct block_device *bdev = inode->i_bdev;
  1350. struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
  1351. ide_drive_t *drive = floppy->drive;
  1352. idefloppy_pc_t pc;
  1353. void __user *argp = (void __user *)arg;
  1354. int err;
  1355. switch (cmd) {
  1356. case CDROMEJECT:
  1357. /* fall through */
  1358. case CDROM_LOCKDOOR:
  1359. return ide_floppy_lockdoor(floppy, &pc, arg, cmd);
  1360. case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
  1361. return 0;
  1362. case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
  1363. return ide_floppy_get_format_capacities(drive, argp);
  1364. case IDEFLOPPY_IOCTL_FORMAT_START:
  1365. if (!(file->f_mode & 2))
  1366. return -EPERM;
  1367. return ide_floppy_format_unit(floppy, (int __user *)arg);
  1368. case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
  1369. return idefloppy_get_format_progress(drive, argp);
  1370. }
  1371. /*
  1372. * skip SCSI_IOCTL_SEND_COMMAND (deprecated)
  1373. * and CDROM_SEND_PACKET (legacy) ioctls
  1374. */
  1375. if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
  1376. err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
  1377. bdev->bd_disk, cmd, argp);
  1378. else
  1379. err = -ENOTTY;
  1380. if (err == -ENOTTY)
  1381. err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
  1382. return err;
  1383. }
  1384. static int idefloppy_media_changed(struct gendisk *disk)
  1385. {
  1386. struct ide_floppy_obj *floppy = ide_floppy_g(disk);
  1387. ide_drive_t *drive = floppy->drive;
  1388. int ret;
  1389. /* do not scan partitions twice if this is a removable device */
  1390. if (drive->attach) {
  1391. drive->attach = 0;
  1392. return 0;
  1393. }
  1394. ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED);
  1395. floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED;
  1396. return ret;
  1397. }
  1398. static int idefloppy_revalidate_disk(struct gendisk *disk)
  1399. {
  1400. struct ide_floppy_obj *floppy = ide_floppy_g(disk);
  1401. set_capacity(disk, idefloppy_capacity(floppy->drive));
  1402. return 0;
  1403. }
  1404. static struct block_device_operations idefloppy_ops = {
  1405. .owner = THIS_MODULE,
  1406. .open = idefloppy_open,
  1407. .release = idefloppy_release,
  1408. .ioctl = idefloppy_ioctl,
  1409. .getgeo = idefloppy_getgeo,
  1410. .media_changed = idefloppy_media_changed,
  1411. .revalidate_disk= idefloppy_revalidate_disk
  1412. };
  1413. static int ide_floppy_probe(ide_drive_t *drive)
  1414. {
  1415. idefloppy_floppy_t *floppy;
  1416. struct gendisk *g;
  1417. if (!strstr("ide-floppy", drive->driver_req))
  1418. goto failed;
  1419. if (!drive->present)
  1420. goto failed;
  1421. if (drive->media != ide_floppy)
  1422. goto failed;
  1423. if (!idefloppy_identify_device(drive, drive->id)) {
  1424. printk(KERN_ERR "ide-floppy: %s: not supported by this version"
  1425. " of ide-floppy\n", drive->name);
  1426. goto failed;
  1427. }
  1428. if (drive->scsi) {
  1429. printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi"
  1430. " emulation.\n", drive->name);
  1431. goto failed;
  1432. }
  1433. floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL);
  1434. if (!floppy) {
  1435. printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy"
  1436. " structure\n", drive->name);
  1437. goto failed;
  1438. }
  1439. g = alloc_disk(1 << PARTN_BITS);
  1440. if (!g)
  1441. goto out_free_floppy;
  1442. ide_init_disk(g, drive);
  1443. ide_proc_register_driver(drive, &idefloppy_driver);
  1444. kref_init(&floppy->kref);
  1445. floppy->drive = drive;
  1446. floppy->driver = &idefloppy_driver;
  1447. floppy->disk = g;
  1448. g->private_data = &floppy->driver;
  1449. drive->driver_data = floppy;
  1450. idefloppy_setup(drive, floppy);
  1451. g->minors = 1 << PARTN_BITS;
  1452. g->driverfs_dev = &drive->gendev;
  1453. g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
  1454. g->fops = &idefloppy_ops;
  1455. drive->attach = 1;
  1456. add_disk(g);
  1457. return 0;
  1458. out_free_floppy:
  1459. kfree(floppy);
  1460. failed:
  1461. return -ENODEV;
  1462. }
  1463. static void __exit idefloppy_exit(void)
  1464. {
  1465. driver_unregister(&idefloppy_driver.gen_driver);
  1466. }
  1467. static int __init idefloppy_init(void)
  1468. {
  1469. printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
  1470. return driver_register(&idefloppy_driver.gen_driver);
  1471. }
  1472. MODULE_ALIAS("ide:*m-floppy*");
  1473. module_init(idefloppy_init);
  1474. module_exit(idefloppy_exit);
  1475. MODULE_LICENSE("GPL");
  1476. MODULE_DESCRIPTION("ATAPI FLOPPY Driver");