Change structure/usage of interface provided callbacks. (read, write, reset)

Push these up to the ieee1394 softc level and make the naming scheme
consistant.
This commit is contained in:
jmc 2002-11-22 16:20:17 +00:00
parent af8aa9d5df
commit 77b603bc96
4 changed files with 49 additions and 43 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fwnode.c,v 1.17 2002/10/02 16:33:54 thorpej Exp $ */
/* $NetBSD: fwnode.c,v 1.18 2002/11/22 16:20:17 jmc Exp $ */
/*
* Copyright (c) 2001,2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.17 2002/10/02 16:33:54 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.18 2002/11/22 16:20:17 jmc Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -103,10 +103,14 @@ fwnode_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sc1394.sc1394_node_id = fwa->nodeid;
memcpy(sc->sc_sc1394.sc1394_guid, fwa->uid, 8);
sc->sc1394_read = fwa->read;
sc->sc1394_write = fwa->write;
sc->sc1394_inreg = fwa->inreg;
sc->sc1394_unreg = fwa->unreg;
sc->sc_sc1394.sc1394_callback.sc1394_read =
psc->sc1394_callback.sc1394_read;
sc->sc_sc1394.sc1394_callback.sc1394_write =
psc->sc1394_callback.sc1394_write;
sc->sc_sc1394.sc1394_callback.sc1394_inreg =
psc->sc1394_callback.sc1394_inreg;
sc->sc_sc1394.sc1394_callback.sc1394_unreg =
psc->sc1394_callback.sc1394_unreg;
/* XXX. Fix the fw code to use the generic routines. */
sc->sc_sc1394.sc1394_ifinreg = psc->sc1394_ifinreg;
@ -124,7 +128,7 @@ fwnode_attach(struct device *parent, struct device *self, void *aux)
ab->ab_retlen = 0;
ab->ab_cbarg = NULL;
ab->ab_cb = fwnode_configrom_input;
sc->sc1394_read(ab);
sc->sc_sc1394.sc1394_callback.sc1394_read(ab);
}
int
@ -135,8 +139,9 @@ fwnode_detach(struct device *self, int flags)
if (sc->sc_children) {
children = sc->sc_children;
while (*children++)
do {
config_detach(*children, 0);
} while (*(++children));
free(sc->sc_children, M_DEVBUF);
}
@ -216,7 +221,7 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
ab->ab_retlen = 0;
ab->ab_cbarg = NULL;
ab->ab_cb = fwnode_configrom_input;
sc->sc1394_read(ab);
sc->sc_sc1394.sc1394_callback.sc1394_read(ab);
return;
} else {
sc->sc_sc1394.sc1394_configrom_len = ab->ab_retlen;
@ -270,13 +275,13 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
sc->sc_sc1394.sc1394_dev.dv_xname,
ieee1394_speeds[sc->sc_sc1394.sc1394_link_speed],
IEEE1394_MAX_REC(sc->sc_sc1394.sc1394_max_receive));
sc->sc_children = p1212_match_units(&sc->sc_sc1394.sc1394_dev,
sc->sc_configrom->root, fwnode_print);
#ifdef FWNODE_DEBUG
fwnode_dump_rom(sc, sc->sc_sc1394.sc1394_configrom,
sc->sc_sc1394.sc1394_configrom_len);
p1212_print(sc->sc_configrom->root);
#endif
sc->sc_children = p1212_match_units(&sc->sc_sc1394.sc1394_dev,
sc->sc_configrom->root, fwnode_print);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fwnodevar.h,v 1.4 2002/02/27 05:02:25 jmc Exp $ */
/* $NetBSD: fwnodevar.h,v 1.5 2002/11/22 16:20:18 jmc Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -44,14 +44,9 @@ struct fwnode_softc {
int sc_flags;
int (*sc1394_read)(struct ieee1394_abuf *);
int (*sc1394_write)(struct ieee1394_abuf *);
int (*sc1394_inreg)(struct ieee1394_abuf *, int);
int (*sc1394_unreg)(struct ieee1394_abuf *, int);
struct device **sc_children;
struct p1212_rom *sc_configrom;
struct device **sc_children;
};
#endif /* _DEV_IEEE1394_FWNODEVAR_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: fwohci.c,v 1.57 2002/09/27 15:37:21 provos Exp $ */
/* $NetBSD: fwohci.c,v 1.58 2002/11/22 16:20:18 jmc Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.57 2002/09/27 15:37:21 provos Exp $");
__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.58 2002/11/22 16:20:18 jmc Exp $");
#define DOUBLEBUF 1
#define NO_THREAD 1
@ -278,6 +278,11 @@ fwohci_init(struct fwohci_softc *sc, const struct evcnt *ev)
sc->sc_dying = 0;
sc->sc_nodeid = 0xffff; /* invalid */
sc->sc_sc1394.sc1394_callback.sc1394_read = fwohci_read;
sc->sc_sc1394.sc1394_callback.sc1394_write = fwohci_write;
sc->sc_sc1394.sc1394_callback.sc1394_inreg = fwohci_inreg;
sc->sc_sc1394.sc1394_callback.sc1394_unreg = fwohci_unreg;
kthread_create(fwohci_create_event_thread, sc);
return 0;
}
@ -2669,16 +2674,15 @@ fwohci_uid_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *res)
DPRINTF(("%s: Updating nodeid to %d\n",
iea->sc1394_dev.dv_xname,
iea->sc1394_node_id));
if (iea->sc1394_callback.sc1394_reset)
iea->sc1394_callback.sc1394_reset(iea,
iea->sc1394_callback.sc1394_resetarg);
break;
}
if (!found) {
strcpy(fwa.name, "fwnode");
memcpy(fwa.uid, fu->fu_uid, 8);
fwa.nodeid = n;
fwa.read = fwohci_read;
fwa.write = fwohci_write;
fwa.inreg = fwohci_inreg;
fwa.unreg = fwohci_unreg;
iea = (struct ieee1394_softc *)
config_found_sm(&sc->sc_sc1394.sc1394_dev, &fwa,
fwohci_print, fwohci_submatch);
@ -3245,6 +3249,7 @@ fwohci_write(struct ieee1394_abuf *ab)
lo = (ab->ab_addr & 0x00000000ffffffff);
pkt.fp_hdr[0] = 0x00000100 | (sc->sc1394_link_speed << 16) |
(psc->sc_tlabel << 10) | (pkt.fp_tcode << 4);
psc->sc_tlabel = (psc->sc_tlabel + 1) & 0x3f;
break;
}
@ -3590,7 +3595,7 @@ fwohci_inreg(struct ieee1394_abuf *ab, int allow)
* amount is ok.
*/
if (ab->ab_cb)
ab->ab_data = (void *)1;
ab->ab_subok = 1;
} else {
if (ab->ab_cb)
rv = fwohci_handler_set(psc, ab->ab_tcode, high,
@ -3633,31 +3638,34 @@ fwohci_parse_input(struct fwohci_softc *sc, void *arg, struct fwohci_pkt *pkt)
ab->ab_tlabel = (pkt->fp_hdr[0] >> 10) & 0x3f;
addr = (((u_int64_t)(pkt->fp_hdr[1] & 0xffff) << 32) | pkt->fp_hdr[2]);
/* Make sure it's always 0 in case this gets reused multiple times. */
ab->ab_retlen = 0;
switch (ab->ab_tcode) {
case IEEE1394_TCODE_READ_REQ_QUAD:
ab->ab_retlen = 4;
break;
case IEEE1394_TCODE_READ_REQ_BLOCK:
ab->ab_retlen = (pkt->fp_hdr[3] >> 16) & 0xffff;
if (ab->ab_data) {
if (ab->ab_subok) {
if ((addr + ab->ab_retlen) >
(ab->ab_addr + ab->ab_length))
return IEEE1394_RCODE_ADDRESS_ERROR;
ab->ab_data = NULL;
} else
if (ab->ab_retlen != ab->ab_length)
return IEEE1394_RCODE_ADDRESS_ERROR;
break;
case IEEE1394_TCODE_WRITE_REQ_QUAD:
ab->ab_retlen = 4;
/* Fall through. */
case IEEE1394_TCODE_WRITE_REQ_BLOCK:
if (!ab->ab_retlen)
ab->ab_retlen = (pkt->fp_hdr[3] >> 16) & 0xffff;
if (ab->ab_data) {
if (ab->ab_subok) {
if ((addr + ab->ab_retlen) >
(ab->ab_addr + ab->ab_length))
return IEEE1394_RCODE_ADDRESS_ERROR;
ab->ab_data = NULL;
} else
if (ab->ab_retlen != ab->ab_length)
return IEEE1394_RCODE_ADDRESS_ERROR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee1394var.h,v 1.15 2002/02/27 05:04:28 jmc Exp $ */
/* $NetBSD: ieee1394var.h,v 1.16 2002/11/22 16:20:20 jmc Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -47,8 +47,7 @@ struct ieee1394_node;
* requisite reference counting.
*/
struct ieee1394_abuf {
struct ieee1394_softc *ab_req; /* requestor */
struct ieee1394_softc *ab_resp; /* response */
struct ieee1394_softc *ab_req; /* requestee */
u_int32_t *ab_data;
struct uio *ab_uio;
u_int64_t ab_addr;
@ -57,33 +56,32 @@ struct ieee1394_abuf {
u_int32_t ab_length;
u_int32_t ab_retlen; /* length returned from read. */
u_int32_t ab_retries;
u_int8_t ab_subok;
void (*ab_cb)(struct ieee1394_abuf *, int);
void *ab_cbarg;
};
struct ieee1394_callbacks {
void (*cb1394_busreset)(struct ieee1394_softc *);
void (*cb1394_at_queue)(struct ieee1394_softc *, int type,
struct ieee1394_abuf *);
void (*cb1394_at_done)(struct ieee1394_softc *,
struct ieee1394_abuf *);
void (*sc1394_reset)(struct ieee1394_softc *, void *);
void *sc1394_resetarg;
int (*sc1394_read)(struct ieee1394_abuf *);
int (*sc1394_write)(struct ieee1394_abuf *);
int (*sc1394_inreg)(struct ieee1394_abuf *, int);
int (*sc1394_unreg)(struct ieee1394_abuf *, int);
};
struct ieee1394_attach_args {
char name[7];
u_int8_t uid[8];
u_int16_t nodeid;
int (*read)(struct ieee1394_abuf *);
int (*write)(struct ieee1394_abuf *);
int (*inreg)(struct ieee1394_abuf *, int);
int (*unreg)(struct ieee1394_abuf *, int);
};
struct ieee1394_softc {
struct device sc1394_dev;
struct device *sc1394_if; /* Move to fwohci level. */
const struct ieee1394_callbacks sc1394_callback; /* Nuke probably. */
struct ieee1394_callbacks sc1394_callback; /* Nuke probably. */
u_int32_t *sc1394_configrom;
u_int32_t sc1394_configrom_len; /* quadlets. */
u_int32_t sc1394_max_receive;