dev/agp: use our nitems() macro when it is avaliable through param.h.

Consistently capitalize the macros used in the driver.

No functional change.
This commit is contained in:
Pedro F. Giffuni 2016-04-19 23:31:35 +00:00
parent e4ad736f4d
commit 4ec642f1d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298306
3 changed files with 9 additions and 10 deletions

View File

@ -185,7 +185,7 @@ static u_int agp_max[][2] = {
{2048, 1920},
{4096, 3932}
};
#define agp_max_size (sizeof(agp_max) / sizeof(agp_max[0]))
#define AGP_MAX_SIZE nitems(agp_max)
/**
* Sets the PCI resource which represents the AGP aperture.
@ -228,12 +228,12 @@ agp_generic_attach(device_t dev)
* uses a heurisitc table from the Linux driver.
*/
memsize = ptoa(realmem) >> 20;
for (i = 0; i < agp_max_size; i++) {
for (i = 0; i < AGP_MAX_SIZE; i++) {
if (memsize <= agp_max[i][0])
break;
}
if (i == agp_max_size)
i = agp_max_size - 1;
if (i == AGP_MAX_SIZE)
i = AGP_MAX_SIZE - 1;
sc->as_maxmem = agp_max[i][1] << 20U;
/*

View File

@ -171,7 +171,7 @@ static u_int32_t agp_ali_table[] = {
128*M, /* 9 - invalid */
256*M, /* 10 - invalid */
};
#define agp_ali_table_size (sizeof(agp_ali_table) / sizeof(agp_ali_table[0]))
#define AGP_ALI_TABLE_SIZE nitems(agp_ali_table)
static u_int32_t
agp_ali_get_aperture(device_t dev)
@ -181,7 +181,7 @@ agp_ali_get_aperture(device_t dev)
* I'm not sure this is correct..
*/
int i = pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xf;
if (i >= agp_ali_table_size)
if (i >= AGP_ALI_TABLE_SIZE)
return 0;
return agp_ali_table[i];
}
@ -192,10 +192,10 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture)
int i;
u_int32_t attbase;
for (i = 0; i < agp_ali_table_size; i++)
for (i = 0; i < AGP_ALI_TABLE_SIZE; i++)
if (agp_ali_table[i] == aperture)
break;
if (i == agp_ali_table_size)
if (i == AGP_ALI_TABLE_SIZE)
return EINVAL;
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);

View File

@ -274,8 +274,7 @@ static uint32_t agp_amd64_table[] = {
0x80000000, /* 2048 MB */
};
#define AGP_AMD64_TABLE_SIZE \
(sizeof(agp_amd64_table) / sizeof(agp_amd64_table[0]))
#define AGP_AMD64_TABLE_SIZE nitems(agp_amd64_table)
static uint32_t
agp_amd64_get_aperture(device_t dev)