Annotation of sys/dev/usb/uberry.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: uberry.c,v 1.10 2007/06/14 10:11:15 mbalmer Exp $ */
2:
3: /*-
4: * Copyright (c) 2006 Theo de Raadt <deraadt@openbsd.org>
5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #include <sys/param.h>
20: #include <sys/sockio.h>
21: #include <sys/sysctl.h>
22: #include <sys/mbuf.h>
23: #include <sys/kernel.h>
24: #include <sys/socket.h>
25: #include <sys/systm.h>
26: #include <sys/malloc.h>
27: #include <sys/timeout.h>
28: #include <sys/conf.h>
29: #include <sys/device.h>
30:
31: #include <machine/bus.h>
32: #include <machine/endian.h>
33: #include <machine/intr.h>
34:
35: #include <dev/usb/usb.h>
36: #include <dev/usb/usbdi.h>
37: #include <dev/usb/usbdi_util.h>
38: #include <dev/usb/usbdevs.h>
39:
40: struct uberry_softc {
41: struct device sc_dev;
42: usbd_device_handle sc_udev;
43: usbd_interface_handle sc_iface;
44: };
45:
46: #define UBERRY_CONFIG_NO 0
47:
48: struct usb_devno const uberry_devices[] = {
49: { USB_VENDOR_RIM, USB_PRODUCT_RIM_BLACKBERRY }
50: };
51:
52: int uberry_match(struct device *, void *, void *);
53: void uberry_attach(struct device *, struct device *, void *);
54: int uberry_detach(struct device *, int);
55: int uberry_activate(struct device *, enum devact);
56:
57: struct cfdriver uberry_cd = {
58: NULL, "uberry", DV_DULL
59: };
60:
61: const struct cfattach uberry_ca = {
62: sizeof(struct uberry_softc),
63: uberry_match,
64: uberry_attach,
65: uberry_detach,
66: uberry_activate,
67: };
68:
69: int
70: uberry_match(struct device *parent, void *match, void *aux)
71: {
72: struct usb_attach_arg *uaa = aux;
73:
74: if (uaa->iface != NULL)
75: return UMATCH_NONE;
76:
77: return (usb_lookup(uberry_devices, uaa->vendor, uaa->product) != NULL) ?
78: UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
79: }
80:
81: void
82: uberry_attach(struct device *parent, struct device *self, void *aux)
83: {
84: struct uberry_softc *sc = (struct uberry_softc *)self;
85: struct usb_attach_arg *uaa = aux;
86: char *devinfop;
87:
88: sc->sc_udev = uaa->device;
89:
90: devinfop = usbd_devinfo_alloc(uaa->device, 0);
91: printf("\n%s: %s\n", sc->sc_dev.dv_xname, devinfop);
92: usbd_devinfo_free(devinfop);
93:
94: /* Enable the device, then it cannot idle, and will charge */
95: if (usbd_set_config_no(sc->sc_udev, UBERRY_CONFIG_NO, 1) != 0) {
96: printf("%s: could not set configuration no\n",
97: sc->sc_dev.dv_xname);
98: return;
99: }
100: printf("%s: Charging enabled\n", sc->sc_dev.dv_xname);
101:
102: usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
103: &sc->sc_dev);
104: }
105:
106: int
107: uberry_detach(struct device *self, int flags)
108: {
109: struct uberry_softc *sc = (struct uberry_softc *)self;
110:
111: usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
112: &sc->sc_dev);
113:
114: return 0;
115: }
116:
117: int
118: uberry_activate(struct device *self, enum devact act)
119: {
120: switch (act) {
121: case DVACT_ACTIVATE:
122: break;
123:
124: case DVACT_DEACTIVATE:
125: break;
126: }
127: return 0;
128: }
CVSweb