From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: manivannan.sadhasivam@oss.qualcomm.com
Cc: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Bartosz Golaszewski <brgl@kernel.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Amitkumar Karwar <amitkumar.karwar@nxp.com>,
Neeraj Kale <neeraj.sanjaykale@nxp.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org,
linux-pm@vger.kernel.org,
Rahul Samana <rahul.samana@oss.qualcomm.com>,
Wei Deng <wei.deng@oss.qualcomm.com>,
Loic Poulain <loic.poulain@oss.qualcomm.com>
Subject: Re: [PATCH 2/5] Bluetooth: btnxpuart: Add auxiliary driver for PCIe M.2 modules
Date: Tue, 15 Sep 2026 17:51:00 +0300 [thread overview]
Message-ID: <aqlbVNjTUHXlObgy@ashevche-desk.local> (raw)
In-Reply-To: <20260915-pci-m2-bt-rework-v1-2-3c7d9cf9c010@oss.qualcomm.com>
On Tue, Sep 15, 2026 at 04:24:03PM +0200, Manivannan Sadhasivam via B4 Relay wrote:
> The 88W8987 combo module exposes Bluetooth over UART. Since this module is
> attached over PCIe, it is not described in firmware like devicetree. So it
> is discovered at runtime over PCIe by the power sequencing driver, which
> allocates the UART serdev and creates an auxiliary device carrying that
> transport and the power sequencing target to power up the Bluetooth
> function.
>
> Add an auxiliary driver that binds to this device. It reuses the serdev
> provided by the producer, brings up the controller through the existing
> UART transport with nxp_register_dev() and drives power through the
> sequencer obtained with pwrseq_get().
>
> Factor the HCI device setup and teardown shared with the serdev probe into
> helpers so both paths register the same controller.
...
> -static int nxp_serdev_probe(struct serdev_device *serdev)
> +static int nxp_register_dev(struct btnxpuart_dev *nxpdev)
> {
> + struct serdev_device *serdev = nxpdev->serdev;
Why not also
struct device *dev = &serdev->dev;
and use it to make lines even shorter?
...
> - device_property_read_u32(&nxpdev->serdev->dev, "max-speed",
> + device_property_read_u32(&serdev->dev, "max-speed",
> &nxpdev->secondary_baudrate);
device_property_read_u32(dev, "max-speed", &nxpdev->secondary_baudrate);
Now exactly a single line (out of 80 characters).
...
> - device_property_read_u8_array(&nxpdev->serdev->dev,
> + device_property_read_u8_array(&serdev->dev,
> "local-bd-address",
> (u8 *)&ba, sizeof(ba));
device_property_read_u8_array(dev, "local-bd-address",
(u8 *)&ba, sizeof(ba));
Now two lines instead of three. But ideally this casting should gone and
instead something like ether_addr_copy() to be used. (The latter is out
of scope here, of course.)
...
> +static int nxp_serdev_probe(struct serdev_device *serdev)
> +{
> + struct btnxpuart_dev *nxpdev;
> + int err;
> +
> + nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
> + if (!nxpdev)
> + return -ENOMEM;
> + nxpdev->nxp_data = (struct btnxpuart_data *)device_get_match_data(&serdev->dev);
This is bad. The const qualifier is for a reason. Make sure it's kept.
On top the same suggestion as per above, use local 'dev' pointer.
Also Sashiko found a nice issue with the driver data, id est driver_override
mechanism that in some cases may lead to NULL dereferencing. Please, double
check if it's not the case, otherwise check for NULL and return -ENODATA.
> + nxpdev->serdev = serdev;
> +
> + nxpdev->pdn = devm_reset_control_get_optional_shared(&serdev->dev, NULL);
> + if (IS_ERR(nxpdev->pdn))
> + return PTR_ERR(nxpdev->pdn);
> +
> + err = devm_regulator_get_enable(&serdev->dev, "vcc");
> + if (err) {
> + dev_err(&serdev->dev, "Failed to enable vcc regulator\n");
> + return err;
> + }
> +
> + if (nxp_m2_connector_is_available(&serdev->ctrl->dev)) {
> + struct pwrseq_desc *pwrseq;
> +
> + pwrseq = pwrseq_get(&serdev->ctrl->dev, "uart");
> + if (IS_ERR(pwrseq))
> + return dev_err_probe(&serdev->dev, PTR_ERR(pwrseq),
> + "failed to get pwrseq\n");
> +
> + nxpdev->pwrseq = pwrseq;
> + err = pwrseq_enable(pwrseq);
> + if (err)
> + goto err_pwrseq_put;
> + }
> +
> + err = nxp_register_dev(nxpdev);
> + if (err)
> + goto err_pwrseq_put;
> +
> + return 0;
> +
> err_pwrseq_put:
> if (nxpdev->pwrseq)
> pwrseq_put(nxpdev->pwrseq);
> return err;
> }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-09-15 14:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 14:24 [PATCH 0/5] Rework M.2 Bluetooth instantiation using the auxiliary bus Manivannan Sadhasivam via B4 Relay
2026-09-15 14:24 ` [PATCH 1/5] Bluetooth: hci_qca: Add auxiliary driver for PCIe M.2 modules Manivannan Sadhasivam via B4 Relay
2026-09-16 9:39 ` Bartosz Golaszewski
2026-09-15 14:24 ` [PATCH 2/5] Bluetooth: btnxpuart: " Manivannan Sadhasivam via B4 Relay
2026-09-15 14:51 ` Andy Shevchenko [this message]
2026-09-15 14:24 ` [PATCH 3/5] power: sequencing: pcie-m2: Create auxiliary device for the M.2 BT interface Manivannan Sadhasivam via B4 Relay
2026-09-16 9:19 ` Bartosz Golaszewski
2026-09-15 14:24 ` [PATCH 4/5] Bluetooth: hci_qca: Drop serdev based M.2 power sequencing code Manivannan Sadhasivam via B4 Relay
2026-09-15 14:24 ` [PATCH 5/5] Bluetooth: btnxpuart: " Manivannan Sadhasivam via B4 Relay
2026-09-18 9:48 ` [PATCH 0/5] Rework M.2 Bluetooth instantiation using the auxiliary bus Sherry Sun
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=aqlbVNjTUHXlObgy@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=amitkumar.karwar@nxp.com \
--cc=brgl@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=luiz.dentz@gmail.com \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=marcel@holtmann.org \
--cc=neeraj.sanjaykale@nxp.com \
--cc=p.zabel@pengutronix.de \
--cc=rahul.samana@oss.qualcomm.com \
--cc=wei.deng@oss.qualcomm.com \
/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®