source: mainline/uspace/drv/bus/usb/usbdiag/device.c@ a8723748

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a8723748 was b7e1458, checked in by Petr Mánek <petr.manek@…>, 8 years ago

usbdiag: rename usbdbg to usbdiag

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * Copyright (c) 2017 Petr Manek
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 drvusbdiag
30 * @{
31 */
32/**
33 * @file
34 * Code for managing debug device structures.
35 */
36#include <errno.h>
37#include <usb/debug.h>
38
39#include "device.h"
40
41#define NAME "usbdiag"
42
43static int device_init(usb_diag_dev_t *dev)
44{
45 // TODO: allocate data structures, set up stuffs
46
47 return EOK;
48}
49
50static void device_fini(usb_diag_dev_t *dev)
51{
52 // TODO: tear down data structures
53}
54
55int usb_diag_dev_create(usb_device_t *dev, usb_diag_dev_t **out_diag_dev)
56{
57 assert(dev);
58 assert(out_diag_dev);
59
60 usb_diag_dev_t *diag_dev = usb_device_data_alloc(dev, sizeof(usb_diag_dev_t));
61 if (!diag_dev)
62 return ENOMEM;
63
64 diag_dev->usb_dev = dev;
65
66 int err;
67 if ((err = device_init(diag_dev)))
68 goto err_init;
69
70 *out_diag_dev = diag_dev;
71 return EOK;
72
73err_init:
74 /* There is no usb_device_data_free. */
75 return err;
76}
77
78void usb_diag_dev_destroy(usb_diag_dev_t *dev)
79{
80 assert(dev);
81
82 device_fini(dev);
83 /* There is no usb_device_data_free. */
84}
85
86/**
87 * @}
88 */
Note: See TracBrowser for help on using the repository browser.