get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 793167,
    "url": "http://patchwork.ozlabs.org/api/patches/793167/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1500954024-6860-2-git-send-email-preid@electromag.com.au/",
    "project": {
        "id": 35,
        "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api",
        "name": "Linux I2C development",
        "link_name": "linux-i2c",
        "list_id": "linux-i2c.vger.kernel.org",
        "list_email": "linux-i2c@vger.kernel.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1500954024-6860-2-git-send-email-preid@electromag.com.au>",
    "list_archive_url": null,
    "date": "2017-07-25T03:40:15",
    "name": "[v10,01/10] i2c: i2c-smbus: Use threaded irq for smbalert",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "a52c36a224f84f2e877a86c2bd01fc4132bbbfca",
    "submitter": {
        "id": 66145,
        "url": "http://patchwork.ozlabs.org/api/people/66145/?format=api",
        "name": "Phil Reid",
        "email": "preid@electromag.com.au"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1500954024-6860-2-git-send-email-preid@electromag.com.au/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/793167/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/793167/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linux-i2c-owner@vger.kernel.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.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=linux-i2c-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 3xGkXl37h1z9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 25 Jul 2017 13:40:39 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755165AbdGYDkg (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 24 Jul 2017 23:40:36 -0400",
            "from anchovy1.45ru.net.au ([203.30.46.145]:36557 \"EHLO\n\tanchovy.45ru.net.au\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1753468AbdGYDkf (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Mon, 24 Jul 2017 23:40:35 -0400",
            "(qmail 7145 invoked by uid 5089); 25 Jul 2017 03:40:33 -0000",
            "by simscan 1.2.0 ppid: 7037, pid: 7040, t: 0.0537s\n\tscanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950",
            "from unknown (HELO preid-centos7.electromag.com.au)\n\t(preid@electromag.com.au@203.59.230.133)\n\tby anchovy1.45ru.net.au with ESMTPA; 25 Jul 2017 03:40:32 -0000",
            "by preid-centos7.electromag.com.au (Postfix, from userid 1000)\n\tid 7F6C1302644C1; Tue, 25 Jul 2017 11:40:29 +0800 (AWST)"
        ],
        "X-RBL": "$rbltext",
        "From": "Phil Reid <preid@electromag.com.au>",
        "To": "wsa@the-dreams.de, robh+dt@kernel.org, mark.rutland@arm.com,\n\tsre@kernel.org, jdelvare@suse.com, jglauber@cavium.com,\n\tdavid.daney@cavium.com, peda@axentia.se, preid@electromag.com.au,\n\tbenjamin.tissoires@redhat.com, linux-i2c@vger.kernel.org,\n\tdevicetree@vger.kernel.org, linux-pm@vger.kernel.org",
        "Subject": "[PATCH v10 01/10] i2c: i2c-smbus: Use threaded irq for smbalert",
        "Date": "Tue, 25 Jul 2017 11:40:15 +0800",
        "Message-Id": "<1500954024-6860-2-git-send-email-preid@electromag.com.au>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1500954024-6860-1-git-send-email-preid@electromag.com.au>",
        "References": "<1500954024-6860-1-git-send-email-preid@electromag.com.au>",
        "Sender": "linux-i2c-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<linux-i2c.vger.kernel.org>",
        "X-Mailing-List": "linux-i2c@vger.kernel.org"
    },
    "content": "Prior to this commit the smbalert_irq was handling in the hard irq\ncontext. This change switch to using a thread irq which avoids the need\nfor the work thread. Using threaded irq also removes the need for the\nedge_triggered flag as the enabling / disabling of the hard irq for level\ntriggered interrupts will be handled by the irq core.\n\nWithout this change have an irq connected to something like an i2c gpio\nresulted in a null ptr deferences. Specifically handle_nested_irq calls\nthe threaded irq handler.\n\nThere are currently 3 in tree drivers affected by this change.\n\ni2c-parport driver calls i2c_handle_smbus_alert in a hard irq context.\nThis driver use edge trigger interrupts which skip the enable / disable\ncalls. But it still need to handle the smbus transaction on a thread. So\nthe work thread is kept for this driver.\n\ni2c-parport-light & i2c-thunderx-pcidrv provide the irq number in the\nsetup which will result in the thread irq being used.\n\ni2c-parport-light is edge trigger so the enable / disable call was\nskipped as well.\n\ni2c-thunderx-pcidrv is getting the edge / level trigger setting from of\ndata and was setting the flag as required. However the irq core should\nhandle this automatically.\n\nSigned-off-by: Phil Reid <preid@electromag.com.au>\nReviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>\n---\n drivers/i2c/busses/i2c-parport-light.c   |  1 -\n drivers/i2c/busses/i2c-parport.c         |  1 -\n drivers/i2c/busses/i2c-thunderx-pcidrv.c |  6 -----\n drivers/i2c/i2c-smbus.c                  | 41 +++++++++++++-------------------\n include/linux/i2c-smbus.h                |  1 -\n 5 files changed, 17 insertions(+), 33 deletions(-)",
    "diff": "diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c\nindex faa8fb8..fa41ff7 100644\n--- a/drivers/i2c/busses/i2c-parport-light.c\n+++ b/drivers/i2c/busses/i2c-parport-light.c\n@@ -123,7 +123,6 @@ static int parport_getsda(void *data)\n \n /* SMBus alert support */\n static struct i2c_smbus_alert_setup alert_data = {\n-\t.alert_edge_triggered\t= 1,\n };\n static struct i2c_client *ara;\n static struct lineop parport_ctrl_irq = {\ndiff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c\nindex a8e54df..319209a 100644\n--- a/drivers/i2c/busses/i2c-parport.c\n+++ b/drivers/i2c/busses/i2c-parport.c\n@@ -237,7 +237,6 @@ static void i2c_parport_attach(struct parport *port)\n \n \t/* Setup SMBus alert if supported */\n \tif (adapter_parm[type].smbus_alert) {\n-\t\tadapter->alert_data.alert_edge_triggered = 1;\n \t\tadapter->ara = i2c_setup_smbus_alert(&adapter->adapter,\n \t\t\t\t\t\t     &adapter->alert_data);\n \t\tif (adapter->ara)\ndiff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c\nindex ea35a895..925da84 100644\n--- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c\n+++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c\n@@ -118,8 +118,6 @@ static void thunder_i2c_clock_disable(struct device *dev, struct clk *clk)\n static int thunder_i2c_smbus_setup_of(struct octeon_i2c *i2c,\n \t\t\t\t      struct device_node *node)\n {\n-\tu32 type;\n-\n \tif (!node)\n \t\treturn -EINVAL;\n \n@@ -127,10 +125,6 @@ static int thunder_i2c_smbus_setup_of(struct octeon_i2c *i2c,\n \tif (!i2c->alert_data.irq)\n \t\treturn -EINVAL;\n \n-\ttype = irqd_get_trigger_type(irq_get_irq_data(i2c->alert_data.irq));\n-\ti2c->alert_data.alert_edge_triggered =\n-\t\t(type & IRQ_TYPE_LEVEL_MASK) ? 1 : 0;\n-\n \ti2c->ara = i2c_setup_smbus_alert(&i2c->adap, &i2c->alert_data);\n \tif (!i2c->ara)\n \t\treturn -ENODEV;\ndiff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c\nindex f9271c7..d4af270 100644\n--- a/drivers/i2c/i2c-smbus.c\n+++ b/drivers/i2c/i2c-smbus.c\n@@ -25,8 +25,6 @@\n #include <linux/workqueue.h>\n \n struct i2c_smbus_alert {\n-\tunsigned int\t\talert_edge_triggered:1;\n-\tint\t\t\tirq;\n \tstruct work_struct\talert;\n \tstruct i2c_client\t*ara;\t\t/* Alert response address */\n };\n@@ -72,13 +70,12 @@ static int smbus_do_alert(struct device *dev, void *addrp)\n  * The alert IRQ handler needs to hand work off to a task which can issue\n  * SMBus calls, because those sleeping calls can't be made in IRQ context.\n  */\n-static void smbus_alert(struct work_struct *work)\n+static irqreturn_t smbus_alert(int irq, void *d)\n {\n-\tstruct i2c_smbus_alert *alert;\n+\tstruct i2c_smbus_alert *alert = d;\n \tstruct i2c_client *ara;\n \tunsigned short prev_addr = 0;\t/* Not a valid address */\n \n-\talert = container_of(work, struct i2c_smbus_alert, alert);\n \tara = alert->ara;\n \n \tfor (;;) {\n@@ -115,21 +112,17 @@ static void smbus_alert(struct work_struct *work)\n \t\tprev_addr = data.addr;\n \t}\n \n-\t/* We handled all alerts; re-enable level-triggered IRQs */\n-\tif (!alert->alert_edge_triggered)\n-\t\tenable_irq(alert->irq);\n+\treturn IRQ_HANDLED;\n }\n \n-static irqreturn_t smbalert_irq(int irq, void *d)\n+static void smbalert_work(struct work_struct *work)\n {\n-\tstruct i2c_smbus_alert *alert = d;\n+\tstruct i2c_smbus_alert *alert;\n+\n+\talert = container_of(work, struct i2c_smbus_alert, alert);\n \n-\t/* Disable level-triggered IRQs until we handle them */\n-\tif (!alert->alert_edge_triggered)\n-\t\tdisable_irq_nosync(irq);\n+\tsmbus_alert(0, alert);\n \n-\tschedule_work(&alert->alert);\n-\treturn IRQ_HANDLED;\n }\n \n /* Setup SMBALERT# infrastructure */\n@@ -139,28 +132,28 @@ static int smbalert_probe(struct i2c_client *ara,\n \tstruct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev);\n \tstruct i2c_smbus_alert *alert;\n \tstruct i2c_adapter *adapter = ara->adapter;\n-\tint res;\n+\tint res, irq;\n \n \talert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert),\n \t\t\t     GFP_KERNEL);\n \tif (!alert)\n \t\treturn -ENOMEM;\n \n-\talert->alert_edge_triggered = setup->alert_edge_triggered;\n-\talert->irq = setup->irq;\n-\tINIT_WORK(&alert->alert, smbus_alert);\n+\tirq = setup->irq;\n+\tINIT_WORK(&alert->alert, smbalert_work);\n \talert->ara = ara;\n \n-\tif (setup->irq > 0) {\n-\t\tres = devm_request_irq(&ara->dev, setup->irq, smbalert_irq,\n-\t\t\t\t       0, \"smbus_alert\", alert);\n+\tif (irq > 0) {\n+\t\tres = devm_request_threaded_irq(&ara->dev, irq,\n+\t\t\t\t\t\tNULL, smbus_alert,\n+\t\t\t\t\t\tIRQF_SHARED | IRQF_ONESHOT,\n+\t\t\t\t\t\t\"smbus_alert\", alert);\n \t\tif (res)\n \t\t\treturn res;\n \t}\n \n \ti2c_set_clientdata(ara, alert);\n-\tdev_info(&adapter->dev, \"supports SMBALERT#, %s trigger\\n\",\n-\t\t setup->alert_edge_triggered ? \"edge\" : \"level\");\n+\tdev_info(&adapter->dev, \"supports SMBALERT#\\n\");\n \n \treturn 0;\n }\ndiff --git a/include/linux/i2c-smbus.h b/include/linux/i2c-smbus.h\nindex a138502..19efbd1 100644\n--- a/include/linux/i2c-smbus.h\n+++ b/include/linux/i2c-smbus.h\n@@ -42,7 +42,6 @@\n  * properly set.\n  */\n struct i2c_smbus_alert_setup {\n-\tunsigned int\t\talert_edge_triggered:1;\n \tint\t\t\tirq;\n };\n \n",
    "prefixes": [
        "v10",
        "01/10"
    ]
}