Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354286
b: refs/heads/master
c: 4df5bb0
h: refs/heads/master
v: v3
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Jan 30, 2013
1 parent 52346c4 commit 7e538e3
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e16d1ded85b9ceddbf8092d239646ee520353e47
refs/heads/master: 4df5bb0464769a07ce6d6a265174477786512f2e
82 changes: 82 additions & 0 deletions trunk/drivers/staging/fwserial/fwserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ static struct kmem_cache *fwtty_txn_cache;
struct tty_driver *fwtty_driver;
static struct tty_driver *fwloop_driver;

static struct dentry *fwserial_debugfs;

struct fwtty_transaction;
typedef void (*fwtty_transaction_cb)(struct fw_card *card, int rcode,
void *data, size_t length,
Expand Down Expand Up @@ -1568,11 +1570,71 @@ static int fwtty_proc_show(struct seq_file *m, void *v)
return 0;
}

static int fwtty_debugfs_stats_show(struct seq_file *m, void *v)
{
struct fw_serial *serial = m->private;
struct fwtty_port *port;
int i;

for (i = 0; i < num_ports; ++i) {
port = fwtty_port_get(serial->ports[i]->index);
if (port) {
seq_printf(m, "%2d:", port->index);
fwtty_proc_show_port(m, port);
fwtty_debugfs_show_port(m, port);
fwtty_port_put(port);
seq_printf(m, "\n");
}
}
return 0;
}

static int fwtty_debugfs_peers_show(struct seq_file *m, void *v)
{
struct fw_serial *serial = m->private;
struct fwtty_peer *peer;

rcu_read_lock();
seq_printf(m, "card: %s guid: %016llx\n",
dev_name(serial->card->device),
(unsigned long long) serial->card->guid);
list_for_each_entry_rcu(peer, &serial->peer_list, list)
fwtty_debugfs_show_peer(m, peer);
rcu_read_unlock();
return 0;
}

static int fwtty_proc_open(struct inode *inode, struct file *fp)
{
return single_open(fp, fwtty_proc_show, NULL);
}

static int fwtty_stats_open(struct inode *inode, struct file *fp)
{
return single_open(fp, fwtty_debugfs_stats_show, inode->i_private);
}

static int fwtty_peers_open(struct inode *inode, struct file *fp)
{
return single_open(fp, fwtty_debugfs_peers_show, inode->i_private);
}

static const struct file_operations fwtty_stats_fops = {
.owner = THIS_MODULE,
.open = fwtty_stats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct file_operations fwtty_peers_fops = {
.owner = THIS_MODULE,
.open = fwtty_peers_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct file_operations fwtty_proc_fops = {
.owner = THIS_MODULE,
.open = fwtty_proc_open,
Expand Down Expand Up @@ -2309,6 +2371,17 @@ static int fwserial_create(struct fw_unit *unit)
serial->ports[j]->loopback = true;
}

if (!IS_ERR_OR_NULL(fwserial_debugfs)) {
serial->debugfs = debugfs_create_dir(dev_name(&unit->device),
fwserial_debugfs);
if (!IS_ERR_OR_NULL(serial->debugfs)) {
debugfs_create_file("peers", 0444, serial->debugfs,
serial, &fwtty_peers_fops);
debugfs_create_file("stats", 0444, serial->debugfs,
serial, &fwtty_stats_fops);
}
}

list_add_rcu(&serial->list, &fwserial_list);

fwtty_notice(&unit, "TTY over FireWire on device %s (guid %016llx)",
Expand All @@ -2321,6 +2394,8 @@ static int fwserial_create(struct fw_unit *unit)
fwtty_err(&unit, "unable to add peer unit device (%d)", err);

/* fall-through to error processing */
debugfs_remove_recursive(serial->debugfs);

list_del_rcu(&serial->list);
if (create_loop_dev)
tty_unregister_device(fwloop_driver, loop_idx(serial->ports[j]));
Expand Down Expand Up @@ -2412,6 +2487,8 @@ static int fwserial_remove(struct device *dev)
/* unlink from the fwserial_list here */
list_del_rcu(&serial->list);

debugfs_remove_recursive(serial->debugfs);

for (i = 0; i < num_ttys; ++i)
fwserial_close_port(fwtty_driver, serial->ports[i]);
if (create_loop_dev)
Expand Down Expand Up @@ -2806,6 +2883,9 @@ static int __init fwserial_init(void)
{
int err, num_loops = !!(create_loop_dev);

/* XXX: placeholder for a "firewire" debugfs node */
fwserial_debugfs = debugfs_create_dir(KBUILD_MODNAME, NULL);

/* num_ttys/num_ports must not be set above the static alloc avail */
if (num_ttys + num_loops > MAX_CARD_PORTS)
num_ttys = MAX_CARD_PORTS - num_loops;
Expand Down Expand Up @@ -2920,6 +3000,7 @@ static int __init fwserial_init(void)
tty_unregister_driver(fwtty_driver);
put_tty:
put_tty_driver(fwtty_driver);
debugfs_remove_recursive(fwserial_debugfs);
return err;
}

Expand All @@ -2935,6 +3016,7 @@ static void __exit fwserial_exit(void)
}
tty_unregister_driver(fwtty_driver);
put_tty_driver(fwtty_driver);
debugfs_remove_recursive(fwserial_debugfs);
}

module_init(fwserial_init);
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/staging/fwserial/fwserial.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/serial_reg.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>

#include "dma_fifo.h"

Expand Down Expand Up @@ -338,6 +339,7 @@ struct fw_serial {
struct fw_card *card;
struct kref kref;

struct dentry *debugfs;
struct fwtty_peer *self;

struct list_head list;
Expand Down

0 comments on commit 7e538e3

Please sign in to comment.