Split device_t/softc.
This commit is contained in:
parent
efec14320d
commit
11da9127f7
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iha.c,v 1.37 2008/04/08 12:07:26 cegger Exp $ */
|
||||
/* $NetBSD: iha.c,v 1.38 2008/04/12 08:21:19 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
|
||||
|
@ -39,7 +39,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iha.c,v 1.37 2008/04/08 12:07:26 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iha.c,v 1.38 2008/04/12 08:21:19 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -498,14 +498,14 @@ iha_attach(struct iha_softc *sc)
|
|||
TAILQ_INIT(&sc->sc_donescb);
|
||||
error = iha_alloc_sglist(sc);
|
||||
if (error != 0) {
|
||||
printf(": cannot allocate sglist\n");
|
||||
aprint_error_dev(sc->sc_dev, "cannot allocate sglist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
sc->sc_scb = malloc(sizeof(struct iha_scb) * IHA_MAX_SCB,
|
||||
M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
if (sc->sc_scb == NULL) {
|
||||
printf(": cannot allocate SCB\n");
|
||||
aprint_error_dev(sc->sc_dev, "cannot allocate SCB\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,8 @@ iha_attach(struct iha_softc *sc)
|
|||
BUS_DMA_NOWAIT, &scb->dmap);
|
||||
|
||||
if (error != 0) {
|
||||
printf(": couldn't create SCB DMA map, error = %d\n",
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
"couldn't create SCB DMA map, error = %d\n",
|
||||
error);
|
||||
return;
|
||||
}
|
||||
|
@ -577,7 +578,7 @@ iha_attach(struct iha_softc *sc)
|
|||
/*
|
||||
* fill in the adapter.
|
||||
*/
|
||||
sc->sc_adapter.adapt_dev = &sc->sc_dev;
|
||||
sc->sc_adapter.adapt_dev = sc->sc_dev;
|
||||
sc->sc_adapter.adapt_nchannels = 1;
|
||||
sc->sc_adapter.adapt_openings = IHA_MAX_SCB;
|
||||
sc->sc_adapter.adapt_max_periph = IHA_MAX_SCB;
|
||||
|
@ -598,7 +599,7 @@ iha_attach(struct iha_softc *sc)
|
|||
/*
|
||||
* Now try to attach all the sub devices.
|
||||
*/
|
||||
config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
|
||||
config_found(sc->sc_dev, &sc->sc_channel, scsiprint);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -658,7 +659,7 @@ iha_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req,
|
|||
struct iha_softc *sc;
|
||||
int error, s;
|
||||
|
||||
sc = (struct iha_softc *)chan->chan_adapter->adapt_dev;
|
||||
sc = device_private(chan->chan_adapter->adapt_dev);
|
||||
|
||||
switch (req) {
|
||||
case ADAPTER_REQ_RUN_XFER:
|
||||
|
@ -717,8 +718,8 @@ iha_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req,
|
|||
BUS_DMA_READ : BUS_DMA_WRITE));
|
||||
|
||||
if (error) {
|
||||
aprint_error_dev(&sc->sc_dev, "error %d loading DMA map\n",
|
||||
error);
|
||||
printf("%s: error %d loading DMA map\n",
|
||||
device_xname(sc->sc_dev), error);
|
||||
iha_append_free_scb(sc, scb);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
scsipi_done(xs);
|
||||
|
@ -1241,7 +1242,8 @@ iha_done_scb(struct iha_softc *sc, struct iha_scb *scb)
|
|||
if ((scb->flags & FLAG_RSENS) != 0 ||
|
||||
iha_push_sense_request(sc, scb) != 0) {
|
||||
scb->flags &= ~FLAG_RSENS;
|
||||
aprint_error_dev(&sc->sc_dev, "request sense failed\n");
|
||||
printf("%s: request sense failed\n",
|
||||
device_xname(sc->sc_dev));
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
break;
|
||||
}
|
||||
|
@ -1266,7 +1268,7 @@ iha_done_scb(struct iha_softc *sc, struct iha_scb *scb)
|
|||
|
||||
case HOST_SPERR:
|
||||
printf("%s: SCSI Parity error detected\n",
|
||||
device_xname(&sc->sc_dev));
|
||||
device_xname(sc->sc_dev));
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
break;
|
||||
|
||||
|
@ -1348,7 +1350,7 @@ iha_timeout(void *arg)
|
|||
|
||||
periph = xs->xs_periph;
|
||||
|
||||
sc = (void *)periph->periph_channel->chan_adapter->adapt_dev;
|
||||
sc = device_private(periph->periph_channel->chan_adapter->adapt_dev);
|
||||
|
||||
scsipi_printaddr(periph);
|
||||
printf("SCSI OpCode 0x%02x timed out\n", xs->cmd->opcode);
|
||||
|
@ -2621,7 +2623,7 @@ iha_read_eeprom(struct iha_softc *sc, struct iha_eeprom *eeprom)
|
|||
|
||||
/* Read EEProm */
|
||||
if (iha_se2_rd_all(sc, tbuf) == 0)
|
||||
panic("%s: cannot read EEPROM", device_xname(&sc->sc_dev));
|
||||
panic("%s: cannot read EEPROM", device_xname(sc->sc_dev));
|
||||
|
||||
/* Disable EEProm programming */
|
||||
gctrl = bus_space_read_1(iot, ioh, TUL_GCTRL0) & ~EEPRG;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ihavar.h,v 1.10 2005/12/11 12:21:27 christos Exp $ */
|
||||
/* $NetBSD: ihavar.h,v 1.11 2008/04/12 08:21:19 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
|
||||
|
@ -138,7 +138,7 @@ struct tcs {
|
|||
};
|
||||
|
||||
struct iha_softc {
|
||||
struct device sc_dev;
|
||||
device_t sc_dev;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iha_pci.c,v 1.14 2008/04/10 19:13:37 cegger Exp $ */
|
||||
/* $NetBSD: iha_pci.c,v 1.15 2008/04/12 08:21:19 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Device driver for the INI-9XXXU/UW or INIC-940/950 PCI SCSI Controller.
|
||||
|
@ -34,12 +34,12 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Ported to NetBSD by Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> from OpenBSD:
|
||||
* Ported to NetBSD by Izumi Tsutsui <tsutsui@NetBSD.org> from OpenBSD:
|
||||
* $OpenBSD: iha_pci.c,v 1.2 2001/03/29 23:53:38 krw Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iha_pci.c,v 1.14 2008/04/10 19:13:37 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iha_pci.c,v 1.15 2008/04/12 08:21:19 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -56,45 +56,47 @@ __KERNEL_RCSID(0, "$NetBSD: iha_pci.c,v 1.14 2008/04/10 19:13:37 cegger Exp $");
|
|||
|
||||
#include <dev/ic/ihavar.h>
|
||||
|
||||
static int iha_pci_match(struct device *, struct cfdata *, void *);
|
||||
static void iha_pci_attach(struct device *, struct device *, void *);
|
||||
static int iha_pci_match(device_t, cfdata_t, void *);
|
||||
static void iha_pci_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL(iha_pci, sizeof(struct iha_softc),
|
||||
CFATTACH_DECL_NEW(iha_pci, sizeof(struct iha_softc),
|
||||
iha_pci_match, iha_pci_attach, NULL, NULL);
|
||||
|
||||
static int
|
||||
iha_pci_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
iha_pci_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INITIO)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_INITIO_I940:
|
||||
case PCI_PRODUCT_INITIO_I950:
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
iha_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
iha_pci_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct iha_softc *sc = device_private(self);
|
||||
struct pci_attach_args *pa = aux;
|
||||
bus_space_tag_t iot;
|
||||
bus_space_handle_t ioh;
|
||||
pci_intr_handle_t ih;
|
||||
struct iha_softc *sc = (struct iha_softc *)self;
|
||||
const char *intrstr;
|
||||
pcireg_t command;
|
||||
int ioh_valid;
|
||||
char devinfo[256];
|
||||
|
||||
sc->sc_dev = self;
|
||||
|
||||
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
||||
printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
|
||||
aprint_normal(": %s (rev. 0x%02x)\n",
|
||||
devinfo, PCI_REVISION(pa->pa_class));
|
||||
|
||||
command = pci_conf_read(pa->pa_pc,pa->pa_tag,PCI_COMMAND_STATUS_REG);
|
||||
command |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_PARITY_ENABLE;
|
||||
|
@ -109,7 +111,7 @@ iha_pci_attach(struct device *parent, struct device *self, void *aux)
|
|||
&iot, &ioh, NULL, NULL);
|
||||
|
||||
if (ioh_valid != 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "unable to map registers\n");
|
||||
aprint_error_dev(self, "unable to map registers\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -118,7 +120,7 @@ iha_pci_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_dmat = pa->pa_dmat;
|
||||
|
||||
if (pci_intr_map(pa, &ih)) {
|
||||
aprint_error_dev(&sc->sc_dev, "couldn't map interrupt\n");
|
||||
aprint_error_dev(self, "couldn't map interrupt\n");
|
||||
return;
|
||||
}
|
||||
intrstr = pci_intr_string(pa->pa_pc, ih);
|
||||
|
@ -126,13 +128,13 @@ iha_pci_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, iha_intr, sc);
|
||||
|
||||
if (sc->sc_ih == NULL) {
|
||||
aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt");
|
||||
aprint_error_dev(self, "couldn't establish interrupt");
|
||||
if (intrstr != NULL)
|
||||
printf(" at %s", intrstr);
|
||||
printf("\n");
|
||||
aprint_error(" at %s", intrstr);
|
||||
aprint_error("\n");
|
||||
return;
|
||||
}
|
||||
printf("%s: interrupting at %s\n", device_xname(&sc->sc_dev), intrstr);
|
||||
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
|
||||
|
||||
iha_attach(sc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue