Commit 6cdf6eb357c2681596b7b1672b92396ba82333d4
1 parent
8c2eece50a
Exists in
master
and in
4 other branches
ide: add ->dev and ->host_priv fields to struct ide_host
* Add 'struct device *dev[2]' and 'void *host_priv' fields to struct ide_host. * Set ->dev[] in ide_host_alloc_all()/ide_setup_pci_device[s](). * Pass 'void *priv' argument to ide_setup_pci_device[s]() and use it to set ->host_priv. * Set PCI dev's ->driver_data to point to the struct ide_host instance if PCI host driver wants to use ->host_priv. * Rename ide_setup_pci_device[s]() to ide_pci_init_{one,two}(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Showing 33 changed files with 85 additions and 41 deletions Side-by-side Diff
- drivers/ide/ide-probe.c
- drivers/ide/pci/aec62xx.c
- drivers/ide/pci/alim15x3.c
- drivers/ide/pci/amd74xx.c
- drivers/ide/pci/atiixp.c
- drivers/ide/pci/cmd64x.c
- drivers/ide/pci/cs5530.c
- drivers/ide/pci/cs5535.c
- drivers/ide/pci/cy82c693.c
- drivers/ide/pci/generic.c
- drivers/ide/pci/hpt34x.c
- drivers/ide/pci/hpt366.c
- drivers/ide/pci/it8213.c
- drivers/ide/pci/it821x.c
- drivers/ide/pci/jmicron.c
- drivers/ide/pci/ns87415.c
- drivers/ide/pci/opti621.c
- drivers/ide/pci/pdc202xx_new.c
- drivers/ide/pci/pdc202xx_old.c
- drivers/ide/pci/piix.c
- drivers/ide/pci/rz1000.c
- drivers/ide/pci/sc1200.c
- drivers/ide/pci/serverworks.c
- drivers/ide/pci/siimage.c
- drivers/ide/pci/sis5513.c
- drivers/ide/pci/sl82c105.c
- drivers/ide/pci/slc90e66.c
- drivers/ide/pci/tc86c001.c
- drivers/ide/pci/triflex.c
- drivers/ide/pci/trm290.c
- drivers/ide/pci/via82cxxx.c
- drivers/ide/setup-pci.c
- include/linux/ide.h
drivers/ide/ide-probe.c
drivers/ide/pci/aec62xx.c
drivers/ide/pci/alim15x3.c
drivers/ide/pci/amd74xx.c
drivers/ide/pci/atiixp.c
... | ... | @@ -167,7 +167,7 @@ |
167 | 167 | |
168 | 168 | static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
169 | 169 | { |
170 | - return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]); | |
170 | + return ide_pci_init_one(dev, &atiixp_pci_info[id->driver_data], NULL); | |
171 | 171 | } |
172 | 172 | |
173 | 173 | static const struct pci_device_id atiixp_pci_tbl[] = { |
drivers/ide/pci/cmd64x.c
drivers/ide/pci/cs5530.c
... | ... | @@ -256,7 +256,7 @@ |
256 | 256 | |
257 | 257 | static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
258 | 258 | { |
259 | - return ide_setup_pci_device(dev, &cs5530_chipset); | |
259 | + return ide_pci_init_one(dev, &cs5530_chipset, NULL); | |
260 | 260 | } |
261 | 261 | |
262 | 262 | static const struct pci_device_id cs5530_pci_tbl[] = { |
drivers/ide/pci/cs5535.c
... | ... | @@ -180,7 +180,7 @@ |
180 | 180 | static int __devinit cs5535_init_one(struct pci_dev *dev, |
181 | 181 | const struct pci_device_id *id) |
182 | 182 | { |
183 | - return ide_setup_pci_device(dev, &cs5535_chipset); | |
183 | + return ide_pci_init_one(dev, &cs5535_chipset, NULL); | |
184 | 184 | } |
185 | 185 | |
186 | 186 | static const struct pci_device_id cs5535_pci_tbl[] = { |
drivers/ide/pci/cy82c693.c
... | ... | @@ -419,7 +419,7 @@ |
419 | 419 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
420 | 420 | PCI_FUNC(dev->devfn) == 1) { |
421 | 421 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
422 | - ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset); | |
422 | + ret = ide_pci_init_two(dev, dev2, &cy82c693_chipset, NULL); | |
423 | 423 | /* We leak pci refs here but thats ok - we can't be unloaded */ |
424 | 424 | } |
425 | 425 | return ret; |
drivers/ide/pci/generic.c
drivers/ide/pci/hpt34x.c
drivers/ide/pci/hpt366.c
... | ... | @@ -1608,13 +1608,13 @@ |
1608 | 1608 | d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE; |
1609 | 1609 | } |
1610 | 1610 | |
1611 | - ret = ide_setup_pci_devices(dev, dev2, &d); | |
1611 | + ret = ide_pci_init_two(dev, dev2, &d, NULL); | |
1612 | 1612 | if (ret < 0) |
1613 | 1613 | pci_dev_put(dev2); |
1614 | 1614 | return ret; |
1615 | 1615 | } |
1616 | 1616 | |
1617 | - return ide_setup_pci_device(dev, &d); | |
1617 | + return ide_pci_init_one(dev, &d, NULL); | |
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = { |
drivers/ide/pci/it8213.c
... | ... | @@ -184,7 +184,7 @@ |
184 | 184 | |
185 | 185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
186 | 186 | { |
187 | - return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); | |
187 | + return ide_pci_init_one(dev, &it8213_chipsets[id->driver_data], NULL); | |
188 | 188 | } |
189 | 189 | |
190 | 190 | static const struct pci_device_id it8213_pci_tbl[] = { |
drivers/ide/pci/it821x.c
... | ... | @@ -664,7 +664,7 @@ |
664 | 664 | |
665 | 665 | pci_set_drvdata(dev, itdevs); |
666 | 666 | |
667 | - return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); | |
667 | + return ide_pci_init_one(dev, &it821x_chipsets[id->driver_data], NULL); | |
668 | 668 | } |
669 | 669 | |
670 | 670 | static const struct pci_device_id it821x_pci_tbl[] = { |
drivers/ide/pci/jmicron.c
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | |
122 | 122 | static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
123 | 123 | { |
124 | - return ide_setup_pci_device(dev, &jmicron_chipset); | |
124 | + return ide_pci_init_one(dev, &jmicron_chipset, NULL); | |
125 | 125 | } |
126 | 126 | |
127 | 127 | /* All JMB PATA controllers have and will continue to have the same |
drivers/ide/pci/ns87415.c
drivers/ide/pci/opti621.c
... | ... | @@ -209,7 +209,7 @@ |
209 | 209 | |
210 | 210 | static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
211 | 211 | { |
212 | - return ide_setup_pci_device(dev, &opti621_chipset); | |
212 | + return ide_pci_init_one(dev, &opti621_chipset, NULL); | |
213 | 213 | } |
214 | 214 | |
215 | 215 | static const struct pci_device_id opti621_pci_tbl[] = { |
drivers/ide/pci/pdc202xx_new.c
... | ... | @@ -524,7 +524,7 @@ |
524 | 524 | dev2 = pdc20270_get_dev2(dev); |
525 | 525 | |
526 | 526 | if (dev2) { |
527 | - int ret = ide_setup_pci_devices(dev, dev2, d); | |
527 | + int ret = ide_pci_init_two(dev, dev2, d, NULL); | |
528 | 528 | if (ret < 0) |
529 | 529 | pci_dev_put(dev2); |
530 | 530 | return ret; |
... | ... | @@ -540,7 +540,7 @@ |
540 | 540 | return -ENODEV; |
541 | 541 | } |
542 | 542 | |
543 | - return ide_setup_pci_device(dev, d); | |
543 | + return ide_pci_init_one(dev, d, NULL); | |
544 | 544 | } |
545 | 545 | |
546 | 546 | static const struct pci_device_id pdc202new_pci_tbl[] = { |
drivers/ide/pci/pdc202xx_old.c
drivers/ide/pci/piix.c
... | ... | @@ -394,7 +394,7 @@ |
394 | 394 | |
395 | 395 | static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
396 | 396 | { |
397 | - return ide_setup_pci_device(dev, &piix_pci_info[id->driver_data]); | |
397 | + return ide_pci_init_one(dev, &piix_pci_info[id->driver_data], NULL); | |
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
drivers/ide/pci/rz1000.c
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | |
49 | 49 | static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
50 | 50 | { |
51 | - return ide_setup_pci_device(dev, &rz1000_chipset); | |
51 | + return ide_pci_init_one(dev, &rz1000_chipset, NULL); | |
52 | 52 | } |
53 | 53 | |
54 | 54 | static const struct pci_device_id rz1000_pci_tbl[] = { |
drivers/ide/pci/sc1200.c
... | ... | @@ -317,7 +317,7 @@ |
317 | 317 | |
318 | 318 | static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
319 | 319 | { |
320 | - return ide_setup_pci_device(dev, &sc1200_chipset); | |
320 | + return ide_pci_init_one(dev, &sc1200_chipset, NULL); | |
321 | 321 | } |
322 | 322 | |
323 | 323 | static const struct pci_device_id sc1200_pci_tbl[] = { |
drivers/ide/pci/serverworks.c
drivers/ide/pci/siimage.c
drivers/ide/pci/sis5513.c
drivers/ide/pci/sl82c105.c
drivers/ide/pci/slc90e66.c
... | ... | @@ -144,7 +144,7 @@ |
144 | 144 | |
145 | 145 | static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
146 | 146 | { |
147 | - return ide_setup_pci_device(dev, &slc90e66_chipset); | |
147 | + return ide_pci_init_one(dev, &slc90e66_chipset, NULL); | |
148 | 148 | } |
149 | 149 | |
150 | 150 | static const struct pci_device_id slc90e66_pci_tbl[] = { |
drivers/ide/pci/tc86c001.c
... | ... | @@ -215,7 +215,7 @@ |
215 | 215 | static int __devinit tc86c001_init_one(struct pci_dev *dev, |
216 | 216 | const struct pci_device_id *id) |
217 | 217 | { |
218 | - return ide_setup_pci_device(dev, &tc86c001_chipset); | |
218 | + return ide_pci_init_one(dev, &tc86c001_chipset, NULL); | |
219 | 219 | } |
220 | 220 | |
221 | 221 | static const struct pci_device_id tc86c001_pci_tbl[] = { |
drivers/ide/pci/triflex.c
... | ... | @@ -104,7 +104,7 @@ |
104 | 104 | static int __devinit triflex_init_one(struct pci_dev *dev, |
105 | 105 | const struct pci_device_id *id) |
106 | 106 | { |
107 | - return ide_setup_pci_device(dev, &triflex_device); | |
107 | + return ide_pci_init_one(dev, &triflex_device, NULL); | |
108 | 108 | } |
109 | 109 | |
110 | 110 | static const struct pci_device_id triflex_pci_tbl[] = { |
drivers/ide/pci/trm290.c
... | ... | @@ -340,7 +340,7 @@ |
340 | 340 | |
341 | 341 | static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
342 | 342 | { |
343 | - return ide_setup_pci_device(dev, &trm290_chipset); | |
343 | + return ide_pci_init_one(dev, &trm290_chipset, NULL); | |
344 | 344 | } |
345 | 345 | |
346 | 346 | static const struct pci_device_id trm290_pci_tbl[] = { |
drivers/ide/pci/via82cxxx.c
drivers/ide/setup-pci.c
... | ... | @@ -525,8 +525,10 @@ |
525 | 525 | return ret; |
526 | 526 | } |
527 | 527 | |
528 | -int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | |
528 | +int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, | |
529 | + void *priv) | |
529 | 530 | { |
531 | + struct ide_host *host; | |
530 | 532 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
531 | 533 | int ret; |
532 | 534 | |
... | ... | @@ -536,6 +538,19 @@ |
536 | 538 | |
537 | 539 | ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]); |
538 | 540 | |
541 | + host = ide_host_alloc(d, hws); | |
542 | + if (host == NULL) { | |
543 | + ret = -ENOMEM; | |
544 | + goto out; | |
545 | + } | |
546 | + | |
547 | + host->dev[0] = &dev->dev; | |
548 | + | |
549 | + host->host_priv = priv; | |
550 | + | |
551 | + if (priv) | |
552 | + pci_set_drvdata(dev, host); | |
553 | + | |
539 | 554 | ret = do_ide_setup_pci_device(dev, d, 1); |
540 | 555 | if (ret < 0) |
541 | 556 | goto out; |
542 | 557 | |
543 | 558 | |
544 | 559 | |
... | ... | @@ -543,16 +558,19 @@ |
543 | 558 | /* fixup IRQ */ |
544 | 559 | hw[1].irq = hw[0].irq = ret; |
545 | 560 | |
546 | - ret = ide_host_add(d, hws, NULL); | |
561 | + ret = ide_host_register(host, d, hws); | |
562 | + if (ret) | |
563 | + ide_host_free(host); | |
547 | 564 | out: |
548 | 565 | return ret; |
549 | 566 | } |
550 | -EXPORT_SYMBOL_GPL(ide_setup_pci_device); | |
567 | +EXPORT_SYMBOL_GPL(ide_pci_init_one); | |
551 | 568 | |
552 | -int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |
553 | - const struct ide_port_info *d) | |
569 | +int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, | |
570 | + const struct ide_port_info *d, void *priv) | |
554 | 571 | { |
555 | 572 | struct pci_dev *pdev[] = { dev1, dev2 }; |
573 | + struct ide_host *host; | |
556 | 574 | int ret, i; |
557 | 575 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
558 | 576 | |
559 | 577 | |
... | ... | @@ -562,7 +580,25 @@ |
562 | 580 | goto out; |
563 | 581 | |
564 | 582 | ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]); |
583 | + } | |
565 | 584 | |
585 | + host = ide_host_alloc(d, hws); | |
586 | + if (host == NULL) { | |
587 | + ret = -ENOMEM; | |
588 | + goto out; | |
589 | + } | |
590 | + | |
591 | + host->dev[0] = &dev1->dev; | |
592 | + host->dev[1] = &dev2->dev; | |
593 | + | |
594 | + host->host_priv = priv; | |
595 | + | |
596 | + if (priv) { | |
597 | + pci_set_drvdata(pdev[0], host); | |
598 | + pci_set_drvdata(pdev[1], host); | |
599 | + } | |
600 | + | |
601 | + for (i = 0; i < 2; i++) { | |
566 | 602 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
567 | 603 | |
568 | 604 | /* |
569 | 605 | |
... | ... | @@ -576,9 +612,11 @@ |
576 | 612 | hw[i*2 + 1].irq = hw[i*2].irq = ret; |
577 | 613 | } |
578 | 614 | |
579 | - ret = ide_host_add(d, hws, NULL); | |
615 | + ret = ide_host_register(host, d, hws); | |
616 | + if (ret) | |
617 | + ide_host_free(host); | |
580 | 618 | out: |
581 | 619 | return ret; |
582 | 620 | } |
583 | -EXPORT_SYMBOL_GPL(ide_setup_pci_devices); | |
621 | +EXPORT_SYMBOL_GPL(ide_pci_init_two); |
include/linux/ide.h
... | ... | @@ -626,6 +626,8 @@ |
626 | 626 | struct ide_host { |
627 | 627 | ide_hwif_t *ports[MAX_HWIFS]; |
628 | 628 | unsigned int n_ports; |
629 | + struct device *dev[2]; | |
630 | + void *host_priv; | |
629 | 631 | }; |
630 | 632 | |
631 | 633 | /* |
... | ... | @@ -1201,8 +1203,9 @@ |
1201 | 1203 | u8 udma_mask; |
1202 | 1204 | }; |
1203 | 1205 | |
1204 | -int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *); | |
1205 | -int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *); | |
1206 | +int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *); | |
1207 | +int ide_pci_init_two(struct pci_dev *, struct pci_dev *, | |
1208 | + const struct ide_port_info *, void *); | |
1206 | 1209 | |
1207 | 1210 | void ide_map_sg(ide_drive_t *, struct request *); |
1208 | 1211 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |