svn commit: r298306 - head/sys/dev/agp
Pedro F. Giffuni
pfg at FreeBSD.org
Tue Apr 19 23:31:37 UTC 2016
Author: pfg
Date: Tue Apr 19 23:31:35 2016
New Revision: 298306
URL: https://svnweb.freebsd.org/changeset/base/298306
Log:
dev/agp: use our nitems() macro when it is avaliable through param.h.
Consistently capitalize the macros used in the driver.
No functional change.
Modified:
head/sys/dev/agp/agp.c
head/sys/dev/agp/agp_ali.c
head/sys/dev/agp/agp_amd64.c
Modified: head/sys/dev/agp/agp.c
==============================================================================
--- head/sys/dev/agp/agp.c Tue Apr 19 23:30:22 2016 (r298305)
+++ head/sys/dev/agp/agp.c Tue Apr 19 23:31:35 2016 (r298306)
@@ -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;
/*
Modified: head/sys/dev/agp/agp_ali.c
==============================================================================
--- head/sys/dev/agp/agp_ali.c Tue Apr 19 23:30:22 2016 (r298305)
+++ head/sys/dev/agp/agp_ali.c Tue Apr 19 23:31:35 2016 (r298306)
@@ -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_int
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);
Modified: head/sys/dev/agp/agp_amd64.c
==============================================================================
--- head/sys/dev/agp/agp_amd64.c Tue Apr 19 23:30:22 2016 (r298305)
+++ head/sys/dev/agp/agp_amd64.c Tue Apr 19 23:31:35 2016 (r298306)
@@ -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)
More information about the svn-src-all
mailing list