Blame view

drivers/ide/ide-legacy.c 1.25 KB
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
1
  #include <linux/kernel.h>
38789fda2   Paul Gortmaker   ide/ata: Add expo...
2
  #include <linux/export.h>
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
3
  #include <linux/ide.h>
9f36d3143   Bartlomiej Zolnierkiewicz   ide: remove hw_re...
4
  static void ide_legacy_init_one(struct ide_hw **hws, struct ide_hw *hw,
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  				u8 port_no, const struct ide_port_info *d,
  				unsigned long config)
  {
  	unsigned long base, ctl;
  	int irq;
  
  	if (port_no == 0) {
  		base = 0x1f0;
  		ctl  = 0x3f6;
  		irq  = 14;
  	} else {
  		base = 0x170;
  		ctl  = 0x376;
  		irq  = 15;
  	}
  
  	if (!request_region(base, 8, d->name)) {
  		printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.
  ",
  				d->name, base, base + 7);
  		return;
  	}
  
  	if (!request_region(ctl, 1, d->name)) {
  		printk(KERN_ERR "%s: I/O resource 0x%lX not free.
  ",
  				d->name, ctl);
  		release_region(base, 8);
  		return;
  	}
  
  	ide_std_init_ports(hw, base, ctl);
  	hw->irq = irq;
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
38
39
40
41
42
43
44
  	hw->config = config;
  
  	hws[port_no] = hw;
  }
  
  int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
  {
9f36d3143   Bartlomiej Zolnierkiewicz   ide: remove hw_re...
45
  	struct ide_hw hw[2], *hws[] = { NULL, NULL };
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
46
47
48
49
50
51
52
53
54
55
  
  	memset(&hw, 0, sizeof(hw));
  
  	if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
  		ide_legacy_init_one(hws, &hw[0], 0, d, config);
  	ide_legacy_init_one(hws, &hw[1], 1, d, config);
  
  	if (hws[0] == NULL && hws[1] == NULL &&
  	    (d->host_flags & IDE_HFLAG_SINGLE))
  		return -ENOENT;
dca398305   Bartlomiej Zolnierkiewicz   ide: pass number ...
56
  	return ide_host_add(d, hws, 2, NULL);
7f92b11c1   Bartlomiej Zolnierkiewicz   ide: move legacy ...
57
58
  }
  EXPORT_SYMBOL_GPL(ide_legacy_device_add);