Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806741/?format=api
{ "id": 806741, "url": "http://patchwork.ozlabs.org/api/patches/806741/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170828191748.19492-3-vivien.didelot@savoirfairelinux.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170828191748.19492-3-vivien.didelot@savoirfairelinux.com>", "list_archive_url": null, "date": "2017-08-28T19:17:40", "name": "[net-next,v2,02/10] net: dsa: debugfs: add tree", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "bd60a7ac4c6a8526deb1a770356d2ccd56aed7fd", "submitter": { "id": 15889, "url": "http://patchwork.ozlabs.org/api/people/15889/?format=api", "name": "Vivien Didelot", "email": "vivien.didelot@savoirfairelinux.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170828191748.19492-3-vivien.didelot@savoirfairelinux.com/mbox/", "series": [ { "id": 246, "url": "http://patchwork.ozlabs.org/api/series/246/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=246", "date": "2017-08-28T19:17:41", "name": "net: dsa: add generic debugfs interface", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/246/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806741/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806741/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xh2475qj3z9s8P\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 29 Aug 2017 05:33:11 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751827AbdH1TXS (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 15:23:18 -0400", "from mail.savoirfairelinux.com ([208.88.110.44]:36434 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751280AbdH1TVl (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 28 Aug 2017 15:21:41 -0400", "from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id ACEA39C1D26;\n\tMon, 28 Aug 2017 15:21:40 -0400 (EDT)", "from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10032)\n\twith ESMTP id 3bgoTaj1S2x0; Mon, 28 Aug 2017 15:21:37 -0400 (EDT)", "from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id A9EFE9C238B;\n\tMon, 28 Aug 2017 15:21:37 -0400 (EDT)", "from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10026)\n\twith ESMTP id GAM_Mp_Z3Wm5; Mon, 28 Aug 2017 15:21:37 -0400 (EDT)", "from weeman.mtl.sfl (unknown [192.168.50.91])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id 65AE89C1BAC;\n\tMon, 28 Aug 2017 15:21:37 -0400 (EDT)" ], "X-Virus-Scanned": "amavisd-new at mail.savoirfairelinux.com", "From": "Vivien Didelot <vivien.didelot@savoirfairelinux.com>", "To": "netdev@vger.kernel.org", "Cc": "linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tFlorian Fainelli <f.fainelli@gmail.com>, Andrew Lunn <andrew@lunn.ch>,\n\tEgil Hjelmeland <privat@egil-hjelmeland.no>,\n\tJohn Crispin <john@phrozen.org>, Woojung Huh <Woojung.Huh@microchip.com>,\n\tSean Wang <sean.wang@mediatek.com>,\n\tNikita Yushchenko <nikita.yoush@cogentembedded.com>,\n\tChris Healy <cphealy@gmail.com>,\n\tVivien Didelot <vivien.didelot@savoirfairelinux.com>", "Subject": "[PATCH net-next v2 02/10] net: dsa: debugfs: add tree", "Date": "Mon, 28 Aug 2017 15:17:40 -0400", "Message-Id": "<20170828191748.19492-3-vivien.didelot@savoirfairelinux.com>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<20170828191748.19492-1-vivien.didelot@savoirfairelinux.com>", "References": "<20170828191748.19492-1-vivien.didelot@savoirfairelinux.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "This commit adds the boiler plate to create a DSA related debug\nfilesystem entry as well as a \"tree\" file, containing the tree index.\n\n # cat switch1/tree\n 0\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\nReviewed-by: Florian Fainelli <f.fainelli@gmail.com>\nReviewed-by: Andrew Lunn <andrew@lunn.ch>\n---\n net/dsa/debugfs.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 107 insertions(+)", "diff": "diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c\nindex b6b5e5c97389..54e97e05a9d7 100644\n--- a/net/dsa/debugfs.c\n+++ b/net/dsa/debugfs.c\n@@ -10,6 +10,7 @@\n */\n \n #include <linux/debugfs.h>\n+#include <linux/seq_file.h>\n \n #include \"dsa_priv.h\"\n \n@@ -19,6 +20,107 @@\n /* DSA module debugfs directory */\n static struct dentry *dsa_debugfs_dir;\n \n+struct dsa_debugfs_ops {\n+\tint (*read)(struct dsa_switch *ds, int id, struct seq_file *seq);\n+\tint (*write)(struct dsa_switch *ds, int id, char *buf);\n+};\n+\n+struct dsa_debugfs_priv {\n+\tconst struct dsa_debugfs_ops *ops;\n+\tstruct dsa_switch *ds;\n+\tint id;\n+};\n+\n+static int dsa_debugfs_show(struct seq_file *seq, void *p)\n+{\n+\tstruct dsa_debugfs_priv *priv = seq->private;\n+\tstruct dsa_switch *ds = priv->ds;\n+\n+\t/* Somehow file mode is bypassed... Double check here */\n+\tif (!priv->ops->read)\n+\t\treturn -EOPNOTSUPP;\n+\n+\treturn priv->ops->read(ds, priv->id, seq);\n+}\n+\n+static ssize_t dsa_debugfs_write(struct file *file, const char __user *user_buf,\n+\t\t\t\t size_t count, loff_t *ppos)\n+{\n+\tstruct seq_file *seq = file->private_data;\n+\tstruct dsa_debugfs_priv *priv = seq->private;\n+\tstruct dsa_switch *ds = priv->ds;\n+\tchar buf[count + 1];\n+\tint err;\n+\n+\t/* Somehow file mode is bypassed... Double check here */\n+\tif (!priv->ops->write)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tif (copy_from_user(buf, user_buf, count))\n+\t\treturn -EFAULT;\n+\n+\tbuf[count] = '\\0';\n+\n+\terr = priv->ops->write(ds, priv->id, buf);\n+\n+\treturn err ? err : count;\n+}\n+\n+static int dsa_debugfs_open(struct inode *inode, struct file *file)\n+{\n+\treturn single_open(file, dsa_debugfs_show, inode->i_private);\n+}\n+\n+static const struct file_operations dsa_debugfs_fops = {\n+\t.open = dsa_debugfs_open,\n+\t.read = seq_read,\n+\t.write = dsa_debugfs_write,\n+\t.llseek = no_llseek,\n+\t.release = single_release,\n+\t.owner = THIS_MODULE,\n+};\n+\n+static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,\n+\t\t\t\t char *name, int id,\n+\t\t\t\t const struct dsa_debugfs_ops *ops)\n+{\n+\tstruct dsa_debugfs_priv *priv;\n+\tstruct dentry *entry;\n+\tumode_t mode;\n+\n+\tpriv = devm_kzalloc(ds->dev, sizeof(*priv), GFP_KERNEL);\n+\tif (!priv)\n+\t\treturn -ENOMEM;\n+\n+\tpriv->ops = ops;\n+\tpriv->ds = ds;\n+\tpriv->id = id;\n+\n+\tmode = 0;\n+\tif (ops->read)\n+\t\tmode |= 0444;\n+\tif (ops->write)\n+\t\tmode |= 0200;\n+\n+\tentry = debugfs_create_file(name, mode, dir, priv, &dsa_debugfs_fops);\n+\tif (IS_ERR_OR_NULL(entry))\n+\t\treturn -EFAULT;\n+\n+\treturn 0;\n+}\n+\n+static int dsa_debugfs_tree_read(struct dsa_switch *ds, int id,\n+\t\t\t\t struct seq_file *seq)\n+{\n+\tseq_printf(seq, \"%d\\n\", ds->dst->tree);\n+\n+\treturn 0;\n+}\n+\n+static const struct dsa_debugfs_ops dsa_debugfs_tree_ops = {\n+\t.read = dsa_debugfs_tree_read,\n+};\n+\n static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)\n {\n \tstruct dentry *dir;\n@@ -48,6 +150,11 @@ static int dsa_debugfs_create_switch(struct dsa_switch *ds)\n \tif (IS_ERR_OR_NULL(ds->debugfs_dir))\n \t\treturn -EFAULT;\n \n+\terr = dsa_debugfs_create_file(ds, ds->debugfs_dir, \"tree\", -1,\n+\t\t\t\t &dsa_debugfs_tree_ops);\n+\tif (err)\n+\t\treturn err;\n+\n \tfor (i = 0; i < ds->num_ports; i++) {\n \t\tif (ds->enabled_port_mask & BIT(i)) {\n \t\t\terr = dsa_debugfs_create_port(ds, i);\n", "prefixes": [ "net-next", "v2", "02/10" ] }