summaryrefslogtreecommitdiffstats
path: root/sys/dev/ichsmb/ichsmb_pci.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-01-11 19:56:24 +0000
committerjhb <jhb@FreeBSD.org>2007-01-11 19:56:24 +0000
commitafb4cfc54730fc4d0a2e88684ce0e206183e1e12 (patch)
tree939162cf86e1bf400a9cd9525a74dde0f62ddc2a /sys/dev/ichsmb/ichsmb_pci.c
parent13d4be4423daeef02c737b4e4cc24cbb9b9b46b1 (diff)
downloadFreeBSD-src-afb4cfc54730fc4d0a2e88684ce0e206183e1e12.zip
FreeBSD-src-afb4cfc54730fc4d0a2e88684ce0e206183e1e12.tar.gz
Various updates to most of the smbus(4) drivers:
- Use printf() and device_printf() instead of log() in ichsmb(4). - Create the mutex sooner during ichsmb(4) attach. - Attach the interrupt handler later during ichsmb(4) attach to avoid races. - Don't try to set PCIM_CMD_PORTEN in ichsmb(4) attach as the PCI bus driver does this already. - Add locking to alpm(4), amdpm(4), amdsmb(4), intsmb(4), nfsmb(4), and viapm(4). - Axe ALPM_SMBIO_BASE_ADDR, it's not really safe to write arbitrary values into BARs, and the PCI bus layer will allocate resources now if needed. - Merge intpm(4) and intsmb(4) into just intsmb(4). Previously, intpm(4) attached to the PCI device and created an intsmb(4) child. Now, intsmb(4) just attaches to PCI directly. - Change several intsmb functions to take a softc instead of a device_t to make things simpler.
Diffstat (limited to 'sys/dev/ichsmb/ichsmb_pci.c')
-rw-r--r--sys/dev/ichsmb/ichsmb_pci.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/sys/dev/ichsmb/ichsmb_pci.c b/sys/dev/ichsmb/ichsmb_pci.c
index 54c3b97..336c01c 100644
--- a/sys/dev/ichsmb/ichsmb_pci.c
+++ b/sys/dev/ichsmb/ichsmb_pci.c
@@ -164,7 +164,6 @@ static int
ichsmb_pci_attach(device_t dev)
{
const sc_p sc = device_get_softc(dev);
- u_int32_t cmd;
int error;
/* Initialize private state */
@@ -180,7 +179,7 @@ ichsmb_pci_attach(device_t dev)
sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
&sc->io_rid, 0, ~0, 32, RF_ACTIVE);
if (sc->io_res == NULL) {
- log(LOG_ERR, "%s: can't map I/O\n", device_get_nameunit(dev));
+ device_printf(dev, "can't map I/O\n");
error = ENXIO;
goto fail;
}
@@ -192,27 +191,7 @@ ichsmb_pci_attach(device_t dev)
sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
&sc->irq_rid, RF_ACTIVE | RF_SHAREABLE);
if (sc->irq_res == NULL) {
- log(LOG_ERR, "%s: can't get IRQ\n", device_get_nameunit(dev));
- error = ENXIO;
- goto fail;
- }
-
- /* Set up interrupt handler */
- error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
- ichsmb_device_intr, sc, &sc->irq_handle);
- if (error != 0) {
- log(LOG_ERR, "%s: can't setup irq\n", device_get_nameunit(dev));
- goto fail;
- }
-
- /* Enable I/O mapping */
- cmd = pci_read_config(dev, PCIR_COMMAND, 4);
- cmd |= PCIM_CMD_PORTEN;
- pci_write_config(dev, PCIR_COMMAND, cmd, 4);
- cmd = pci_read_config(dev, PCIR_COMMAND, 4);
- if ((cmd & PCIM_CMD_PORTEN) == 0) {
- log(LOG_ERR, "%s: can't enable memory map\n",
- device_get_nameunit(dev));
+ device_printf(dev, "can't get IRQ\n");
error = ENXIO;
goto fail;
}
@@ -221,7 +200,10 @@ ichsmb_pci_attach(device_t dev)
pci_write_config(dev, ICH_HOSTC, ICH_HOSTC_HST_EN, 1);
/* Done */
- return (ichsmb_attach(dev));
+ error = ichsmb_attach(dev);
+ if (error)
+ goto fail;
+ return (0);
fail:
/* Attach failed, release resources */
OpenPOWER on IntegriCloud