Split device_t/softc.

And cosmetic change.
This commit is contained in:
kiyohara 2008-03-29 16:22:53 +00:00
parent 9826f6af3a
commit 64e7d595e1
5 changed files with 111 additions and 133 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: firewire.c,v 1.19 2007/12/15 00:39:28 perry Exp $ */
/* $NetBSD: firewire.c,v 1.20 2008/03/29 16:22:53 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.19 2007/12/15 00:39:28 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.20 2008/03/29 16:22:53 kiyohara Exp $");
#if defined(__FreeBSD__)
#include <sys/param.h>
@ -196,11 +196,11 @@ static int firewire_shutdown (device_t);
#endif
static device_t firewire_add_child (device_t, int, const char *, int);
#elif defined(__NetBSD__)
int firewirematch (struct device *, struct cfdata *, void *);
void firewireattach (struct device *, struct device *, void *);
int firewiredetach (struct device *, int);
int firewirematch (device_t, struct cfdata *, void *);
void firewireattach (device_t, device_t, void *);
int firewiredetach (device_t, int);
int firewire_print (void *, const char *);
int firewire_resume(struct firewire_comm *);
int firewire_resume (struct firewire_comm *);
#endif
static void firewire_xfer_timeout(void *, int);
static void fw_try_bmr (void *);
@ -234,7 +234,7 @@ static device_method_t firewire_methods[] = {
{ 0, 0 }
};
#elif defined(__NetBSD__)
CFATTACH_DECL(ieee1394if, sizeof (struct firewire_softc),
CFATTACH_DECL_NEW(ieee1394if, sizeof(struct firewire_softc),
firewirematch, firewireattach, firewiredetach, NULL);
#endif
const char *fw_linkspeed[] = {
@ -452,8 +452,7 @@ firewire_probe(device_t dev)
}
#elif defined(__NetBSD__)
int
firewirematch(struct device *parent, struct cfdata *cf,
void *aux)
firewirematch(device_t parent, struct cfdata *cf, void *aux)
{
struct fwbus_attach_args *faa = (struct fwbus_attach_args *)aux;

View File

@ -1,4 +1,4 @@
/* $NetBSD: firewirereg.h,v 1.7 2007/11/05 19:08:56 kiyohara Exp $ */
/* $NetBSD: firewirereg.h,v 1.8 2008/03/29 16:22:53 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@ -67,8 +67,7 @@ struct firewire_softc {
fw_dev_t dev;
device_t sbp_dev;
#elif defined(__NetBSD__)
struct device _dev;
struct device *dev;
device_t dev;
SLIST_HEAD(, firewire_dev_list) devlist;
void *si_drv1;
int si_iosize_max;
@ -78,7 +77,7 @@ struct firewire_softc {
#if defined(__NetBSD__)
struct firewire_dev_list {
SLIST_ENTRY(firewire_dev_list) link;
struct device *dev;
device_t dev;
struct fw_device *fwdev;
};
#endif
@ -88,9 +87,6 @@ struct firewire_dev_list {
#define FW_XFERTIMEOUT 1
struct firewire_dev_comm {
#if defined(__NetBSD__)
struct device _dev;
#endif
device_t dev;
struct firewire_comm *fc;
void (*post_busreset) (void *);
@ -109,9 +105,6 @@ struct tcode_info {
};
struct firewire_comm{
#if defined(__NetBSD__)
struct device _dev;
#endif
device_t dev;
device_t bdev;
uint16_t busid:10,

View File

@ -1,4 +1,4 @@
/* $NetBSD: fw_port.h,v 1.27 2007/12/25 18:33:39 perry Exp $ */
/* $NetBSD: fw_port.h,v 1.28 2008/03/29 16:22:53 kiyohara Exp $ */
/*
* Copyright (c) 2004 KIYOHARA Takashi
* All rights reserved.
@ -64,8 +64,7 @@
#define fw_get_nameunit(dev) device_get_nameunit((dev))
#define fw_get_unit(dev) device_get_unit((dev))
#define fw_printf(dev, fmt, ...) \
device_printf((dev), (fmt), __VA_ARGS__);
#define fw_printf(dev, ...) device_printf((dev), __VA_ARGS__)
/* atomic macros */
#define fw_atomic_set_int(P, V) atomic_set_int((P), (V))
@ -615,15 +614,11 @@ struct fw_hwaddr {
#define fw_get_nameunit(dev) (dev)->dv_xname
#define fw_get_unit(dev) device_unit((dev))
#define fw_printf(dev, fmt, ...) \
do { \
printf("%s: ", (dev)->dv_xname);\
printf((fmt), ##__VA_ARGS__); \
} while (/*CONSTCOND*/0)
#define fw_printf(dev, ...) aprint_normal_dev((dev), __VA_ARGS__)
/* atomic macros */
/* XXXX: unsafe... */
#define fw_atomic_set_int(P, V) (*(u_int*)(P) |= (V))
#define fw_atomic_set_int(P, V) (*(u_int *)(P) |= (V))
static __inline int
fw_atomic_readandclear_int(int *p)
{
@ -716,7 +711,7 @@ _fw_bus_dma_tag_create(bus_dma_tag_t parent,
{
fw_bus_dma_tag_t tag;
tag = malloc(sizeof (struct fw_bus_dma_tag), M_DEVBUF, M_NOWAIT);
tag = malloc(sizeof(struct fw_bus_dma_tag), M_DEVBUF, M_NOWAIT);
if (tag == NULL)
return ENOMEM;
@ -837,12 +832,10 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
#define FW_ATTACH(dname) \
void \
__CONCAT(dname,attach) \
(struct device *parent, struct device *self, void *aux)
(device_t parent, device_t self, void *aux)
#define FW_ATTACH_START(dname, sc, fwa) \
struct __CONCAT(dname,_softc) *sc = \
(struct __CONCAT(dname,_softc) *)self; \
__unused struct fw_attach_args *fwa = \
(struct fw_attach_args *)aux
struct __CONCAT(dname,_softc) *sc = device_private(self); \
__unused struct fw_attach_args *fwa = (struct fw_attach_args *)aux
#define FW_ATTACH_RETURN(r) return
/*
@ -850,23 +843,21 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
*/
#define FW_DETACH(dname) \
int \
__CONCAT(dname,detach)(struct device *self, int flags)
#define FW_DETACH_START(dname, sc) \
struct __CONCAT(dname,_softc) *sc = \
(struct __CONCAT(dname,_softc) *)self
__CONCAT(dname,detach)(device_t self, int flags)
#define FW_DETACH_START(dname, sc) \
struct __CONCAT(dname,_softc) *sc = device_private(self)
/*
* fw open macro for NetBSD
*/
#define FW_OPEN(dname) \
int \
__CONCAT(dname,_open)(dev_t _dev, int flags, int fmt, \
fw_proc_t td)
#define FW_OPEN_START \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup(&ieee1394if_cd, DEV2UNIT(_dev)); \
if (dev == NULL) \
__CONCAT(dname,_open)(dev_t _dev, int flags, int fmt, fw_proc_t td)
#define FW_OPEN_START \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup_private(&ieee1394if_cd, DEV2UNIT(_dev));\
if (dev == NULL) \
return ENXIO
/*
@ -874,13 +865,13 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
*/
#define FW_CLOSE(dname) \
int \
__CONCAT(dname,_close)(dev_t _dev, int flags, \
int fmt, fw_proc_t td)
#define FW_CLOSE_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev = device_lookup(&ieee1394if_cd, unit); \
\
if (dev == NULL) \
__CONCAT(dname,_close)(dev_t _dev, int flags, int fmt, fw_proc_t td)
#define FW_CLOSE_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
@ -889,12 +880,12 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
#define FW_READ(dname) \
int \
__CONCAT(dname,_read)(dev_t _dev, struct uio *uio, int ioflag)
#define FW_READ_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
#define FW_READ_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
@ -903,28 +894,27 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
#define FW_WRITE(dname) \
int \
__CONCAT(dname,_write)(dev_t _dev, struct uio *uio, int ioflag)
#define FW_WRITE_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
#define FW_WRITE_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
* fw ioctl macro for NetBSD
*/
#define FW_IOCTL(dname) \
int \
__CONCAT(dname,_ioctl) \
(dev_t _dev, u_long cmd, void *data, \
int flag, fw_proc_t td)
#define FW_IOCTL_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
#define FW_IOCTL(dname) \
int \
__CONCAT(dname,_ioctl) \
(dev_t _dev, u_long cmd, void *data, int flag, fw_proc_t td)
#define FW_IOCTL_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
@ -932,14 +922,13 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
*/
#define FW_POLL(dname) \
int \
__CONCAT(dname,_poll)(dev_t _dev, int events, \
fw_proc_t td)
#define FW_POLL_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
__CONCAT(dname,_poll)(dev_t _dev, int events, fw_proc_t td)
#define FW_POLL_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
@ -947,34 +936,32 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
*/
#define FW_MMAP(dname) \
paddr_t \
__CONCAT(dname,_mmap)(dev_t _dev, off_t offset, \
int nproto)
#define FW_MMAP_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
__CONCAT(dname,_mmap)(dev_t _dev, off_t offset, int nproto)
#define FW_MMAP_START \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *dev; \
\
dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return ENXIO
/*
* fw strategy macro for NetBSD
*/
#define FW_STRATEGY_START \
dev_t _dev = bp->bio_dev; \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup(&ieee1394if_cd, unit); \
if (dev == NULL) \
#define FW_STRATEGY_START \
dev_t _dev = bp->bio_dev; \
int unit = DEV2UNIT(_dev); \
struct firewire_softc *sc, *dev; \
\
sc = dev = device_lookup_private(&ieee1394if_cd, unit); \
if (dev == NULL) \
return
/*
* if macro for NetBSD
*/
#define IF_DETACH_START(dname, sc) \
struct __CONCAT(dname,_softc) *sc = \
(struct __CONCAT(dname,_softc) *)self
struct __CONCAT(dname,_softc) *sc = device_private(self)
#define IF_IOCTL_START(dname, sc) \
struct __CONCAT(dname,_softc) *sc = \
((struct fwip_eth_softc *)ifp->if_softc)->fwip
@ -1013,12 +1000,11 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
* firewire macro for NetBSD
*/
#define FIREWIRE_ATTACH_START \
struct firewire_comm *fc = (struct firewire_comm *)parent; \
struct firewire_comm *fc = device_private(parent); \
\
aprint_normal(": IEEE1394 bus\n"); \
\
fc->bdev = (struct device *)sc; \
sc->dev = &sc->_dev; \
fc->bdev = sc->dev = self; \
SLIST_INIT(&sc->devlist)
#define FWDEV_DESTROYDEV(sc)
#define FIREWIRE_GENERIC_ATTACH \
@ -1027,7 +1013,7 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
struct firewire_dev_list *devlist, *elm; \
\
devlist = malloc( \
sizeof (struct firewire_dev_list), M_DEVBUF, M_NOWAIT); \
sizeof(struct firewire_dev_list), M_DEVBUF, M_NOWAIT); \
if (devlist == NULL) \
break; \
\
@ -1064,12 +1050,12 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
} while (/*CONSTCOND*/0)
#define FIREWIRE_SBP_ATTACH \
do { \
struct firewire_softc *sc = (struct firewire_softc *)fc->bdev;\
struct firewire_softc *sc = device_private(fc->bdev); \
struct firewire_dev_list *devlist, *elm; \
int locs[IEEE1394IFCF_NLOCS]; \
\
devlist = malloc( \
sizeof (struct firewire_dev_list), M_DEVBUF, M_NOWAIT); \
sizeof(struct firewire_dev_list), M_DEVBUF, M_NOWAIT); \
if (devlist == NULL) { \
printf("memory allocation failed\n"); \
break; \
@ -1100,7 +1086,7 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
} while (/*CONSTCOND*/0)
#define FIREWIRE_SBP_DETACH \
do { \
struct firewire_softc *sc = (struct firewire_softc *)fc->bdev;\
struct firewire_softc *sc = device_private(fc->bdev); \
struct firewire_dev_list *devlist; \
\
SLIST_FOREACH(devlist, &sc->devlist, link) { \
@ -1117,12 +1103,11 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
#define FIREWIRE_CHILDREN_FOREACH_FUNC(func, fdc) \
do { \
struct firewire_dev_list *devlist; \
struct firewire_softc *sc = (struct firewire_softc *)fc->bdev;\
struct firewire_softc *sc = device_private(fc->bdev); \
\
if (!SLIST_EMPTY(&sc->devlist)) { \
SLIST_FOREACH(devlist, &sc->devlist, link) { \
(fdc) = \
(struct firewire_dev_comm *)devlist->dev; \
(fdc) = device_private(devlist->dev); \
if ((fdc)->func != NULL) \
(fdc)->func((fdc)); \
} \
@ -1136,7 +1121,7 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
do { \
aprint_normal(": SBP-2/SCSI over IEEE1394\n"); \
\
sbp->fd.dev = &sbp->fd._dev; \
sbp->fd.dev = self; \
} while (/*CONSTCOND*/0)
#define SBP_SCSIBUS_ATTACH \
do { \
@ -1201,11 +1186,12 @@ fw_bus_dmamem_alloc(fw_bus_dma_tag_t ft, void **vp, int f, bus_dmamap_t *mp)
* fwip macro for NetBSD
*/
#define FWIP_ATTACH_START \
device_t dev = &fwip->fd._dev; \
device_t dev = self; \
struct fw_hwaddr *hwaddr;
#define FWIP_ATTACH_SETUP \
do { \
aprint_normal(": IP over IEEE1394\n"); \
fwip->fd.dev = self; \
fwip->fw_softc.fwip_ifp = &fwip->fw_softc.fwcom.fc_if; \
hwaddr = (struct fw_hwaddr *)&fwip->fw_softc.fwcom.ic_hwaddr; \
} while (/*CONSTCOND*/0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fwip.c,v 1.13 2008/02/07 01:21:54 dyoung Exp $ */
/* $NetBSD: if_fwip.c,v 1.14 2008/03/29 16:22:53 kiyohara Exp $ */
/*-
* Copyright (c) 2004
* Doug Rabson
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.13 2008/02/07 01:21:54 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.14 2008/03/29 16:22:53 kiyohara Exp $");
#ifdef HAVE_KERNEL_OPTION_HEADERS
#include "opt_device_polling.h"
@ -118,10 +118,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.13 2008/02/07 01:21:54 dyoung Exp $");
#define TX_MAX_QUEUE (FWMAXQUEUE - 1)
#if defined(__NetBSD__)
int fwipmatch (struct device *, struct cfdata *, void *);
void fwipattach (struct device *, struct device *, void *);
int fwipdetach (struct device *, int);
int fwipactivate (struct device *, enum devact);
int fwipmatch (device_t, struct cfdata *, void *);
void fwipattach (device_t, device_t, void *);
int fwipdetach (device_t, int);
int fwipactivate (device_t, enum devact);
#endif
/* network interface */
@ -247,7 +247,7 @@ fwip_probe(device_t dev)
}
#elif defined(__NetBSD__)
int
fwipmatch(struct device *parent, struct cfdata *cf, void *aux)
fwipmatch(device_t parent, struct cfdata *cf, void *aux)
{
struct fw_attach_args *fwa = aux;
@ -401,9 +401,9 @@ FW_DETACH(fwip)
#if defined(__NetBSD__)
int
fwipactivate(struct device *self, enum devact act)
fwipactivate(device_t self, enum devact act)
{
struct fwip_softc *fwip = (struct fwip_softc *)self;
struct fwip_softc *fwip = device_private(self);
int s, error = 0;
s = splfwnet();
@ -1129,6 +1129,6 @@ DRIVER_MODULE(fwip, firewire, fwip_driver, fwip_devclass, 0, 0);
MODULE_VERSION(fwip, 1);
MODULE_DEPEND(fwip, firewire, 1, 1, 1);
#elif defined(__NetBSD__)
CFATTACH_DECL(fwip, sizeof (struct fwip_softc),
CFATTACH_DECL_NEW(fwip, sizeof(struct fwip_softc),
fwipmatch, fwipattach, fwipdetach, NULL);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbp.c,v 1.20 2007/12/11 11:34:09 lukem Exp $ */
/* $NetBSD: sbp.c,v 1.21 2008/03/29 16:22:53 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.20 2007/12/11 11:34:09 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.21 2008/03/29 16:22:53 kiyohara Exp $");
#if defined(__FreeBSD__)
#include <sys/param.h>
@ -423,7 +423,7 @@ struct sbp_softc {
#elif defined(__NetBSD__)
struct scsipi_adapter sc_adapter;
struct scsipi_channel sc_channel;
struct device *sc_bus;
device_t sc_bus;
struct lwp *lwp;
#endif
struct sbp_target target;
@ -438,9 +438,9 @@ struct sbp_softc {
#define SBP_UNLOCK(sbp) fw_mtx_unlock(&(sbp)->mtx)
#if defined(__NetBSD__)
int sbpmatch (struct device *, struct cfdata *, void *);
void sbpattach (struct device *parent, struct device *self, void *aux);
int sbpdetach (struct device *self, int flags);
int sbpmatch (device_t, struct cfdata *, void *);
void sbpattach (device_t parent, device_t self, void *aux);
int sbpdetach (device_t self, int flags);
#endif
static void sbp_post_explore (void *);
static void sbp_recv (struct fw_xfer *);
@ -579,7 +579,7 @@ END_DEBUG
}
#elif defined(__NetBSD__)
int
sbpmatch(struct device *parent, struct cfdata *cf, void *aux)
sbpmatch(device_t parent, struct cfdata *cf, void *aux)
{
struct fw_attach_args *fwa = aux;
@ -1210,7 +1210,7 @@ sbp_scan_dev(struct sbp_dev *sdev)
fw_callout_reset(&sdev->target->scan_callout, scan_delay * hz / 1000,
sbp_cam_scan_target, (void *)sdev->target);
}
#else
#elif defined(__NetBSD__)
static void
sbp_scsipi_scan_target(void *arg)
{
@ -1218,7 +1218,7 @@ sbp_scsipi_scan_target(void *arg)
struct sbp_softc *sbp = target->sbp;
struct sbp_dev *sdev;
struct scsipi_channel *chan = &sbp->sc_channel;
struct scsibus_softc *sc_bus = (struct scsibus_softc *)sbp->sc_bus;
struct scsibus_softc *sc_bus = device_private(sbp->sc_bus);
int lun, yet;
do {
@ -3185,7 +3185,7 @@ sbp_scsipi_request(
{
int i, s;
struct sbp_softc *sbp =
(struct sbp_softc *)channel->chan_adapter->adapt_dev;
device_private(channel->chan_adapter->adapt_dev);
struct scsipi_xfer *xs = arg;
if (debug > 1)
@ -3241,6 +3241,6 @@ sbp_minphys(struct buf *bp)
minphys(bp);
}
CFATTACH_DECL(sbp, sizeof (struct sbp_softc),
CFATTACH_DECL_NEW(sbp, sizeof(struct sbp_softc),
sbpmatch, sbpattach, sbpdetach, NULL);
#endif