split softc/device_t

This commit is contained in:
matt 2008-03-26 18:04:15 +00:00
parent 595211a098
commit 5d109a29b5
4 changed files with 57 additions and 61 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb_bt.c,v 1.1 2007/04/16 23:34:43 macallan Exp $ */ /* $NetBSD: adb_bt.c,v 1.2 2008/03/26 18:04:15 matt Exp $ */
/*- /*-
* Copyright (c) 2006 Michael Lorenz * Copyright (c) 2006 Michael Lorenz
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: adb_bt.c,v 1.1 2007/04/16 23:34:43 macallan Exp $"); __KERNEL_RCSID(0, "$NetBSD: adb_bt.c,v 1.2 2008/03/26 18:04:15 matt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -72,14 +72,14 @@ __KERNEL_RCSID(0, "$NetBSD: adb_bt.c,v 1.1 2007/04/16 23:34:43 macallan Exp $");
#define BT_F7 0x0c #define BT_F7 0x0c
#define BT_NUMLOCK 0x7f #define BT_NUMLOCK 0x7f
static int adbbt_match(struct device *, struct cfdata *, void *); static int adbbt_match(device_t, cfdata_t, void *);
static void adbbt_attach(struct device *, struct device *, void *); static void adbbt_attach(device_t, device_t, void *);
struct adbbt_softc { struct adbbt_softc {
struct device sc_dev; device_t sc_dev;
struct adb_device *sc_adbdev; struct adb_device *sc_adbdev;
struct adb_bus_accessops *sc_ops; struct adb_bus_accessops *sc_ops;
struct device *sc_wskbddev; device_t sc_wskbddev;
int sc_msg_len; int sc_msg_len;
int sc_event; int sc_event;
int sc_poll; int sc_poll;
@ -92,7 +92,7 @@ struct adbbt_softc {
}; };
/* Driver definition. */ /* Driver definition. */
CFATTACH_DECL(adbbt, sizeof(struct adbbt_softc), CFATTACH_DECL_NEW(adbbt, sizeof(struct adbbt_softc),
adbbt_match, adbbt_attach, NULL, NULL); adbbt_match, adbbt_attach, NULL, NULL);
extern struct cfdriver adbbt_cd; extern struct cfdriver adbbt_cd;
@ -118,10 +118,7 @@ struct wskbd_mapdata adbbt_keymapdata = {
}; };
static int static int
adbbt_match(parent, cf, aux) adbbt_match(device_t parent, cfdata_t cf, void *aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{ {
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
@ -133,12 +130,13 @@ adbbt_match(parent, cf, aux)
} }
static void static void
adbbt_attach(struct device *parent, struct device *self, void *aux) adbbt_attach(device_t parent, device_t self, void *aux)
{ {
struct adbbt_softc *sc = (struct adbbt_softc *)self; struct adbbt_softc *sc = device_private(self);
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
struct wskbddev_attach_args a; struct wskbddev_attach_args a;
sc->sc_dev = self;
sc->sc_ops = aaa->ops; sc->sc_ops = aaa->ops;
sc->sc_adbdev = aaa->dev; sc->sc_adbdev = aaa->dev;
sc->sc_adbdev->cookie = sc; sc->sc_adbdev->cookie = sc;

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb_bus.c,v 1.6 2007/10/19 11:59:36 ad Exp $ */ /* $NetBSD: adb_bus.c,v 1.7 2008/03/26 18:04:15 matt Exp $ */
/*- /*-
* Copyright (c) 2006 Michael Lorenz * Copyright (c) 2006 Michael Lorenz
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: adb_bus.c,v 1.6 2007/10/19 11:59:36 ad Exp $"); __KERNEL_RCSID(0, "$NetBSD: adb_bus.c,v 1.7 2008/03/26 18:04:15 matt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -50,11 +50,11 @@ __KERNEL_RCSID(0, "$NetBSD: adb_bus.c,v 1.6 2007/10/19 11:59:36 ad Exp $");
#define DPRINTF while (0) printf #define DPRINTF while (0) printf
#endif #endif
static int nadb_match(struct device *, struct cfdata *, void *); static int nadb_match(device_t, cfdata_t, void *);
static void nadb_attach(struct device *, struct device *, void *); static void nadb_attach(device_t, device_t, void *);
struct nadb_softc { struct nadb_softc {
struct device sc_dev; device_t sc_dev;
struct adb_bus_accessops *sc_ops; struct adb_bus_accessops *sc_ops;
uint32_t sc_msg; uint32_t sc_msg;
uint32_t sc_event; uint32_t sc_event;
@ -64,10 +64,10 @@ struct nadb_softc {
uint8_t sc_data[16]; uint8_t sc_data[16];
}; };
CFATTACH_DECL(nadb, sizeof(struct nadb_softc), CFATTACH_DECL_NEW(nadb, sizeof(struct nadb_softc),
nadb_match, nadb_attach, NULL, NULL); nadb_match, nadb_attach, NULL, NULL);
static void nadb_init(struct device *); static void nadb_init(device_t );
static void nadb_handler(void *, int, uint8_t *); static void nadb_handler(void *, int, uint8_t *);
static void nadb_send_sync(void *, int, int, uint8_t *); static void nadb_send_sync(void *, int, int, uint8_t *);
static int nadb_register(struct nadb_softc *, int, int, int); static int nadb_register(struct nadb_softc *, int, int, int);
@ -75,28 +75,29 @@ static void nadb_remove(struct nadb_softc *, int);
static int nadb_devprint(void *, const char *); static int nadb_devprint(void *, const char *);
static int static int
nadb_match(struct device *parent, struct cfdata *cf, void *aux) nadb_match(device_t parent, cfdata_t cf, void *aux)
{ {
return 1; return 1;
} }
static void static void
nadb_attach(struct device *parent, struct device *us, void *aux) nadb_attach(device_t parent, device_t self, void *aux)
{ {
struct nadb_softc *sc = (struct nadb_softc *)us; struct nadb_softc *sc = device_private(self);
struct adb_bus_accessops *ops = aux; struct adb_bus_accessops *ops = aux;
sc->sc_dev = self;
sc->sc_ops = ops; sc->sc_ops = ops;
sc->sc_ops->set_handler(sc->sc_ops->cookie, nadb_handler, sc); sc->sc_ops->set_handler(sc->sc_ops->cookie, nadb_handler, sc);
config_interrupts(us, nadb_init); config_interrupts(self, nadb_init);
} }
static void static void
nadb_init(struct device *dev) nadb_init(device_t dev)
{ {
struct nadb_softc *sc = (struct nadb_softc *)dev; struct nadb_softc *sc = device_private(dev);
struct adb_attach_args aaa; struct adb_attach_args aaa;
int i, last_moved_up, devmask = 0; int i, last_moved_up, devmask = 0;
uint8_t cmd[2]; uint8_t cmd[2];
@ -170,7 +171,7 @@ nadb_init(struct device *dev)
sc->sc_devtable[i].original_addr, sc->sc_devtable[i].original_addr,
sc->sc_devtable[i].handler_id); sc->sc_devtable[i].handler_id);
aaa.dev = &sc->sc_devtable[i]; aaa.dev = &sc->sc_devtable[i];
if (config_found(&sc->sc_dev, &aaa, nadb_devprint)) { if (config_found(sc->sc_dev, &aaa, nadb_devprint)) {
devmask |= (1 << i); devmask |= (1 << i);
} else { } else {
printf(" not configured\n"); printf(" not configured\n");
@ -185,7 +186,6 @@ nadb_init(struct device *dev)
int int
nadb_print(void *aux, const char *what) nadb_print(void *aux, const char *what)
{ {
printf(": Apple Desktop Bus\n"); printf(": Apple Desktop Bus\n");
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb_kbd.c,v 1.11 2007/10/10 18:36:52 macallan Exp $ */ /* $NetBSD: adb_kbd.c,v 1.12 2008/03/26 18:04:15 matt Exp $ */
/* /*
* Copyright (C) 1998 Colin Wood * Copyright (C) 1998 Colin Wood
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.11 2007/10/10 18:36:52 macallan Exp $"); __KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.12 2008/03/26 18:04:15 matt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -65,12 +65,12 @@ __KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.11 2007/10/10 18:36:52 macallan Exp $"
#include "wsmouse.h" #include "wsmouse.h"
struct adbkbd_softc { struct adbkbd_softc {
struct device sc_dev; device_t sc_dev;
struct adb_device *sc_adbdev; struct adb_device *sc_adbdev;
struct adb_bus_accessops *sc_ops; struct adb_bus_accessops *sc_ops;
struct device *sc_wskbddev; device_t sc_wskbddev;
#if NWSMOUSE > 0 #if NWSMOUSE > 0
struct device *sc_wsmousedev; device_t sc_wsmousedev;
#endif #endif
struct sysmon_pswitch sc_sm_pbutton; struct sysmon_pswitch sc_sm_pbutton;
int sc_leds; int sc_leds;
@ -94,8 +94,8 @@ struct adbkbd_softc {
/* /*
* Function declarations. * Function declarations.
*/ */
static int adbkbd_match(struct device *, struct cfdata *, void *); static int adbkbd_match(device_t, cfdata_t, void *);
static void adbkbd_attach(struct device *, struct device *, void *); static void adbkbd_attach(device_t, device_t, void *);
static void adbkbd_initleds(struct adbkbd_softc *); static void adbkbd_initleds(struct adbkbd_softc *);
static void adbkbd_keys(struct adbkbd_softc *, uint8_t, uint8_t); static void adbkbd_keys(struct adbkbd_softc *, uint8_t, uint8_t);
@ -103,7 +103,7 @@ static inline void adbkbd_key(struct adbkbd_softc *, uint8_t);
static int adbkbd_wait(struct adbkbd_softc *, int); static int adbkbd_wait(struct adbkbd_softc *, int);
/* Driver definition. */ /* Driver definition. */
CFATTACH_DECL(adbkbd, sizeof(struct adbkbd_softc), CFATTACH_DECL_NEW(adbkbd, sizeof(struct adbkbd_softc),
adbkbd_match, adbkbd_attach, NULL, NULL); adbkbd_match, adbkbd_attach, NULL, NULL);
extern struct cfdriver adbkbd_cd; extern struct cfdriver adbkbd_cd;
@ -163,10 +163,7 @@ static int adbkbd_is_console = 0;
static int adbkbd_console_attached = 0; static int adbkbd_console_attached = 0;
static int static int
adbkbd_match(parent, cf, aux) adbkbd_match(device_t parent, cfdata_t cf, void *aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{ {
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
@ -177,9 +174,9 @@ adbkbd_match(parent, cf, aux)
} }
static void static void
adbkbd_attach(struct device *parent, struct device *self, void *aux) adbkbd_attach(device_t parent, device_t self, void *aux)
{ {
struct adbkbd_softc *sc = (struct adbkbd_softc *)self; struct adbkbd_softc *sc = device_private(self);
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
short cmd; short cmd;
struct wskbddev_attach_args a; struct wskbddev_attach_args a;
@ -187,6 +184,7 @@ adbkbd_attach(struct device *parent, struct device *self, void *aux)
struct wsmousedev_attach_args am; struct wsmousedev_attach_args am;
#endif #endif
sc->sc_dev = self;
sc->sc_ops = aaa->ops; sc->sc_ops = aaa->ops;
sc->sc_adbdev = aaa->dev; sc->sc_adbdev = aaa->dev;
sc->sc_adbdev->cookie = sc; sc->sc_adbdev->cookie = sc;
@ -328,11 +326,11 @@ adbkbd_attach(struct device *parent, struct device *self, void *aux)
/* finally register the power button */ /* finally register the power button */
sysmon_task_queue_init(); sysmon_task_queue_init();
memset(&sc->sc_sm_pbutton, 0, sizeof(struct sysmon_pswitch)); memset(&sc->sc_sm_pbutton, 0, sizeof(struct sysmon_pswitch));
sc->sc_sm_pbutton.smpsw_name = sc->sc_dev.dv_xname; sc->sc_sm_pbutton.smpsw_name = device_xname(sc->sc_dev);
sc->sc_sm_pbutton.smpsw_type = PSWITCH_TYPE_POWER; sc->sc_sm_pbutton.smpsw_type = PSWITCH_TYPE_POWER;
if (sysmon_pswitch_register(&sc->sc_sm_pbutton) != 0) if (sysmon_pswitch_register(&sc->sc_sm_pbutton) != 0)
printf("%s: unable to register power button with sysmon\n", aprint_error_dev(sc->sc_dev,
sc->sc_dev.dv_xname); "unable to register power button with sysmon\n");
} }
static void static void
@ -342,7 +340,7 @@ adbkbd_handler(void *cookie, int len, uint8_t *data)
#ifdef ADBKBD_DEBUG #ifdef ADBKBD_DEBUG
int i; int i;
printf("%s: %02x - ", sc->sc_dev.dv_xname, sc->sc_us); printf("%s: %02x - ", device_xname(sc->sc_dev), sc->sc_us);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
printf(" %02x", data[i]); printf(" %02x", data[i]);
} }
@ -424,8 +422,7 @@ adbkbd_key(struct adbkbd_softc *sc, uint8_t k)
if (sc->sc_poll) { if (sc->sc_poll) {
if (sc->sc_polled_chars >= 16) { if (sc->sc_polled_chars >= 16) {
printf("%s: polling buffer is full\n", aprint_error_dev(sc->sc_dev,"polling buffer is full\n");
sc->sc_dev.dv_xname);
} }
sc->sc_pollbuf[sc->sc_polled_chars] = k; sc->sc_pollbuf[sc->sc_polled_chars] = k;
sc->sc_polled_chars++; sc->sc_polled_chars++;
@ -661,10 +658,10 @@ adbkbd_setup_sysctl(struct adbkbd_softc *sc)
struct sysctlnode *node, *me; struct sysctlnode *node, *me;
int ret; int ret;
DPRINTF("%s: sysctl setup\n", sc->sc_dev.dv_xname); DPRINTF("%s: sysctl setup\n", device_xname(sc->sc_dev));
ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me, ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me,
CTLFLAG_READWRITE, CTLFLAG_READWRITE,
CTLTYPE_NODE, sc->sc_dev.dv_xname, NULL, CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
NULL, 0, NULL, 0, NULL, 0, NULL, 0,
CTL_MACHDEP, CTL_CREATE, CTL_EOL); CTL_MACHDEP, CTL_CREATE, CTL_EOL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb_ms.c,v 1.7 2007/04/16 00:22:55 macallan Exp $ */ /* $NetBSD: adb_ms.c,v 1.8 2008/03/26 18:04:15 matt Exp $ */
/* /*
* Copyright (C) 1998 Colin Wood * Copyright (C) 1998 Colin Wood
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.7 2007/04/16 00:22:55 macallan Exp $"); __KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.8 2008/03/26 18:04:15 matt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -65,7 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.7 2007/04/16 00:22:55 macallan Exp $");
* State info, per mouse instance. * State info, per mouse instance.
*/ */
struct adbms_softc { struct adbms_softc {
struct device sc_dev; device_t sc_dev;
struct adb_device *sc_adbdev; struct adb_device *sc_adbdev;
struct adb_bus_accessops *sc_ops; struct adb_bus_accessops *sc_ops;
@ -104,8 +104,8 @@ struct adbms_softc {
/* /*
* Function declarations. * Function declarations.
*/ */
static int adbms_match(struct device *, struct cfdata *, void *); static int adbms_match(device_t, cfdata_t, void *);
static void adbms_attach(struct device *, struct device *, void *); static void adbms_attach(device_t, device_t, void *);
static void ems_init(struct adbms_softc *); static void ems_init(struct adbms_softc *);
//static void ms_processevent(adb_event_t *event, struct adbms_softc *); //static void ms_processevent(adb_event_t *event, struct adbms_softc *);
static void init_trackpad(struct adbms_softc *); static void init_trackpad(struct adbms_softc *);
@ -116,7 +116,7 @@ static void adbms_process_event(struct adbms_softc *, int, uint8_t *);
static int adbms_send_sync(struct adbms_softc *, uint8_t, int, uint8_t *); static int adbms_send_sync(struct adbms_softc *, uint8_t, int, uint8_t *);
/* Driver definition. */ /* Driver definition. */
CFATTACH_DECL(adbms, sizeof(struct adbms_softc), CFATTACH_DECL_NEW(adbms, sizeof(struct adbms_softc),
adbms_match, adbms_attach, NULL, NULL); adbms_match, adbms_attach, NULL, NULL);
static int adbms_enable(void *); static int adbms_enable(void *);
@ -141,7 +141,7 @@ const struct wsmouse_accessops adbms_accessops = {
}; };
static int static int
adbms_match(struct device *parent, struct cfdata *cf, void *aux) adbms_match(device_t parent, cfdata_t cf, void *aux)
{ {
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
@ -152,12 +152,13 @@ adbms_match(struct device *parent, struct cfdata *cf, void *aux)
} }
static void static void
adbms_attach(struct device *parent, struct device *self, void *aux) adbms_attach(device_t parent, device_t self, void *aux)
{ {
struct adbms_softc *sc = (struct adbms_softc *)self; struct adbms_softc *sc = device_private(self);
struct adb_attach_args *aaa = aux; struct adb_attach_args *aaa = aux;
struct wsmousedev_attach_args a; struct wsmousedev_attach_args a;
sc->sc_dev = self;
sc->sc_ops = aaa->ops; sc->sc_ops = aaa->ops;
sc->sc_adbdev = aaa->dev; sc->sc_adbdev = aaa->dev;
sc->sc_adbdev->cookie = sc; sc->sc_adbdev->cookie = sc;
@ -482,7 +483,7 @@ adbms_handler(void *cookie, int len, uint8_t *data)
#ifdef ADBMS_DEBUG #ifdef ADBMS_DEBUG
int i; int i;
printf("%s: %02x - ", sc->sc_dev.dv_xname, sc->sc_us); printf("%s: %02x - ", device_xname(sc->sc_dev), sc->sc_us);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
printf(" %02x", data[i]); printf(" %02x", data[i]);
} }
@ -732,7 +733,7 @@ init_trackpad(struct adbms_softc *sc)
ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me, ret = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me,
CTLFLAG_READWRITE, CTLFLAG_READWRITE,
CTLTYPE_NODE, sc->sc_dev.dv_xname, NULL, CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
NULL, 0, NULL, 0, NULL, 0, NULL, 0,
CTL_MACHDEP, CTL_CREATE, CTL_EOL); CTL_MACHDEP, CTL_CREATE, CTL_EOL);