aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:33 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:33 -0400
commit05236ea6df7419f0f37cf9603cfee265cfce5832 (patch)
tree42aa04bc4106f80dd3f09895909fb6495c55a9cd /drivers
parent170dc5b085e688639aa2b7acd1b907e2e1c7a48a (diff)
ide: move ioctls handling to ide-ioctls.c
* Move ioctls handling to ide-ioctls.c (except HDIO_DRIVE_TASKFILE for now). * Make ide_{cmd,task}() static. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/Makefile4
-rw-r--r--drivers/ide/ide-ioctls.c289
-rw-r--r--drivers/ide/ide-taskfile.c109
-rw-r--r--drivers/ide/ide.c174
4 files changed, 291 insertions, 285 deletions
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 64e0ecdc4ed5..76a30d763384 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -4,8 +4,8 @@
4 4
5EXTRA_CFLAGS += -Idrivers/ide 5EXTRA_CFLAGS += -Idrivers/ide
6 6
7ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o \ 7ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \
8 ide-pio-blacklist.o 8 ide-taskfile.o ide-pio-blacklist.o
9 9
10# core IDE code 10# core IDE code
11ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o 11ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
new file mode 100644
index 000000000000..7a0d62e7286b
--- /dev/null
+++ b/drivers/ide/ide-ioctls.c
@@ -0,0 +1,289 @@
1/*
2 * IDE ioctls handling.
3 */
4
5#include <linux/hdreg.h>
6#include <linux/ide.h>
7
8static const struct ide_ioctl_devset ide_ioctl_settings[] = {
9{ HDIO_GET_32BIT, HDIO_SET_32BIT, get_io_32bit, set_io_32bit },
10{ HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, get_ksettings, set_ksettings },
11{ HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, get_unmaskirq, set_unmaskirq },
12{ HDIO_GET_DMA, HDIO_SET_DMA, get_using_dma, set_using_dma },
13{ -1, HDIO_SET_PIO_MODE, NULL, set_pio_mode },
14{ 0 }
15};
16
17int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
18 unsigned int cmd, unsigned long arg,
19 const struct ide_ioctl_devset *s)
20{
21 unsigned long flags;
22 int err = -EOPNOTSUPP;
23
24 for (; s->get_ioctl; s++) {
25 if (s->get && s->get_ioctl == cmd)
26 goto read_val;
27 else if (s->set && s->set_ioctl == cmd)
28 goto set_val;
29 }
30
31 return err;
32
33read_val:
34 mutex_lock(&ide_setting_mtx);
35 spin_lock_irqsave(&ide_lock, flags);
36 err = s->get(drive);
37 spin_unlock_irqrestore(&ide_lock, flags);
38 mutex_unlock(&ide_setting_mtx);
39 return err >= 0 ? put_user(err, (long __user *)arg) : err;
40
41set_val:
42 if (bdev != bdev->bd_contains)
43 err = -EINVAL;
44 else {
45 if (!capable(CAP_SYS_ADMIN))
46 err = -EACCES;
47 else {
48 mutex_lock(&ide_setting_mtx);
49 err = s->set(drive, arg);
50 mutex_unlock(&ide_setting_mtx);
51 }
52 }
53 return err;
54}
55EXPORT_SYMBOL_GPL(ide_setting_ioctl);
56
57static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
58 unsigned long arg)
59{
60 u16 *id = NULL;
61 int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142;
62 int rc = 0;
63
64 if (drive->id_read == 0) {
65 rc = -ENOMSG;
66 goto out;
67 }
68
69 id = kmalloc(size, GFP_KERNEL);
70 if (id == NULL) {
71 rc = -ENOMEM;
72 goto out;
73 }
74
75 memcpy(id, drive->id, size);
76 ata_id_to_hd_driveid(id);
77
78 if (copy_to_user((void __user *)arg, id, size))
79 rc = -EFAULT;
80
81 kfree(id);
82out:
83 return rc;
84}
85
86static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg)
87{
88 return put_user((drive->dsc_overlap << IDE_NICE_DSC_OVERLAP) |
89 (drive->nice1 << IDE_NICE_1), (long __user *)arg);
90}
91
92static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg)
93{
94 if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1))))
95 return -EPERM;
96
97 if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) &&
98 (drive->media == ide_disk || drive->media == ide_floppy ||
99 drive->scsi))
100 return -EPERM;
101
102 drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1;
103 drive->nice1 = (arg >> IDE_NICE_1) & 1;
104
105 return 0;
106}
107
108static int ide_cmd_ioctl(ide_drive_t *drive, unsigned cmd, unsigned long arg)
109{
110 u8 *buf = NULL;
111 int bufsize = 0, err = 0;
112 u8 args[4], xfer_rate = 0;
113 ide_task_t tfargs;
114 struct ide_taskfile *tf = &tfargs.tf;
115 u16 *id = drive->id;
116
117 if (NULL == (void *) arg) {
118 struct request *rq;
119
120 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
121 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
122 err = blk_execute_rq(drive->queue, NULL, rq, 0);
123 blk_put_request(rq);
124
125 return err;
126 }
127
128 if (copy_from_user(args, (void __user *)arg, 4))
129 return -EFAULT;
130
131 memset(&tfargs, 0, sizeof(ide_task_t));
132 tf->feature = args[2];
133 if (args[0] == ATA_CMD_SMART) {
134 tf->nsect = args[3];
135 tf->lbal = args[1];
136 tf->lbam = 0x4f;
137 tf->lbah = 0xc2;
138 tfargs.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_IN_NSECT;
139 } else {
140 tf->nsect = args[1];
141 tfargs.tf_flags = IDE_TFLAG_OUT_FEATURE |
142 IDE_TFLAG_OUT_NSECT | IDE_TFLAG_IN_NSECT;
143 }
144 tf->command = args[0];
145 tfargs.data_phase = args[3] ? TASKFILE_IN : TASKFILE_NO_DATA;
146
147 if (args[3]) {
148 tfargs.tf_flags |= IDE_TFLAG_IO_16BIT;
149 bufsize = SECTOR_SIZE * args[3];
150 buf = kzalloc(bufsize, GFP_KERNEL);
151 if (buf == NULL)
152 return -ENOMEM;
153 }
154
155 if (tf->command == ATA_CMD_SET_FEATURES &&
156 tf->feature == SETFEATURES_XFER &&
157 tf->nsect >= XFER_SW_DMA_0 &&
158 (id[ATA_ID_UDMA_MODES] ||
159 id[ATA_ID_MWDMA_MODES] ||
160 id[ATA_ID_SWDMA_MODES])) {
161 xfer_rate = args[1];
162 if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) {
163 printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
164 "be set\n", drive->name);
165 goto abort;
166 }
167 }
168
169 err = ide_raw_taskfile(drive, &tfargs, buf, args[3]);
170
171 args[0] = tf->status;
172 args[1] = tf->error;
173 args[2] = tf->nsect;
174
175 if (!err && xfer_rate) {
176 /* active-retuning-calls future */
177 ide_set_xfer_rate(drive, xfer_rate);
178 ide_driveid_update(drive);
179 }
180abort:
181 if (copy_to_user((void __user *)arg, &args, 4))
182 err = -EFAULT;
183 if (buf) {
184 if (copy_to_user((void __user *)(arg + 4), buf, bufsize))
185 err = -EFAULT;
186 kfree(buf);
187 }
188 return err;
189}
190
191static int ide_task_ioctl(ide_drive_t *drive, unsigned cmd, unsigned long arg)
192{
193 void __user *p = (void __user *)arg;
194 int err = 0;
195 u8 args[7];
196 ide_task_t task;
197
198 if (copy_from_user(args, p, 7))
199 return -EFAULT;
200
201 memset(&task, 0, sizeof(task));
202 memcpy(&task.tf_array[7], &args[1], 6);
203 task.tf.command = args[0];
204 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
205
206 err = ide_no_data_taskfile(drive, &task);
207
208 args[0] = task.tf.command;
209 memcpy(&args[1], &task.tf_array[7], 6);
210
211 if (copy_to_user(p, args, 7))
212 err = -EFAULT;
213
214 return err;
215}
216
217static int generic_drive_reset(ide_drive_t *drive)
218{
219 struct request *rq;
220 int ret = 0;
221
222 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
223 rq->cmd_type = REQ_TYPE_SPECIAL;
224 rq->cmd_len = 1;
225 rq->cmd[0] = REQ_DRIVE_RESET;
226 rq->cmd_flags |= REQ_SOFTBARRIER;
227 if (blk_execute_rq(drive->queue, NULL, rq, 1))
228 ret = rq->errors;
229 blk_put_request(rq);
230 return ret;
231}
232
233int generic_ide_ioctl(ide_drive_t *drive, struct file *file,
234 struct block_device *bdev,
235 unsigned int cmd, unsigned long arg)
236{
237 int err;
238
239 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_ioctl_settings);
240 if (err != -EOPNOTSUPP)
241 return err;
242
243 switch (cmd) {
244 case HDIO_OBSOLETE_IDENTITY:
245 case HDIO_GET_IDENTITY:
246 if (bdev != bdev->bd_contains)
247 return -EINVAL;
248 return ide_get_identity_ioctl(drive, cmd, arg);
249 case HDIO_GET_NICE:
250 return ide_get_nice_ioctl(drive, arg);
251 case HDIO_SET_NICE:
252 if (!capable(CAP_SYS_ADMIN))
253 return -EACCES;
254 return ide_set_nice_ioctl(drive, arg);
255#ifdef CONFIG_IDE_TASK_IOCTL
256 case HDIO_DRIVE_TASKFILE:
257 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
258 return -EACCES;
259 if (drive->media == ide_disk)
260 return ide_taskfile_ioctl(drive, cmd, arg);
261 return -ENOMSG;
262#endif
263 case HDIO_DRIVE_CMD:
264 if (!capable(CAP_SYS_RAWIO))
265 return -EACCES;
266 return ide_cmd_ioctl(drive, cmd, arg);
267 case HDIO_DRIVE_TASK:
268 if (!capable(CAP_SYS_RAWIO))
269 return -EACCES;
270 return ide_task_ioctl(drive, cmd, arg);
271 case HDIO_DRIVE_RESET:
272 if (!capable(CAP_SYS_ADMIN))
273 return -EACCES;
274 return generic_drive_reset(drive);
275 case HDIO_GET_BUSSTATE:
276 if (!capable(CAP_SYS_ADMIN))
277 return -EACCES;
278 if (put_user(BUSSTATE_ON, (long __user *)arg))
279 return -EFAULT;
280 return 0;
281 case HDIO_SET_BUSSTATE:
282 if (!capable(CAP_SYS_ADMIN))
283 return -EACCES;
284 return -EOPNOTSUPP;
285 default:
286 return -EINVAL;
287 }
288}
289EXPORT_SYMBOL(generic_ide_ioctl);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 7ffe9004a4d6..487b18b3ebae 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -726,112 +726,3 @@ abort:
726 return err; 726 return err;
727} 727}
728#endif 728#endif
729
730int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
731{
732 u8 *buf = NULL;
733 int bufsize = 0, err = 0;
734 u8 args[4], xfer_rate = 0;
735 ide_task_t tfargs;
736 struct ide_taskfile *tf = &tfargs.tf;
737 u16 *id = drive->id;
738
739 if (NULL == (void *) arg) {
740 struct request *rq;
741
742 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
743 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
744 err = blk_execute_rq(drive->queue, NULL, rq, 0);
745 blk_put_request(rq);
746
747 return err;
748 }
749
750 if (copy_from_user(args, (void __user *)arg, 4))
751 return -EFAULT;
752
753 memset(&tfargs, 0, sizeof(ide_task_t));
754 tf->feature = args[2];
755 if (args[0] == ATA_CMD_SMART) {
756 tf->nsect = args[3];
757 tf->lbal = args[1];
758 tf->lbam = 0x4f;
759 tf->lbah = 0xc2;
760 tfargs.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_IN_NSECT;
761 } else {
762 tf->nsect = args[1];
763 tfargs.tf_flags = IDE_TFLAG_OUT_FEATURE |
764 IDE_TFLAG_OUT_NSECT | IDE_TFLAG_IN_NSECT;
765 }
766 tf->command = args[0];
767 tfargs.data_phase = args[3] ? TASKFILE_IN : TASKFILE_NO_DATA;
768
769 if (args[3]) {
770 tfargs.tf_flags |= IDE_TFLAG_IO_16BIT;
771 bufsize = SECTOR_SIZE * args[3];
772 buf = kzalloc(bufsize, GFP_KERNEL);
773 if (buf == NULL)
774 return -ENOMEM;
775 }
776
777 if (tf->command == ATA_CMD_SET_FEATURES &&
778 tf->feature == SETFEATURES_XFER &&
779 tf->nsect >= XFER_SW_DMA_0 &&
780 (id[ATA_ID_UDMA_MODES] ||
781 id[ATA_ID_MWDMA_MODES] ||
782 id[ATA_ID_SWDMA_MODES])) {
783 xfer_rate = args[1];
784 if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) {
785 printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
786 "be set\n", drive->name);
787 goto abort;
788 }
789 }
790
791 err = ide_raw_taskfile(drive, &tfargs, buf, args[3]);
792
793 args[0] = tf->status;
794 args[1] = tf->error;
795 args[2] = tf->nsect;
796
797 if (!err && xfer_rate) {
798 /* active-retuning-calls future */
799 ide_set_xfer_rate(drive, xfer_rate);
800 ide_driveid_update(drive);
801 }
802abort:
803 if (copy_to_user((void __user *)arg, &args, 4))
804 err = -EFAULT;
805 if (buf) {
806 if (copy_to_user((void __user *)(arg + 4), buf, bufsize))
807 err = -EFAULT;
808 kfree(buf);
809 }
810 return err;
811}
812
813int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
814{
815 void __user *p = (void __user *)arg;
816 int err = 0;
817 u8 args[7];
818 ide_task_t task;
819
820 if (copy_from_user(args, p, 7))
821 return -EFAULT;
822
823 memset(&task, 0, sizeof(task));
824 memcpy(&task.tf_array[7], &args[1], 6);
825 task.tf.command = args[0];
826 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
827
828 err = ide_no_data_taskfile(drive, &task);
829
830 args[0] = task.tf.command;
831 memcpy(&args[1], &task.tf_array[7], 6);
832
833 if (copy_to_user(p, args, 7))
834 err = -EFAULT;
835
836 return err;
837}
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 19181493e722..349d7fa75585 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -489,180 +489,6 @@ static int generic_ide_resume(struct device *dev)
489 return err; 489 return err;
490} 490}
491 491
492static int generic_drive_reset(ide_drive_t *drive)
493{
494 struct request *rq;
495 int ret = 0;
496
497 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
498 rq->cmd_type = REQ_TYPE_SPECIAL;
499 rq->cmd_len = 1;
500 rq->cmd[0] = REQ_DRIVE_RESET;
501 rq->cmd_flags |= REQ_SOFTBARRIER;
502 if (blk_execute_rq(drive->queue, NULL, rq, 1))
503 ret = rq->errors;
504 blk_put_request(rq);
505 return ret;
506}
507
508static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
509 unsigned long arg)
510{
511 u16 *id = NULL;
512 int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142;
513 int rc = 0;
514
515 if (drive->id_read == 0) {
516 rc = -ENOMSG;
517 goto out;
518 }
519
520 id = kmalloc(size, GFP_KERNEL);
521 if (id == NULL) {
522 rc = -ENOMEM;
523 goto out;
524 }
525
526 memcpy(id, drive->id, size);
527 ata_id_to_hd_driveid(id);
528
529 if (copy_to_user((void __user *)arg, id, size))
530 rc = -EFAULT;
531
532 kfree(id);
533out:
534 return rc;
535}
536
537static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg)
538{
539 return put_user((drive->dsc_overlap << IDE_NICE_DSC_OVERLAP) |
540 (drive->nice1 << IDE_NICE_1), (long __user *)arg);
541}
542
543static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg)
544{
545 if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1))))
546 return -EPERM;
547
548 if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) &&
549 (drive->media == ide_disk || drive->media == ide_floppy ||
550 drive->scsi))
551 return -EPERM;
552
553 drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1;
554 drive->nice1 = (arg >> IDE_NICE_1) & 1;
555
556 return 0;
557}
558
559static const struct ide_ioctl_devset ide_ioctl_settings[] = {
560{ HDIO_GET_32BIT, HDIO_SET_32BIT, get_io_32bit, set_io_32bit },
561{ HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, get_ksettings, set_ksettings },
562{ HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, get_unmaskirq, set_unmaskirq },
563{ HDIO_GET_DMA, HDIO_SET_DMA, get_using_dma, set_using_dma },
564{ -1, HDIO_SET_PIO_MODE, NULL, set_pio_mode },
565{ 0 }
566};
567
568int generic_ide_ioctl(ide_drive_t *drive, struct file *file,
569 struct block_device *bdev,
570 unsigned int cmd, unsigned long arg)
571{
572 int err;
573
574 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_ioctl_settings);
575 if (err != -EOPNOTSUPP)
576 return err;
577
578 switch (cmd) {
579 case HDIO_OBSOLETE_IDENTITY:
580 case HDIO_GET_IDENTITY:
581 if (bdev != bdev->bd_contains)
582 return -EINVAL;
583 return ide_get_identity_ioctl(drive, cmd, arg);
584 case HDIO_GET_NICE:
585 return ide_get_nice_ioctl(drive, arg);
586 case HDIO_SET_NICE:
587 if (!capable(CAP_SYS_ADMIN))
588 return -EACCES;
589 return ide_set_nice_ioctl(drive, arg);
590#ifdef CONFIG_IDE_TASK_IOCTL
591 case HDIO_DRIVE_TASKFILE:
592 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
593 return -EACCES;
594 if (drive->media == ide_disk)
595 return ide_taskfile_ioctl(drive, cmd, arg);
596 return -ENOMSG;
597#endif
598 case HDIO_DRIVE_CMD:
599 if (!capable(CAP_SYS_RAWIO))
600 return -EACCES;
601 return ide_cmd_ioctl(drive, cmd, arg);
602 case HDIO_DRIVE_TASK:
603 if (!capable(CAP_SYS_RAWIO))
604 return -EACCES;
605 return ide_task_ioctl(drive, cmd, arg);
606 case HDIO_DRIVE_RESET:
607 if (!capable(CAP_SYS_ADMIN))
608 return -EACCES;
609 return generic_drive_reset(drive);
610 case HDIO_GET_BUSSTATE:
611 if (!capable(CAP_SYS_ADMIN))
612 return -EACCES;
613 if (put_user(BUSSTATE_ON, (long __user *)arg))
614 return -EFAULT;
615 return 0;
616 case HDIO_SET_BUSSTATE:
617 if (!capable(CAP_SYS_ADMIN))
618 return -EACCES;
619 return -EOPNOTSUPP;
620 default:
621 return -EINVAL;
622 }
623}
624EXPORT_SYMBOL(generic_ide_ioctl);
625
626int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
627 unsigned int cmd, unsigned long arg,
628 const struct ide_ioctl_devset *s)
629{
630 unsigned long flags;
631 int err = -EOPNOTSUPP;
632
633 for (; s->get_ioctl; s++) {
634 if (s->get && s->get_ioctl == cmd)
635 goto read_val;
636 else if (s->set && s->set_ioctl == cmd)
637 goto set_val;
638 }
639
640 return err;
641
642read_val:
643 mutex_lock(&ide_setting_mtx);
644 spin_lock_irqsave(&ide_lock, flags);
645 err = s->get(drive);
646 spin_unlock_irqrestore(&ide_lock, flags);
647 mutex_unlock(&ide_setting_mtx);
648 return err >= 0 ? put_user(err, (long __user *)arg) : err;
649
650set_val:
651 if (bdev != bdev->bd_contains)
652 err = -EINVAL;
653 else {
654 if (!capable(CAP_SYS_ADMIN))
655 err = -EACCES;
656 else {
657 mutex_lock(&ide_setting_mtx);
658 err = s->set(drive, arg);
659 mutex_unlock(&ide_setting_mtx);
660 }
661 }
662 return err;
663}
664EXPORT_SYMBOL_GPL(ide_setting_ioctl);
665
666/** 492/**
667 * ide_device_get - get an additional reference to a ide_drive_t 493 * ide_device_get - get an additional reference to a ide_drive_t
668 * @drive: device to get a reference to 494 * @drive: device to get a reference to