[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Me8WQ=aMd-NJ1yzzHzqU8fT1u4eb7as=EjSpZ+Rpv9+rg@mail.gmail.com>
Date: Fri, 2 Jan 2026 12:57:47 +0100
From: Bartosz Golaszewski <brgl@...nel.org>
To: Shivendra Pratap <shivendra.pratap@....qualcomm.com>
Cc: Lorenzo Pieralisi <lpieralisi@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Bjorn Andersson <andersson@...nel.org>, Sebastian Reichel <sre@...nel.org>, Rob Herring <robh@...nel.org>,
Sudeep Holla <sudeep.holla@....com>, Souvik Chakravarty <Souvik.Chakravarty@....com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Andy Yan <andy.yan@...k-chips.com>,
John Stultz <john.stultz@...aro.org>, Matthias Brugger <matthias.bgg@...il.com>,
Moritz Fischer <moritz.fischer@...us.com>, Mark Rutland <mark.rutland@....com>,
Conor Dooley <conor+dt@...nel.org>, Konrad Dybcio <konradybcio@...nel.org>,
Florian Fainelli <florian.fainelli@...adcom.com>, Krzysztof Kozlowski <krzk@...nel.org>,
Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
Mukesh Ojha <mukesh.ojha@....qualcomm.com>, Andre Draszik <andre.draszik@...aro.org>,
Kathiravan Thirumoorthy <kathiravan.thirumoorthy@....qualcomm.com>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org,
Srinivas Kandagatla <srini@...nel.org>
Subject: Re: [PATCH v19 06/10] power: reset: Add psci-reboot-mode driver
On Sun, Dec 28, 2025 at 6:21 PM Shivendra Pratap
<shivendra.pratap@....qualcomm.com> wrote:
>
[snip]
> +
> +static int psci_reboot_mode_probe(struct faux_device *fdev)
> +{
> + struct reboot_mode_driver *reboot;
> + struct device_node *psci_np;
> + struct device_node *np;
> + int ret;
> +
> + psci_np = of_find_compatible_node(NULL, NULL, "arm,psci-1.0");
> + if (!psci_np)
> + return -ENODEV;
> +
> + /*
> + * Find the psci:reboot-mode node.
> + * If NULL, continue to register predefined modes.
> + * np refcount to be handled by dev;
> + * psci_np refcount is decremented by of_find_node_by_name;
> + */
Can you make this comment into full sentences, I had trouble parsing
the meaning for a minute.
> + np = of_find_node_by_name(psci_np, "reboot-mode");
> + fdev->dev.of_node = np;
The logic of the device assigning its own node is a bit sketchy,
ideally this should be done before the device probes.
> +
> + reboot = devm_kzalloc(&fdev->dev, sizeof(*reboot), GFP_KERNEL);
> + if (!reboot)
> + return -ENOMEM;
> +
> + psci_reboot_mode_set_predefined_modes(reboot);
> + reboot->write = psci_reboot_mode_write;
> + reboot->dev = &fdev->dev;
> +
> + ret = devm_reboot_mode_register(&fdev->dev, reboot);
> + if (ret) {
> + dev_err(&fdev->dev, "devm_reboot_mode_register failed %d\n", ret);
> + return ret;
Use dev_err_probe().
> + }
> +
> + return 0;
> +}
> +
> +static struct faux_device_ops psci_reboot_mode_ops = {
> + .probe = psci_reboot_mode_probe,
> +};
> +
> +static int __init psci_reboot_mode_init(void)
> +{
> + struct faux_device *fdev;
> +
> + fdev = faux_device_create("psci-reboot-mode", NULL, &psci_reboot_mode_ops);
> + if (!fdev)
> + return -ENODEV;
This will always create this device for everyone who includes this
module. Move the of_find_compatible_node(NULL, NULL, "arm,psci-1.0")
call from probe() here instead and don't create the device if it
fails.
Bart
> +
> + return 0;
> +}
> +device_initcall(psci_reboot_mode_init);
>
> --
> 2.34.1
>
Powered by blists - more mailing lists