diff options
author | Zachary Amsden <zach@vmware.com> | 2007-04-10 09:53:08 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-04-17 18:04:20 -0400 |
commit | 1079a2d251f24a7d9e7576217f5f738bc4218337 (patch) | |
tree | 657af3b24dd40d413c659c7aac212907a6127c80 /drivers/scsi | |
parent | ad1331a792f9f253bef362de9b6872c6b8f88c0c (diff) |
[SCSI] BusLogic: stop using check_region
I got so sick of seing the check_region warnings from BusLogic.c I actually
fixed it properly. Never use check region, reserve it before the probe
with request region instead and check the error result; free region if
setup fails. Should be functionally identical to the original except for
fixing the potential race.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/BusLogic.c | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index e874b8944875..96f4cab07614 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c | |||
@@ -579,17 +579,17 @@ static void __init BusLogic_InitializeProbeInfoListISA(struct BusLogic_HostAdapt | |||
579 | /* | 579 | /* |
580 | Append the list of standard BusLogic MultiMaster ISA I/O Addresses. | 580 | Append the list of standard BusLogic MultiMaster ISA I/O Addresses. |
581 | */ | 581 | */ |
582 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0) | 582 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe330) |
583 | BusLogic_AppendProbeAddressISA(0x330); | 583 | BusLogic_AppendProbeAddressISA(0x330); |
584 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0) | 584 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe334) |
585 | BusLogic_AppendProbeAddressISA(0x334); | 585 | BusLogic_AppendProbeAddressISA(0x334); |
586 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0) | 586 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe230) |
587 | BusLogic_AppendProbeAddressISA(0x230); | 587 | BusLogic_AppendProbeAddressISA(0x230); |
588 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0) | 588 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe234) |
589 | BusLogic_AppendProbeAddressISA(0x234); | 589 | BusLogic_AppendProbeAddressISA(0x234); |
590 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0) | 590 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe130) |
591 | BusLogic_AppendProbeAddressISA(0x130); | 591 | BusLogic_AppendProbeAddressISA(0x130); |
592 | if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0) | 592 | if (!BusLogic_ProbeOptions.LimitedProbeISA || BusLogic_ProbeOptions.Probe134) |
593 | BusLogic_AppendProbeAddressISA(0x134); | 593 | BusLogic_AppendProbeAddressISA(0x134); |
594 | } | 594 | } |
595 | 595 | ||
@@ -795,7 +795,9 @@ static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAd | |||
795 | host adapters are probed. | 795 | host adapters are probed. |
796 | */ | 796 | */ |
797 | if (!BusLogic_ProbeOptions.NoProbeISA) | 797 | if (!BusLogic_ProbeOptions.NoProbeISA) |
798 | if (PrimaryProbeInfo->IO_Address == 0 && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)) { | 798 | if (PrimaryProbeInfo->IO_Address == 0 && |
799 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
800 | BusLogic_ProbeOptions.Probe330)) { | ||
799 | PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster; | 801 | PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster; |
800 | PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus; | 802 | PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus; |
801 | PrimaryProbeInfo->IO_Address = 0x330; | 803 | PrimaryProbeInfo->IO_Address = 0x330; |
@@ -805,15 +807,25 @@ static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAd | |||
805 | omitting the Primary I/O Address which has already been handled. | 807 | omitting the Primary I/O Address which has already been handled. |
806 | */ | 808 | */ |
807 | if (!BusLogic_ProbeOptions.NoProbeISA) { | 809 | if (!BusLogic_ProbeOptions.NoProbeISA) { |
808 | if (!StandardAddressSeen[1] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0)) | 810 | if (!StandardAddressSeen[1] && |
811 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
812 | BusLogic_ProbeOptions.Probe334)) | ||
809 | BusLogic_AppendProbeAddressISA(0x334); | 813 | BusLogic_AppendProbeAddressISA(0x334); |
810 | if (!StandardAddressSeen[2] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0)) | 814 | if (!StandardAddressSeen[2] && |
815 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
816 | BusLogic_ProbeOptions.Probe230)) | ||
811 | BusLogic_AppendProbeAddressISA(0x230); | 817 | BusLogic_AppendProbeAddressISA(0x230); |
812 | if (!StandardAddressSeen[3] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0)) | 818 | if (!StandardAddressSeen[3] && |
819 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
820 | BusLogic_ProbeOptions.Probe234)) | ||
813 | BusLogic_AppendProbeAddressISA(0x234); | 821 | BusLogic_AppendProbeAddressISA(0x234); |
814 | if (!StandardAddressSeen[4] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0)) | 822 | if (!StandardAddressSeen[4] && |
823 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
824 | BusLogic_ProbeOptions.Probe130)) | ||
815 | BusLogic_AppendProbeAddressISA(0x130); | 825 | BusLogic_AppendProbeAddressISA(0x130); |
816 | if (!StandardAddressSeen[5] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0)) | 826 | if (!StandardAddressSeen[5] && |
827 | (!BusLogic_ProbeOptions.LimitedProbeISA || | ||
828 | BusLogic_ProbeOptions.Probe134)) | ||
817 | BusLogic_AppendProbeAddressISA(0x134); | 829 | BusLogic_AppendProbeAddressISA(0x134); |
818 | } | 830 | } |
819 | /* | 831 | /* |
@@ -2220,22 +2232,35 @@ static int __init BusLogic_init(void) | |||
2220 | HostAdapter->PCI_Device = ProbeInfo->PCI_Device; | 2232 | HostAdapter->PCI_Device = ProbeInfo->PCI_Device; |
2221 | HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel; | 2233 | HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel; |
2222 | HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType]; | 2234 | HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType]; |
2235 | |||
2236 | /* | ||
2237 | Make sure region is free prior to probing. | ||
2238 | */ | ||
2239 | if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, | ||
2240 | "BusLogic")) | ||
2241 | continue; | ||
2223 | /* | 2242 | /* |
2224 | Probe the Host Adapter. If unsuccessful, abort further initialization. | 2243 | Probe the Host Adapter. If unsuccessful, abort further initialization. |
2225 | */ | 2244 | */ |
2226 | if (!BusLogic_ProbeHostAdapter(HostAdapter)) | 2245 | if (!BusLogic_ProbeHostAdapter(HostAdapter)) { |
2246 | release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); | ||
2227 | continue; | 2247 | continue; |
2248 | } | ||
2228 | /* | 2249 | /* |
2229 | Hard Reset the Host Adapter. If unsuccessful, abort further | 2250 | Hard Reset the Host Adapter. If unsuccessful, abort further |
2230 | initialization. | 2251 | initialization. |
2231 | */ | 2252 | */ |
2232 | if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) | 2253 | if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true)) { |
2254 | release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); | ||
2233 | continue; | 2255 | continue; |
2256 | } | ||
2234 | /* | 2257 | /* |
2235 | Check the Host Adapter. If unsuccessful, abort further initialization. | 2258 | Check the Host Adapter. If unsuccessful, abort further initialization. |
2236 | */ | 2259 | */ |
2237 | if (!BusLogic_CheckHostAdapter(HostAdapter)) | 2260 | if (!BusLogic_CheckHostAdapter(HostAdapter)) { |
2261 | release_region(HostAdapter->IO_Address, HostAdapter->AddressCount); | ||
2238 | continue; | 2262 | continue; |
2263 | } | ||
2239 | /* | 2264 | /* |
2240 | Initialize the Driver Options field if provided. | 2265 | Initialize the Driver Options field if provided. |
2241 | */ | 2266 | */ |
@@ -2247,16 +2272,6 @@ static int __init BusLogic_init(void) | |||
2247 | */ | 2272 | */ |
2248 | BusLogic_AnnounceDriver(HostAdapter); | 2273 | BusLogic_AnnounceDriver(HostAdapter); |
2249 | /* | 2274 | /* |
2250 | Register usage of the I/O Address range. From this point onward, any | ||
2251 | failure will be assumed to be due to a problem with the Host Adapter, | ||
2252 | rather than due to having mistakenly identified this port as belonging | ||
2253 | to a BusLogic Host Adapter. The I/O Address range will not be | ||
2254 | released, thereby preventing it from being incorrectly identified as | ||
2255 | any other type of Host Adapter. | ||
2256 | */ | ||
2257 | if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, "BusLogic")) | ||
2258 | continue; | ||
2259 | /* | ||
2260 | Register the SCSI Host structure. | 2275 | Register the SCSI Host structure. |
2261 | */ | 2276 | */ |
2262 | 2277 | ||
@@ -2280,6 +2295,12 @@ static int __init BusLogic_init(void) | |||
2280 | Acquire the System Resources necessary to use the Host Adapter, then | 2295 | Acquire the System Resources necessary to use the Host Adapter, then |
2281 | Create the Initial CCBs, Initialize the Host Adapter, and finally | 2296 | Create the Initial CCBs, Initialize the Host Adapter, and finally |
2282 | perform Target Device Inquiry. | 2297 | perform Target Device Inquiry. |
2298 | |||
2299 | From this point onward, any failure will be assumed to be due to a | ||
2300 | problem with the Host Adapter, rather than due to having mistakenly | ||
2301 | identified this port as belonging to a BusLogic Host Adapter. The | ||
2302 | I/O Address range will not be released, thereby preventing it from | ||
2303 | being incorrectly identified as any other type of Host Adapter. | ||
2283 | */ | 2304 | */ |
2284 | if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && | 2305 | if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && |
2285 | BusLogic_ReportHostAdapterConfiguration(HostAdapter) && | 2306 | BusLogic_ReportHostAdapterConfiguration(HostAdapter) && |
@@ -3598,6 +3619,7 @@ static void __exit BusLogic_exit(void) | |||
3598 | 3619 | ||
3599 | __setup("BusLogic=", BusLogic_Setup); | 3620 | __setup("BusLogic=", BusLogic_Setup); |
3600 | 3621 | ||
3622 | #ifdef MODULE | ||
3601 | static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = { | 3623 | static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = { |
3602 | { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, | 3624 | { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, |
3603 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 3625 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
@@ -3607,6 +3629,7 @@ static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = { | |||
3607 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 3629 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
3608 | { } | 3630 | { } |
3609 | }; | 3631 | }; |
3632 | #endif | ||
3610 | MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl); | 3633 | MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl); |
3611 | 3634 | ||
3612 | module_init(BusLogic_init); | 3635 | module_init(BusLogic_init); |