Fix compile problem with suspend due to a missed
[linux-2.6/history.git] / net / bluetooth / hci_proc.c
blob494436344b1c3fbc62a53b8071ce60fe5c9908da
1 /*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
26 * Bluetooth HCI Proc FS support.
28 * $Id: hci_proc.c,v 1.0 2002/04/17 17:37:16 maxk Exp $
31 #include <linux/config.h>
32 #include <linux/module.h>
34 #include <linux/types.h>
35 #include <linux/errno.h>
36 #include <linux/kernel.h>
37 #include <linux/major.h>
38 #include <linux/fcntl.h>
39 #include <linux/init.h>
40 #include <linux/proc_fs.h>
41 #include <linux/seq_file.h>
42 #include <net/sock.h>
44 #include <net/bluetooth/bluetooth.h>
45 #include <net/bluetooth/hci_core.h>
47 #ifndef CONFIG_BT_HCI_CORE_DEBUG
48 #undef BT_DBG
49 #define BT_DBG( A... )
50 #endif
52 #ifdef CONFIG_PROC_FS
53 struct proc_dir_entry *proc_bt_hci;
55 static int hci_seq_open(struct file *file, struct seq_operations *op, void *priv)
57 struct seq_file *seq;
59 if (seq_open(file, op))
60 return -ENOMEM;
62 seq = file->private_data;
63 seq->private = priv;
64 return 0;
67 static void *inq_seq_start(struct seq_file *seq, loff_t *pos)
69 struct hci_dev *hdev = seq->private;
70 struct inquiry_entry *inq;
71 loff_t l = *pos;
73 hci_dev_lock_bh(hdev);
75 for (inq = hdev->inq_cache.list; inq; inq = inq->next)
76 if (!l--)
77 return inq;
78 return NULL;
81 static void *inq_seq_next(struct seq_file *seq, void *e, loff_t *pos)
83 struct inquiry_entry *inq = e;
84 return inq->next;
87 static void inq_seq_stop(struct seq_file *seq, void *e)
89 struct hci_dev *hdev = seq->private;
90 hci_dev_unlock_bh(hdev);
93 static int inq_seq_show(struct seq_file *seq, void *e)
95 struct inquiry_entry *inq = e;
96 struct inquiry_info *info = &inq->info;
98 seq_printf(seq, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %u\n", batostr(&info->bdaddr),
99 info->pscan_rep_mode, info->pscan_period_mode, info->pscan_mode,
100 info->dev_class[0], info->dev_class[1], info->dev_class[2],
101 info->clock_offset, inq->timestamp);
102 return 0;
105 static struct seq_operations inq_seq_ops = {
106 .start = inq_seq_start,
107 .next = inq_seq_next,
108 .stop = inq_seq_stop,
109 .show = inq_seq_show
112 static int inq_seq_open(struct inode *inode, struct file *file)
114 return hci_seq_open(file, &inq_seq_ops, PDE(inode)->data);
117 static struct file_operations inq_seq_fops = {
118 .owner = THIS_MODULE,
119 .open = inq_seq_open,
120 .read = seq_read,
121 .llseek = seq_lseek,
122 .release = seq_release,
125 int hci_dev_proc_init(struct hci_dev *hdev)
127 struct proc_dir_entry *e;
128 char id[10];
130 sprintf(id, "%d", hdev->id);
132 hdev->proc = proc_mkdir(id, proc_bt_hci);
133 if (!hdev->proc)
134 return -ENOMEM;
136 e = create_proc_entry("inquiry_cache", S_IRUGO, hdev->proc);
137 if (e) {
138 e->proc_fops = &inq_seq_fops;
139 e->data = (void *) hdev;
142 return 0;
145 void hci_dev_proc_cleanup(struct hci_dev *hdev)
147 char id[10];
148 sprintf(id, "%d", hdev->id);
150 remove_proc_entry("inquiry_cache", hdev->proc);
152 remove_proc_entry(id, proc_bt_hci);
155 int __init hci_proc_init(void)
157 proc_bt_hci = proc_mkdir("hci", proc_bt);
158 return 0;
161 void __exit hci_proc_cleanup(void)
163 remove_proc_entry("hci", proc_bt);
166 #else /* CONFIG_PROC_FS */
168 int hci_dev_proc_init(struct hci_dev *hdev)
170 return 0;
173 void hci_dev_proc_cleanup(struct hci_dev *hdev)
175 return;
178 int __init hci_proc_init(void)
180 return 0;
183 void __exit hci_proc_cleanup(void)
185 return;
188 #endif /* CONFIG_PROC_FS */