Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/buslogic/bt_pci.c
Context not available. | |||||
#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140104Bul | #define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140104Bul | ||||
#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130104Bul | #define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130104Bul | ||||
static struct bt_dev { | |||||
uint16_t vendorid; | |||||
uint32_t deviceid; | |||||
const char *description; | |||||
} bt_devs[] = { | |||||
{0x104B, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, | |||||
"Buslogic Multi-Master SCSI Host Adapter"}, | |||||
{0x104B, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, | |||||
"Buslogic Multi-Master SCSI Host Adapter"}, | |||||
{0, 0, 0}, | |||||
}; | |||||
static int | static int | ||||
bt_pci_alloc_resources(device_t dev) | bt_pci_alloc_resources(device_t dev) | ||||
{ | { | ||||
Context not available. | |||||
static int | static int | ||||
bt_pci_probe(device_t dev) | bt_pci_probe(device_t dev) | ||||
{ | { | ||||
switch (pci_get_devid(dev)) { | const struct bt_dev *btd; | ||||
imp: This doesn't look right at all... | |||||
case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER: | uint32_t did; | ||||
case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC: | size_t i; | ||||
{ | |||||
did = pci_get_devid(dev); | |||||
for (i = 0; i < nitems(bt_devs) - 1; i++) { | |||||
Not Done Inline ActionsSince the bt_devs[] is null terminated, shouldn't the bounds check be nitems() instead of nitems() - 1? chuck: Since the `bt_devs[]` is null terminated, shouldn't the bounds check be `nitems()` instead of… | |||||
Not Done Inline ActionsSo, in this case nitems(bt_devs) comes out to be 3, so the for loop is for(i=0; i<2; i++). This iterates through the two valid devices present in bt_devs. It doesn't check the sentinel. This is what i wanted to iterate on. Does it sound right ? lakhanshiva_gmail.com: So, in this case nitems(bt_devs) comes out to be 3, so the for loop is for(i=0; i<2; i++). This… | |||||
btd = &bt_devs[i]; | |||||
if (btd->deviceid == did) { | |||||
struct bt_softc *bt = device_get_softc(dev); | struct bt_softc *bt = device_get_softc(dev); | ||||
pci_info_data_t pci_info; | pci_info_data_t pci_info; | ||||
int error; | int error; | ||||
Context not available. | |||||
/*param*/NULL, /*paramlen*/0, | /*param*/NULL, /*paramlen*/0, | ||||
(u_int8_t*)&pci_info, sizeof(pci_info), | (u_int8_t*)&pci_info, sizeof(pci_info), | ||||
DEFAULT_CMD_TIMEOUT); | DEFAULT_CMD_TIMEOUT); | ||||
if (error == 0 | if (error == 0 | ||||
&& pci_info.io_port < BIO_DISABLED) { | && pci_info.io_port < BIO_DISABLED) { | ||||
bt_mark_probed_bio(pci_info.io_port); | bt_mark_probed_bio(pci_info.io_port); | ||||
if (rman_get_start(bt->port) != | if (rman_get_start(bt->port) != | ||||
bt_iop_from_bio(pci_info.io_port)) { | bt_iop_from_bio(pci_info.io_port)) { | ||||
u_int8_t new_addr; | u_int8_t new_addr; | ||||
new_addr = BIO_DISABLED; | new_addr = BIO_DISABLED; | ||||
bt_cmd(bt, BOP_MODIFY_IO_ADDR, | bt_cmd(bt, BOP_MODIFY_IO_ADDR, | ||||
/*param*/&new_addr, | /*param*/&new_addr, | ||||
/*paramlen*/1, /*reply_buf*/NULL, | /*paramlen*/1, /*reply_buf*/NULL, | ||||
/*reply_len*/0, | /*reply_len*/0, | ||||
DEFAULT_CMD_TIMEOUT); | DEFAULT_CMD_TIMEOUT); | ||||
} | } | ||||
} | } | ||||
bt_pci_release_resources(dev); | bt_pci_release_resources(dev); | ||||
device_set_desc(dev, "Buslogic Multi-Master SCSI Host Adapter"); | device_set_desc(dev, btd->description); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
default: | |||||
break; | |||||
} | } | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
Context not available. | |||||
static devclass_t bt_devclass; | static devclass_t bt_devclass; | ||||
DRIVER_MODULE(bt, pci, bt_pci_driver, bt_devclass, 0, 0); | DRIVER_MODULE(bt, pci, bt_pci_driver, bt_devclass, 0, 0); | ||||
MODULE_PNP_INFO("U16:vendor;W32:vendor/device;D:#", pci, bt, bt_devs, | |||||
sizeof(bt_devs[0]), nitems(bt_devs) - 1); | |||||
MODULE_DEPEND(bt, pci, 1, 1, 1); | MODULE_DEPEND(bt, pci, 1, 1, 1); | ||||
Context not available. |
This doesn't look right at all...