diff options
author | Alan Cox <alan@redhat.com> | 2007-05-08 03:39:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:32 -0400 |
commit | d37363409bacd1142c6e49edfb3e1f8b153d47dc (patch) | |
tree | 2aa26a4e06020b714192f746a11c0be4c7b7c5fb /drivers/video | |
parent | dbe7e429fedb3fbc93b496cc1c3eb4fc28333ac0 (diff) |
nvidiafb/rivafb: switch to pci_get refcounting
Switch to pci_get refcounting APIs
[adaplas]
Fix a long-standing bug where the return value of
pci_find_slot()/pci_get_bus_and_slot() is ignored.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/nvidia/nv_hw.c | 15 | ||||
-rw-r--r-- | drivers/video/nvidia/nv_setup.c | 3 | ||||
-rw-r--r-- | drivers/video/riva/nv_driver.c | 6 | ||||
-rw-r--r-- | drivers/video/riva/riva_hw.c | 12 |
4 files changed, 23 insertions, 13 deletions
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c index ea426115c6f9..f297c7b14a41 100644 --- a/drivers/video/nvidia/nv_hw.c +++ b/drivers/video/nvidia/nv_hw.c | |||
@@ -686,7 +686,7 @@ static void nForceUpdateArbitrationSettings(unsigned VClk, | |||
686 | 686 | ||
687 | if ((par->Chipset & 0x0FF0) == 0x01A0) { | 687 | if ((par->Chipset & 0x0FF0) == 0x01A0) { |
688 | unsigned int uMClkPostDiv; | 688 | unsigned int uMClkPostDiv; |
689 | dev = pci_find_slot(0, 3); | 689 | dev = pci_get_bus_and_slot(0, 3); |
690 | pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); | 690 | pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); |
691 | uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; | 691 | uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; |
692 | 692 | ||
@@ -694,11 +694,11 @@ static void nForceUpdateArbitrationSettings(unsigned VClk, | |||
694 | uMClkPostDiv = 4; | 694 | uMClkPostDiv = 4; |
695 | MClk = 400000 / uMClkPostDiv; | 695 | MClk = 400000 / uMClkPostDiv; |
696 | } else { | 696 | } else { |
697 | dev = pci_find_slot(0, 5); | 697 | dev = pci_get_bus_and_slot(0, 5); |
698 | pci_read_config_dword(dev, 0x4c, &MClk); | 698 | pci_read_config_dword(dev, 0x4c, &MClk); |
699 | MClk /= 1000; | 699 | MClk /= 1000; |
700 | } | 700 | } |
701 | 701 | pci_dev_put(dev); | |
702 | pll = NV_RD32(par->PRAMDAC0, 0x0500); | 702 | pll = NV_RD32(par->PRAMDAC0, 0x0500); |
703 | M = (pll >> 0) & 0xFF; | 703 | M = (pll >> 0) & 0xFF; |
704 | N = (pll >> 8) & 0xFF; | 704 | N = (pll >> 8) & 0xFF; |
@@ -707,19 +707,21 @@ static void nForceUpdateArbitrationSettings(unsigned VClk, | |||
707 | sim_data.pix_bpp = (char)pixelDepth; | 707 | sim_data.pix_bpp = (char)pixelDepth; |
708 | sim_data.enable_video = 0; | 708 | sim_data.enable_video = 0; |
709 | sim_data.enable_mp = 0; | 709 | sim_data.enable_mp = 0; |
710 | pci_find_slot(0, 1); | 710 | dev = pci_get_bus_and_slot(0, 1); |
711 | pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); | 711 | pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); |
712 | pci_dev_put(dev); | ||
712 | sim_data.memory_type = (sim_data.memory_type >> 12) & 1; | 713 | sim_data.memory_type = (sim_data.memory_type >> 12) & 1; |
713 | sim_data.memory_width = 64; | 714 | sim_data.memory_width = 64; |
714 | 715 | ||
715 | dev = pci_find_slot(0, 3); | 716 | dev = pci_get_bus_and_slot(0, 3); |
716 | pci_read_config_dword(dev, 0, &memctrl); | 717 | pci_read_config_dword(dev, 0, &memctrl); |
718 | pci_dev_put(dev); | ||
717 | memctrl >>= 16; | 719 | memctrl >>= 16; |
718 | 720 | ||
719 | if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) { | 721 | if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) { |
720 | int dimm[3]; | 722 | int dimm[3]; |
721 | 723 | ||
722 | pci_find_slot(0, 2); | 724 | dev = pci_get_bus_and_slot(0, 2); |
723 | pci_read_config_dword(dev, 0x40, &dimm[0]); | 725 | pci_read_config_dword(dev, 0x40, &dimm[0]); |
724 | dimm[0] = (dimm[0] >> 8) & 0x4f; | 726 | dimm[0] = (dimm[0] >> 8) & 0x4f; |
725 | pci_read_config_dword(dev, 0x44, &dimm[1]); | 727 | pci_read_config_dword(dev, 0x44, &dimm[1]); |
@@ -731,6 +733,7 @@ static void nForceUpdateArbitrationSettings(unsigned VClk, | |||
731 | printk("nvidiafb: your nForce DIMMs are not arranged " | 733 | printk("nvidiafb: your nForce DIMMs are not arranged " |
732 | "in optimal banks!\n"); | 734 | "in optimal banks!\n"); |
733 | } | 735 | } |
736 | pci_dev_put(dev); | ||
734 | } | 737 | } |
735 | 738 | ||
736 | sim_data.mem_latency = 3; | 739 | sim_data.mem_latency = 3; |
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c index 336ddb0d10b8..707e2c8a13ed 100644 --- a/drivers/video/nvidia/nv_setup.c +++ b/drivers/video/nvidia/nv_setup.c | |||
@@ -261,7 +261,7 @@ static void nv10GetConfig(struct nvidia_par *par) | |||
261 | } | 261 | } |
262 | #endif | 262 | #endif |
263 | 263 | ||
264 | dev = pci_find_slot(0, 1); | 264 | dev = pci_get_bus_and_slot(0, 1); |
265 | if ((par->Chipset & 0xffff) == 0x01a0) { | 265 | if ((par->Chipset & 0xffff) == 0x01a0) { |
266 | int amt = 0; | 266 | int amt = 0; |
267 | 267 | ||
@@ -276,6 +276,7 @@ static void nv10GetConfig(struct nvidia_par *par) | |||
276 | par->RamAmountKBytes = | 276 | par->RamAmountKBytes = |
277 | (NV_RD32(par->PFB, 0x020C) & 0xFFF00000) >> 10; | 277 | (NV_RD32(par->PFB, 0x020C) & 0xFFF00000) >> 10; |
278 | } | 278 | } |
279 | pci_dev_put(dev); | ||
279 | 280 | ||
280 | par->CrystalFreqKHz = (NV_RD32(par->PEXTDEV, 0x0000) & (1 << 6)) ? | 281 | par->CrystalFreqKHz = (NV_RD32(par->PEXTDEV, 0x0000) & (1 << 6)) ? |
281 | 14318 : 13500; | 282 | 14318 : 13500; |
diff --git a/drivers/video/riva/nv_driver.c b/drivers/video/riva/nv_driver.c index be630a0ccfd4..a11026812d1b 100644 --- a/drivers/video/riva/nv_driver.c +++ b/drivers/video/riva/nv_driver.c | |||
@@ -231,12 +231,14 @@ unsigned long riva_get_memlen(struct riva_par *par) | |||
231 | case NV_ARCH_30: | 231 | case NV_ARCH_30: |
232 | if(chipset == NV_CHIP_IGEFORCE2) { | 232 | if(chipset == NV_CHIP_IGEFORCE2) { |
233 | 233 | ||
234 | dev = pci_find_slot(0, 1); | 234 | dev = pci_get_bus_and_slot(0, 1); |
235 | pci_read_config_dword(dev, 0x7C, &amt); | 235 | pci_read_config_dword(dev, 0x7C, &amt); |
236 | pci_dev_put(dev); | ||
236 | memlen = (((amt >> 6) & 31) + 1) * 1024; | 237 | memlen = (((amt >> 6) & 31) + 1) * 1024; |
237 | } else if (chipset == NV_CHIP_0x01F0) { | 238 | } else if (chipset == NV_CHIP_0x01F0) { |
238 | dev = pci_find_slot(0, 1); | 239 | dev = pci_get_bus_and_slot(0, 1); |
239 | pci_read_config_dword(dev, 0x84, &amt); | 240 | pci_read_config_dword(dev, 0x84, &amt); |
241 | pci_dev_put(dev); | ||
240 | memlen = (((amt >> 4) & 127) + 1) * 1024; | 242 | memlen = (((amt >> 4) & 127) + 1) * 1024; |
241 | } else { | 243 | } else { |
242 | switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) & | 244 | switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) & |
diff --git a/drivers/video/riva/riva_hw.c b/drivers/video/riva/riva_hw.c index e0b8c521cc9c..70bfd78eca81 100644 --- a/drivers/video/riva/riva_hw.c +++ b/drivers/video/riva/riva_hw.c | |||
@@ -1118,8 +1118,9 @@ static void nForceUpdateArbitrationSettings | |||
1118 | unsigned int uMClkPostDiv; | 1118 | unsigned int uMClkPostDiv; |
1119 | struct pci_dev *dev; | 1119 | struct pci_dev *dev; |
1120 | 1120 | ||
1121 | dev = pci_find_slot(0, 3); | 1121 | dev = pci_get_bus_and_slot(0, 3); |
1122 | pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); | 1122 | pci_read_config_dword(dev, 0x6C, &uMClkPostDiv); |
1123 | pci_dev_put(dev); | ||
1123 | uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; | 1124 | uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf; |
1124 | 1125 | ||
1125 | if(!uMClkPostDiv) uMClkPostDiv = 4; | 1126 | if(!uMClkPostDiv) uMClkPostDiv = 4; |
@@ -1132,8 +1133,9 @@ static void nForceUpdateArbitrationSettings | |||
1132 | sim_data.enable_video = 0; | 1133 | sim_data.enable_video = 0; |
1133 | sim_data.enable_mp = 0; | 1134 | sim_data.enable_mp = 0; |
1134 | 1135 | ||
1135 | dev = pci_find_slot(0, 1); | 1136 | dev = pci_get_bus_and_slot(0, 1); |
1136 | pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); | 1137 | pci_read_config_dword(dev, 0x7C, &sim_data.memory_type); |
1138 | pci_dev_put(dev); | ||
1137 | sim_data.memory_type = (sim_data.memory_type >> 12) & 1; | 1139 | sim_data.memory_type = (sim_data.memory_type >> 12) & 1; |
1138 | 1140 | ||
1139 | sim_data.memory_width = 64; | 1141 | sim_data.memory_width = 64; |
@@ -2112,12 +2114,14 @@ static void nv10GetConfig | |||
2112 | * Fill in chip configuration. | 2114 | * Fill in chip configuration. |
2113 | */ | 2115 | */ |
2114 | if(chipset == NV_CHIP_IGEFORCE2) { | 2116 | if(chipset == NV_CHIP_IGEFORCE2) { |
2115 | dev = pci_find_slot(0, 1); | 2117 | dev = pci_get_bus_and_slot(0, 1); |
2116 | pci_read_config_dword(dev, 0x7C, &amt); | 2118 | pci_read_config_dword(dev, 0x7C, &amt); |
2119 | pci_dev_put(dev); | ||
2117 | chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024; | 2120 | chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024; |
2118 | } else if(chipset == NV_CHIP_0x01F0) { | 2121 | } else if(chipset == NV_CHIP_0x01F0) { |
2119 | dev = pci_find_slot(0, 1); | 2122 | dev = pci_get_bus_and_slot(0, 1); |
2120 | pci_read_config_dword(dev, 0x84, &amt); | 2123 | pci_read_config_dword(dev, 0x84, &amt); |
2124 | pci_dev_put(dev); | ||
2121 | chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024; | 2125 | chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024; |
2122 | } else { | 2126 | } else { |
2123 | switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) & 0x000000FF) | 2127 | switch ((NV_RD32(chip->PFB, 0x0000020C) >> 20) & 0x000000FF) |