mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 03:00:53 +07:00
bluetooth: switch to proc_create_seq_data
And use proc private data directly instead of doing a detour through seq->private and private state. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
1cd6718272
commit
a9170e0a92
@ -605,15 +605,10 @@ int bt_sock_wait_ready(struct sock *sk, unsigned long flags)
|
|||||||
EXPORT_SYMBOL(bt_sock_wait_ready);
|
EXPORT_SYMBOL(bt_sock_wait_ready);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
struct bt_seq_state {
|
|
||||||
struct bt_sock_list *l;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
|
static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
__acquires(seq->private->l->lock)
|
__acquires(seq->private->l->lock)
|
||||||
{
|
{
|
||||||
struct bt_seq_state *s = seq->private;
|
struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
|
||||||
struct bt_sock_list *l = s->l;
|
|
||||||
|
|
||||||
read_lock(&l->lock);
|
read_lock(&l->lock);
|
||||||
return seq_hlist_start_head(&l->head, *pos);
|
return seq_hlist_start_head(&l->head, *pos);
|
||||||
@ -621,8 +616,7 @@ static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
|
|
||||||
static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct bt_seq_state *s = seq->private;
|
struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
|
||||||
struct bt_sock_list *l = s->l;
|
|
||||||
|
|
||||||
return seq_hlist_next(v, &l->head, pos);
|
return seq_hlist_next(v, &l->head, pos);
|
||||||
}
|
}
|
||||||
@ -630,16 +624,14 @@ static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|||||||
static void bt_seq_stop(struct seq_file *seq, void *v)
|
static void bt_seq_stop(struct seq_file *seq, void *v)
|
||||||
__releases(seq->private->l->lock)
|
__releases(seq->private->l->lock)
|
||||||
{
|
{
|
||||||
struct bt_seq_state *s = seq->private;
|
struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
|
||||||
struct bt_sock_list *l = s->l;
|
|
||||||
|
|
||||||
read_unlock(&l->lock);
|
read_unlock(&l->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bt_seq_show(struct seq_file *seq, void *v)
|
static int bt_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct bt_seq_state *s = seq->private;
|
struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
|
||||||
struct bt_sock_list *l = s->l;
|
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN) {
|
if (v == SEQ_START_TOKEN) {
|
||||||
seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Parent");
|
seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Parent");
|
||||||
@ -681,35 +673,13 @@ static const struct seq_operations bt_seq_ops = {
|
|||||||
.show = bt_seq_show,
|
.show = bt_seq_show,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bt_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
struct bt_sock_list *sk_list;
|
|
||||||
struct bt_seq_state *s;
|
|
||||||
|
|
||||||
sk_list = PDE_DATA(inode);
|
|
||||||
s = __seq_open_private(file, &bt_seq_ops,
|
|
||||||
sizeof(struct bt_seq_state));
|
|
||||||
if (!s)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
s->l = sk_list;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations bt_fops = {
|
|
||||||
.open = bt_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = seq_release_private
|
|
||||||
};
|
|
||||||
|
|
||||||
int bt_procfs_init(struct net *net, const char *name,
|
int bt_procfs_init(struct net *net, const char *name,
|
||||||
struct bt_sock_list *sk_list,
|
struct bt_sock_list *sk_list,
|
||||||
int (* seq_show)(struct seq_file *, void *))
|
int (* seq_show)(struct seq_file *, void *))
|
||||||
{
|
{
|
||||||
sk_list->custom_seq_show = seq_show;
|
sk_list->custom_seq_show = seq_show;
|
||||||
|
|
||||||
if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list))
|
if (!proc_create_seq_data(name, 0, net->proc_net, &bt_seq_ops, sk_list))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user