From: Bartosz Golaszewski <brgl@kernel.org>
To: manivannan.sadhasivam@oss.qualcomm.com
Cc: "Manivannan Sadhasivam via B4 Relay"
<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org,
platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org,
"Stephan Gerhold" <stephan.gerhold@linaro.org>,
"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
linux-acpi@vger.kernel.org,
"Hans de Goede" <johannes.goede@oss.qualcomm.com>,
"Rob Herring" <robh@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nicolas.schier@linux.dev>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Derek J. Clark" <derekjohn.clark@gmail.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marcel Holtmann" <marcel@holtmann.org>,
"Luiz Augusto von Dentz" <luiz.dentz@gmail.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Bartosz Golaszewski" <brgl@kernel.org>
Subject: Re: [PATCH v5 2/9] serdev: Add an API to find the serdev controller associated with the devicetree node
Date: Tue, 24 Feb 2026 02:16:17 -0800 [thread overview]
Message-ID: <CAMRc=MethnZu_GrujadpBZwj4SpgdNXEnTfEikSvPkO2f9MJjg@mail.gmail.com> (raw)
In-Reply-To: <20260224-pci-m2-e-v5-2-dd9b9501d33c@oss.qualcomm.com>
On Tue, 24 Feb 2026 06:30:48 +0100, Manivannan Sadhasivam via B4 Relay
<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org> said:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> Add of_find_serdev_controller_by_node() API to find the serdev controller
> device associated with the devicetree node.
>
> Tested-by: Hans de Goede <johannes.goede@oss.qualcomm.com> # ThinkPad T14s gen6 (arm64)
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/tty/serdev/core.c | 19 +++++++++++++++++++
> include/linux/serdev.h | 9 +++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 8f25510f89b6..bf88b95f7458 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -514,6 +514,25 @@ struct serdev_controller *serdev_controller_alloc(struct device *host,
> }
> EXPORT_SYMBOL_GPL(serdev_controller_alloc);
>
> +#ifdef CONFIG_OF
> +/**
> + * of_find_serdev_controller_by_node() - Find the serdev controller associated
> + * with the devicetree node
> + * @node: Devicetree node
> + *
> + * Return: Pointer to the serdev controller associated with the node. NULL if
> + * the controller is not found. Caller is responsible for calling
> + * serdev_controller_put() to drop the reference.
> + */
> +struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node)
> +{
> + struct device *dev = bus_find_device_by_of_node(&serdev_bus_type, node);
> +
> + return (dev && dev->type == &serdev_ctrl_type) ? to_serdev_controller(dev) : NULL;
> +}
> +EXPORT_SYMBOL_GPL(of_find_serdev_controller_by_node);
I'm not sure if I commented on it before but there's no reason for this to be
OF-centric. It would work equally well as (I think the same should keep the
"serdev" prefix too for correct namespacing):
struct serdev_controller *serdev_find_controller_by_fwnode(struct
fwnode_handle *fwnode)
{
struct device *dev = bus_find_device_by_fwnode();
...
}
It would be more flexible and users can always use to_of_node().
Bart
> +#endif
> +
> static int of_serdev_register_devices(struct serdev_controller *ctrl)
> {
> struct device_node *node;
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 0c7d3c27d1f8..188c0ba62d50 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -334,4 +334,13 @@ static inline bool serdev_acpi_get_uart_resource(struct acpi_resource *ares,
> }
> #endif /* CONFIG_ACPI */
>
> +#ifdef CONFIG_OF
> +struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node);
> +#else
> +static inline struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node)
> +{
> + return NULL;
> +}
> +#endif /* CONFIG_OF */
> +
> #endif /*_LINUX_SERDEV_H */
>
> --
> 2.51.0
>
>
>
next prev parent reply other threads:[~2026-02-24 10:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 5:30 [PATCH v5 0/9] Add support for handling PCIe M.2 Key E connectors in devicetree Manivannan Sadhasivam via B4 Relay
2026-02-24 5:30 ` [PATCH v5 1/9] serdev: Convert to_serdev_*() helpers to macros and use container_of_const() Manivannan Sadhasivam via B4 Relay
2026-02-24 5:30 ` [PATCH v5 2/9] serdev: Add an API to find the serdev controller associated with the devicetree node Manivannan Sadhasivam via B4 Relay
2026-02-24 10:16 ` Bartosz Golaszewski [this message]
2026-02-24 10:29 ` Andy Shevchenko
2026-02-24 10:54 ` Bartosz Golaszewski
2026-02-24 5:30 ` [PATCH v5 3/9] serdev: Do not return -ENODEV from of_serdev_register_devices() if external connector is used Manivannan Sadhasivam via B4 Relay
2026-02-24 5:30 ` [PATCH v5 4/9] dt-bindings: serial: Document the graph port Manivannan Sadhasivam via B4 Relay
2026-02-24 7:09 ` Krzysztof Kozlowski
2026-02-24 7:20 ` Manivannan Sadhasivam
2026-02-24 5:30 ` [PATCH v5 5/9] dt-bindings: connector: Add PCIe M.2 Mechanical Key E connector Manivannan Sadhasivam via B4 Relay
2026-02-24 7:08 ` Krzysztof Kozlowski
2026-03-06 0:37 ` Rob Herring (Arm)
2026-03-06 10:27 ` Loic Poulain
2026-02-24 5:30 ` [PATCH v5 6/9] dt-bindings: connector: m2: Add M.2 1620 LGA soldered down connector Manivannan Sadhasivam via B4 Relay
2026-02-24 7:08 ` Krzysztof Kozlowski
2026-02-24 5:30 ` [PATCH v5 7/9] Bluetooth: hci_qca: Add M.2 Bluetooth device support using pwrseq Manivannan Sadhasivam via B4 Relay
2026-02-24 5:30 ` [PATCH v5 8/9] power: sequencing: pcie-m2: Add support for PCIe M.2 Key E connectors Manivannan Sadhasivam via B4 Relay
2026-02-24 5:30 ` [PATCH v5 9/9] power: sequencing: pcie-m2: Create serdev device for WCN7850 bluetooth Manivannan Sadhasivam via B4 Relay
2026-02-25 11:22 ` Bartosz Golaszewski
2026-03-17 4:18 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMRc=MethnZu_GrujadpBZwj4SpgdNXEnTfEikSvPkO2f9MJjg@mail.gmail.com' \
--to=brgl@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=derekjohn.clark@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=johannes.goede@oss.qualcomm.com \
--cc=krzk+dt@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=marcel@holtmann.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=nathan@kernel.org \
--cc=nicolas.schier@linux.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=robh@kernel.org \
--cc=stephan.gerhold@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®