get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1032816/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1032816,
    "url": "http://patchwork.ozlabs.org/api/patches/1032816/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20190129150143.12681-26-mika.westerberg@linux.intel.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": "<20190129150143.12681-26-mika.westerberg@linux.intel.com>",
    "list_archive_url": null,
    "date": "2019-01-29T15:01:40",
    "name": "[25/28] thunderbolt: Make tb_switch_alloc() return ERR_PTR()",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "f83eb9a184ea8331d55048dac845ed0019ff4e8a",
    "submitter": {
        "id": 14534,
        "url": "http://patchwork.ozlabs.org/api/people/14534/?format=api",
        "name": "Mika Westerberg",
        "email": "mika.westerberg@linux.intel.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/20190129150143.12681-26-mika.westerberg@linux.intel.com/mbox/",
    "series": [
        {
            "id": 88859,
            "url": "http://patchwork.ozlabs.org/api/series/88859/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=88859",
            "date": "2019-01-29T15:01:18",
            "name": "thunderbolt: Software connection manager improvements",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/88859/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1032816/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1032816/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming-netdev@ozlabs.org",
        "Delivered-To": "patchwork-incoming-netdev@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>)",
            "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=linux.intel.com"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 43pqTv1TQ1z9sMM\n\tfor <patchwork-incoming-netdev@ozlabs.org>;\n\tWed, 30 Jan 2019 02:02:11 +1100 (AEDT)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1728683AbfA2PCH (ORCPT\n\t<rfc822;patchwork-incoming-netdev@ozlabs.org>);\n\tTue, 29 Jan 2019 10:02:07 -0500",
            "from mga12.intel.com ([192.55.52.136]:8099 \"EHLO mga12.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1728390AbfA2PCA (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 29 Jan 2019 10:02:00 -0500",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Jan 2019 07:01:59 -0800",
            "from black.fi.intel.com ([10.237.72.28])\n\tby orsmga003.jf.intel.com with ESMTP; 29 Jan 2019 07:01:51 -0800",
            "by black.fi.intel.com (Postfix, from userid 1001)\n\tid 6098DD22; Tue, 29 Jan 2019 17:01:45 +0200 (EET)"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,537,1539673200\"; d=\"scan'208\";a=\"122266167\"",
        "From": "Mika Westerberg <mika.westerberg@linux.intel.com>",
        "To": "linux-kernel@vger.kernel.org",
        "Cc": "Michael Jamet <michael.jamet@intel.com>,\n\tYehezkel Bernat <YehezkelShB@gmail.com>,\n\tAndreas Noever <andreas.noever@gmail.com>,\n\tLukas Wunner <lukas@wunner.de>, \"David S . Miller\" <davem@davemloft.net>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tnetdev@vger.kernel.org",
        "Subject": "[PATCH 25/28] thunderbolt: Make tb_switch_alloc() return ERR_PTR()",
        "Date": "Tue, 29 Jan 2019 18:01:40 +0300",
        "Message-Id": "<20190129150143.12681-26-mika.westerberg@linux.intel.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190129150143.12681-1-mika.westerberg@linux.intel.com>",
        "References": "<20190129150143.12681-1-mika.westerberg@linux.intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "In order to detect possible connections to other domains we need to be\nable to find out why tb_switch_alloc() fails so make it return ERR_PTR()\ninstead. This allows the caller to differentiate between errors such as\n-ENOMEM which comes from the kernel and for instance -EIO which comes\nfrom the hardware when trying to access the possible switch.\n\nConvert all the current call sites to handle this properly.\n\nSigned-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>\n---\n drivers/thunderbolt/icm.c    |  6 +++---\n drivers/thunderbolt/switch.c | 36 ++++++++++++++++++++----------------\n drivers/thunderbolt/tb.c     |  6 +++---\n 3 files changed, 26 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c\nindex 041e7ab0efd3..e28a4255d56a 100644\n--- a/drivers/thunderbolt/icm.c\n+++ b/drivers/thunderbolt/icm.c\n@@ -468,7 +468,7 @@ static void add_switch(struct tb_switch *parent_sw, u64 route,\n \tpm_runtime_get_sync(&parent_sw->dev);\n \n \tsw = tb_switch_alloc(parent_sw->tb, &parent_sw->dev, route);\n-\tif (!sw)\n+\tif (IS_ERR(sw))\n \t\tgoto out;\n \n \tsw->uuid = kmemdup(uuid, sizeof(*uuid), GFP_KERNEL);\n@@ -1852,8 +1852,8 @@ static int icm_start(struct tb *tb)\n \t\ttb->root_switch = tb_switch_alloc_safe_mode(tb, &tb->dev, 0);\n \telse\n \t\ttb->root_switch = tb_switch_alloc(tb, &tb->dev, 0);\n-\tif (!tb->root_switch)\n-\t\treturn -ENODEV;\n+\tif (IS_ERR(tb->root_switch))\n+\t\treturn PTR_ERR(tb->root_switch);\n \n \t/*\n \t * NVM upgrade has not been tested on Apple systems and they\ndiff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c\nindex bcf8b447facb..e10bae4a770c 100644\n--- a/drivers/thunderbolt/switch.c\n+++ b/drivers/thunderbolt/switch.c\n@@ -1481,30 +1481,32 @@ static int tb_switch_get_generation(struct tb_switch *sw)\n  * separately. The returned switch should be released by calling\n  * tb_switch_put().\n  *\n- * Return: Pointer to the allocated switch or %NULL in case of failure\n+ * Return: Pointer to the allocated switch or ERR_PTR() in case of\n+ * failure.\n  */\n struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,\n \t\t\t\t  u64 route)\n {\n \tstruct tb_switch *sw;\n \tint upstream_port;\n-\tint i, cap, depth;\n+\tint i, ret, depth;\n \n \t/* Make sure we do not exceed maximum topology limit */\n \tdepth = tb_route_length(route);\n \tif (depth > TB_SWITCH_MAX_DEPTH)\n-\t\treturn NULL;\n+\t\treturn ERR_PTR(-EADDRNOTAVAIL);\n \n \tupstream_port = tb_cfg_get_upstream_port(tb->ctl, route);\n \tif (upstream_port < 0)\n-\t\treturn NULL;\n+\t\treturn ERR_PTR(upstream_port);\n \n \tsw = kzalloc(sizeof(*sw), GFP_KERNEL);\n \tif (!sw)\n-\t\treturn NULL;\n+\t\treturn ERR_PTR(-ENOMEM);\n \n \tsw->tb = tb;\n-\tif (tb_cfg_read(tb->ctl, &sw->config, route, 0, TB_CFG_SWITCH, 0, 5))\n+\tret = tb_cfg_read(tb->ctl, &sw->config, route, 0, TB_CFG_SWITCH, 0, 5);\n+\tif (ret)\n \t\tgoto err_free_sw_ports;\n \n \ttb_dbg(tb, \"current switch config:\\n\");\n@@ -1520,8 +1522,10 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,\n \t/* initialize ports */\n \tsw->ports = kcalloc(sw->config.max_port_number + 1, sizeof(*sw->ports),\n \t\t\t\tGFP_KERNEL);\n-\tif (!sw->ports)\n+\tif (!sw->ports) {\n+\t\tret = -ENOMEM;\n \t\tgoto err_free_sw_ports;\n+\t}\n \n \tfor (i = 0; i <= sw->config.max_port_number; i++) {\n \t\t/* minimum setup for tb_find_cap and tb_drom_read to work */\n@@ -1531,16 +1535,16 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,\n \n \tsw->generation = tb_switch_get_generation(sw);\n \n-\tcap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);\n-\tif (cap < 0) {\n+\tret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);\n+\tif (ret < 0) {\n \t\ttb_sw_warn(sw, \"cannot find TB_VSE_CAP_PLUG_EVENTS aborting\\n\");\n \t\tgoto err_free_sw_ports;\n \t}\n-\tsw->cap_plug_events = cap;\n+\tsw->cap_plug_events = ret;\n \n-\tcap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER);\n-\tif (cap > 0)\n-\t\tsw->cap_lc = cap;\n+\tret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER);\n+\tif (ret > 0)\n+\t\tsw->cap_lc = ret;\n \n \t/* Root switch is always authorized */\n \tif (!route)\n@@ -1559,7 +1563,7 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,\n \tkfree(sw->ports);\n \tkfree(sw);\n \n-\treturn NULL;\n+\treturn ERR_PTR(ret);\n }\n \n /**\n@@ -1574,7 +1578,7 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,\n  *\n  * The returned switch must be released by calling tb_switch_put().\n  *\n- * Return: Pointer to the allocated switch or %NULL in case of failure\n+ * Return: Pointer to the allocated switch or ERR_PTR() in case of failure\n  */\n struct tb_switch *\n tb_switch_alloc_safe_mode(struct tb *tb, struct device *parent, u64 route)\n@@ -1583,7 +1587,7 @@ tb_switch_alloc_safe_mode(struct tb *tb, struct device *parent, u64 route)\n \n \tsw = kzalloc(sizeof(*sw), GFP_KERNEL);\n \tif (!sw)\n-\t\treturn NULL;\n+\t\treturn ERR_PTR(-ENOMEM);\n \n \tsw->tb = tb;\n \tsw->config.depth = tb_route_length(route);\ndiff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c\nindex 56bbd1237bd9..4eb74254116c 100644\n--- a/drivers/thunderbolt/tb.c\n+++ b/drivers/thunderbolt/tb.c\n@@ -155,7 +155,7 @@ static void tb_scan_port(struct tb_port *port)\n \t}\n \tsw = tb_switch_alloc(port->sw->tb, &port->sw->dev,\n \t\t\t     tb_downstream_route(port));\n-\tif (!sw)\n+\tif (IS_ERR(sw))\n \t\treturn;\n \n \tif (tb_switch_configure(sw)) {\n@@ -516,8 +516,8 @@ static int tb_start(struct tb *tb)\n \tint ret;\n \n \ttb->root_switch = tb_switch_alloc(tb, &tb->dev, 0);\n-\tif (!tb->root_switch)\n-\t\treturn -ENOMEM;\n+\tif (IS_ERR(tb->root_switch))\n+\t\treturn PTR_ERR(tb->root_switch);\n \n \t/*\n \t * ICM firmware upgrade needs running firmware and in native\n",
    "prefixes": [
        "25/28"
    ]
}