Commit e277f91f authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: use ide_find_port() in legacy VLB host drivers (take 2)



* Add IDE_HFLAG_QD_2ND_PORT host flag to indicate the need of skipping
  first ide_hwifs[] slot for the second port of QD65xx controller.

* Handle this new host flag in ide_find_port_slot().

* Convert legacy VLB host drivers to use ide_find_port().

While at it:

* Fix couple of printk()-s in qd65xx host driver to not use hwif->name.

v2:
* Fix qd65xx.

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent fe80b937
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1468,7 +1468,9 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
	 * ports 0x1f0/0x170 (the ide0/ide1 defaults).
	 */
	if (bootable) {
		for (i = 0; i < MAX_HWIFS; i++) {
		i = (d && (d->host_flags & IDE_HFLAG_QD_2ND_PORT)) ? 1 : 0;

		for (; i < MAX_HWIFS; i++) {
			hwif = &ide_hwifs[i];
			if (hwif->chipset == ide_unknown)
				return hwif;
+14 −5
Original line number Diff line number Diff line
@@ -199,7 +199,8 @@ static const struct ide_port_info ali14xx_port_info = {

static int __init ali14xx_probe(void)
{
	static u8 idx[4] = { 0, 1, 0xff, 0xff };
	ide_hwif_t *hwif, *mate;
	static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
	hw_regs_t hw[2];

	printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
@@ -219,11 +220,19 @@ static int __init ali14xx_probe(void)
	ide_std_init_ports(&hw[1], 0x170, 0x376);
	hw[1].irq = 15;

	ide_init_port_hw(&ide_hwifs[0], &hw[0]);
	ide_init_port_hw(&ide_hwifs[1], &hw[1]);
	hwif = ide_find_port();
	if (hwif) {
		ide_init_port_hw(hwif, &hw[0]);
		hwif->set_pio_mode = &ali14xx_set_pio_mode;
		idx[0] = hwif->index;
	}

	ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode;
	ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode;
	mate = ide_find_port();
	if (mate) {
		ide_init_port_hw(mate, &hw[1]);
		mate->set_pio_mode = &ali14xx_set_pio_mode;
		idx[1] = mate->index;
	}

	ide_device_add(idx, &ali14xx_port_info);

+12 −10
Original line number Diff line number Diff line
@@ -102,15 +102,9 @@ static int __init dtc2278_probe(void)
{
	unsigned long flags;
	ide_hwif_t *hwif, *mate;
	static u8 idx[4] = { 0, 1, 0xff, 0xff };
	static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
	hw_regs_t hw[2];

	hwif = &ide_hwifs[0];
	mate = &ide_hwifs[1];

	if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown)
		return 1;

	local_irq_save(flags);
	/*
	 * This enables the second interface
@@ -137,10 +131,18 @@ static int __init dtc2278_probe(void)
	ide_std_init_ports(&hw[1], 0x170, 0x376);
	hw[1].irq = 15;

	hwif = ide_find_port();
	if (hwif) {
		ide_init_port_hw(hwif, &hw[0]);
	ide_init_port_hw(mate, &hw[1]);
		hwif->set_pio_mode = dtc2278_set_pio_mode;
		idx[0] = hwif->index;
	}

	hwif->set_pio_mode = &dtc2278_set_pio_mode;
	mate = ide_find_port();
	if (mate) {
		ide_init_port_hw(mate, &hw[1]);
		idx[1] = mate->index;
	}

	ide_device_add(idx, &dtc2278_port_info);

+17 −14
Original line number Diff line number Diff line
@@ -340,15 +340,12 @@ static const struct ide_port_info ht6560b_port_info __initdata = {
static int __init ht6560b_init(void)
{
	ide_hwif_t *hwif, *mate;
	static u8 idx[4] = { 0, 1, 0xff, 0xff };
	static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
	hw_regs_t hw[2];

	if (probe_ht6560b == 0)
		return -ENODEV;

	hwif = &ide_hwifs[0];
	mate = &ide_hwifs[1];

	if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) {
		printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
			__FUNCTION__);
@@ -368,17 +365,23 @@ static int __init ht6560b_init(void)
	ide_std_init_ports(&hw[1], 0x170, 0x376);
	hw[1].irq = 15;

	hwif = ide_find_port();
	if (hwif) {
		ide_init_port_hw(hwif, &hw[0]);
	ide_init_port_hw(mate, &hw[1]);

	hwif->selectproc = &ht6560b_selectproc;
	hwif->set_pio_mode = &ht6560b_set_pio_mode;

	mate->selectproc = &ht6560b_selectproc;
	mate->set_pio_mode = &ht6560b_set_pio_mode;

		hwif->selectproc     = ht6560b_selectproc;
		hwif->set_pio_mode   = ht6560b_set_pio_mode;
		hwif->port_init_devs = ht6560b_port_init_devs;
		idx[0] = hwif->index;
	}

	mate = ide_find_port();
	if (mate) {
		ide_init_port_hw(mate, &hw[1]);
		mate->selectproc     = ht6560b_selectproc;
		mate->set_pio_mode   = ht6560b_set_pio_mode;
		mate->port_init_devs = ht6560b_port_init_devs;
		idx[1] = mate->index;
	}

	ide_device_add(idx, &ht6560b_port_info);

+20 −14
Original line number Diff line number Diff line
@@ -12,31 +12,37 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
static int __init ide_4drives_init(void)
{
	ide_hwif_t *hwif, *mate;
	u8 idx[4] = { 0, 1, 0xff, 0xff };
	u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
	hw_regs_t hw;

	if (probe_4drives == 0)
		return -ENODEV;

	hwif = &ide_hwifs[0];
	mate = &ide_hwifs[1];

	memset(&hw, 0, sizeof(hw));

	ide_std_init_ports(&hw, 0x1f0, 0x3f6);
	hw.irq = 14;
	hw.chipset = ide_4drives;

	hwif = ide_find_port();
	if (hwif) {
		ide_init_port_hw(hwif, &hw);
	ide_init_port_hw(mate, &hw);
		idx[0] = hwif->index;
	}

	mate = ide_find_port();
	if (mate) {
		ide_init_port_hw(mate, &hw);
		mate->drives[0].select.all ^= 0x20;
		mate->drives[1].select.all ^= 0x20;
		idx[1] = mate->index;

		if (hwif) {
			hwif->mate = mate;
			mate->mate = hwif;

			hwif->serialized = mate->serialized = 1;
		}
	}

	ide_device_add(idx, NULL);

Loading