diff options
author | Pavel Machek <pavel@ucw.cz> | 2008-05-20 10:27:17 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-22 05:35:14 -0400 |
commit | 0abbc78a0137fee60ef092f0b20a3d3d7e7e0cc2 (patch) | |
tree | 861c8de86a39a9c3235f949dcad01ba96cfb18c6 /drivers | |
parent | 538f0fd0f210c2ce5c585799f18d0e5c7cf6155e (diff) |
x86, aperture_64: use symbolic constants
Factor-out common aperture_valid code.
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/agp/amd64-agp.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index e3c7ea07f57c..f5af65ac8c78 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -228,24 +228,10 @@ static const struct agp_bridge_driver amd_8151_driver = { | |||
228 | }; | 228 | }; |
229 | 229 | ||
230 | /* Some basic sanity checks for the aperture. */ | 230 | /* Some basic sanity checks for the aperture. */ |
231 | static int __devinit aperture_valid(u64 aper, u32 size) | 231 | static int __devinit agp_aperture_valid(u64 aper, u32 size) |
232 | { | 232 | { |
233 | if (aper == 0) { | 233 | if (!aperture_valid(aper, size, 32*1024*1024)) |
234 | printk(KERN_ERR PFX "No aperture\n"); | ||
235 | return 0; | 234 | return 0; |
236 | } | ||
237 | if ((u64)aper + size > 0x100000000ULL) { | ||
238 | printk(KERN_ERR PFX "Aperture out of bounds\n"); | ||
239 | return 0; | ||
240 | } | ||
241 | if (e820_any_mapped(aper, aper + size, E820_RAM)) { | ||
242 | printk(KERN_ERR PFX "Aperture pointing to RAM\n"); | ||
243 | return 0; | ||
244 | } | ||
245 | if (size < 32*1024*1024) { | ||
246 | printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); | ||
247 | return 0; | ||
248 | } | ||
249 | 235 | ||
250 | /* Request the Aperture. This catches cases when someone else | 236 | /* Request the Aperture. This catches cases when someone else |
251 | already put a mapping in there - happens with some very broken BIOS | 237 | already put a mapping in there - happens with some very broken BIOS |
@@ -282,7 +268,7 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
282 | nb_order = (nb_order >> 1) & 7; | 268 | nb_order = (nb_order >> 1) & 7; |
283 | pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); | 269 | pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); |
284 | nb_aper = nb_base << 25; | 270 | nb_aper = nb_base << 25; |
285 | if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { | 271 | if (agp_aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { |
286 | return 0; | 272 | return 0; |
287 | } | 273 | } |
288 | 274 | ||
@@ -313,7 +299,7 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
313 | } | 299 | } |
314 | 300 | ||
315 | printk(KERN_INFO PFX "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order); | 301 | printk(KERN_INFO PFX "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order); |
316 | if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order)) | 302 | if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) |
317 | return -1; | 303 | return -1; |
318 | 304 | ||
319 | pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); | 305 | pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); |