aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:44 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:44 -0400
commit11938c929022bb92b1a42f5e1289524a1e465dc0 (patch)
tree7698cdcb8b45d30d7e4831cfa884c1ed13e1fe4c /drivers/ide/ide.c
parentc4e66c36cce3f23d68013c4112013123ffe80bdb (diff)
ide: move device settings code to ide-devsets.c
Remove stale comment from ide.c while at it. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c154
1 files changed, 0 insertions, 154 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index c779aa24dbe6..92c9b90931e7 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -62,160 +62,6 @@
62 62
63struct class *ide_port_class; 63struct class *ide_port_class;
64 64
65/*
66 * Locks for IDE setting functionality
67 */
68
69DEFINE_MUTEX(ide_setting_mtx);
70
71ide_devset_get(io_32bit, io_32bit);
72
73static int set_io_32bit(ide_drive_t *drive, int arg)
74{
75 if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT)
76 return -EPERM;
77
78 if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1))
79 return -EINVAL;
80
81 drive->io_32bit = arg;
82
83 return 0;
84}
85
86ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS);
87
88static int set_ksettings(ide_drive_t *drive, int arg)
89{
90 if (arg < 0 || arg > 1)
91 return -EINVAL;
92
93 if (arg)
94 drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS;
95 else
96 drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS;
97
98 return 0;
99}
100
101ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA);
102
103static int set_using_dma(ide_drive_t *drive, int arg)
104{
105#ifdef CONFIG_BLK_DEV_IDEDMA
106 int err = -EPERM;
107
108 if (arg < 0 || arg > 1)
109 return -EINVAL;
110
111 if (ata_id_has_dma(drive->id) == 0)
112 goto out;
113
114 if (drive->hwif->dma_ops == NULL)
115 goto out;
116
117 err = 0;
118
119 if (arg) {
120 if (ide_set_dma(drive))
121 err = -EIO;
122 } else
123 ide_dma_off(drive);
124
125out:
126 return err;
127#else
128 if (arg < 0 || arg > 1)
129 return -EINVAL;
130
131 return -EPERM;
132#endif
133}
134
135/*
136 * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away
137 */
138static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio)
139{
140 switch (req_pio) {
141 case 202:
142 case 201:
143 case 200:
144 case 102:
145 case 101:
146 case 100:
147 return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0;
148 case 9:
149 case 8:
150 return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0;
151 case 7:
152 case 6:
153 return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0;
154 default:
155 return 0;
156 }
157}
158
159static int set_pio_mode(ide_drive_t *drive, int arg)
160{
161 ide_hwif_t *hwif = drive->hwif;
162 const struct ide_port_ops *port_ops = hwif->port_ops;
163
164 if (arg < 0 || arg > 255)
165 return -EINVAL;
166
167 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
168 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
169 return -ENOSYS;
170
171 if (set_pio_mode_abuse(drive->hwif, arg)) {
172 if (arg == 8 || arg == 9) {
173 unsigned long flags;
174
175 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
176 spin_lock_irqsave(&hwif->lock, flags);
177 port_ops->set_pio_mode(drive, arg);
178 spin_unlock_irqrestore(&hwif->lock, flags);
179 } else
180 port_ops->set_pio_mode(drive, arg);
181 } else {
182 int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
183
184 ide_set_pio(drive, arg);
185
186 if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) {
187 if (keep_dma)
188 ide_dma_on(drive);
189 }
190 }
191
192 return 0;
193}
194
195ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK);
196
197static int set_unmaskirq(ide_drive_t *drive, int arg)
198{
199 if (drive->dev_flags & IDE_DFLAG_NO_UNMASK)
200 return -EPERM;
201
202 if (arg < 0 || arg > 1)
203 return -EINVAL;
204
205 if (arg)
206 drive->dev_flags |= IDE_DFLAG_UNMASK;
207 else
208 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
209
210 return 0;
211}
212
213ide_ext_devset_rw_sync(io_32bit, io_32bit);
214ide_ext_devset_rw_sync(keepsettings, ksettings);
215ide_ext_devset_rw_sync(unmaskirq, unmaskirq);
216ide_ext_devset_rw_sync(using_dma, using_dma);
217__IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode);
218
219/** 65/**
220 * ide_device_get - get an additional reference to a ide_drive_t 66 * ide_device_get - get an additional reference to a ide_drive_t
221 * @drive: device to get a reference to 67 * @drive: device to get a reference to