diff options
author | Andreas Noever <andreas.noever@gmail.com> | 2014-06-03 16:04:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-06-19 17:07:07 -0400 |
commit | d6cc51cd1a4aed1d9e2dd66d643d729acb4be560 (patch) | |
tree | a193e0c2807cf18e11c770392c71e51bafbe378a /drivers/thunderbolt/nhi.c | |
parent | f25bf6fcb1a83a149bc8b5285d33b48cbd47c7d7 (diff) |
thunderbolt: Setup control channel
Add struct tb which will contain our view of the thunderbolt bus. For
now it just contains a pointer to the control channel and a workqueue
for hotplug events.
Add thunderbolt_alloc_and_start() and thunderbolt_shutdown_and_free()
which are responsible for setup and teardown of struct tb.
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt/nhi.c')
-rw-r--r-- | drivers/thunderbolt/nhi.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 11070ff2cec7..d2b9ce857818 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include "nhi.h" | 17 | #include "nhi.h" |
18 | #include "nhi_regs.h" | 18 | #include "nhi_regs.h" |
19 | #include "tb.h" | ||
19 | 20 | ||
20 | #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring") | 21 | #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring") |
21 | 22 | ||
@@ -517,6 +518,7 @@ static void nhi_shutdown(struct tb_nhi *nhi) | |||
517 | static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 518 | static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
518 | { | 519 | { |
519 | struct tb_nhi *nhi; | 520 | struct tb_nhi *nhi; |
521 | struct tb *tb; | ||
520 | int res; | 522 | int res; |
521 | 523 | ||
522 | res = pcim_enable_device(pdev); | 524 | res = pcim_enable_device(pdev); |
@@ -575,14 +577,26 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
575 | /* magic value - clock related? */ | 577 | /* magic value - clock related? */ |
576 | iowrite32(3906250 / 10000, nhi->iobase + 0x38c00); | 578 | iowrite32(3906250 / 10000, nhi->iobase + 0x38c00); |
577 | 579 | ||
578 | pci_set_drvdata(pdev, nhi); | 580 | dev_info(&nhi->pdev->dev, "NHI initialized, starting thunderbolt\n"); |
581 | tb = thunderbolt_alloc_and_start(nhi); | ||
582 | if (!tb) { | ||
583 | /* | ||
584 | * At this point the RX/TX rings might already have been | ||
585 | * activated. Do a proper shutdown. | ||
586 | */ | ||
587 | nhi_shutdown(nhi); | ||
588 | return -EIO; | ||
589 | } | ||
590 | pci_set_drvdata(pdev, tb); | ||
579 | 591 | ||
580 | return 0; | 592 | return 0; |
581 | } | 593 | } |
582 | 594 | ||
583 | static void nhi_remove(struct pci_dev *pdev) | 595 | static void nhi_remove(struct pci_dev *pdev) |
584 | { | 596 | { |
585 | struct tb_nhi *nhi = pci_get_drvdata(pdev); | 597 | struct tb *tb = pci_get_drvdata(pdev); |
598 | struct tb_nhi *nhi = tb->nhi; | ||
599 | thunderbolt_shutdown_and_free(tb); | ||
586 | nhi_shutdown(nhi); | 600 | nhi_shutdown(nhi); |
587 | } | 601 | } |
588 | 602 | ||