1 /* ppa.c -- low level driver for the IOMEGA PPA3
2 * parallel port SCSI host adapter.
4 * (The PPA3 is the embedded controller in the ZIP drive.)
6 * (c) 1995,1996 Grant R. Guenther, grant@torque.net,
7 * under the terms of the GNU General Public License.
9 * Current Maintainer: David Campbell (Perth, Western Australia, GMT+0800)
13 #include <linux/config.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/blkdev.h>
19 #include <linux/parport.h>
20 #include <linux/workqueue.h>
23 static void ppa_reset_pulse(unsigned int base);
26 struct pardevice *dev; /* Parport device entry */
27 int base; /* Actual port address */
28 int mode; /* Transfer mode */
29 Scsi_Cmnd *cur_cmd; /* Current queued command */
30 struct work_struct ppa_tq; /* Polling interrupt stuff */
31 unsigned long jstart; /* Jiffies at start */
32 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
33 unsigned int failed:1; /* Failure flag */
34 unsigned wanted:1; /* Parport sharing busy flag */
35 wait_queue_head_t *waiting;
36 struct Scsi_Host *host;
37 struct list_head list;
42 static inline ppa_struct *ppa_dev(struct Scsi_Host *host)
44 return *(ppa_struct **)&host->hostdata;
47 static spinlock_t arbitration_lock = SPIN_LOCK_UNLOCKED;
49 static void got_it(ppa_struct *dev)
51 dev->base = dev->dev->port->base;
53 dev->cur_cmd->SCp.phase = 1;
55 wake_up(dev->waiting);
58 static void ppa_wakeup(void *ref)
60 ppa_struct *dev = (ppa_struct *) ref;
63 spin_lock_irqsave(&arbitration_lock, flags);
65 parport_claim(dev->dev);
69 spin_unlock_irqrestore(&arbitration_lock, flags);
73 static int ppa_pb_claim(ppa_struct *dev)
77 spin_lock_irqsave(&arbitration_lock, flags);
78 if (parport_claim(dev->dev) == 0) {
83 spin_unlock_irqrestore(&arbitration_lock, flags);
87 static void ppa_pb_dismiss(ppa_struct *dev)
91 spin_lock_irqsave(&arbitration_lock, flags);
94 spin_unlock_irqrestore(&arbitration_lock, flags);
96 parport_release(dev->dev);
99 static inline void ppa_pb_release(ppa_struct *dev)
101 parport_release(dev->dev);
105 * Start of Chipset kludges
108 /* This is to give the ppa driver a way to modify the timings (and other
109 * parameters) by writing to the /proc/scsi/ppa/0 file.
110 * Very simple method really... (To simple, no error checking :( )
111 * Reason: Kernel hackers HATE having to unload and reload modules for
113 * Also gives a method to use a script to obtain optimum timings (TODO)
116 static inline int ppa_proc_write(ppa_struct *dev, char *buffer, int length)
120 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
121 x = simple_strtoul(buffer + 5, NULL, 0);
125 if ((length > 10) && (strncmp(buffer, "recon_tmo=", 10) == 0)) {
126 x = simple_strtoul(buffer + 10, NULL, 0);
128 printk("ppa: recon_tmo set to %ld\n", x);
131 printk("ppa /proc: invalid variable\n");
135 static int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout)
138 ppa_struct *dev = ppa_dev(host);
141 return ppa_proc_write(dev, buffer, length);
143 len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION);
145 sprintf(buffer + len, "Parport : %s\n",
146 dev->dev->port->name);
148 sprintf(buffer + len, "Mode : %s\n",
149 PPA_MODE_STRING[dev->mode]);
152 sprintf(buffer + len, "recon_tmo : %lu\n", dev->recon_tmo);
155 /* Request for beyond end of buffer */
159 *start = buffer + offset;
166 static int device_check(ppa_struct *dev);
169 #define ppa_fail(x,y) printk("ppa: ppa_fail(%i) from %s at line %d\n",\
170 y, __FUNCTION__, __LINE__); ppa_fail_func(x,y);
171 static inline void ppa_fail_func(ppa_struct *dev, int error_code)
173 static inline void ppa_fail(ppa_struct *dev, int error_code)
176 /* If we fail a device then we trash status / message bytes */
178 dev->cur_cmd->result = error_code << 16;
184 * Wait for the high bit to be set.
186 * In principle, this could be tied to an interrupt, but the adapter
187 * doesn't appear to be designed to support interrupts. We spin on
188 * the 0x80 ready bit.
190 static unsigned char ppa_wait(ppa_struct *dev)
193 unsigned short ppb = dev->base;
197 /* Wait for bit 6 and 7 - PJC */
198 for (r = r_str(ppb); ((r & 0xc0) != 0xc0) && (k); k--) {
204 * return some status information.
205 * Semantics: 0xc0 = ZIP wants more data
206 * 0xd0 = ZIP wants to send more data
207 * 0xe0 = ZIP is expecting SCSI command data
208 * 0xf0 = end of transfer, ZIP is sending status
213 /* Counter expired - Time out occurred */
214 ppa_fail(dev, DID_TIME_OUT);
215 printk("ppa timeout in ppa_wait\n");
216 return 0; /* command timed out */
220 * Clear EPP Timeout Bit
222 static inline void epp_reset(unsigned short ppb)
228 w_str(ppb, i & 0xfe);
232 * Wait for empty ECP fifo (if we are in ECP fifo mode only)
234 static inline void ecp_sync(ppa_struct *dev)
236 int i, ppb_hi = dev->dev->port->base_hi;
241 if ((r_ecr(ppb_hi) & 0xe0) == 0x60) { /* mode 011 == ECP fifo mode */
242 for (i = 0; i < 100; i++) {
243 if (r_ecr(ppb_hi) & 0x01)
247 printk("ppa: ECP sync failed as data still present in FIFO.\n");
251 static int ppa_byte_out(unsigned short base, const char *buffer, int len)
255 for (i = len; i; i--) {
256 w_dtr(base, *buffer++);
260 return 1; /* All went well - we hope! */
263 static int ppa_byte_in(unsigned short base, char *buffer, int len)
267 for (i = len; i; i--) {
268 *buffer++ = r_dtr(base);
272 return 1; /* All went well - we hope! */
275 static int ppa_nibble_in(unsigned short base, char *buffer, int len)
281 h = r_str(base) & 0xf0;
283 *buffer++ = h | ((r_str(base) & 0xf0) >> 4);
285 return 1; /* All went well - we hope! */
288 static int ppa_out(ppa_struct *dev, char *buffer, int len)
291 unsigned short ppb = dev->base;
295 if ((r & 0x50) != 0x40) {
296 ppa_fail(dev, DID_ERROR);
302 /* 8 bit output, with a loop */
303 r = ppa_byte_out(ppb, buffer, len);
311 #ifdef CONFIG_SCSI_IZIP_EPP16
312 if (!(((long) buffer | len) & 0x01))
313 outsw(ppb + 4, buffer, len >> 1);
315 if (!(((long) buffer | len) & 0x03))
316 outsl(ppb + 4, buffer, len >> 2);
319 outsb(ppb + 4, buffer, len);
321 r = !(r_str(ppb) & 0x01);
327 printk("PPA: bug in ppa_out()\n");
333 static int ppa_in(ppa_struct *dev, char *buffer, int len)
336 unsigned short ppb = dev->base;
340 if ((r & 0x50) != 0x50) {
341 ppa_fail(dev, DID_ERROR);
346 /* 4 bit input, with a loop */
347 r = ppa_nibble_in(ppb, buffer, len);
352 /* 8 bit input, with a loop */
354 r = ppa_byte_in(ppb, buffer, len);
364 #ifdef CONFIG_SCSI_IZIP_EPP16
365 if (!(((long) buffer | len) & 0x01))
366 insw(ppb + 4, buffer, len >> 1);
368 if (!(((long) buffer | len) & 0x03))
369 insl(ppb + 4, buffer, len >> 2);
372 insb(ppb + 4, buffer, len);
374 r = !(r_str(ppb) & 0x01);
380 printk("PPA: bug in ppa_ins()\n");
387 /* end of ppa_io.h */
388 static inline void ppa_d_pulse(unsigned short ppb, unsigned char b)
398 static void ppa_disconnect(ppa_struct *dev)
400 unsigned short ppb = dev->base;
403 ppa_d_pulse(ppb, 0x3c);
404 ppa_d_pulse(ppb, 0x20);
405 ppa_d_pulse(ppb, 0xf);
408 static inline void ppa_c_pulse(unsigned short ppb, unsigned char b)
417 static inline void ppa_connect(ppa_struct *dev, int flag)
419 unsigned short ppb = dev->base;
422 ppa_c_pulse(ppb, 0x3c);
423 ppa_c_pulse(ppb, 0x20);
424 if ((flag == CONNECT_EPP_MAYBE) && IN_EPP_MODE(dev->mode))
425 ppa_c_pulse(ppb, 0xcf);
427 ppa_c_pulse(ppb, 0x8f);
430 static int ppa_select(ppa_struct *dev, int target)
433 unsigned short ppb = dev->base;
436 * Bit 6 (0x40) is the device selected bit.
437 * First we must wait till the current device goes off line...
443 } while ((r_str(ppb) & 0x40) && (k));
447 w_dtr(ppb, (1 << target));
450 w_dtr(ppb, 0x80); /* This is NOT the initator */
458 while (!(r_str(ppb) & 0x40) && (k));
466 * This is based on a trace of what the Iomega DOS 'guest' driver does.
467 * I've tried several different kinds of parallel ports with guest and
468 * coded this to react in the same ways that it does.
470 * The return value from this function is just a hint about where the
471 * handshaking failed.
474 static int ppa_init(ppa_struct *dev)
477 unsigned short ppb = dev->base;
480 ppa_connect(dev, CONNECT_NORMAL);
482 retv = 2; /* Failed */
485 if ((r_str(ppb) & 0x08) == 0x08)
489 if ((r_str(ppb) & 0x08) == 0x00)
493 ppa_reset_pulse(ppb);
494 udelay(1000); /* Allow devices to settle down */
496 udelay(1000); /* Another delay to allow devices to settle */
501 return device_check(dev);
504 static inline int ppa_send_command(Scsi_Cmnd *cmd)
506 ppa_struct *dev = ppa_dev(cmd->device->host);
509 w_ctr(dev->base, 0x0c);
511 for (k = 0; k < cmd->cmd_len; k++)
512 if (!ppa_out(dev, &cmd->cmnd[k], 1))
518 * The bulk flag enables some optimisations in the data transfer loops,
519 * it should be true for any command that transfers data in integral
520 * numbers of sectors.
522 * The driver appears to remain stable if we speed up the parallel port
523 * i/o in this function, but not elsewhere.
525 static int ppa_completion(Scsi_Cmnd *cmd)
530 * 1 Finished data transfer
532 ppa_struct *dev = ppa_dev(cmd->device->host);
533 unsigned short ppb = dev->base;
534 unsigned long start_jiffies = jiffies;
537 int fast, bulk, status;
540 bulk = ((v == READ_6) ||
541 (v == READ_10) || (v == WRITE_6) || (v == WRITE_10));
544 * We only get here if the drive is ready to comunicate,
545 * hence no need for a full ppa_wait.
547 r = (r_str(ppb) & 0xf0);
549 while (r != (unsigned char) 0xf0) {
551 * If we have been running for more than a full timer tick
554 if (time_after(jiffies, start_jiffies + 1))
557 if ((cmd->SCp.this_residual <= 0)) {
558 ppa_fail(dev, DID_ERROR);
559 return -1; /* ERROR_RETURN */
562 /* On some hardware we have SCSI disconnected (6th bit low)
563 * for about 100usecs. It is too expensive to wait a
564 * tick on every loop so we busy wait for no more than
565 * 500usecs to give the drive a chance first. We do not
566 * change things for "normal" hardware since generally
567 * the 6th bit is always high.
568 * This makes the CPU load higher on some hardware
569 * but otherwise we can not get more than 50K/secs
570 * on this problem hardware.
572 if ((r & 0xc0) != 0xc0) {
573 /* Wait for reconnection should be no more than
574 * jiffy/2 = 5ms = 5000 loops
576 unsigned long k = dev->recon_tmo;
577 for (; k && ((r = (r_str(ppb) & 0xf0)) & 0xc0) != 0xc0;
585 /* determine if we should use burst I/O */
586 fast = (bulk && (cmd->SCp.this_residual >= PPA_BURST_SIZE))
587 ? PPA_BURST_SIZE : 1;
589 if (r == (unsigned char) 0xc0)
590 status = ppa_out(dev, cmd->SCp.ptr, fast);
592 status = ppa_in(dev, cmd->SCp.ptr, fast);
594 cmd->SCp.ptr += fast;
595 cmd->SCp.this_residual -= fast;
598 ppa_fail(dev, DID_BUS_BUSY);
599 return -1; /* ERROR_RETURN */
601 if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
602 /* if scatter/gather, advance to the next segment */
603 if (cmd->SCp.buffers_residual--) {
605 cmd->SCp.this_residual =
606 cmd->SCp.buffer->length;
608 page_address(cmd->SCp.buffer->page) +
609 cmd->SCp.buffer->offset;
612 /* Now check to see if the drive is ready to comunicate */
613 r = (r_str(ppb) & 0xf0);
614 /* If not, drop back down to the scheduler and wait a timer tick */
618 return 1; /* FINISH_RETURN */
622 * Since the PPA itself doesn't generate interrupts, we use
623 * the scheduler's task queue to generate a stream of call-backs and
624 * complete the request when the drive is ready.
626 static void ppa_interrupt(void *data)
628 ppa_struct *dev = (ppa_struct *) data;
629 Scsi_Cmnd *cmd = dev->cur_cmd;
632 printk("PPA: bug in ppa_interrupt\n");
635 if (ppa_engine(dev, cmd)) {
636 dev->ppa_tq.data = (void *) dev;
637 schedule_delayed_work(&dev->ppa_tq, 1);
640 /* Command must of completed hence it is safe to let go... */
642 switch ((cmd->result >> 16) & 0xff) {
646 printk("ppa: no device at SCSI ID %i\n", cmd->device->target);
649 printk("ppa: BUS BUSY - EPP timeout detected\n");
652 printk("ppa: unknown timeout\n");
655 printk("ppa: told to abort\n");
658 printk("ppa: parity error (???)\n");
661 printk("ppa: internal driver error\n");
664 printk("ppa: told to reset device\n");
667 printk("ppa: bad interrupt (???)\n");
670 printk("ppa: bad return code (%02x)\n",
671 (cmd->result >> 16) & 0xff);
675 if (cmd->SCp.phase > 1)
685 static int ppa_engine(ppa_struct *dev, Scsi_Cmnd *cmd)
687 unsigned short ppb = dev->base;
688 unsigned char l = 0, h = 0;
691 /* First check for any errors that may of occurred
692 * Here we check for internal errors
697 switch (cmd->SCp.phase) {
698 case 0: /* Phase 0 - Waiting for parport */
699 if (time_after(jiffies, dev->jstart + HZ)) {
701 * We waited more than a second
702 * for parport to call us
704 ppa_fail(dev, DID_BUS_BUSY);
707 return 1; /* wait until ppa_wakeup claims parport */
708 case 1: /* Phase 1 - Connected */
709 { /* Perform a sanity check for cable unplugged */
710 int retv = 2; /* Failed */
712 ppa_connect(dev, CONNECT_EPP_MAYBE);
715 if ((r_str(ppb) & 0x08) == 0x08)
719 if ((r_str(ppb) & 0x08) == 0x00)
723 if ((jiffies - dev->jstart) > (1 * HZ)) {
725 ("ppa: Parallel port cable is unplugged!!\n");
726 ppa_fail(dev, DID_BUS_BUSY);
730 return 1; /* Try again in a jiffy */
736 case 2: /* Phase 2 - We are now talking to the scsi bus */
737 if (!ppa_select(dev, cmd->device->id)) {
738 ppa_fail(dev, DID_NO_CONNECT);
743 case 3: /* Phase 3 - Ready to accept a command */
745 if (!(r_str(ppb) & 0x80))
748 if (!ppa_send_command(cmd))
752 case 4: /* Phase 4 - Setup scatter/gather buffers */
754 /* if many buffers are available, start filling the first */
756 (struct scatterlist *) cmd->request_buffer;
757 cmd->SCp.this_residual = cmd->SCp.buffer->length;
759 page_address(cmd->SCp.buffer->page) +
760 cmd->SCp.buffer->offset;
762 /* else fill the only available buffer */
763 cmd->SCp.buffer = NULL;
764 cmd->SCp.this_residual = cmd->request_bufflen;
765 cmd->SCp.ptr = cmd->request_buffer;
767 cmd->SCp.buffers_residual = cmd->use_sg - 1;
770 case 5: /* Phase 5 - Data transfer stage */
772 if (!(r_str(ppb) & 0x80))
775 retv = ppa_completion(cmd);
782 case 6: /* Phase 6 - Read status/message */
783 cmd->result = DID_OK << 16;
784 /* Check for data overrun */
785 if (ppa_wait(dev) != (unsigned char) 0xf0) {
786 ppa_fail(dev, DID_ERROR);
789 if (ppa_in(dev, &l, 1)) { /* read status byte */
790 /* Check for optional message byte */
791 if (ppa_wait(dev) == (unsigned char) 0xf0)
794 (DID_OK << 16) + (h << 8) + (l & STATUS_MASK);
796 return 0; /* Finished */
800 printk("ppa: Invalid scsi phase\n");
805 static int ppa_queuecommand(Scsi_Cmnd *cmd, void (*done) (Scsi_Cmnd *))
807 ppa_struct *dev = ppa_dev(cmd->device->host);
810 printk("PPA: bug in ppa_queuecommand\n");
814 dev->jstart = jiffies;
816 cmd->scsi_done = done;
817 cmd->result = DID_ERROR << 16; /* default return code */
818 cmd->SCp.phase = 0; /* bus free */
820 dev->ppa_tq.data = dev;
821 schedule_work(&dev->ppa_tq);
829 * Apparently the disk->capacity attribute is off by 1 sector
830 * for all disk drives. We add the one here, but it should really
831 * be done in sd.c. Even if it gets fixed there, this will still
834 static int ppa_biosparam(struct scsi_device *sdev, struct block_device *dev,
835 sector_t capacity, int ip[])
839 ip[2] = ((unsigned long) capacity + 1) / (ip[0] * ip[1]);
843 ip[2] = ((unsigned long) capacity + 1) / (ip[0] * ip[1]);
850 static int ppa_abort(Scsi_Cmnd *cmd)
852 ppa_struct *dev = ppa_dev(cmd->device->host);
854 * There is no method for aborting commands since Iomega
855 * have tied the SCSI_MESSAGE line high in the interface
858 switch (cmd->SCp.phase) {
859 case 0: /* Do not have access to parport */
860 case 1: /* Have not connected to interface */
861 dev->cur_cmd = NULL; /* Forget the problem */
864 default: /* SCSI command sent, can not abort */
870 static void ppa_reset_pulse(unsigned int base)
878 static int ppa_reset(Scsi_Cmnd *cmd)
880 ppa_struct *dev = ppa_dev(cmd->device->host);
884 dev->cur_cmd = NULL; /* Forget the problem */
886 ppa_connect(dev, CONNECT_NORMAL);
887 ppa_reset_pulse(dev->base);
888 udelay(1000); /* device settle delay */
890 udelay(1000); /* device settle delay */
894 static int device_check(ppa_struct *dev)
896 /* This routine looks for a device and then attempts to use EPP
897 to send a command. If all goes as planned then EPP is available. */
899 static char cmd[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
900 int loop, old_mode, status, k, ppb = dev->base;
903 old_mode = dev->mode;
904 for (loop = 0; loop < 8; loop++) {
905 /* Attempt to use EPP for Test Unit Ready */
906 if ((ppb & 0x0007) == 0x0000)
907 dev->mode = PPA_EPP_32;
910 ppa_connect(dev, CONNECT_EPP_MAYBE);
911 /* Select SCSI device */
912 if (!ppa_select(dev, loop)) {
916 printk("ppa: Found device at ID %i, Attempting to use %s\n",
917 loop, PPA_MODE_STRING[dev->mode]);
919 /* Send SCSI command */
922 for (l = 0; (l < 6) && (status); l++)
923 status = ppa_out(dev, cmd, 1);
927 ppa_connect(dev, CONNECT_EPP_MAYBE);
935 if (dev->mode == PPA_EPP_32) {
936 dev->mode = old_mode;
942 k = 1000000; /* 1 Second */
947 } while (!(l & 0x80) && (k));
953 ppa_connect(dev, CONNECT_EPP_MAYBE);
954 ppa_reset_pulse(ppb);
958 if (dev->mode == PPA_EPP_32) {
959 dev->mode = old_mode;
965 printk("ppa: Communication established with ID %i using %s\n",
966 loop, PPA_MODE_STRING[dev->mode]);
967 ppa_connect(dev, CONNECT_EPP_MAYBE);
968 ppa_reset_pulse(ppb);
977 static Scsi_Host_Template ppa_template = {
978 .module = THIS_MODULE,
980 .proc_info = ppa_proc_info,
981 .name = "Iomega VPI0 (ppa) interface",
982 .queuecommand = ppa_queuecommand,
983 .eh_abort_handler = ppa_abort,
984 .eh_bus_reset_handler = ppa_reset,
985 .eh_host_reset_handler = ppa_reset,
986 .bios_param = ppa_biosparam,
988 .sg_tablesize = SG_ALL,
990 .use_clustering = ENABLE_CLUSTERING,
994 /***************************************************************************
995 * Parallel port probing routines *
996 ***************************************************************************/
998 static LIST_HEAD(ppa_hosts);
1000 static int __ppa_attach(struct parport *pb)
1002 struct Scsi_Host *host;
1003 DECLARE_WAIT_QUEUE_HEAD(waiting);
1007 int modes, ppb, ppb_hi;
1010 dev = kmalloc(sizeof(ppa_struct), GFP_KERNEL);
1013 memset(dev, 0, sizeof(ppa_struct));
1015 dev->mode = PPA_AUTODETECT;
1016 dev->recon_tmo = PPA_RECON_TMO;
1017 init_waitqueue_head(&waiting);
1018 dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup,
1024 /* Claim the bus so it remembers what we do to the control
1025 * registers. [ CTR and ECP ]
1028 dev->waiting = &waiting;
1029 prepare_to_wait(&waiting, &wait, TASK_UNINTERRUPTIBLE);
1030 if (ppa_pb_claim(dev))
1031 schedule_timeout(3 * HZ);
1033 printk(KERN_ERR "ppa%d: failed to claim parport because "
1034 "a pardevice is owning the port for too long "
1035 "time!\n", pb->number);
1036 ppa_pb_dismiss(dev);
1037 dev->waiting = NULL;
1038 finish_wait(&waiting, &wait);
1041 dev->waiting = NULL;
1042 finish_wait(&waiting, &wait);
1043 ppb = dev->base = dev->dev->port->base;
1044 ppb_hi = dev->dev->port->base_hi;
1046 modes = dev->dev->port->modes;
1048 /* Mode detection works up the chain of speed
1049 * This avoids a nasty if-then-else-if-... tree
1051 dev->mode = PPA_NIBBLE;
1053 if (modes & PARPORT_MODE_TRISTATE)
1054 dev->mode = PPA_PS2;
1056 if (modes & PARPORT_MODE_ECP) {
1057 w_ecr(ppb_hi, 0x20);
1058 dev->mode = PPA_PS2;
1060 if ((modes & PARPORT_MODE_EPP) && (modes & PARPORT_MODE_ECP))
1061 w_ecr(ppb_hi, 0x80);
1063 /* Done configuration */
1065 err = ppa_init(dev);
1066 ppa_pb_release(dev);
1071 /* now the glue ... */
1072 if (dev->mode == PPA_NIBBLE || dev->mode == PPA_PS2)
1077 INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev);
1080 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *));
1083 host->io_port = pb->base;
1084 host->n_io_port = ports;
1085 host->dma_channel = -1;
1086 host->unique_id = pb->number;
1087 *(ppa_struct **)&host->hostdata = dev;
1089 list_add_tail(&dev->list, &ppa_hosts);
1090 err = scsi_add_host(host, NULL);
1093 scsi_scan_host(host);
1096 list_del_init(&dev->list);
1097 scsi_host_put(host);
1099 parport_unregister_device(dev->dev);
1105 static void ppa_attach(struct parport *pb)
1110 static void ppa_detach(struct parport *pb)
1113 list_for_each_entry(dev, &ppa_hosts, list) {
1114 if (dev->dev->port == pb) {
1115 list_del_init(&dev->list);
1116 scsi_remove_host(dev->host);
1117 scsi_host_put(dev->host);
1118 parport_unregister_device(dev->dev);
1125 static struct parport_driver ppa_driver = {
1127 .attach = ppa_attach,
1128 .detach = ppa_detach,
1131 static int __init ppa_driver_init(void)
1133 printk("ppa: Version %s\n", PPA_VERSION);
1134 return parport_register_driver(&ppa_driver);
1137 static void __exit ppa_driver_exit(void)
1139 parport_unregister_driver(&ppa_driver);
1142 module_init(ppa_driver_init);
1143 module_exit(ppa_driver_exit);
1144 MODULE_LICENSE("GPL");