From: Inochi Amaoto <inochiama@gmail.com>
To: Vinod Koul <vkoul@kernel.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Vladimir Oltean <olteanv@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Rhys Tumelty <rhys@tumelty.co.uk>,
Inochi Amaoto <inochiama@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-phy@lists.infradead.org, Yixun Lan <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: Re: [PATCH v4 3/5] phy: core: Add phy bulk data helper functions
Date: Sat, 21 Nov 2026 15:52:55 +0800 [thread overview]
Message-ID: <awFL17YyVU7yRKZz@inochi.infowork> (raw)
In-Reply-To: <20260929085235.469515-4-inochiama@gmail.com>
On Tue, Sep 29, 2026 at 04:52:33PM +0800, Inochi Amaoto wrote:
> Add several helper functions that allow drivers to get several phy
> consumers in one operation. If any of the phy cannot be acquired then
> any phys that were got will be put before returning to the caller.
>
> This can relieve the driver owners' life who needs to handle many phys,
> as well as each phy error reporting.
>
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> ---
> drivers/phy/phy-core.c | 253 ++++++++++++++++++++++++++++++++++++++++
> include/linux/phy/phy.h | 55 +++++++++
> 2 files changed, 308 insertions(+)
>
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 8fbaea003b90..5b76c006575b 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -1004,6 +1004,259 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
> }
> EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
[...]
> +/**
> + * phy_bulk_init() - initialize multiple PHYs
> + * @num_phys: number of entries in the phys array
> + * @phys: array of struct phy_bulk_data to initialize
> + *
> + * Initializes the PHYs in array order. If an initialization fails, all PHYs
> + * initialized by this call are exited in reverse order.
> + *
> + * Return: %0 if successful, a negative error code otherwise
> + */
> +int phy_bulk_init(unsigned int num_phys, struct phy_bulk_data *phys)
> +{
> + unsigned int i;
> + int ret;
> +
> + for (i = 0; i < num_phys; i++) {
> + ret = phy_init(phys[i].phy);
> + if (ret)
> + goto err;
> + }
> +
> + return 0;
> +
> +err:
> + while (i--)
> + phy_exit(phys[i].phy);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(phy_bulk_init);
> +
> +/**
> + * phy_bulk_exit() - exit multiple PHYs
> + * @num_phys: number of entries in the phys array
> + * @phys: array of struct phy_bulk_data to exit
> + *
> + * Exits the PHYs in reverse array order. All PHYs are processed even if an
> + * error occurs.
> + *
> + * Return: %0 if successful, the first negative error code otherwise
> + */
> +int phy_bulk_exit(unsigned int num_phys, struct phy_bulk_data *phys)
> +{
> + int ret = 0;
> + int err;
> +
> + while (num_phys--) {
> + err = phy_exit(phys[num_phys].phy);
> + if (err && !ret)
> + ret = err;
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(phy_bulk_exit);
> +
Hi Vinod, Vladimir and Manivannan,
Before sending the next patch (I guess I can update it in the next
week), I have a question for the error handle.
As the phy_exit()/phy_power_off()/phy_power_on() can return an
error code, should the corresponding bulk api need to call the
corresponding phy_init()/phy_power_on()/phy_power_off() when
there is an error occurs. Or just leave the state as it is.
I saw the reset subsystem does this rollback.
Regards,
Inochi
next prev parent reply other threads:[~2026-11-21 7:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 8:52 [PATCH v4 0/5] phy: core: Add phy bulk helpers support Inochi Amaoto
2026-09-29 8:52 ` [PATCH v4 1/5] phy: core: Add common helper to add phy phandle device link Inochi Amaoto
2026-09-29 8:52 ` [PATCH v4 2/5] phy: core: Add common helper for get phy phandle by index Inochi Amaoto
2026-09-29 8:52 ` [PATCH v4 3/5] phy: core: Add phy bulk data helper functions Inochi Amaoto
2026-09-30 8:22 ` Andy Shevchenko
2026-09-30 8:59 ` Inochi Amaoto
2026-10-05 10:12 ` Vinod Koul
2026-10-05 11:41 ` Inochi Amaoto
2026-10-06 20:49 ` Vladimir Oltean
2026-10-18 12:39 ` Manivannan Sadhasivam
2026-10-27 8:41 ` Inochi Amaoto
2026-10-28 11:24 ` Manivannan Sadhasivam
2026-10-06 21:15 ` Vladimir Oltean
2026-11-21 7:52 ` Inochi Amaoto [this message]
2026-09-29 8:52 ` [PATCH v4 4/5] phy: core: Add managed " Inochi Amaoto
2026-09-30 8:29 ` Andy Shevchenko
2026-09-30 9:21 ` Inochi Amaoto
2026-09-30 9:23 ` Inochi Amaoto
2026-09-30 9:44 ` Andy Shevchenko
2026-09-29 8:52 ` [PATCH v4 5/5] doc: phy: Document some bulk " Inochi Amaoto
2026-09-30 8:30 ` Andy Shevchenko
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=awFL17YyVU7yRKZz@inochi.infowork \
--to=inochiama@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=dlan@gentoo.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=looong.bin@gmail.com \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=rdunlap@infradead.org \
--cc=rhys@tumelty.co.uk \
--cc=skhan@linuxfoundation.org \
--cc=vkoul@kernel.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®