Add support for uhidev children (eg, ums, ukbd) as rnd entropy

sources.

Multifunction devices, such as keyboards with built-in mice or
scrollwheels on different interfaces and/or repid's are each handled
as a separate entropy source.
This commit is contained in:
dan 2002-10-08 09:56:17 +00:00
parent 20040ef785
commit 234b471752
2 changed files with 22 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhidev.c,v 1.8 2002/09/27 03:18:21 thorpej Exp $ */
/* $NetBSD: uhidev.c,v 1.9 2002/10/08 09:56:17 dan Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -234,6 +234,11 @@ USB_ATTACH(uhidev)
USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
}
#endif
#if NRND > 0
rnd_attach_source(&dev->rnd_source,
USBDEVNAME(dev->sc_dev),
RND_TYPE_TTY, 0);
#endif
}
}
@ -324,6 +329,9 @@ USB_DETACH(uhidev)
rv = 0;
for (i = 0; i < sc->sc_nrepid; i++) {
if (sc->sc_subdevs[i] != NULL) {
#if NRND > 0
rnd_detach_source(&sc->sc_subdevs[i]->rnd_source);
#endif
rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags);
sc->sc_subdevs[i] = NULL;
}
@ -386,6 +394,9 @@ uhidev_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
if (scd->sc_in_rep_size != cc)
printf("%s: bad input length %d != %d\n",USBDEVNAME(sc->sc_dev),
scd->sc_in_rep_size, cc);
#endif
#if NRND > 0
rnd_add_uint32(&scd->rnd_source, (u_int32_t)(sc->sc_ibuf));
#endif
scd->sc_intr(scd, p, cc);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhidev.h,v 1.2 2001/12/29 18:56:52 augustss Exp $ */
/* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,6 +37,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "rnd.h"
#if NRND > 0
#include <sys/rnd.h>
#endif
#include "locators.h"
#define uhidevcf_reportid cf_loc[UHIDBUSCF_REPORTID]
#define UHIDEV_UNK_REPORTID UHIDBUSCF_REPORTID_DEFAULT
@ -69,6 +75,9 @@ struct uhidev {
int sc_in_rep_size;
#define UHIDEV_OPEN 0x01 /* device is open */
void (*sc_intr)(struct uhidev *, void *, u_int);
#if NRND > 0
rndsource_element_t rnd_source;
#endif
};
struct uhidev_attach_arg {