Two style(9) fixes:

- return(foo);	(note parens)
- use __FBSDID()
This commit is contained in:
Warner Losh 2002-03-07 00:11:42 +00:00
parent 8e635fb764
commit a3133b5897

View File

@ -62,10 +62,7 @@
#define DEVPRINTF(x) #define DEVPRINTF(x)
#endif #endif
#if !defined(lint) __FBSDID("$FreeBSD$");
static const char rcsid[] =
"$FreeBSD$";
#endif
#define DECODE_PARAMS \ #define DECODE_PARAMS \
(device_t cbdev, device_t child, int id, int len, \ (device_t cbdev, device_t child, int id, int len, \
@ -165,12 +162,12 @@ DECODE_PROTOTYPE(generic)
} }
printf("\n"); printf("\n");
#endif #endif
return 0; return (0);
} }
DECODE_PROTOTYPE(nothing) DECODE_PROTOTYPE(nothing)
{ {
return 0; return (0);
} }
DECODE_PROTOTYPE(copy) DECODE_PROTOTYPE(copy)
@ -191,7 +188,7 @@ DECODE_PROTOTYPE(copy)
cisread_buf[ncisread_buf].data = malloc(len, M_DEVBUF, M_WAITOK); cisread_buf[ncisread_buf].data = malloc(len, M_DEVBUF, M_WAITOK);
memcpy(cisread_buf[ncisread_buf].data, tupledata, len); memcpy(cisread_buf[ncisread_buf].data, tupledata, len);
ncisread_buf++; ncisread_buf++;
return 0; return (0);
} }
DECODE_PROTOTYPE(linktarget) DECODE_PROTOTYPE(linktarget)
@ -213,9 +210,9 @@ DECODE_PROTOTYPE(linktarget)
printf("Invalid data for CIS Link Target!\n"); printf("Invalid data for CIS Link Target!\n");
decode_tuple_generic(cbdev, child, id, len, tupledata, decode_tuple_generic(cbdev, child, id, len, tupledata,
start, off, info); start, off, info);
return EINVAL; return (EINVAL);
} }
return 0; return (0);
} }
DECODE_PROTOTYPE(vers_1) DECODE_PROTOTYPE(vers_1)
@ -232,7 +229,7 @@ DECODE_PROTOTYPE(vers_1)
printf("%c", tupledata[i]); printf("%c", tupledata[i]);
} }
printf("\n"); printf("\n");
return 0; return (0);
} }
DECODE_PROTOTYPE(funcid) DECODE_PROTOTYPE(funcid)
@ -250,7 +247,7 @@ DECODE_PROTOTYPE(funcid)
printf(", "); printf(", ");
} }
printf("\n"); printf("\n");
return 0; return (0);
} }
DECODE_PROTOTYPE(manfid) DECODE_PROTOTYPE(manfid)
@ -260,7 +257,7 @@ DECODE_PROTOTYPE(manfid)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
printf("%02x", tupledata[i]); printf("%02x", tupledata[i]);
printf("\n"); printf("\n");
return 0; return (0);
} }
DECODE_PROTOTYPE(funce) DECODE_PROTOTYPE(funce)
@ -270,14 +267,14 @@ DECODE_PROTOTYPE(funce)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
printf("%02x", tupledata[i]); printf("%02x", tupledata[i]);
printf("\n"); printf("\n");
return 0; return (0);
} }
DECODE_PROTOTYPE(bar) DECODE_PROTOTYPE(bar)
{ {
if (len != 6) { if (len != 6) {
printf("*** ERROR *** BAR length not 6 (%d)\n", len); printf("*** ERROR *** BAR length not 6 (%d)\n", len);
return EINVAL; return (EINVAL);
} else { } else {
struct cardbus_devinfo *dinfo = device_get_ivars(child); struct cardbus_devinfo *dinfo = device_get_ivars(child);
int type; int type;
@ -296,7 +293,7 @@ DECODE_PROTOTYPE(bar)
(type == SYS_RES_IOPORT && bar == 5)) { (type == SYS_RES_IOPORT && bar == 5)) {
device_printf(cbdev, "Invalid BAR number: %02x(%02x)\n", device_printf(cbdev, "Invalid BAR number: %02x(%02x)\n",
reg, bar); reg, bar);
return 0; return (0);
} }
bar = CARDBUS_BASE0_REG + bar * 4; bar = CARDBUS_BASE0_REG + bar * 4;
if (type == SYS_RES_MEMORY) { if (type == SYS_RES_MEMORY) {
@ -320,19 +317,19 @@ DECODE_PROTOTYPE(bar)
resource_list_add(&dinfo->pci.resources, type, bar, 0UL, ~0UL, len); resource_list_add(&dinfo->pci.resources, type, bar, 0UL, ~0UL, len);
} }
return 0; return (0);
} }
DECODE_PROTOTYPE(unhandled) DECODE_PROTOTYPE(unhandled)
{ {
printf("TUPLE: %s [%d] is unhandled! Bailing...", info->name, len); printf("TUPLE: %s [%d] is unhandled! Bailing...", info->name, len);
return -1; return (-1);
} }
DECODE_PROTOTYPE(end) DECODE_PROTOTYPE(end)
{ {
printf("CIS reading done\n"); printf("CIS reading done\n");
return 0; return (0);
} }
/* /*
@ -365,7 +362,7 @@ cardbus_read_tuple_conf(device_t cbdev, device_t child, u_int32_t start,
e >>= 8; e >>= 8;
} }
*off += *len + 2; *off += *len + 2;
return 0; return (0);
} }
static int static int
@ -384,7 +381,7 @@ cardbus_read_tuple_mem(device_t cbdev, struct resource *res, u_int32_t start,
bus_space_read_region_1(bt, bh, *off + start + 2, tupledata, *len); bus_space_read_region_1(bt, bh, *off + start + 2, tupledata, *len);
ret = 0; ret = 0;
*off += *len + 2; *off += *len + 2;
return ret; return (ret);
} }
static int static int
@ -393,11 +390,11 @@ cardbus_read_tuple(device_t cbdev, device_t child, struct resource *res,
u_int8_t *tupledata) u_int8_t *tupledata)
{ {
if (res == (struct resource*)~0UL) { if (res == (struct resource*)~0UL) {
return cardbus_read_tuple_conf(cbdev, child, start, off, return (cardbus_read_tuple_conf(cbdev, child, start, off,
tupleid, len, tupledata); tupleid, len, tupledata));
} else { } else {
return cardbus_read_tuple_mem(cbdev, res, start, off, return (cardbus_read_tuple_mem(cbdev, res, start, off,
tupleid, len, tupledata); tupleid, len, tupledata));
} }
} }
@ -423,7 +420,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
switch (CARDBUS_CIS_SPACE(*start)) { switch (CARDBUS_CIS_SPACE(*start)) {
case CARDBUS_CIS_ASI_TUPLE: case CARDBUS_CIS_ASI_TUPLE:
/* CIS in tuple space need no initialization */ /* CIS in tuple space need no initialization */
return (struct resource*)~0UL; return (NULL);
case CARDBUS_CIS_ASI_BAR0: case CARDBUS_CIS_ASI_BAR0:
case CARDBUS_CIS_ASI_BAR1: case CARDBUS_CIS_ASI_BAR1:
case CARDBUS_CIS_ASI_BAR2: case CARDBUS_CIS_ASI_BAR2:
@ -440,14 +437,14 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
default: default:
device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n", device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n",
CARDBUS_CIS_SPACE(*start)); CARDBUS_CIS_SPACE(*start));
return NULL; return (NULL);
} }
/* figure out how much space we need */ /* figure out how much space we need */
testval = pci_read_config(child, *rid, 4); testval = pci_read_config(child, *rid, 4);
if (testval & 1) { if (testval & 1) {
device_printf(cbdev, "CIS Space is IO, expecting memory.\n"); device_printf(cbdev, "CIS Space is IO, expecting memory.\n");
return NULL; return (NULL);
} }
size = CARDBUS_MAPREG_MEM_SIZE(testval); size = CARDBUS_MAPREG_MEM_SIZE(testval);
if (size < 4096) if (size < 4096)
@ -458,7 +455,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
if (res == NULL) { if (res == NULL) {
device_printf(cbdev, "Unable to allocate resource " device_printf(cbdev, "Unable to allocate resource "
"to read CIS.\n"); "to read CIS.\n");
return NULL; return (NULL);
} }
pci_write_config(child, *rid, pci_write_config(child, *rid,
rman_get_start(res) | ((*rid == CARDBUS_ROM_REG)? rman_get_start(res) | ((*rid == CARDBUS_ROM_REG)?
@ -491,7 +488,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
bus_release_resource(cbdev, SYS_RES_MEMORY, bus_release_resource(cbdev, SYS_RES_MEMORY,
*rid, res); *rid, res);
*rid = 0; *rid = 0;
return NULL; return (NULL);
} }
dataptr = mystart + bus_space_read_2(bt, bh, dataptr = mystart + bus_space_read_2(bt, bh,
mystart + CARDBUS_EXROM_DATA_PTR); mystart + CARDBUS_EXROM_DATA_PTR);
@ -513,7 +510,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
CARDBUS_EXROM_DATA_INDICATOR) & 0x80) == 0) { CARDBUS_EXROM_DATA_INDICATOR) & 0x80) == 0) {
device_printf(cbdev, "Cannot read CIS: " device_printf(cbdev, "Cannot read CIS: "
"Not enough images of rom\n"); "Not enough images of rom\n");
return NULL; return (NULL);
} }
mystart += imagesize; mystart += imagesize;
} }
@ -521,7 +518,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start,
} else { } else {
*start = CARDBUS_CIS_SPACE(*start); *start = CARDBUS_CIS_SPACE(*start);
} }
return res; return (res);
} }
/* /*
@ -536,17 +533,17 @@ decode_tuple(device_t cbdev, device_t child, int tupleid, int len,
int i; int i;
for (i = 0; callbacks[i].id != CISTPL_GENERIC; i++) { for (i = 0; callbacks[i].id != CISTPL_GENERIC; i++) {
if (tupleid == callbacks[i].id) if (tupleid == callbacks[i].id)
return callbacks[i].func(cbdev, child, tupleid, len, return (callbacks[i].func(cbdev, child, tupleid, len,
tupledata, start, off, &callbacks[i]); tupledata, start, off, &callbacks[i]));
} }
if (tupleid < CISTPL_CUSTOMSTART) { if (tupleid < CISTPL_CUSTOMSTART) {
device_printf(cbdev, "Undefined tuple encountered, " device_printf(cbdev, "Undefined tuple encountered, "
"CIS parsing terminated\n"); "CIS parsing terminated\n");
return EINVAL; return (EINVAL);
} }
return callbacks[i].func(cbdev, child, tupleid, len, return (callbacks[i].func(cbdev, child, tupleid, len,
tupledata, start, off, NULL); tupledata, start, off, NULL));
} }
static int static int
@ -567,37 +564,37 @@ cardbus_parse_cis(device_t cbdev, device_t child,
off = 0; off = 0;
res = cardbus_read_tuple_init(cbdev, child, &start, &rid); res = cardbus_read_tuple_init(cbdev, child, &start, &rid);
if (res == NULL) if (res == NULL)
return ENXIO; return (ENXIO);
do { do {
if (0 != cardbus_read_tuple(cbdev, child, res, start, &off, if (0 != cardbus_read_tuple(cbdev, child, res, start, &off,
&tupleid, &len, tupledata)) { &tupleid, &len, tupledata)) {
device_printf(cbdev, "Failed to read CIS.\n"); device_printf(cbdev, "Failed to read CIS.\n");
cardbus_read_tuple_finish(cbdev, child, rid, res); cardbus_read_tuple_finish(cbdev, child, rid, res);
return ENXIO; return (ENXIO);
} }
if (expect_linktarget && tupleid != CISTPL_LINKTARGET) { if (expect_linktarget && tupleid != CISTPL_LINKTARGET) {
device_printf(cbdev, "Expecting link target, got 0x%x\n", device_printf(cbdev, "Expecting link target, got 0x%x\n",
tupleid); tupleid);
cardbus_read_tuple_finish(cbdev, child, rid, res); cardbus_read_tuple_finish(cbdev, child, rid, res);
return EINVAL; return (EINVAL);
} }
expect_linktarget = decode_tuple(cbdev, child, tupleid, len, expect_linktarget = decode_tuple(cbdev, child, tupleid, len,
tupledata, start, &off, callbacks); tupledata, start, &off, callbacks);
if (expect_linktarget != 0) { if (expect_linktarget != 0) {
cardbus_read_tuple_finish(cbdev, child, rid, res); cardbus_read_tuple_finish(cbdev, child, rid, res);
return expect_linktarget; return (expect_linktarget);
} }
} while (tupleid != CISTPL_END); } while (tupleid != CISTPL_END);
cardbus_read_tuple_finish(cbdev, child, rid, res); cardbus_read_tuple_finish(cbdev, child, rid, res);
return 0; return (0);
} }
static int static int
barsort(const void *a, const void *b) barsort(const void *a, const void *b)
{ {
return (*(const struct resource_list_entry **)b)->count - return ((*(const struct resource_list_entry **)b)->count -
(*(const struct resource_list_entry **)a)->count; (*(const struct resource_list_entry **)a)->count);
} }
static int static int
@ -617,7 +614,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
SLIST_FOREACH(rle, &dinfo->pci.resources, link) SLIST_FOREACH(rle, &dinfo->pci.resources, link)
count++; count++;
if (count == 0) if (count == 0)
return 0; return (0);
barlist = malloc(sizeof(struct resource_list_entry*) * count, M_DEVBUF, barlist = malloc(sizeof(struct resource_list_entry*) * count, M_DEVBUF,
M_WAITOK); M_WAITOK);
count = 0; count = 0;
@ -666,7 +663,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
if (res == NULL) { /* XXX need cleanup*/ if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate memory for " device_printf(cbdev, "Unable to allocate memory for "
"prefetchable memory.\n"); "prefetchable memory.\n");
return ENOMEM; return (ENOMEM);
} }
start = rman_get_start(res); start = rman_get_start(res);
end = rman_get_end(res); end = rman_get_end(res);
@ -738,7 +735,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
if (res == NULL) { /* XXX need cleanup*/ if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate memory for " device_printf(cbdev, "Unable to allocate memory for "
"non-prefetchable memory.\n"); "non-prefetchable memory.\n");
return ENOMEM; return (ENOMEM);
} }
start = rman_get_start(res); start = rman_get_start(res);
end = rman_get_end(res); end = rman_get_end(res);
@ -802,7 +799,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
io_size, flags); io_size, flags);
if (res == NULL) { /* XXX need cleanup*/ if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate I/O ports\n"); device_printf(cbdev, "Unable to allocate I/O ports\n");
return ENOMEM; return (ENOMEM);
} }
start = rman_get_start(res); start = rman_get_start(res);
end = rman_get_end(res); end = rman_get_end(res);
@ -824,7 +821,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
if (barlist[tmp]->res == NULL) { if (barlist[tmp]->res == NULL) {
DEVPRINTF((cbdev, "Cannot pre-allocate " DEVPRINTF((cbdev, "Cannot pre-allocate "
"IO port for cardbus device\n")); "IO port for cardbus device\n"));
return ENOMEM; return (ENOMEM);
} }
barlist[tmp]->start = barlist[tmp]->start =
rman_get_start(barlist[tmp]->res); rman_get_start(barlist[tmp]->res);
@ -848,7 +845,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
RF_SHAREABLE); RF_SHAREABLE);
if (res == NULL) { /* XXX need cleanup*/ if (res == NULL) { /* XXX need cleanup*/
device_printf(cbdev, "Unable to allocate IRQ\n"); device_printf(cbdev, "Unable to allocate IRQ\n");
return ENOMEM; return (ENOMEM);
} }
resource_list_add(&dinfo->pci.resources, SYS_RES_IRQ, rid, resource_list_add(&dinfo->pci.resources, SYS_RES_IRQ, rid,
rman_get_start(res), rman_get_end(res), 1); rman_get_start(res), rman_get_end(res), 1);
@ -856,7 +853,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child)
pci_write_config(child, PCIR_INTLINE, rman_get_start(res), 1); pci_write_config(child, PCIR_INTLINE, rman_get_start(res), 1);
bus_release_resource(cbdev, SYS_RES_IRQ, rid, res); bus_release_resource(cbdev, SYS_RES_IRQ, rid, res);
return 0; return (0);
} }
/* /*
@ -983,7 +980,7 @@ cardbus_cis_read(device_t cbdev, device_t child, u_int8_t id,
*buff = cisread_buf; *buff = cisread_buf;
*nret = ncisread_buf; *nret = ncisread_buf;
return ret; return (ret);
} }
void void
@ -1044,7 +1041,7 @@ cardbus_do_cis(device_t cbdev, device_t child)
ret = cardbus_parse_cis(cbdev, child, init_callbacks); ret = cardbus_parse_cis(cbdev, child, init_callbacks);
if (ret < 0) if (ret < 0)
return ret; return (ret);
cardbus_pickup_maps(cbdev, child); cardbus_pickup_maps(cbdev, child);
return cardbus_alloc_resources(cbdev, child); return (cardbus_alloc_resources(cbdev, child));
} }