Skip to content

Commit be9d122

Browse files
holtmanndavem330
authored andcommitted
[Bluetooth]: Remove the usage of /proc completely
This patch removes all relics of the /proc usage from the Bluetooth subsystem core and its upper layers. All the previous information are now available via /sys/class/bluetooth through appropriate functions. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1ebb925 commit be9d122

9 files changed

Lines changed: 65 additions & 368 deletions

File tree

‎include/net/bluetooth/bluetooth.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg)
5858
#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg)
5959

60-
extern struct proc_dir_entry *proc_bt;
61-
6260
/* Connection and socket states */
6361
enum {
6462
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
@@ -177,4 +175,6 @@ extern int hci_sock_cleanup(void);
177175
extern int bt_sysfs_init(void);
178176
extern void bt_sysfs_cleanup(void);
179177

178+
extern struct class bt_class;
179+
180180
#endif /* __BLUETOOTH_H */

‎include/net/bluetooth/hci_core.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#ifndef __HCI_CORE_H
2626
#define __HCI_CORE_H
2727

28-
#include <linux/proc_fs.h>
2928
#include <net/bluetooth/hci.h>
3029

3130
/* HCI upper protocols */
@@ -34,8 +33,6 @@
3433

3534
#define HCI_INIT_TIMEOUT (HZ * 10)
3635

37-
extern struct proc_dir_entry *proc_bt_hci;
38-
3936
/* HCI Core structures */
4037

4138
struct inquiry_data {
@@ -126,10 +123,6 @@ struct hci_dev {
126123

127124
atomic_t promisc;
128125

129-
#ifdef CONFIG_PROC_FS
130-
struct proc_dir_entry *proc;
131-
#endif
132-
133126
struct class_device class_dev;
134127

135128
struct module *owner;

‎include/net/bluetooth/rfcomm.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,4 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
351351
int rfcomm_init_ttys(void);
352352
void rfcomm_cleanup_ttys(void);
353353

354-
extern struct proc_dir_entry *proc_bt_rfcomm;
355-
356354
#endif /* __RFCOMM_H */

‎net/bluetooth/af_bluetooth.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <linux/skbuff.h>
3737
#include <linux/init.h>
3838
#include <linux/poll.h>
39-
#include <linux/proc_fs.h>
4039
#include <net/sock.h>
4140

4241
#if defined(CONFIG_KMOD)
@@ -50,10 +49,7 @@
5049
#define BT_DBG(D...)
5150
#endif
5251

53-
#define VERSION "2.7"
54-
55-
struct proc_dir_entry *proc_bt;
56-
EXPORT_SYMBOL(proc_bt);
52+
#define VERSION "2.8"
5753

5854
/* Bluetooth sockets */
5955
#define BT_MAX_PROTO 8
@@ -312,10 +308,6 @@ static int __init bt_init(void)
312308
{
313309
BT_INFO("Core ver %s", VERSION);
314310

315-
proc_bt = proc_mkdir("bluetooth", NULL);
316-
if (proc_bt)
317-
proc_bt->owner = THIS_MODULE;
318-
319311
sock_register(&bt_sock_family_ops);
320312

321313
BT_INFO("HCI device and connection manager initialized");
@@ -334,8 +326,6 @@ static void __exit bt_exit(void)
334326
bt_sysfs_cleanup();
335327

336328
sock_unregister(PF_BLUETOOTH);
337-
338-
remove_proc_entry("bluetooth", NULL);
339329
}
340330

341331
subsys_initcall(bt_init);

‎net/bluetooth/hci_sysfs.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ static void bt_release(struct class_device *cdev)
103103
kfree(hdev);
104104
}
105105

106-
static struct class bt_class = {
106+
struct class bt_class = {
107107
.name = "bluetooth",
108108
.release = bt_release,
109109
#ifdef CONFIG_HOTPLUG
110110
.hotplug = bt_hotplug,
111111
#endif
112112
};
113113

114+
EXPORT_SYMBOL_GPL(bt_class);
115+
114116
int hci_register_sysfs(struct hci_dev *hdev)
115117
{
116118
struct class_device *cdev = &hdev->class_dev;

‎net/bluetooth/l2cap.c‎

Lines changed: 16 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
#include <linux/interrupt.h>
3939
#include <linux/socket.h>
4040
#include <linux/skbuff.h>
41-
#include <linux/proc_fs.h>
42-
#include <linux/seq_file.h>
4341
#include <linux/list.h>
42+
#include <linux/device.h>
4443
#include <net/sock.h>
4544

4645
#include <asm/system.h>
@@ -56,7 +55,7 @@
5655
#define BT_DBG(D...)
5756
#endif
5857

59-
#define VERSION "2.7"
58+
#define VERSION "2.8"
6059

6160
static struct proto_ops l2cap_sock_ops;
6261

@@ -2137,94 +2136,29 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
21372136
return 0;
21382137
}
21392138

2140-
/* ---- Proc fs support ---- */
2141-
#ifdef CONFIG_PROC_FS
2142-
static void *l2cap_seq_start(struct seq_file *seq, loff_t *pos)
2139+
static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
21432140
{
21442141
struct sock *sk;
21452142
struct hlist_node *node;
2146-
loff_t l = *pos;
2143+
char *str = buf;
21472144

21482145
read_lock_bh(&l2cap_sk_list.lock);
21492146

2150-
sk_for_each(sk, node, &l2cap_sk_list.head)
2151-
if (!l--)
2152-
goto found;
2153-
sk = NULL;
2154-
found:
2155-
return sk;
2156-
}
2147+
sk_for_each(sk, node, &l2cap_sk_list.head) {
2148+
struct l2cap_pinfo *pi = l2cap_pi(sk);
21572149

2158-
static void *l2cap_seq_next(struct seq_file *seq, void *e, loff_t *pos)
2159-
{
2160-
(*pos)++;
2161-
return sk_next(e);
2162-
}
2150+
str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d 0x%x\n",
2151+
batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2152+
sk->sk_state, pi->psm, pi->scid, pi->dcid, pi->imtu,
2153+
pi->omtu, pi->link_mode);
2154+
}
21632155

2164-
static void l2cap_seq_stop(struct seq_file *seq, void *e)
2165-
{
21662156
read_unlock_bh(&l2cap_sk_list.lock);
2167-
}
21682157

2169-
static int l2cap_seq_show(struct seq_file *seq, void *e)
2170-
{
2171-
struct sock *sk = e;
2172-
struct l2cap_pinfo *pi = l2cap_pi(sk);
2173-
2174-
seq_printf(seq, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d 0x%x\n",
2175-
batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2176-
sk->sk_state, pi->psm, pi->scid, pi->dcid, pi->imtu,
2177-
pi->omtu, pi->link_mode);
2178-
return 0;
2158+
return (str - buf);
21792159
}
21802160

2181-
static struct seq_operations l2cap_seq_ops = {
2182-
.start = l2cap_seq_start,
2183-
.next = l2cap_seq_next,
2184-
.stop = l2cap_seq_stop,
2185-
.show = l2cap_seq_show
2186-
};
2187-
2188-
static int l2cap_seq_open(struct inode *inode, struct file *file)
2189-
{
2190-
return seq_open(file, &l2cap_seq_ops);
2191-
}
2192-
2193-
static struct file_operations l2cap_seq_fops = {
2194-
.owner = THIS_MODULE,
2195-
.open = l2cap_seq_open,
2196-
.read = seq_read,
2197-
.llseek = seq_lseek,
2198-
.release = seq_release,
2199-
};
2200-
2201-
static int __init l2cap_proc_init(void)
2202-
{
2203-
struct proc_dir_entry *p = create_proc_entry("l2cap", S_IRUGO, proc_bt);
2204-
if (!p)
2205-
return -ENOMEM;
2206-
p->owner = THIS_MODULE;
2207-
p->proc_fops = &l2cap_seq_fops;
2208-
return 0;
2209-
}
2210-
2211-
static void __exit l2cap_proc_cleanup(void)
2212-
{
2213-
remove_proc_entry("l2cap", proc_bt);
2214-
}
2215-
2216-
#else /* CONFIG_PROC_FS */
2217-
2218-
static int __init l2cap_proc_init(void)
2219-
{
2220-
return 0;
2221-
}
2222-
2223-
static void __exit l2cap_proc_cleanup(void)
2224-
{
2225-
return;
2226-
}
2227-
#endif /* CONFIG_PROC_FS */
2161+
static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
22282162

22292163
static struct proto_ops l2cap_sock_ops = {
22302164
.family = PF_BLUETOOTH,
@@ -2266,7 +2200,7 @@ static struct hci_proto l2cap_hci_proto = {
22662200
static int __init l2cap_init(void)
22672201
{
22682202
int err;
2269-
2203+
22702204
err = proto_register(&l2cap_proto, 0);
22712205
if (err < 0)
22722206
return err;
@@ -2284,7 +2218,7 @@ static int __init l2cap_init(void)
22842218
goto error;
22852219
}
22862220

2287-
l2cap_proc_init();
2221+
class_create_file(&bt_class, &class_attr_l2cap);
22882222

22892223
BT_INFO("L2CAP ver %s", VERSION);
22902224
BT_INFO("L2CAP socket layer initialized");
@@ -2298,7 +2232,7 @@ static int __init l2cap_init(void)
22982232

22992233
static void __exit l2cap_exit(void)
23002234
{
2301-
l2cap_proc_cleanup();
2235+
class_remove_file(&bt_class, &class_attr_l2cap);
23022236

23032237
if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
23042238
BT_ERR("L2CAP socket unregistration failed");

0 commit comments

Comments
 (0)