source: mainline/uspace/drv/hid/adb-mouse/main.c

Last change on this file was 6404aca, checked in by Jakub Jermar <jakub@…>, 7 years ago

Disambiguate doxygroup genarch*

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2017 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup uspace_drv_adb_mouse
30 * @{
31 */
32/** @file ADB mouse driver
33 */
34
35#include <ddf/driver.h>
36#include <ddf/log.h>
37#include <errno.h>
38#include <stdio.h>
39
40#include "adb-mouse.h"
41
42#define NAME "adb-mouse"
43
44static errno_t adb_mouse_dev_add(ddf_dev_t *dev);
45static errno_t adb_mouse_dev_remove(ddf_dev_t *dev);
46static errno_t adb_mouse_dev_gone(ddf_dev_t *dev);
47static errno_t adb_mouse_fun_online(ddf_fun_t *fun);
48static errno_t adb_mouse_fun_offline(ddf_fun_t *fun);
49
50static driver_ops_t driver_ops = {
51 .dev_add = adb_mouse_dev_add,
52 .dev_remove = adb_mouse_dev_remove,
53 .dev_gone = adb_mouse_dev_gone,
54 .fun_online = adb_mouse_fun_online,
55 .fun_offline = adb_mouse_fun_offline
56};
57
58static driver_t adb_mouse_driver = {
59 .name = NAME,
60 .driver_ops = &driver_ops
61};
62
63static errno_t adb_mouse_dev_add(ddf_dev_t *dev)
64{
65 adb_mouse_t *adb_mouse;
66
67 ddf_msg(LVL_DEBUG, "adb_mouse_dev_add(%p)", dev);
68 adb_mouse = ddf_dev_data_alloc(dev, sizeof(adb_mouse_t));
69 if (adb_mouse == NULL) {
70 ddf_msg(LVL_ERROR, "Failed allocating soft state.");
71 return ENOMEM;
72 }
73
74 adb_mouse->dev = dev;
75
76 return adb_mouse_add(adb_mouse);
77}
78
79static errno_t adb_mouse_dev_remove(ddf_dev_t *dev)
80{
81 adb_mouse_t *adb_mouse = (adb_mouse_t *)ddf_dev_data_get(dev);
82
83 ddf_msg(LVL_DEBUG, "adb_mouse_dev_remove(%p)", dev);
84
85 return adb_mouse_remove(adb_mouse);
86}
87
88static errno_t adb_mouse_dev_gone(ddf_dev_t *dev)
89{
90 adb_mouse_t *adb_mouse = (adb_mouse_t *)ddf_dev_data_get(dev);
91
92 ddf_msg(LVL_DEBUG, "adb_mouse_dev_gone(%p)", dev);
93
94 return adb_mouse_gone(adb_mouse);
95}
96
97static errno_t adb_mouse_fun_online(ddf_fun_t *fun)
98{
99 ddf_msg(LVL_DEBUG, "adb_mouse_fun_online()");
100 return ddf_fun_online(fun);
101}
102
103static errno_t adb_mouse_fun_offline(ddf_fun_t *fun)
104{
105 ddf_msg(LVL_DEBUG, "adb_mouse_fun_offline()");
106 return ddf_fun_offline(fun);
107}
108
109int main(int argc, char *argv[])
110{
111 printf(NAME ": ADB mouse driver\n");
112 ddf_log_init(NAME);
113 return ddf_driver_main(&adb_mouse_driver);
114}
115
116/** @}
117 */
Note: See TracBrowser for help on using the repository browser.