Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: regulator: regulator_shell: create command to print regulators #83970

Closed

Conversation

bdesterBE
Copy link

The regulator shell commands require that you provide the name of the regulator node to be able to interact with them (e.g. regulator enable myRegulator). It can be inconvenient to have to go to Devicetree files to find the name of the regulator to change.

Fixes: #83073

Copy link

Hello @bdesterBE, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't make sense, you're documenting "Print regulator names", but only regulator-fixed is considered.

@bdesterBE
Copy link
Author

this doesn't make sense, you're documenting "Print regulator names", but only regulator-fixed is considered.

Thanks for the reply. I originally implemented this as any node with status okay that has the regulator-name property. Does that solution satisfy this?

@gmarull
Copy link
Member

gmarull commented Jan 21, 2025

this doesn't make sense, you're documenting "Print regulator names", but only regulator-fixed is considered.

Thanks for the reply. I originally implemented this as any node with status okay that has the regulator-name property. Does that solution satisfy this?

First, name should be stored on each regulator, then, you can iterate over all regulators and retrieve their name.

@bdesterBE bdesterBE force-pushed the 83073_print_regulators branch 2 times, most recently from 4fc0046 to 701c08e Compare January 30, 2025 19:24
@bdesterBE bdesterBE requested a review from gmarull January 30, 2025 22:54
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still fail to see the utility of this. List may be incomplete to start with, and you can't obtain a regulator device handle from its 'regulator-name'. It's now possible to list all devices from a particular class, so better use that.

@bdesterBE bdesterBE force-pushed the 83073_print_regulators branch 2 times, most recently from 11807f4 to cd4d80f Compare February 11, 2025 17:59
…ames.

The regulator shell commands require that you provide the name of the
regulator node to be able to interact with them
(e.g. regulator enable myRegulator). It can be inconvenient to have to go
to Devicetree files to find the name of the regulator to change. This
commit visits all nodes with an 'okay' status and prints the node names
of nodes belonging to the regulator device API class.

Note that the name printed is the node name and not the value of
'regulator_name'. This is because the node name is what is used to interact
with the regulators in the shell.

Fixes: zephyrproject-rtos#83073

Signed-off-by: Brandon Dester <bdester@boston-engineering.com>
@bdesterBE bdesterBE force-pushed the 83073_print_regulators branch from cd4d80f to 65bb39a Compare February 12, 2025 00:19
@bdesterBE
Copy link
Author

The intended utility is to be able to easily get the names of regulator nodes without needing to reference devicetree files or guess from tab completion. The node names are needed in order to do anything with regulators from the shell.

I pushed the change to use the device class, thanks for the suggestion as it's definitely a better solution. Please let me know if it's preferred to use DEVICE_API_IS() directly rather than device_is_regulator() so that the command functions remain organized together. Alternatively, could declare device_is_regulator() prototype at the top of the file.

@bdesterBE bdesterBE requested a review from gmarull February 12, 2025 01:50
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pasting tons of if (device_is_regulator(device_get_binding(DT_NODE_FULL_NAME(node_id)))), ie, runtime checks, when regulator devices are known at compile time now. Why is this useful when tab autocompletes regulators only?

@bdesterBE bdesterBE closed this Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shell: regulator: Add ability to print regulator names from Devicetree
3 participants