Thread (16 messages) flat view 16 messages, 5 authors, 2021-08-23

Re: [PATCH] PCI: rockchip-dwc: Potential error pointer dereference in probe

From: Robin Murphy <robin.murphy@arm.com>
Date: 2021-08-13 15:03:10
Also in: kernel-janitors, linux-pci, linux-rockchip

On 2021-08-13 15:32, Mark Brown wrote:
On Fri, Aug 13, 2021 at 03:01:10PM +0100, Robin Murphy wrote:
quoted
Indeed I've thought before that it would be nice if regulators worked like
GPIOs, where the absence of an optional one does give you NULL, and most of
the API is also NULL-safe. Probably a pretty big job though...
It also encourages *really* bad practice with error handling, and in
general there are few use cases for optional regulators where there's
not some other actions that need to be taken in the case where the
supply isn't there (elimintating some operating points or features,
reconfiguring power internally and so on).  If we genuninely don't need
to do anything special one wonders why we're trying to turn the power on
in the first place.
Sure, once you get into it, regulators are arguably a rather deeper area 
than GPIOs, so in terms of the NULL-safe aspect anything beyond 
enable/disable - for the sake of keeping trivial usage simple - would be 
pretty questionable for sure.

A lot of the usage of regulator_get_optional() seems to be just making 
sure some external thing is powered between probe() and remove() if it's 
not hard-wired already, so maybe something like a 
devm_regulator_get_optional_enabled() could be an answer to that 
argument without even touching the underlying API.

Robin.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help