use device_lookup_private to get softc

use device_lookup to get device_t
This commit is contained in:
cegger 2008-06-12 23:04:37 +00:00
parent 3bde75a1bc
commit ee1dc8ea5f
3 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsdisplay.c,v 1.121 2008/06/11 16:17:01 cegger Exp $ */
/* $NetBSD: wsdisplay.c,v 1.122 2008/06/12 23:04:37 cegger Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.121 2008/06/11 16:17:01 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.122 2008/06/12 23:04:37 cegger Exp $");
#include "opt_wsdisplay_compat.h"
#include "opt_wsmsgattrs.h"
@ -662,7 +662,7 @@ wsdisplay_handlex(int resume)
device_t dv;
for (i = 0; i < wsdisplay_cd.cd_ndevs; i++) {
dv = wsdisplay_cd.cd_devs[i];
dv = device_lookup(&wsdisplay_cd, i);
if (!dv)
continue;
res = wsdisplay_dosync(device_private(dv), resume);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wskbd.c,v 1.119 2008/05/04 13:19:17 martin Exp $ */
/* $NetBSD: wskbd.c,v 1.120 2008/06/12 23:04:37 cegger Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -105,7 +105,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.119 2008/05/04 13:19:17 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.120 2008/06/12 23:04:37 cegger Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -1284,7 +1284,8 @@ wskbd_pickfree(void)
struct wskbd_softc *sc;
for (i = 0; i < wskbd_cd.cd_ndevs; i++) {
if ((sc = device_private(wskbd_cd.cd_devs[i])) == NULL)
sc = device_lookup_private(&wskbd_cd, i);
if (sc == NULL)
continue;
if (sc->sc_base.me_dispdv == NULL)
return (i);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmouse.c,v 1.59 2008/04/30 14:07:14 ad Exp $ */
/* $NetBSD: wsmouse.c,v 1.60 2008/06/12 23:04:37 cegger Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -104,7 +104,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.59 2008/04/30 14:07:14 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.60 2008/06/12 23:04:37 cegger Exp $");
#include "wsmouse.h"
#include "wsdisplay.h"
@ -561,12 +561,11 @@ wsmouseopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct wsmouse_softc *sc;
struct wseventvar *evar;
int error, unit;
int error;
unit = minor(dev);
if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */
(sc = device_private(wsmouse_cd.cd_devs[unit])) == NULL)
return (ENXIO);
sc = device_lookup_private(&wsmouse_cd, minor(dev));
if (sc == NULL)
return ENXIO;
#if NWSMUX > 0
DPRINTF(("wsmouseopen: %s mux=%p p=%p\n", device_xname(sc->sc_base.me_dv),
@ -602,7 +601,7 @@ wsmouseclose(dev_t dev, int flags, int mode,
struct lwp *l)
{
struct wsmouse_softc *sc =
device_private(wsmouse_cd.cd_devs[minor(dev)]);
device_lookup_private(&wsmouse_cd, minor(dev));
struct wseventvar *evar = sc->sc_base.me_evp;
if (evar == NULL)
@ -638,7 +637,7 @@ int
wsmouseread(dev_t dev, struct uio *uio, int flags)
{
struct wsmouse_softc *sc =
device_private(wsmouse_cd.cd_devs[minor(dev)]);
device_lookup_private(&wsmouse_cd, minor(dev));
int error;
if (sc->sc_dying)
@ -663,7 +662,7 @@ wsmouseread(dev_t dev, struct uio *uio, int flags)
int
wsmouseioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
return (wsmousedoioctl(wsmouse_cd.cd_devs[minor(dev)],
return (wsmousedoioctl(device_lookup(&wsmouse_cd, minor(dev)),
cmd, data, flag, l));
}
@ -764,7 +763,7 @@ int
wsmousepoll(dev_t dev, int events, struct lwp *l)
{
struct wsmouse_softc *sc =
device_private(wsmouse_cd.cd_devs[minor(dev)]);
device_lookup_private(&wsmouse_cd, minor(dev));
if (sc->sc_base.me_evp == NULL)
return (POLLERR);
@ -775,7 +774,7 @@ int
wsmousekqfilter(dev_t dev, struct knote *kn)
{
struct wsmouse_softc *sc =
device_private(wsmouse_cd.cd_devs[minor(dev)]);
device_lookup_private(&wsmouse_cd, minor(dev));
if (sc->sc_base.me_evp == NULL)
return (1);
@ -810,9 +809,9 @@ wsmouse_add_mux(int unit, struct wsmux_softc *muxsc)
{
struct wsmouse_softc *sc;
if (unit < 0 || unit >= wsmouse_cd.cd_ndevs ||
(sc = device_private(wsmouse_cd.cd_devs[unit])) == NULL)
return (ENXIO);
sc = device_lookup_private(&wsmouse_cd, unit);
if (sc == NULL)
return ENXIO;
if (sc->sc_base.me_parent != NULL || sc->sc_base.me_evp != NULL)
return (EBUSY);