drm/nouveau: Kill global state in NvShadowBIOS

Signed-off-by: Marcin Kościelnicki <koriakin@0x04.net>
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Marcin Kościelnicki 2009-12-15 00:37:30 +00:00 committed by Ben Skeggs
parent ef2bb50668
commit 657b6245ba

View file

@ -181,43 +181,42 @@ struct methods {
const char desc[8]; const char desc[8];
void (*loadbios)(struct drm_device *, uint8_t *); void (*loadbios)(struct drm_device *, uint8_t *);
const bool rw; const bool rw;
int score;
}; };
static struct methods nv04_methods[] = { static struct methods nv04_methods[] = {
{ "PROM", load_vbios_prom, false }, { "PROM", load_vbios_prom, false },
{ "PRAMIN", load_vbios_pramin, true }, { "PRAMIN", load_vbios_pramin, true },
{ "PCIROM", load_vbios_pci, true }, { "PCIROM", load_vbios_pci, true },
{ }
}; };
static struct methods nv50_methods[] = { static struct methods nv50_methods[] = {
{ "PRAMIN", load_vbios_pramin, true }, { "PRAMIN", load_vbios_pramin, true },
{ "PROM", load_vbios_prom, false }, { "PROM", load_vbios_prom, false },
{ "PCIROM", load_vbios_pci, true }, { "PCIROM", load_vbios_pci, true },
{ }
}; };
#define METHODCNT 3
static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct methods *methods, *method; struct methods *methods;
int i;
int testscore = 3; int testscore = 3;
int scores[METHODCNT];
if (nouveau_vbios) { if (nouveau_vbios) {
method = nv04_methods; methods = nv04_methods;
while (method->loadbios) { for (i = 0; i < METHODCNT; i++)
if (!strcasecmp(nouveau_vbios, method->desc)) if (!strcasecmp(nouveau_vbios, methods[i].desc))
break; break;
method++;
}
if (method->loadbios) { if (i < METHODCNT) {
NV_INFO(dev, "Attempting to use BIOS image from %s\n", NV_INFO(dev, "Attempting to use BIOS image from %s\n",
method->desc); methods[i].desc);
method->loadbios(dev, data); methods[i].loadbios(dev, data);
if (score_vbios(dev, data, method->rw)) if (score_vbios(dev, data, methods[i].rw))
return true; return true;
} }
@ -229,28 +228,24 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
else else
methods = nv50_methods; methods = nv50_methods;
method = methods; for (i = 0; i < METHODCNT; i++) {
while (method->loadbios) {
NV_TRACE(dev, "Attempting to load BIOS image from %s\n", NV_TRACE(dev, "Attempting to load BIOS image from %s\n",
method->desc); methods[i].desc);
data[0] = data[1] = 0; /* avoid reuse of previous image */ data[0] = data[1] = 0; /* avoid reuse of previous image */
method->loadbios(dev, data); methods[i].loadbios(dev, data);
method->score = score_vbios(dev, data, method->rw); scores[i] = score_vbios(dev, data, methods[i].rw);
if (method->score == testscore) if (scores[i] == testscore)
return true; return true;
method++;
} }
while (--testscore > 0) { while (--testscore > 0) {
method = methods; for (i = 0; i < METHODCNT; i++) {
while (method->loadbios) { if (scores[i] == testscore) {
if (method->score == testscore) {
NV_TRACE(dev, "Using BIOS image from %s\n", NV_TRACE(dev, "Using BIOS image from %s\n",
method->desc); methods[i].desc);
method->loadbios(dev, data); methods[i].loadbios(dev, data);
return true; return true;
} }
method++;
} }
} }