aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c223
1 files changed, 84 insertions, 139 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index a64ec259f3d1..c5adb7b9c5b5 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -101,6 +101,82 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
101 } 101 }
102} 102}
103 103
104static void ide_classify_ata_dev(ide_drive_t *drive)
105{
106 u16 *id = drive->id;
107 char *m = (char *)&id[ATA_ID_PROD];
108 int is_cfa = ata_id_is_cfa(id);
109
110 /* CF devices are *not* removable in Linux definition of the term */
111 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
112 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
113
114 drive->media = ide_disk;
115
116 if (!ata_id_has_unload(drive->id))
117 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
118
119 printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m,
120 is_cfa ? "CFA" : "ATA");
121}
122
123static void ide_classify_atapi_dev(ide_drive_t *drive)
124{
125 u16 *id = drive->id;
126 char *m = (char *)&id[ATA_ID_PROD];
127 u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f;
128
129 printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m);
130 switch (type) {
131 case ide_floppy:
132 if (!strstr(m, "CD-ROM")) {
133 if (!strstr(m, "oppy") &&
134 !strstr(m, "poyp") &&
135 !strstr(m, "ZIP"))
136 printk(KERN_CONT "cdrom or floppy?, assuming ");
137 if (drive->media != ide_cdrom) {
138 printk(KERN_CONT "FLOPPY");
139 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
140 break;
141 }
142 }
143 /* Early cdrom models used zero */
144 type = ide_cdrom;
145 case ide_cdrom:
146 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
147#ifdef CONFIG_PPC
148 /* kludge for Apple PowerBook internal zip */
149 if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) {
150 printk(KERN_CONT "FLOPPY");
151 type = ide_floppy;
152 break;
153 }
154#endif
155 printk(KERN_CONT "CD/DVD-ROM");
156 break;
157 case ide_tape:
158 printk(KERN_CONT "TAPE");
159 break;
160 case ide_optical:
161 printk(KERN_CONT "OPTICAL");
162 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
163 break;
164 default:
165 printk(KERN_CONT "UNKNOWN (type %d)", type);
166 break;
167 }
168
169 printk(KERN_CONT " drive\n");
170 drive->media = type;
171 /* an ATAPI device ignores DRDY */
172 drive->ready_stat = 0;
173 if (ata_id_cdb_intr(id))
174 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT;
175 drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
176 /* we don't do head unloading on ATAPI devices */
177 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
178}
179
104/** 180/**
105 * do_identify - identify a drive 181 * do_identify - identify a drive
106 * @drive: drive to identify 182 * @drive: drive to identify
@@ -117,7 +193,7 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
117 u16 *id = drive->id; 193 u16 *id = drive->id;
118 char *m = (char *)&id[ATA_ID_PROD]; 194 char *m = (char *)&id[ATA_ID_PROD];
119 unsigned long flags; 195 unsigned long flags;
120 int bswap = 1, is_cfa; 196 int bswap = 1;
121 197
122 /* local CPU only; some systems need this */ 198 /* local CPU only; some systems need this */
123 local_irq_save(flags); 199 local_irq_save(flags);
@@ -154,91 +230,23 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
154 if (strstr(m, "E X A B Y T E N E S T")) 230 if (strstr(m, "E X A B Y T E N E S T"))
155 goto err_misc; 231 goto err_misc;
156 232
157 printk(KERN_INFO "%s: %s, ", drive->name, m);
158
159 drive->dev_flags |= IDE_DFLAG_PRESENT; 233 drive->dev_flags |= IDE_DFLAG_PRESENT;
160 drive->dev_flags &= ~IDE_DFLAG_DEAD; 234 drive->dev_flags &= ~IDE_DFLAG_DEAD;
161 235
162 /* 236 /*
163 * Check for an ATAPI device 237 * Check for an ATAPI device
164 */ 238 */
165 if (cmd == ATA_CMD_ID_ATAPI) { 239 if (cmd == ATA_CMD_ID_ATAPI)
166 u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f; 240 ide_classify_atapi_dev(drive);
167 241 else
168 printk(KERN_CONT "ATAPI ");
169 switch (type) {
170 case ide_floppy:
171 if (!strstr(m, "CD-ROM")) {
172 if (!strstr(m, "oppy") &&
173 !strstr(m, "poyp") &&
174 !strstr(m, "ZIP"))
175 printk(KERN_CONT "cdrom or floppy?, assuming ");
176 if (drive->media != ide_cdrom) {
177 printk(KERN_CONT "FLOPPY");
178 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
179 break;
180 }
181 }
182 /* Early cdrom models used zero */
183 type = ide_cdrom;
184 case ide_cdrom:
185 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
186#ifdef CONFIG_PPC
187 /* kludge for Apple PowerBook internal zip */
188 if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) {
189 printk(KERN_CONT "FLOPPY");
190 type = ide_floppy;
191 break;
192 }
193#endif
194 printk(KERN_CONT "CD/DVD-ROM");
195 break;
196 case ide_tape:
197 printk(KERN_CONT "TAPE");
198 break;
199 case ide_optical:
200 printk(KERN_CONT "OPTICAL");
201 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
202 break;
203 default:
204 printk(KERN_CONT "UNKNOWN (type %d)", type);
205 break;
206 }
207 printk(KERN_CONT " drive\n");
208 drive->media = type;
209 /* an ATAPI device ignores DRDY */
210 drive->ready_stat = 0;
211 if (ata_id_cdb_intr(id))
212 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT;
213 drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
214 /* we don't do head unloading on ATAPI devices */
215 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
216 return;
217 }
218
219 /* 242 /*
220 * Not an ATAPI device: looks like a "regular" hard disk 243 * Not an ATAPI device: looks like a "regular" hard disk
221 */ 244 */
222 245 ide_classify_ata_dev(drive);
223 is_cfa = ata_id_is_cfa(id);
224
225 /* CF devices are *not* removable in Linux definition of the term */
226 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
227 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
228
229 drive->media = ide_disk;
230
231 if (!ata_id_has_unload(drive->id))
232 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
233
234 printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA");
235
236 return; 246 return;
237
238err_misc: 247err_misc:
239 kfree(id); 248 kfree(id);
240 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 249 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
241 return;
242} 250}
243 251
244/** 252/**
@@ -641,14 +649,9 @@ static int ide_register_port(ide_hwif_t *hwif)
641 /* register with global device tree */ 649 /* register with global device tree */
642 dev_set_name(&hwif->gendev, hwif->name); 650 dev_set_name(&hwif->gendev, hwif->name);
643 hwif->gendev.driver_data = hwif; 651 hwif->gendev.driver_data = hwif;
644 if (hwif->gendev.parent == NULL) { 652 hwif->gendev.parent = hwif->dev;
645 if (hwif->dev)
646 hwif->gendev.parent = hwif->dev;
647 else
648 /* Would like to do = &device_legacy */
649 hwif->gendev.parent = NULL;
650 }
651 hwif->gendev.release = hwif_release_dev; 653 hwif->gendev.release = hwif_release_dev;
654
652 ret = device_register(&hwif->gendev); 655 ret = device_register(&hwif->gendev);
653 if (ret < 0) { 656 if (ret < 0) {
654 printk(KERN_WARNING "IDE: %s: device_register error: %d\n", 657 printk(KERN_WARNING "IDE: %s: device_register error: %d\n",
@@ -878,8 +881,7 @@ static int ide_init_queue(ide_drive_t *drive)
878 * do not. 881 * do not.
879 */ 882 */
880 883
881 q = blk_init_queue_node(do_ide_request, &hwif->hwgroup->lock, 884 q = blk_init_queue_node(do_ide_request, NULL, hwif_to_node(hwif));
882 hwif_to_node(hwif));
883 if (!q) 885 if (!q)
884 return 1; 886 return 1;
885 887
@@ -1139,8 +1141,6 @@ static struct kobject *ata_probe(dev_t dev, int *part, void *data)
1139 1141
1140 if (drive->media == ide_disk) 1142 if (drive->media == ide_disk)
1141 request_module("ide-disk"); 1143 request_module("ide-disk");
1142 if (drive->dev_flags & IDE_DFLAG_SCSI)
1143 request_module("ide-scsi");
1144 if (drive->media == ide_cdrom || drive->media == ide_optical) 1144 if (drive->media == ide_cdrom || drive->media == ide_optical)
1145 request_module("ide-cd"); 1145 request_module("ide-cd");
1146 if (drive->media == ide_tape) 1146 if (drive->media == ide_tape)
@@ -1417,58 +1417,6 @@ static void ide_port_cable_detect(ide_hwif_t *hwif)
1417 } 1417 }
1418} 1418}
1419 1419
1420static ssize_t store_delete_devices(struct device *portdev,
1421 struct device_attribute *attr,
1422 const char *buf, size_t n)
1423{
1424 ide_hwif_t *hwif = dev_get_drvdata(portdev);
1425
1426 if (strncmp(buf, "1", n))
1427 return -EINVAL;
1428
1429 ide_port_unregister_devices(hwif);
1430
1431 return n;
1432};
1433
1434static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices);
1435
1436static ssize_t store_scan(struct device *portdev,
1437 struct device_attribute *attr,
1438 const char *buf, size_t n)
1439{
1440 ide_hwif_t *hwif = dev_get_drvdata(portdev);
1441
1442 if (strncmp(buf, "1", n))
1443 return -EINVAL;
1444
1445 ide_port_unregister_devices(hwif);
1446 ide_port_scan(hwif);
1447
1448 return n;
1449};
1450
1451static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
1452
1453static struct device_attribute *ide_port_attrs[] = {
1454 &dev_attr_delete_devices,
1455 &dev_attr_scan,
1456 NULL
1457};
1458
1459static int ide_sysfs_register_port(ide_hwif_t *hwif)
1460{
1461 int i, uninitialized_var(rc);
1462
1463 for (i = 0; ide_port_attrs[i]; i++) {
1464 rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
1465 if (rc)
1466 break;
1467 }
1468
1469 return rc;
1470}
1471
1472static unsigned int ide_indexes; 1420static unsigned int ide_indexes;
1473 1421
1474/** 1422/**
@@ -1655,9 +1603,6 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1655 if (hwif == NULL) 1603 if (hwif == NULL)
1656 continue; 1604 continue;
1657 1605
1658 if (hwif->chipset == ide_unknown)
1659 hwif->chipset = ide_generic;
1660
1661 if (hwif->present) 1606 if (hwif->present)
1662 hwif_register_devices(hwif); 1607 hwif_register_devices(hwif);
1663 } 1608 }