2 pd.c (c) 1997-8 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 This is the high-level driver for parallel port IDE hard
6 drives based on chips supported by the paride module.
8 By default, the driver will autoprobe for a single parallel
9 port IDE drive, but if their individual parameters are
10 specified, the driver can handle up to 4 drives.
12 The behaviour of the pd driver can be altered by setting
13 some parameters from the insmod command line. The following
14 parameters are adjustable:
16 drive0 These four arguments can be arrays of
17 drive1 1-8 integers as follows:
19 drive3 <prt>,<pro>,<uni>,<mod>,<geo>,<sby>,<dly>,<slv>
23 <prt> is the base of the parallel port address for
24 the corresponding drive. (required)
26 <pro> is the protocol number for the adapter that
27 supports this drive. These numbers are
28 logged by 'paride' when the protocol modules
29 are initialised. (0 if not given)
31 <uni> for those adapters that support chained
32 devices, this is the unit selector for the
33 chain of devices on the given port. It should
34 be zero for devices that don't support chaining.
37 <mod> this can be -1 to choose the best mode, or one
38 of the mode numbers supported by the adapter.
41 <geo> this defaults to 0 to indicate that the driver
42 should use the CHS geometry provided by the drive
43 itself. If set to 1, the driver will provide
44 a logical geometry with 64 heads and 32 sectors
45 per track, to be consistent with most SCSI
46 drivers. (0 if not given)
48 <sby> set this to zero to disable the power saving
49 standby mode, if needed. (1 if not given)
51 <dly> some parallel ports require the driver to
52 go more slowly. -1 sets a default value that
53 should work with the chosen protocol. Otherwise,
54 set this to a small integer, the larger it is
55 the slower the port i/o. In some cases, setting
56 this to zero will speed up the device. (default -1)
58 <slv> IDE disks can be jumpered to master or slave.
59 Set this to 0 to choose the master drive, 1 to
60 choose the slave, -1 (the default) to choose the
64 major You may use this parameter to overide the
65 default major number (45) that this driver
66 will use. Be sure to change the device
69 name This parameter is a character string that
70 contains the name the kernel will use for this
71 device (in /proc output, for instance).
74 cluster The driver will attempt to aggregate requests
75 for adjacent blocks into larger multi-block
76 clusters. The maximum cluster size (in 512
77 byte sectors) is set with this parameter.
80 verbose This parameter controls the amount of logging
81 that the driver will do. Set it to 0 for
82 normal operation, 1 to see autoprobe progress
83 messages, or 2 to see additional debugging
86 nice This parameter controls the driver's use of
87 idle CPU time, at the expense of some speed.
89 If this driver is built into the kernel, you can use kernel
90 the following command line parameters, with the same values
91 as the corresponding module parameters listed above:
100 In addition, you can use the parameter pd.disable to disable
107 1.01 GRG 1997.01.24 Restored pd_reset()
109 1.02 GRG 1998.05.06 SMP spinlock changes,
111 1.03 GRG 1998.06.16 Eliminate an Ugh.
112 1.04 GRG 1998.08.15 Extra debugging, use HZ in loop timing
113 1.05 GRG 1998.09.24 Added jumbo support
117 #define PD_VERSION "1.05"
122 /* Here are things one can override from the insmod command.
123 Most are autoprobed by paride unless set here. Verbose is off
128 static int verbose
= 0;
129 static int major
= PD_MAJOR
;
130 static char *name
= PD_NAME
;
131 static int cluster
= 64;
133 static int disable
= 0;
135 static int drive0
[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
136 static int drive1
[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
137 static int drive2
[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
138 static int drive3
[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
140 static int (*drives
[4])[8] = {&drive0
, &drive1
, &drive2
, &drive3
};
142 enum {D_PRT
, D_PRO
, D_UNI
, D_MOD
, D_GEO
, D_SBY
, D_DLY
, D_SLV
};
144 /* end of parameters */
146 #include <linux/init.h>
147 #include <linux/module.h>
148 #include <linux/gfp.h>
149 #include <linux/fs.h>
150 #include <linux/delay.h>
151 #include <linux/hdreg.h>
152 #include <linux/cdrom.h> /* for the eject ioctl */
153 #include <linux/blkdev.h>
154 #include <linux/blkpg.h>
155 #include <linux/kernel.h>
156 #include <linux/smp_lock.h>
157 #include <asm/uaccess.h>
158 #include <linux/workqueue.h>
160 static DEFINE_SPINLOCK(pd_lock
);
162 module_param(verbose
, bool, 0);
163 module_param(major
, int, 0);
164 module_param(name
, charp
, 0);
165 module_param(cluster
, int, 0);
166 module_param(nice
, int, 0);
167 module_param_array(drive0
, int, NULL
, 0);
168 module_param_array(drive1
, int, NULL
, 0);
169 module_param_array(drive2
, int, NULL
, 0);
170 module_param_array(drive3
, int, NULL
, 0);
176 /* numbers for "SCSI" geometry */
178 #define PD_LOG_HEADS 64
179 #define PD_LOG_SECTS 32
184 #define PD_MAX_RETRIES 5
185 #define PD_TMO 800 /* interrupt timeout in jiffies */
186 #define PD_SPIN_DEL 50 /* spin delay in micro-seconds */
188 #define PD_SPIN (1000000*PD_TMO)/(HZ*PD_SPIN_DEL)
190 #define STAT_ERR 0x00001
191 #define STAT_INDEX 0x00002
192 #define STAT_ECC 0x00004
193 #define STAT_DRQ 0x00008
194 #define STAT_SEEK 0x00010
195 #define STAT_WRERR 0x00020
196 #define STAT_READY 0x00040
197 #define STAT_BUSY 0x00080
199 #define ERR_AMNF 0x00100
200 #define ERR_TK0NF 0x00200
201 #define ERR_ABRT 0x00400
202 #define ERR_MCR 0x00800
203 #define ERR_IDNF 0x01000
204 #define ERR_MC 0x02000
205 #define ERR_UNC 0x04000
206 #define ERR_TMO 0x10000
208 #define IDE_READ 0x20
209 #define IDE_WRITE 0x30
210 #define IDE_READ_VRFY 0x40
211 #define IDE_INIT_DEV_PARMS 0x91
212 #define IDE_STANDBY 0x96
213 #define IDE_ACKCHANGE 0xdb
214 #define IDE_DOORLOCK 0xde
215 #define IDE_DOORUNLOCK 0xdf
216 #define IDE_IDENTIFY 0xec
217 #define IDE_EJECT 0xed
222 struct pi_adapter pia
; /* interface to paride layer */
223 struct pi_adapter
*pi
;
224 int access
; /* count of active opens ... */
225 int capacity
; /* Size of this volume in sectors */
226 int heads
; /* physical geometry */
230 int drive
; /* master=0 slave=1 */
231 int changed
; /* Have we seen a disk change ? */
232 int removable
; /* removable media device ? */
235 char name
[PD_NAMELEN
]; /* pda, pdb, etc ... */
239 static struct pd_unit pd
[PD_UNITS
];
241 static char pd_scratch
[512]; /* scratch block buffer */
243 static char *pd_errs
[17] = { "ERR", "INDEX", "ECC", "DRQ", "SEEK", "WRERR",
244 "READY", "BUSY", "AMNF", "TK0NF", "ABRT", "MCR",
245 "IDNF", "MC", "UNC", "???", "TMO"
248 static inline int status_reg(struct pd_unit
*disk
)
250 return pi_read_regr(disk
->pi
, 1, 6);
253 static inline int read_reg(struct pd_unit
*disk
, int reg
)
255 return pi_read_regr(disk
->pi
, 0, reg
);
258 static inline void write_status(struct pd_unit
*disk
, int val
)
260 pi_write_regr(disk
->pi
, 1, 6, val
);
263 static inline void write_reg(struct pd_unit
*disk
, int reg
, int val
)
265 pi_write_regr(disk
->pi
, 0, reg
, val
);
268 static inline u8
DRIVE(struct pd_unit
*disk
)
270 return 0xa0+0x10*disk
->drive
;
273 /* ide command interface */
275 static void pd_print_error(struct pd_unit
*disk
, char *msg
, int status
)
279 printk("%s: %s: status = 0x%x =", disk
->name
, msg
, status
);
280 for (i
= 0; i
< ARRAY_SIZE(pd_errs
); i
++)
281 if (status
& (1 << i
))
282 printk(" %s", pd_errs
[i
]);
286 static void pd_reset(struct pd_unit
*disk
)
287 { /* called only for MASTER drive */
288 write_status(disk
, 4);
290 write_status(disk
, 0);
294 #define DBMSG(msg) ((verbose>1)?(msg):NULL)
296 static int pd_wait_for(struct pd_unit
*disk
, int w
, char *msg
)
301 while (k
< PD_SPIN
) {
302 r
= status_reg(disk
);
304 if (((r
& w
) == w
) && !(r
& STAT_BUSY
))
308 e
= (read_reg(disk
, 1) << 8) + read_reg(disk
, 7);
311 if ((e
& (STAT_ERR
| ERR_TMO
)) && (msg
!= NULL
))
312 pd_print_error(disk
, msg
, e
);
316 static void pd_send_command(struct pd_unit
*disk
, int n
, int s
, int h
, int c0
, int c1
, int func
)
318 write_reg(disk
, 6, DRIVE(disk
) + h
);
319 write_reg(disk
, 1, 0); /* the IDE task file */
320 write_reg(disk
, 2, n
);
321 write_reg(disk
, 3, s
);
322 write_reg(disk
, 4, c0
);
323 write_reg(disk
, 5, c1
);
324 write_reg(disk
, 7, func
);
329 static void pd_ide_command(struct pd_unit
*disk
, int func
, int block
, int count
)
335 c0
= (block
>>= 8) & 255;
336 c1
= (block
>>= 8) & 255;
337 h
= ((block
>>= 8) & 15) + 0x40;
339 s
= (block
% disk
->sectors
) + 1;
340 h
= (block
/= disk
->sectors
) % disk
->heads
;
341 c0
= (block
/= disk
->heads
) % 256;
344 pd_send_command(disk
, count
, s
, h
, c0
, c1
, func
);
347 /* The i/o request engine */
349 enum action
{Fail
= 0, Ok
= 1, Hold
, Wait
};
351 static struct request
*pd_req
; /* current request */
352 static enum action (*phase
)(void);
354 static void run_fsm(void);
356 static void ps_tq_int(struct work_struct
*work
);
358 static DECLARE_DELAYED_WORK(fsm_tq
, ps_tq_int
);
360 static void schedule_fsm(void)
363 schedule_delayed_work(&fsm_tq
, 0);
365 schedule_delayed_work(&fsm_tq
, nice
-1);
368 static void ps_tq_int(struct work_struct
*work
)
373 static enum action
do_pd_io_start(void);
374 static enum action
pd_special(void);
375 static enum action
do_pd_read_start(void);
376 static enum action
do_pd_write_start(void);
377 static enum action
do_pd_read_drq(void);
378 static enum action
do_pd_write_done(void);
380 static struct request_queue
*pd_queue
;
381 static int pd_claimed
;
383 static struct pd_unit
*pd_current
; /* current request's drive */
384 static PIA
*pi_current
; /* current request's PIA */
386 static void run_fsm(void)
390 unsigned long saved_flags
;
394 pd_current
= pd_req
->rq_disk
->private_data
;
395 pi_current
= pd_current
->pi
;
396 phase
= do_pd_io_start
;
399 switch (pd_claimed
) {
402 if (!pi_schedule_claimed(pi_current
, run_fsm
))
406 pi_current
->proto
->connect(pi_current
);
409 switch(res
= phase()) {
411 pi_disconnect(pi_current
);
414 spin_lock_irqsave(&pd_lock
, saved_flags
);
415 if (!__blk_end_request_cur(pd_req
,
416 res
== Ok
? 0 : -EIO
)) {
417 pd_req
= blk_fetch_request(pd_queue
);
421 spin_unlock_irqrestore(&pd_lock
, saved_flags
);
428 pi_disconnect(pi_current
);
434 static int pd_retries
= 0; /* i/o error retry count */
435 static int pd_block
; /* address of next requested block */
436 static int pd_count
; /* number of blocks still to do */
437 static int pd_run
; /* sectors in current cluster */
438 static int pd_cmd
; /* current command READ/WRITE */
439 static char *pd_buf
; /* buffer for request in progress */
441 static enum action
do_pd_io_start(void)
443 if (pd_req
->cmd_type
== REQ_TYPE_SPECIAL
) {
448 pd_cmd
= rq_data_dir(pd_req
);
449 if (pd_cmd
== READ
|| pd_cmd
== WRITE
) {
450 pd_block
= blk_rq_pos(pd_req
);
451 pd_count
= blk_rq_cur_sectors(pd_req
);
452 if (pd_block
+ pd_count
> get_capacity(pd_req
->rq_disk
))
454 pd_run
= blk_rq_sectors(pd_req
);
455 pd_buf
= pd_req
->buffer
;
458 return do_pd_read_start();
460 return do_pd_write_start();
465 static enum action
pd_special(void)
467 enum action (*func
)(struct pd_unit
*) = pd_req
->special
;
468 return func(pd_current
);
471 static int pd_next_buf(void)
473 unsigned long saved_flags
;
483 spin_lock_irqsave(&pd_lock
, saved_flags
);
484 __blk_end_request_cur(pd_req
, 0);
485 pd_count
= blk_rq_cur_sectors(pd_req
);
486 pd_buf
= pd_req
->buffer
;
487 spin_unlock_irqrestore(&pd_lock
, saved_flags
);
491 static unsigned long pd_timeout
;
493 static enum action
do_pd_read_start(void)
495 if (pd_wait_for(pd_current
, STAT_READY
, "do_pd_read") & STAT_ERR
) {
496 if (pd_retries
< PD_MAX_RETRIES
) {
502 pd_ide_command(pd_current
, IDE_READ
, pd_block
, pd_run
);
503 phase
= do_pd_read_drq
;
504 pd_timeout
= jiffies
+ PD_TMO
;
508 static enum action
do_pd_write_start(void)
510 if (pd_wait_for(pd_current
, STAT_READY
, "do_pd_write") & STAT_ERR
) {
511 if (pd_retries
< PD_MAX_RETRIES
) {
517 pd_ide_command(pd_current
, IDE_WRITE
, pd_block
, pd_run
);
519 if (pd_wait_for(pd_current
, STAT_DRQ
, "do_pd_write_drq") & STAT_ERR
) {
520 if (pd_retries
< PD_MAX_RETRIES
) {
526 pi_write_block(pd_current
->pi
, pd_buf
, 512);
530 phase
= do_pd_write_done
;
531 pd_timeout
= jiffies
+ PD_TMO
;
535 static inline int pd_ready(void)
537 return !(status_reg(pd_current
) & STAT_BUSY
);
540 static enum action
do_pd_read_drq(void)
542 if (!pd_ready() && !time_after_eq(jiffies
, pd_timeout
))
546 if (pd_wait_for(pd_current
, STAT_DRQ
, "do_pd_read_drq") & STAT_ERR
) {
547 if (pd_retries
< PD_MAX_RETRIES
) {
549 phase
= do_pd_read_start
;
554 pi_read_block(pd_current
->pi
, pd_buf
, 512);
561 static enum action
do_pd_write_done(void)
563 if (!pd_ready() && !time_after_eq(jiffies
, pd_timeout
))
566 if (pd_wait_for(pd_current
, STAT_READY
, "do_pd_write_done") & STAT_ERR
) {
567 if (pd_retries
< PD_MAX_RETRIES
) {
569 phase
= do_pd_write_start
;
577 /* special io requests */
579 /* According to the ATA standard, the default CHS geometry should be
580 available following a reset. Some Western Digital drives come up
581 in a mode where only LBA addresses are accepted until the device
582 parameters are initialised.
585 static void pd_init_dev_parms(struct pd_unit
*disk
)
587 pd_wait_for(disk
, 0, DBMSG("before init_dev_parms"));
588 pd_send_command(disk
, disk
->sectors
, 0, disk
->heads
- 1, 0, 0,
591 pd_wait_for(disk
, 0, "Initialise device parameters");
594 static enum action
pd_door_lock(struct pd_unit
*disk
)
596 if (!(pd_wait_for(disk
, STAT_READY
, "Lock") & STAT_ERR
)) {
597 pd_send_command(disk
, 1, 0, 0, 0, 0, IDE_DOORLOCK
);
598 pd_wait_for(disk
, STAT_READY
, "Lock done");
603 static enum action
pd_door_unlock(struct pd_unit
*disk
)
605 if (!(pd_wait_for(disk
, STAT_READY
, "Lock") & STAT_ERR
)) {
606 pd_send_command(disk
, 1, 0, 0, 0, 0, IDE_DOORUNLOCK
);
607 pd_wait_for(disk
, STAT_READY
, "Lock done");
612 static enum action
pd_eject(struct pd_unit
*disk
)
614 pd_wait_for(disk
, 0, DBMSG("before unlock on eject"));
615 pd_send_command(disk
, 1, 0, 0, 0, 0, IDE_DOORUNLOCK
);
616 pd_wait_for(disk
, 0, DBMSG("after unlock on eject"));
617 pd_wait_for(disk
, 0, DBMSG("before eject"));
618 pd_send_command(disk
, 0, 0, 0, 0, 0, IDE_EJECT
);
619 pd_wait_for(disk
, 0, DBMSG("after eject"));
623 static enum action
pd_media_check(struct pd_unit
*disk
)
625 int r
= pd_wait_for(disk
, STAT_READY
, DBMSG("before media_check"));
626 if (!(r
& STAT_ERR
)) {
627 pd_send_command(disk
, 1, 1, 0, 0, 0, IDE_READ_VRFY
);
628 r
= pd_wait_for(disk
, STAT_READY
, DBMSG("RDY after READ_VRFY"));
630 disk
->changed
= 1; /* say changed if other error */
633 pd_send_command(disk
, 1, 0, 0, 0, 0, IDE_ACKCHANGE
);
634 pd_wait_for(disk
, STAT_READY
, DBMSG("RDY after ACKCHANGE"));
635 pd_send_command(disk
, 1, 1, 0, 0, 0, IDE_READ_VRFY
);
636 r
= pd_wait_for(disk
, STAT_READY
, DBMSG("RDY after VRFY"));
641 static void pd_standby_off(struct pd_unit
*disk
)
643 pd_wait_for(disk
, 0, DBMSG("before STANDBY"));
644 pd_send_command(disk
, 0, 0, 0, 0, 0, IDE_STANDBY
);
645 pd_wait_for(disk
, 0, DBMSG("after STANDBY"));
648 static enum action
pd_identify(struct pd_unit
*disk
)
651 char id
[PD_ID_LEN
+ 1];
653 /* WARNING: here there may be dragons. reset() applies to both drives,
654 but we call it only on probing the MASTER. This should allow most
655 common configurations to work, but be warned that a reset can clear
656 settings on the SLAVE drive.
659 if (disk
->drive
== 0)
662 write_reg(disk
, 6, DRIVE(disk
));
663 pd_wait_for(disk
, 0, DBMSG("before IDENT"));
664 pd_send_command(disk
, 1, 0, 0, 0, 0, IDE_IDENTIFY
);
666 if (pd_wait_for(disk
, STAT_DRQ
, DBMSG("IDENT DRQ")) & STAT_ERR
)
668 pi_read_block(disk
->pi
, pd_scratch
, 512);
669 disk
->can_lba
= pd_scratch
[99] & 2;
670 disk
->sectors
= le16_to_cpu(*(__le16
*) (pd_scratch
+ 12));
671 disk
->heads
= le16_to_cpu(*(__le16
*) (pd_scratch
+ 6));
672 disk
->cylinders
= le16_to_cpu(*(__le16
*) (pd_scratch
+ 2));
674 disk
->capacity
= le32_to_cpu(*(__le32
*) (pd_scratch
+ 120));
676 disk
->capacity
= disk
->sectors
* disk
->heads
* disk
->cylinders
;
678 for (j
= 0; j
< PD_ID_LEN
; j
++)
679 id
[j
^ 1] = pd_scratch
[j
+ PD_ID_OFF
];
681 while ((j
>= 0) && (id
[j
] <= 0x20))
686 disk
->removable
= pd_scratch
[0] & 0x80;
688 printk("%s: %s, %s, %d blocks [%dM], (%d/%d/%d), %s media\n",
690 disk
->drive
? "slave" : "master",
691 disk
->capacity
, disk
->capacity
/ 2048,
692 disk
->cylinders
, disk
->heads
, disk
->sectors
,
693 disk
->removable
? "removable" : "fixed");
696 pd_init_dev_parms(disk
);
698 pd_standby_off(disk
);
703 /* end of io request engine */
705 static void do_pd_request(struct request_queue
* q
)
709 pd_req
= blk_fetch_request(q
);
716 static int pd_special_command(struct pd_unit
*disk
,
717 enum action (*func
)(struct pd_unit
*disk
))
722 rq
= blk_get_request(disk
->gd
->queue
, READ
, __GFP_WAIT
);
724 rq
->cmd_type
= REQ_TYPE_SPECIAL
;
727 err
= blk_execute_rq(disk
->gd
->queue
, disk
->gd
, rq
, 0);
733 /* kernel glue structures */
735 static int pd_open(struct block_device
*bdev
, fmode_t mode
)
737 struct pd_unit
*disk
= bdev
->bd_disk
->private_data
;
742 if (disk
->removable
) {
743 pd_special_command(disk
, pd_media_check
);
744 pd_special_command(disk
, pd_door_lock
);
750 static int pd_getgeo(struct block_device
*bdev
, struct hd_geometry
*geo
)
752 struct pd_unit
*disk
= bdev
->bd_disk
->private_data
;
754 if (disk
->alt_geom
) {
755 geo
->heads
= PD_LOG_HEADS
;
756 geo
->sectors
= PD_LOG_SECTS
;
757 geo
->cylinders
= disk
->capacity
/ (geo
->heads
* geo
->sectors
);
759 geo
->heads
= disk
->heads
;
760 geo
->sectors
= disk
->sectors
;
761 geo
->cylinders
= disk
->cylinders
;
767 static int pd_ioctl(struct block_device
*bdev
, fmode_t mode
,
768 unsigned int cmd
, unsigned long arg
)
770 struct pd_unit
*disk
= bdev
->bd_disk
->private_data
;
775 if (disk
->access
== 1)
776 pd_special_command(disk
, pd_eject
);
784 static int pd_release(struct gendisk
*p
, fmode_t mode
)
786 struct pd_unit
*disk
= p
->private_data
;
789 if (!--disk
->access
&& disk
->removable
)
790 pd_special_command(disk
, pd_door_unlock
);
796 static int pd_check_media(struct gendisk
*p
)
798 struct pd_unit
*disk
= p
->private_data
;
800 if (!disk
->removable
)
802 pd_special_command(disk
, pd_media_check
);
808 static int pd_revalidate(struct gendisk
*p
)
810 struct pd_unit
*disk
= p
->private_data
;
811 if (pd_special_command(disk
, pd_identify
) == 0)
812 set_capacity(p
, disk
->capacity
);
818 static const struct block_device_operations pd_fops
= {
819 .owner
= THIS_MODULE
,
821 .release
= pd_release
,
824 .media_changed
= pd_check_media
,
825 .revalidate_disk
= pd_revalidate
830 static void pd_probe_drive(struct pd_unit
*disk
)
832 struct gendisk
*p
= alloc_disk(1 << PD_BITS
);
835 strcpy(p
->disk_name
, disk
->name
);
838 p
->first_minor
= (disk
- pd
) << PD_BITS
;
840 p
->private_data
= disk
;
843 if (disk
->drive
== -1) {
844 for (disk
->drive
= 0; disk
->drive
<= 1; disk
->drive
++)
845 if (pd_special_command(disk
, pd_identify
) == 0)
847 } else if (pd_special_command(disk
, pd_identify
) == 0)
853 static int pd_detect(void)
855 int found
= 0, unit
, pd_drive_count
= 0;
856 struct pd_unit
*disk
;
858 for (unit
= 0; unit
< PD_UNITS
; unit
++) {
859 int *parm
= *drives
[unit
];
860 struct pd_unit
*disk
= pd
+ unit
;
861 disk
->pi
= &disk
->pia
;
865 disk
->drive
= parm
[D_SLV
];
866 snprintf(disk
->name
, PD_NAMELEN
, "%s%c", name
, 'a'+unit
);
867 disk
->alt_geom
= parm
[D_GEO
];
868 disk
->standby
= parm
[D_SBY
];
873 if (pd_drive_count
== 0) { /* nothing spec'd - so autoprobe for 1 */
875 if (pi_init(disk
->pi
, 1, -1, -1, -1, -1, -1, pd_scratch
,
876 PI_PD
, verbose
, disk
->name
)) {
877 pd_probe_drive(disk
);
879 pi_release(disk
->pi
);
883 for (unit
= 0, disk
= pd
; unit
< PD_UNITS
; unit
++, disk
++) {
884 int *parm
= *drives
[unit
];
887 if (pi_init(disk
->pi
, 0, parm
[D_PRT
], parm
[D_MOD
],
888 parm
[D_UNI
], parm
[D_PRO
], parm
[D_DLY
],
889 pd_scratch
, PI_PD
, verbose
, disk
->name
)) {
890 pd_probe_drive(disk
);
892 pi_release(disk
->pi
);
896 for (unit
= 0, disk
= pd
; unit
< PD_UNITS
; unit
++, disk
++) {
898 set_capacity(disk
->gd
, disk
->capacity
);
904 printk("%s: no valid drive found\n", name
);
908 static int __init
pd_init(void)
913 pd_queue
= blk_init_queue(do_pd_request
, &pd_lock
);
917 blk_queue_max_hw_sectors(pd_queue
, cluster
);
919 if (register_blkdev(major
, name
))
922 printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
923 name
, name
, PD_VERSION
, major
, cluster
, nice
);
930 unregister_blkdev(major
, name
);
932 blk_cleanup_queue(pd_queue
);
937 static void __exit
pd_exit(void)
939 struct pd_unit
*disk
;
941 unregister_blkdev(major
, name
);
942 for (unit
= 0, disk
= pd
; unit
< PD_UNITS
; unit
++, disk
++) {
943 struct gendisk
*p
= disk
->gd
;
948 pi_release(disk
->pi
);
951 blk_cleanup_queue(pd_queue
);
954 MODULE_LICENSE("GPL");