Skip to content

Commit

Permalink
[Bluetooth]: Remove the usage of /proc completely
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marcel Holtmann authored and David S. Miller committed Nov 8, 2005
1 parent 1ebb925 commit be9d122
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 368 deletions.
4 changes: 2 additions & 2 deletions include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
#define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg)
#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg)

extern struct proc_dir_entry *proc_bt;

/* Connection and socket states */
enum {
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
Expand Down Expand Up @@ -177,4 +175,6 @@ extern int hci_sock_cleanup(void);
extern int bt_sysfs_init(void);
extern void bt_sysfs_cleanup(void);

extern struct class bt_class;

#endif /* __BLUETOOTH_H */
7 changes: 0 additions & 7 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#ifndef __HCI_CORE_H
#define __HCI_CORE_H

#include <linux/proc_fs.h>
#include <net/bluetooth/hci.h>

/* HCI upper protocols */
Expand All @@ -34,8 +33,6 @@

#define HCI_INIT_TIMEOUT (HZ * 10)

extern struct proc_dir_entry *proc_bt_hci;

/* HCI Core structures */

struct inquiry_data {
Expand Down Expand Up @@ -126,10 +123,6 @@ struct hci_dev {

atomic_t promisc;

#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc;
#endif

struct class_device class_dev;

struct module *owner;
Expand Down
2 changes: 0 additions & 2 deletions include/net/bluetooth/rfcomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,4 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
int rfcomm_init_ttys(void);
void rfcomm_cleanup_ttys(void);

extern struct proc_dir_entry *proc_bt_rfcomm;

#endif /* __RFCOMM_H */
12 changes: 1 addition & 11 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <net/sock.h>

#if defined(CONFIG_KMOD)
Expand All @@ -50,10 +49,7 @@
#define BT_DBG(D...)
#endif

#define VERSION "2.7"

struct proc_dir_entry *proc_bt;
EXPORT_SYMBOL(proc_bt);
#define VERSION "2.8"

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

proc_bt = proc_mkdir("bluetooth", NULL);
if (proc_bt)
proc_bt->owner = THIS_MODULE;

sock_register(&bt_sock_family_ops);

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

sock_unregister(PF_BLUETOOTH);

remove_proc_entry("bluetooth", NULL);
}

subsys_initcall(bt_init);
Expand Down
4 changes: 3 additions & 1 deletion net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ static void bt_release(struct class_device *cdev)
kfree(hdev);
}

static struct class bt_class = {
struct class bt_class = {
.name = "bluetooth",
.release = bt_release,
#ifdef CONFIG_HOTPLUG
.hotplug = bt_hotplug,
#endif
};

EXPORT_SYMBOL_GPL(bt_class);

int hci_register_sysfs(struct hci_dev *hdev)
{
struct class_device *cdev = &hdev->class_dev;
Expand Down
98 changes: 16 additions & 82 deletions net/bluetooth/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
#include <linux/interrupt.h>
#include <linux/socket.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/list.h>
#include <linux/device.h>
#include <net/sock.h>

#include <asm/system.h>
Expand All @@ -56,7 +55,7 @@
#define BT_DBG(D...)
#endif

#define VERSION "2.7"
#define VERSION "2.8"

static struct proto_ops l2cap_sock_ops;

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

/* ---- Proc fs support ---- */
#ifdef CONFIG_PROC_FS
static void *l2cap_seq_start(struct seq_file *seq, loff_t *pos)
static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
{
struct sock *sk;
struct hlist_node *node;
loff_t l = *pos;
char *str = buf;

read_lock_bh(&l2cap_sk_list.lock);

sk_for_each(sk, node, &l2cap_sk_list.head)
if (!l--)
goto found;
sk = NULL;
found:
return sk;
}
sk_for_each(sk, node, &l2cap_sk_list.head) {
struct l2cap_pinfo *pi = l2cap_pi(sk);

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

static void l2cap_seq_stop(struct seq_file *seq, void *e)
{
read_unlock_bh(&l2cap_sk_list.lock);
}

static int l2cap_seq_show(struct seq_file *seq, void *e)
{
struct sock *sk = e;
struct l2cap_pinfo *pi = l2cap_pi(sk);

seq_printf(seq, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d 0x%x\n",
batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
sk->sk_state, pi->psm, pi->scid, pi->dcid, pi->imtu,
pi->omtu, pi->link_mode);
return 0;
return (str - buf);
}

static struct seq_operations l2cap_seq_ops = {
.start = l2cap_seq_start,
.next = l2cap_seq_next,
.stop = l2cap_seq_stop,
.show = l2cap_seq_show
};

static int l2cap_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &l2cap_seq_ops);
}

static struct file_operations l2cap_seq_fops = {
.owner = THIS_MODULE,
.open = l2cap_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static int __init l2cap_proc_init(void)
{
struct proc_dir_entry *p = create_proc_entry("l2cap", S_IRUGO, proc_bt);
if (!p)
return -ENOMEM;
p->owner = THIS_MODULE;
p->proc_fops = &l2cap_seq_fops;
return 0;
}

static void __exit l2cap_proc_cleanup(void)
{
remove_proc_entry("l2cap", proc_bt);
}

#else /* CONFIG_PROC_FS */

static int __init l2cap_proc_init(void)
{
return 0;
}

static void __exit l2cap_proc_cleanup(void)
{
return;
}
#endif /* CONFIG_PROC_FS */
static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);

static struct proto_ops l2cap_sock_ops = {
.family = PF_BLUETOOTH,
Expand Down Expand Up @@ -2266,7 +2200,7 @@ static struct hci_proto l2cap_hci_proto = {
static int __init l2cap_init(void)
{
int err;

err = proto_register(&l2cap_proto, 0);
if (err < 0)
return err;
Expand All @@ -2284,7 +2218,7 @@ static int __init l2cap_init(void)
goto error;
}

l2cap_proc_init();
class_create_file(&bt_class, &class_attr_l2cap);

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

static void __exit l2cap_exit(void)
{
l2cap_proc_cleanup();
class_remove_file(&bt_class, &class_attr_l2cap);

if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
BT_ERR("L2CAP socket unregistration failed");
Expand Down
Loading

0 comments on commit be9d122

Please sign in to comment.