ia64/linux-2.6.18-xen.hg

view drivers/xen/usbfront/usbfront-dbg.c @ 845:4c7eb2e71e9d

pvusb: Fix license headers.

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:11:23 2009 +0100 (2009-03-31)
parents 8f996719f2ff
children
line source
1 /*
2 * usbfront-dbg.c
3 *
4 * Xen USB Virtual Host Controller - debugging
5 *
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 *
22 * or, by your choice,
23 *
24 * When distributed separately from the Linux kernel or incorporated into
25 * other software packages, subject to the following license:
26 *
27 * Permission is hereby granted, free of charge, to any person obtaining a copy
28 * of this software and associated documentation files (the "Software"), to
29 * deal in the Software without restriction, including without limitation the
30 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
31 * sell copies of the Software, and to permit persons to whom the Software is
32 * furnished to do so, subject to the following conditions:
33 *
34 * The above copyright notice and this permission notice shall be included in
35 * all copies or substantial portions of the Software.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
43 * DEALINGS IN THE SOFTWARE.
44 */
46 static ssize_t show_statistics(struct class_device *class_dev, char *buf)
47 {
48 struct usb_bus *bus;
49 struct usb_hcd *hcd;
50 struct usbfront_info *info;
51 unsigned long flags;
52 unsigned temp, size;
53 char *next;
55 bus = class_get_devdata(class_dev);
56 hcd = bus->hcpriv;
57 info = hcd_to_info(hcd);
58 next = buf;
59 size = PAGE_SIZE;
61 spin_lock_irqsave(&info->lock, flags);
63 temp = scnprintf (next, size,
64 "bus %s, device %s\n"
65 "%s\n"
66 "xenhcd, hcd state %d\n",
67 hcd->self.controller->bus->name,
68 hcd->self.controller->bus_id,
69 hcd->product_desc,
70 hcd->state);
71 size -= temp;
72 next += temp;
74 #ifdef XENHCD_STATS
75 temp = scnprintf(next, size,
76 "complete %ld unlink %ld ring_full %ld\n",
77 info->stats.complete, info->stats.unlink, info->stats.ring_full);
78 size -= temp;
79 next += temp;
80 #endif
82 spin_unlock_irqrestore(&info->lock, flags);
84 return PAGE_SIZE - size;
85 }
87 static CLASS_DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
89 static inline void create_debug_file(struct usbfront_info *info)
90 {
91 struct class_device *cldev = info_to_hcd(info)->self.class_dev;
92 class_device_create_file(cldev, &class_device_attr_statistics);
93 }
95 static inline void remove_debug_file(struct usbfront_info *info)
96 {
97 struct class_device *cldev = info_to_hcd(info)->self.class_dev;
98 class_device_remove_file(cldev, &class_device_attr_statistics);
99 }