ide: remove IDE_*_REG macros
[deliverable/linux.git] / drivers / ide / ide-probe.c
index 468c4ac4181dc8a73984f758e589b8f0fad7dfc7..10ccf278d5be58a86c0a54116f5f41db6bc06ed8 100644 (file)
@@ -271,7 +271,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
        /* take a deep breath */
        msleep(50);
 
-       if (IDE_CONTROL_REG) {
+       if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
                a = ide_read_altstatus(drive);
                s = ide_read_status(drive);
                if ((a ^ s) & ~INDEX_STAT)
@@ -289,10 +289,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
         */
        if ((cmd == WIN_PIDENTIFY))
                /* disable dma & overlap */
-               hwif->OUTB(0, IDE_FEATURE_REG);
+               hwif->OUTB(0, hwif->io_ports[IDE_FEATURE_OFFSET]);
 
        /* ask drive for ID */
-       hwif->OUTB(cmd, IDE_COMMAND_REG);
+       hwif->OUTB(cmd, hwif->io_ports[IDE_COMMAND_OFFSET]);
 
        timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
        timeout += jiffies;
@@ -353,7 +353,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
         * interrupts during the identify-phase that
         * the irq handler isn't expecting.
         */
-       if (IDE_CONTROL_REG) {
+       if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
                if (!hwif->irq) {
                        autoprobe = 1;
                        cookie = probe_irq_on();
@@ -445,7 +445,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
        msleep(50);
        SELECT_DRIVE(drive);
        msleep(50);
-       if (hwif->INB(IDE_SELECT_REG) != drive->select.all && !drive->present) {
+       if (hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]) != drive->select.all &&
+           !drive->present) {
                if (drive->select.b.unit != 0) {
                        /* exit with drive0 selected */
                        SELECT_DRIVE(&hwif->drives[0]);
@@ -477,9 +478,11 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
                        printk(KERN_ERR "%s: no response (status = 0x%02x), "
                                        "resetting drive\n", drive->name, stat);
                        msleep(50);
-                       hwif->OUTB(drive->select.all, IDE_SELECT_REG);
+                       hwif->OUTB(drive->select.all,
+                                  hwif->io_ports[IDE_SELECT_OFFSET]);
                        msleep(50);
-                       hwif->OUTB(WIN_SRST, IDE_COMMAND_REG);
+                       hwif->OUTB(WIN_SRST,
+                                  hwif->io_ports[IDE_COMMAND_OFFSET]);
                        (void)ide_busy_sleep(hwif);
                        rc = try_to_identify(drive, cmd);
                }
@@ -515,7 +518,7 @@ static void enable_nest (ide_drive_t *drive)
        printk("%s: enabling %s -- ", hwif->name, drive->id->model);
        SELECT_DRIVE(drive);
        msleep(50);
-       hwif->OUTB(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG);
+       hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports[IDE_COMMAND_OFFSET]);
 
        if (ide_busy_sleep(hwif)) {
                printk(KERN_CONT "failed (timeout)\n");
@@ -623,7 +626,7 @@ static void hwif_release_dev (struct device *dev)
        complete(&hwif->gendev_rel_comp);
 }
 
-static void ide_register_port(ide_hwif_t *hwif)
+static int ide_register_port(ide_hwif_t *hwif)
 {
        int ret;
 
@@ -639,9 +642,23 @@ static void ide_register_port(ide_hwif_t *hwif)
        }
        hwif->gendev.release = hwif_release_dev;
        ret = device_register(&hwif->gendev);
-       if (ret < 0)
+       if (ret < 0) {
                printk(KERN_WARNING "IDE: %s: device_register error: %d\n",
                        __FUNCTION__, ret);
+               goto out;
+       }
+
+       get_device(&hwif->gendev);
+
+       hwif->portdev = device_create(ide_port_class, &hwif->gendev,
+                                     MKDEV(0, 0), hwif->name);
+       if (IS_ERR(hwif->portdev)) {
+               ret = PTR_ERR(hwif->portdev);
+               device_unregister(&hwif->gendev);
+       }
+       dev_set_drvdata(hwif->portdev, hwif);
+out:
+       return ret;
 }
 
 /**
@@ -1227,13 +1244,6 @@ static int hwif_init(ide_hwif_t *hwif)
                        return 0;
                }
        }
-#ifdef CONFIG_BLK_DEV_HD
-       if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) {
-               printk("%s: CANNOT SHARE IRQ WITH OLD "
-                       "HARDDISK DRIVER (hd.c)\n", hwif->name);
-               return 0;
-       }
-#endif /* CONFIG_BLK_DEV_HD */
 
        if (register_blkdev(hwif->major, hwif->name))
                return 0;
@@ -1378,6 +1388,58 @@ static void ide_port_cable_detect(ide_hwif_t *hwif)
        }
 }
 
+static ssize_t store_delete_devices(struct device *portdev,
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t n)
+{
+       ide_hwif_t *hwif = dev_get_drvdata(portdev);
+
+       if (strncmp(buf, "1", n))
+               return -EINVAL;
+
+       ide_port_unregister_devices(hwif);
+
+       return n;
+};
+
+static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices);
+
+static ssize_t store_scan(struct device *portdev,
+                         struct device_attribute *attr,
+                         const char *buf, size_t n)
+{
+       ide_hwif_t *hwif = dev_get_drvdata(portdev);
+
+       if (strncmp(buf, "1", n))
+               return -EINVAL;
+
+       ide_port_unregister_devices(hwif);
+       ide_port_scan(hwif);
+
+       return n;
+};
+
+static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
+
+static struct device_attribute *ide_port_attrs[] = {
+       &dev_attr_delete_devices,
+       &dev_attr_scan,
+       NULL
+};
+
+static int ide_sysfs_register_port(ide_hwif_t *hwif)
+{
+       int i, rc;
+
+       for (i = 0; ide_port_attrs[i]; i++) {
+               rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
+               if (rc)
+                       break;
+       }
+
+       return rc;
+}
+
 int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
 {
        ide_hwif_t *hwif, *mate = NULL;
@@ -1460,8 +1522,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
                hwif = &ide_hwifs[idx[i]];
 
                if (hwif->present) {
-                       if (hwif->chipset == ide_unknown ||
-                           hwif->chipset == ide_forced)
+                       if (hwif->chipset == ide_unknown)
                                hwif->chipset = ide_generic;
                        hwif_register_devices(hwif);
                }
@@ -1474,6 +1535,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
                hwif = &ide_hwifs[idx[i]];
 
                if (hwif->present) {
+                       ide_sysfs_register_port(hwif);
                        ide_proc_register_port(hwif);
                        ide_proc_port_register_devices(hwif);
                }
This page took 0.040654 seconds and 5 git commands to generate.