Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216247/?format=api
{ "id": 2216247, "url": "http://patchwork.ozlabs.org/api/patches/2216247/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260326-pci-m2-e-v7-8-43324a7866e6@oss.qualcomm.com/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260326-pci-m2-e-v7-8-43324a7866e6@oss.qualcomm.com>", "list_archive_url": null, "date": "2026-03-26T08:06:36", "name": "[v7,8/8] power: sequencing: pcie-m2: Create serdev device for WCN7850 bluetooth", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "405258765e52d733edfe893f1b5857409c678d49", "submitter": { "id": 91277, "url": "http://patchwork.ozlabs.org/api/people/91277/?format=api", "name": "Manivannan Sadhasivam via B4 Relay", "email": "devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260326-pci-m2-e-v7-8-43324a7866e6@oss.qualcomm.com/mbox/", "series": [ { "id": 497544, "url": "http://patchwork.ozlabs.org/api/series/497544/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=497544", "date": "2026-03-26T08:06:33", "name": "Add support for handling PCIe M.2 Key E connectors in devicetree", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/497544/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216247/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216247/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-pci+bounces-51154-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-pci@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=a03kFoVJ;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-51154-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"a03kFoVJ\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhGj32t88z1y1G\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 19:12:23 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id E99D530977E9\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 08:06:51 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 979DC3B8BA8;\n\tThu, 26 Mar 2026 08:06:41 +0000 (UTC)", "from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EAAF3B3C14;\n\tThu, 26 Mar 2026 08:06:41 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPS id 03C9BC2BCB4;\n\tThu, 26 Mar 2026 08:06:41 +0000 (UTC)", "from aws-us-west-2-korg-lkml-1.web.codeaurora.org\n (localhost.localdomain [127.0.0.1])\n\tby smtp.lore.kernel.org (Postfix) with ESMTP id EE26D106F2FA;\n\tThu, 26 Mar 2026 08:06:40 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774512401; cv=none;\n b=rt6yJZ59xUpG/qRydOHXvxUSMBjcJWNEvGxEguRWK86KwyACV0O7egoVdG83jfa7cjDLM0XCGYvCrNbx3ttov/ZN47693fUnm+iCQxOC9Xit0hHrZhxNTRziVj5zil5xLaHw0VVMQe+B7wP02VY0vjBqH+sonqR2bd1a+CYEGZM=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774512401; c=relaxed/simple;\n\tbh=cUxQWPcUIxqHU9aDbacGWrwTw3HZXVXOi2watGla2fs=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=Lg7sYqTeOYwaS0/K2FVTXQtAmy65gOWKbO2Q4O6ijuhq1YeLuy0ofH8PW3LNPoaYF4EWT+u8FN54LnNc/E5wxqtMxN0Jy80nFqbrUGBHDPRRqR7doC+xdq74YQSXPduTge/RADAS4Tk/unxcz5TP4lCukh+OfG1ivx5lyoAls00=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=a03kFoVJ; arc=none smtp.client-ip=10.30.226.201", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1774512401;\n\tbh=cUxQWPcUIxqHU9aDbacGWrwTw3HZXVXOi2watGla2fs=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=a03kFoVJeGxzVGsMk5IIu/GPKWipAOjxMkGQ318jubu2CkqJ/KzlBw7IIQuEsy/63\n\t j0F5Jzyrqdd7bghTEgbnQHjeV+3U0z+ccDW3iaQ1AS1JyNdxqYT5AtSxuWV0gstByU\n\t eadJh6uAVMgKvYqCr6NUvT1vLe7RvCFzCVIUrIwkix14UEkjTRDI7j8NZMVYgoRbgz\n\t hsnkWJDtqf2UCQpDqHJg356wAYtayysHnhflD6t3mxC3kooBXMF+CPxg3xE0vbYxeB\n\t GOw4X+yrmfVbVc6blCNhhGnJfk5030ZTynjwdRw2cuH++6ckdnB6KdlANkiiP1sg7L\n\t PYPdW8ryDaAhg==", "From": "Manivannan Sadhasivam via B4 Relay\n <devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org>", "Date": "Thu, 26 Mar 2026 13:36:36 +0530", "Subject": "[PATCH v7 8/8] power: sequencing: pcie-m2: Create serdev device\n for WCN7850 bluetooth", "Precedence": "bulk", "X-Mailing-List": "linux-pci@vger.kernel.org", "List-Id": "<linux-pci.vger.kernel.org>", "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260326-pci-m2-e-v7-8-43324a7866e6@oss.qualcomm.com>", "References": "<20260326-pci-m2-e-v7-0-43324a7866e6@oss.qualcomm.com>", "In-Reply-To": "<20260326-pci-m2-e-v7-0-43324a7866e6@oss.qualcomm.com>", "To": "Rob Herring <robh@kernel.org>,\n Greg Kroah-Hartman <gregkh@linuxfoundation.org>,\n Jiri Slaby <jirislaby@kernel.org>, Nathan Chancellor <nathan@kernel.org>,\n Nicolas Schier <nicolas.schier@linux.dev>, Hans de Goede <hansg@kernel.org>,\n =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>,\n Mark Pearson <mpearson-lenovo@squebb.ca>,\n \"Derek J. Clark\" <derekjohn.clark@gmail.com>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Krzysztof Kozlowski <krzk+dt@kernel.org>,\n Conor Dooley <conor+dt@kernel.org>, Marcel Holtmann <marcel@holtmann.org>,\n Luiz Augusto von Dentz <luiz.dentz@gmail.com>,\n Bartosz Golaszewski <brgl@bgdev.pl>,\n Andy Shevchenko <andriy.shevchenko@linux.intel.com>,\n Bartosz Golaszewski <brgl@kernel.org>", "Cc": "linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,\n linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org,\n linux-pci@vger.kernel.org, devicetree@vger.kernel.org,\n linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org,\n linux-pm@vger.kernel.org, Stephan Gerhold <stephan.gerhold@linaro.org>,\n Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,\n linux-acpi@vger.kernel.org,\n Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>,\n Hans de Goede <johannes.goede@oss.qualcomm.com>", "X-Mailer": "b4 0.15.0", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=10866;\n i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id;\n bh=idB7rpvSBQMtS24fVx41QmdeqC1DW1juy8+wOcFwZck=;\n b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpxOkN71mkppldChBzZHIYnAftETujoQqLBzvT9\n 82WUo5Q3O+JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCacTpDQAKCRBVnxHm/pHO\n 9flfB/97yEJg/LD7zs2qnTskC+l6aF3wo98whG0oqt3OCuFGWf7q/W1B9q0aHG9Vsw14VUXUrQO\n ibYjfB5wv4MyQQn4mCZ/I0v8CKLQ3wWRgOomiTJZ9Rc4Pt3F9ey3AZ55jPv35AnWeG+YePTt0j+\n LBjXQoZjWTCBkc1D3yiUhrgGz+H72mpIiRb/JskTOwbd7kwEWx2cfhRpTLAslBBF3gpIfrzYFAS\n T2TzZMc0vk2nCTqOuqpn1+bnm+//1khi2Y7I6A1dw+pCnUu7MYSqr4ksYPMvqSrJPnhW2kbmN5c\n KtCbV9aKK1C6s1rnfquu8/8OMACZHy15Q0iuqUcSlQObXX0V", "X-Developer-Key": "i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp;\n fpr=C668AEC3C3188E4C611465E7488550E901166008", "X-Endpoint-Received": "by B4 Relay for\n manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461", "X-Original-From": "Manivannan Sadhasivam\n <manivannan.sadhasivam@oss.qualcomm.com>", "Reply-To": "manivannan.sadhasivam@oss.qualcomm.com" }, "content": "From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>\n\nFor supporting bluetooth over the non-discoverable UART interface of\nWCN7850, create the serdev device after enumerating the PCIe interface.\nThis is mandatory since the device ID is only known after the PCIe\nenumeration and the ID is used for creating the serdev device.\n\nSince by default there is no OF or ACPI node for the created serdev,\ncreate a dynamic OF 'bluetooth' node with the 'compatible' property and\nattach it to the serdev device. This will allow the serdev device to bind\nto the existing bluetooth driver.\n\nTested-by: Hans de Goede <johannes.goede@oss.qualcomm.com> # ThinkPad T14s gen6 (arm64)\nSigned-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>\n---\n drivers/power/sequencing/Kconfig | 3 +-\n drivers/power/sequencing/pwrseq-pcie-m2.c | 253 ++++++++++++++++++++++++++++--\n 2 files changed, 240 insertions(+), 16 deletions(-)", "diff": "diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kconfig\nindex f5fff84566ba..1ec142525a4a 100644\n--- a/drivers/power/sequencing/Kconfig\n+++ b/drivers/power/sequencing/Kconfig\n@@ -37,7 +37,8 @@ config POWER_SEQUENCING_TH1520_GPU\n \n config POWER_SEQUENCING_PCIE_M2\n \ttristate \"PCIe M.2 connector power sequencing driver\"\n-\tdepends on OF || COMPILE_TEST\n+\tdepends on (PCI && OF) || COMPILE_TEST\n+\tselect OF_DYNAMIC if OF\n \thelp\n \t Say Y here to enable the power sequencing driver for PCIe M.2\n \t connectors. This driver handles the power sequencing for the M.2\ndiff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c\nindex 3507cdcb1e7b..a75ca4fda2eb 100644\n--- a/drivers/power/sequencing/pwrseq-pcie-m2.c\n+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c\n@@ -12,9 +12,11 @@\n #include <linux/of.h>\n #include <linux/of_graph.h>\n #include <linux/of_platform.h>\n+#include <linux/pci.h>\n #include <linux/platform_device.h>\n #include <linux/pwrseq/provider.h>\n #include <linux/regulator/consumer.h>\n+#include <linux/serdev.h>\n #include <linux/slab.h>\n \n struct pwrseq_pcie_m2_pdata {\n@@ -30,6 +32,9 @@ struct pwrseq_pcie_m2_ctx {\n \tstruct notifier_block nb;\n \tstruct gpio_desc *w_disable1_gpio;\n \tstruct gpio_desc *w_disable2_gpio;\n+\tstruct serdev_device *serdev;\n+\tstruct of_changeset *ocs;\n+\tstruct device *dev;\n };\n \n static int pwrseq_pcie_m2_vregs_enable(struct pwrseq_device *pwrseq)\n@@ -172,11 +177,202 @@ static int pwrseq_pcie_m2_match(struct pwrseq_device *pwrseq,\n \treturn PWRSEQ_NO_MATCH;\n }\n \n-static void pwrseq_pcie_m2_free_regulators(void *data)\n+static int pwrseq_m2_pcie_create_bt_node(struct pwrseq_pcie_m2_ctx *ctx,\n+\t\t\t\t\tstruct device_node *parent)\n {\n-\tstruct pwrseq_pcie_m2_ctx *ctx = data;\n+\tstruct device *dev = ctx->dev;\n+\tstruct device_node *np;\n+\tint ret;\n \n-\tregulator_bulk_free(ctx->num_vregs, ctx->regs);\n+\tctx->ocs = kzalloc_obj(*ctx->ocs);\n+\tif (!ctx->ocs)\n+\t\treturn -ENOMEM;\n+\n+\tof_changeset_init(ctx->ocs);\n+\n+\tnp = of_changeset_create_node(ctx->ocs, parent, \"bluetooth\");\n+\tif (!np) {\n+\t\tdev_err(dev, \"Failed to create bluetooth node\\n\");\n+\t\tret = -ENODEV;\n+\t\tgoto err_destroy_changeset;\n+\t}\n+\n+\tret = of_changeset_add_prop_string(ctx->ocs, np, \"compatible\", \"qcom,wcn7850-bt\");\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to add bluetooth compatible: %d\\n\", ret);\n+\t\tgoto err_destroy_changeset;\n+\t}\n+\n+\tret = of_changeset_apply(ctx->ocs);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to apply changeset: %d\\n\", ret);\n+\t\tgoto err_destroy_changeset;\n+\t}\n+\n+\tret = device_add_of_node(&ctx->serdev->dev, np);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to add OF node: %d\\n\", ret);\n+\t\tgoto err_revert_changeset;\n+\t}\n+\n+\treturn 0;\n+\n+err_revert_changeset:\n+\tof_changeset_revert(ctx->ocs);\n+err_destroy_changeset:\n+\tof_changeset_destroy(ctx->ocs);\n+\tkfree(ctx->ocs);\n+\tctx->ocs = NULL;\n+\n+\treturn ret;\n+}\n+\n+static int pwrseq_pcie_m2_create_serdev(struct pwrseq_pcie_m2_ctx *ctx)\n+{\n+\tstruct serdev_controller *serdev_ctrl;\n+\tstruct device *dev = ctx->dev;\n+\tint ret;\n+\n+\tstruct device_node *serdev_parent __free(device_node) =\n+\t\tof_graph_get_remote_node(dev_of_node(ctx->dev), 3, 0);\n+\tif (!serdev_parent)\n+\t\treturn 0;\n+\n+\tserdev_ctrl = of_find_serdev_controller_by_node(serdev_parent);\n+\tif (!serdev_ctrl)\n+\t\treturn 0;\n+\n+\t/* Bail out if the device was already attached to this controller */\n+\tif (serdev_ctrl->serdev) {\n+\t\tserdev_controller_put(serdev_ctrl);\n+\t\treturn 0;\n+\t}\n+\n+\tctx->serdev = serdev_device_alloc(serdev_ctrl);\n+\tif (!ctx->serdev) {\n+\t\tret = -ENOMEM;\n+\t\tgoto err_put_ctrl;\n+\t}\n+\n+\tret = pwrseq_m2_pcie_create_bt_node(ctx, serdev_parent);\n+\tif (ret)\n+\t\tgoto err_free_serdev;\n+\n+\tret = serdev_device_add(ctx->serdev);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to add serdev for WCN7850: %d\\n\", ret);\n+\t\tgoto err_free_dt_node;\n+\t}\n+\n+\tserdev_controller_put(serdev_ctrl);\n+\n+\treturn 0;\n+\n+err_free_dt_node:\n+\tdevice_remove_of_node(&ctx->serdev->dev);\n+\tof_changeset_revert(ctx->ocs);\n+\tof_changeset_destroy(ctx->ocs);\n+\tkfree(ctx->ocs);\n+\tctx->ocs = NULL;\n+err_free_serdev:\n+\tserdev_device_put(ctx->serdev);\n+\tctx->serdev = NULL;\n+err_put_ctrl:\n+\tserdev_controller_put(serdev_ctrl);\n+\n+\treturn ret;\n+}\n+\n+static void pwrseq_pcie_m2_remove_serdev(struct pwrseq_pcie_m2_ctx *ctx)\n+{\n+\tif (ctx->serdev) {\n+\t\tdevice_remove_of_node(&ctx->serdev->dev);\n+\t\tserdev_device_remove(ctx->serdev);\n+\t\tctx->serdev = NULL;\n+\t}\n+\n+\tif (ctx->ocs) {\n+\t\tof_changeset_revert(ctx->ocs);\n+\t\tof_changeset_destroy(ctx->ocs);\n+\t\tkfree(ctx->ocs);\n+\t\tctx->ocs = NULL;\n+\t}\n+}\n+\n+static int pwrseq_m2_pcie_notify(struct notifier_block *nb, unsigned long action,\n+\t\t\t void *data)\n+{\n+\tstruct pwrseq_pcie_m2_ctx *ctx = container_of(nb, struct pwrseq_pcie_m2_ctx, nb);\n+\tstruct pci_dev *pdev = to_pci_dev(data);\n+\tint ret;\n+\n+\t/*\n+\t * Check whether the PCI device is associated with this M.2 connector or\n+\t * not, by comparing the OF node of the PCI device parent and the Port 0\n+\t * (PCIe) remote node parent OF node.\n+\t */\n+\tstruct device_node *pci_parent __free(device_node) =\n+\t\t\tof_graph_get_remote_node(dev_of_node(ctx->dev), 0, 0);\n+\tif (!pci_parent || (pci_parent != pdev->dev.parent->of_node))\n+\t\treturn NOTIFY_DONE;\n+\n+\tswitch (action) {\n+\tcase BUS_NOTIFY_ADD_DEVICE:\n+\t\t/* Create serdev device for WCN7850 */\n+\t\tif (pdev->vendor == PCI_VENDOR_ID_QCOM && pdev->device == 0x1107) {\n+\t\t\tret = pwrseq_pcie_m2_create_serdev(ctx);\n+\t\t\tif (ret)\n+\t\t\t\treturn notifier_from_errno(ret);\n+\t\t}\n+\t\tbreak;\n+\tcase BUS_NOTIFY_REMOVED_DEVICE:\n+\t\t/* Destroy serdev device for WCN7850 */\n+\t\tif (pdev->vendor == PCI_VENDOR_ID_QCOM && pdev->device == 0x1107)\n+\t\t\tpwrseq_pcie_m2_remove_serdev(ctx);\n+\n+\t\tbreak;\n+\t}\n+\n+\treturn NOTIFY_OK;\n+}\n+\n+static bool pwrseq_pcie_m2_check_remote_node(struct device *dev, u8 port, u8 endpoint,\n+\t\t\t\t\t const char *node)\n+{\n+\tstruct device_node *remote __free(device_node) =\n+\t\t\tof_graph_get_remote_node(dev_of_node(dev), port, endpoint);\n+\n+\tif (remote && of_node_name_eq(remote, node))\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+/*\n+ * If the connector exposes a non-discoverable bus like UART, the respective\n+ * protocol device needs to be created manually with the help of the notifier\n+ * of the discoverable bus like PCIe.\n+ */\n+static int pwrseq_pcie_m2_register_notifier(struct pwrseq_pcie_m2_ctx *ctx, struct device *dev)\n+{\n+\tint ret;\n+\n+\t/*\n+\t * Register a PCI notifier for Key E connector that has PCIe as Port\n+\t * 0/Endpoint 0 interface and Serial as Port 3/Endpoint 0 interface.\n+\t */\n+\tif (pwrseq_pcie_m2_check_remote_node(dev, 3, 0, \"serial\")) {\n+\t\tif (pwrseq_pcie_m2_check_remote_node(dev, 0, 0, \"pcie\")) {\n+\t\t\tctx->dev = dev;\n+\t\t\tctx->nb.notifier_call = pwrseq_m2_pcie_notify;\n+\t\t\tret = bus_register_notifier(&pci_bus_type, &ctx->nb);\n+\t\t\tif (ret)\n+\t\t\t\treturn dev_err_probe(dev, ret,\n+\t\t\t\t\t\t \"Failed to register notifier for serdev\\n\");\n+\t\t}\n+\t}\n+\n+\treturn 0;\n }\n \n static int pwrseq_pcie_m2_probe(struct platform_device *pdev)\n@@ -190,6 +386,7 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)\n \tif (!ctx)\n \t\treturn -ENOMEM;\n \n+\tplatform_set_drvdata(pdev, ctx);\n \tctx->of_node = of_node_get(dev->of_node);\n \tctx->pdata = device_get_match_data(dev);\n \tif (!ctx->pdata)\n@@ -206,21 +403,21 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)\n \t\treturn dev_err_probe(dev, ret,\n \t\t\t\t \"Failed to get all regulators\\n\");\n \n+\tctx->num_vregs = ret;\n+\n \tctx->w_disable1_gpio = devm_gpiod_get_optional(dev, \"w-disable1\", GPIOD_OUT_HIGH);\n-\tif (IS_ERR(ctx->w_disable1_gpio))\n-\t\treturn dev_err_probe(dev, PTR_ERR(ctx->w_disable1_gpio),\n+\tif (IS_ERR(ctx->w_disable1_gpio)) {\n+\t\tret = dev_err_probe(dev, PTR_ERR(ctx->w_disable1_gpio),\n \t\t\t\t \"Failed to get the W_DISABLE_1# GPIO\\n\");\n+\t\tgoto err_free_regulators;\n+\t}\n \n \tctx->w_disable2_gpio = devm_gpiod_get_optional(dev, \"w-disable2\", GPIOD_OUT_HIGH);\n-\tif (IS_ERR(ctx->w_disable2_gpio))\n-\t\treturn dev_err_probe(dev, PTR_ERR(ctx->w_disable2_gpio),\n+\tif (IS_ERR(ctx->w_disable2_gpio)) {\n+\t\tret = dev_err_probe(dev, PTR_ERR(ctx->w_disable2_gpio),\n \t\t\t\t \"Failed to get the W_DISABLE_2# GPIO\\n\");\n-\n-\tctx->num_vregs = ret;\n-\n-\tret = devm_add_action_or_reset(dev, pwrseq_pcie_m2_free_regulators, ctx);\n-\tif (ret)\n-\t\treturn ret;\n+\t\tgoto err_free_regulators;\n+\t}\n \n \tconfig.parent = dev;\n \tconfig.owner = THIS_MODULE;\n@@ -229,11 +426,36 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)\n \tconfig.targets = ctx->pdata->targets;\n \n \tctx->pwrseq = devm_pwrseq_device_register(dev, &config);\n-\tif (IS_ERR(ctx->pwrseq))\n-\t\treturn dev_err_probe(dev, PTR_ERR(ctx->pwrseq),\n+\tif (IS_ERR(ctx->pwrseq)) {\n+\t\tret = dev_err_probe(dev, PTR_ERR(ctx->pwrseq),\n \t\t\t\t \"Failed to register the power sequencer\\n\");\n+\t\tgoto err_free_regulators;\n+\t}\n+\n+\t/*\n+\t * Register a notifier for creating protocol devices for\n+\t * non-discoverable busses like UART.\n+\t */\n+\tret = pwrseq_pcie_m2_register_notifier(ctx, dev);\n+\tif (ret)\n+\t\tgoto err_free_regulators;\n \n \treturn 0;\n+\n+err_free_regulators:\n+\tregulator_bulk_free(ctx->num_vregs, ctx->regs);\n+\n+\treturn ret;\n+}\n+\n+static void pwrseq_pcie_m2_remove(struct platform_device *pdev)\n+{\n+\tstruct pwrseq_pcie_m2_ctx *ctx = platform_get_drvdata(pdev);\n+\n+\tbus_unregister_notifier(&pci_bus_type, &ctx->nb);\n+\tpwrseq_pcie_m2_remove_serdev(ctx);\n+\n+\tregulator_bulk_free(ctx->num_vregs, ctx->regs);\n }\n \n static const struct of_device_id pwrseq_pcie_m2_of_match[] = {\n@@ -255,6 +477,7 @@ static struct platform_driver pwrseq_pcie_m2_driver = {\n \t\t.of_match_table = pwrseq_pcie_m2_of_match,\n \t},\n \t.probe = pwrseq_pcie_m2_probe,\n+\t.remove = pwrseq_pcie_m2_remove,\n };\n module_platform_driver(pwrseq_pcie_m2_driver);\n \n", "prefixes": [ "v7", "8/8" ] }