From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41330377557 for ; Tue, 24 Feb 2026 10:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771928180; cv=none; b=BrO4DLgiBMGhqx2zRR1UMwJZATdzS3UZm688QKrH+DDLt4na21+OHv4npe60qr/3qMF1a7sTzq9sZJFxJBbH4u9LiyMBWv2GJVEsM5Pvn1IGdchvaB/rQdTPf6n2CDRvPWE+7EDACfusH7NfViiPR/3ZGqnHHIIEDRBeOoGfzqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771928180; c=relaxed/simple; bh=p7Hur+ZLTgSQNp7dSnaF30I5DS+Sq/MFqFTWXOZW21k=; h=From:In-Reply-To:MIME-Version:References:Date:Message-ID:Subject: To:Cc:Content-Type; b=sUD7EFM6S9hbJ3eMKgh8LeWv8siBnH7i7X58SJrACA5oIsgXDLTWbn83wpQky3qUM/Bqd1vkORM5cnqGYd1IW/6woW5BRfuEQ9KOapZoTgL5syJUtorkHCumFkgZP2AaGUfQHb+ie6uN3hayJUVymd/cTsZJYgtm+RrUJpp3eNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J2i13CEQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J2i13CEQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0244BC2BC9E for ; Tue, 24 Feb 2026 10:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771928180; bh=p7Hur+ZLTgSQNp7dSnaF30I5DS+Sq/MFqFTWXOZW21k=; h=From:In-Reply-To:References:Date:Subject:To:Cc:From; b=J2i13CEQ+Em64sZc2ce5aHPCYCMLB9EOZonejhWsu2QqJh+kDGoBGljLLKSK1Z3ig vwV6LVUIZt5VuKDPzg2cKsZPNldl9vImMw3+54HH0jbtnZavg5iMDyC70H70AlUq16 bZNCY9/zIE9upPytFggL4FxUjVmlTGS9tf9uvFRkNwLo2Gab6SYVpTBOxN4N92jv5A F9pGHslex/NI8vSXtozdZJfNAmPDobMUSKAmz013q8P1ptJqmOF1S09HcBdRzqrdYP JlZlTxSx/rSASoMvCkc54z3qgesNroo7b56hbKd3ilvdJX8DIfFtzCKREsYOn4acX+ F3kdl3dnyGevA== Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-59de66fda55so6080588e87.3 for ; Tue, 24 Feb 2026 02:16:19 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU5uyctJJ8X2LrGf2qg9/8HlFnJxO73pWsASRjobSk16qFM6cFPLsLFuojXibTLnKiVzxTGukrCmCrXBRo=@vger.kernel.org X-Gm-Message-State: AOJu0YzTTLOT1a7FbyItRP9opIzCL+KbWWM7V52AAH+vHGwfEKPhc0Ih /s7XNmGUT+HsRfWgq3aqQSblaE1uic6MWwtVr81u30Y+5bK44gQwlt6smy9AqNZzsCj9VKMTLwv KIj0eZsyb8v1HobFBQ6CMxkN5cCkt48zTEKszQuAzKw== X-Received: by 2002:a05:6512:3f16:b0:59e:44fd:8047 with SMTP id 2adb3069b0e04-5a0ed8a5360mr3968763e87.28.1771928178627; Tue, 24 Feb 2026 02:16:18 -0800 (PST) Received: from 969154062570 named unknown by gmailapi.google.com with HTTPREST; Tue, 24 Feb 2026 02:16:17 -0800 Received: from 969154062570 named unknown by gmailapi.google.com with HTTPREST; Tue, 24 Feb 2026 02:16:17 -0800 From: Bartosz Golaszewski In-Reply-To: <20260224-pci-m2-e-v5-2-dd9b9501d33c@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260224-pci-m2-e-v5-0-dd9b9501d33c@oss.qualcomm.com> <20260224-pci-m2-e-v5-2-dd9b9501d33c@oss.qualcomm.com> Date: Tue, 24 Feb 2026 02:16:17 -0800 X-Gmail-Original-Message-ID: X-Gm-Features: AaiRm52E9GG7sUX8QY-OJorqLhZbSTriYRV39ykZ2pMd-1A19dZUhSz2lCghp98 Message-ID: Subject: Re: [PATCH v5 2/9] serdev: Add an API to find the serdev controller associated with the devicetree node To: manivannan.sadhasivam@oss.qualcomm.com Cc: Manivannan Sadhasivam via B4 Relay , 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 , Dmitry Baryshkov , linux-acpi@vger.kernel.org, Hans de Goede , Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski , Andy Shevchenko , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" On Tue, 24 Feb 2026 06:30:48 +0100, Manivannan Sadhasivam via B4 Relay said: > From: Manivannan Sadhasivam > > Add of_find_serdev_controller_by_node() API to find the serdev controller > device associated with the devicetree node. > > Tested-by: Hans de Goede # ThinkPad T14s gen6 (arm64) > Signed-off-by: Manivannan Sadhasivam > --- > 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 > > >