4 * Xen USB Virtual Host Controller - debugging
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
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.
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.
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/>.
24 * When distributed separately from the Linux kernel or incorporated into
25 * other software packages, subject to the following license:
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:
34 * The above copyright notice and this permission notice shall be included in
35 * all copies or substantial portions of the Software.
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.
46 static ssize_t show_statistics(struct device *dev,
47 struct device_attribute *attr, char *buf)
50 struct usbfront_info *info;
55 hcd = dev_get_drvdata(dev);
56 info = hcd_to_info(hcd);
60 spin_lock_irqsave(&info->lock, flags);
62 temp = scnprintf(next, size,
65 "xenhcd, hcd state %d\n",
66 hcd->self.controller->bus->name,
67 dev_name(hcd->self.controller),
74 temp = scnprintf(next, size,
75 "complete %ld unlink %ld ring_full %ld\n",
76 info->stats.complete, info->stats.unlink,
77 info->stats.ring_full);
82 spin_unlock_irqrestore(&info->lock, flags);
84 return PAGE_SIZE - size;
87 static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
89 static inline void create_debug_file(struct usbfront_info *info)
91 struct device *dev = info_to_hcd(info)->self.controller;
92 if (device_create_file(dev, &dev_attr_statistics))
93 pr_warning("statistics file not created for %s\n",
94 info_to_hcd(info)->self.bus_name);
97 static inline void remove_debug_file(struct usbfront_info *info)
99 struct device *dev = info_to_hcd(info)->self.controller;
100 device_remove_file(dev, &dev_attr_statistics);