Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1483072
| From | Brian Norris <briannorris@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] HID: i2c-hid: support the regulator |
| Date | 2016-09-14 10:10 +0200 |
| Message-ID | <shdqx-6LD-3@gated-at.bofh.it> (permalink) |
| References | <sdNVD-3nb-1@gated-at.bofh.it> <sdNVE-3nb-3@gated-at.bofh.it> <shcXw-6ki-33@gated-at.bofh.it> <shdgS-6sF-29@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Sep 14, 2016 at 03:55:05PM +0800, Brian Norris wrote:
> The default behavior of regulator_get() is to provide a dummy regulator
> if none is found. So the pointer is never NULL, and it won't break
> devices without a regulator. If you don't want a dummy regulator you
> would use regulator_get_optional() instead, and you would then need to
> handle ERR_PTR(-ENODEV) specifically.
One caveat to the never-NULL comment above that I just noticed:
If CONFIG_REGULATOR=n, then regulator_get() actually returns NULL (see
include/linux/regulator/consumer.h), but it also specifically has a
comment right next to that NULL return, saying:
/* Nothing except the stubbed out regulator API should be
* looking at the value except to check if it is an error
* value. Drivers are free to handle NULL specifically by
* skipping all regulator API calls, but they don't have to.
* Drivers which don't, should make sure they properly handle
* corner cases of the API, such as regulator_get_voltage()
* returning 0.
*/
So, we still don't need to handle the NULL case specially.
Brian
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 2/2] HID: i2c-hid: support the regulator Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-09-14 09:40 +0200
Re: [PATCH 2/2] HID: i2c-hid: support the regulator Brian Norris <briannorris@chromium.org> - 2016-09-14 10:00 +0200
Re: [PATCH 2/2] HID: i2c-hid: support the regulator Brian Norris <briannorris@chromium.org> - 2016-09-14 10:10 +0200
Re: [PATCH 2/2] HID: i2c-hid: support the regulator Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2016-09-14 16:40 +0200
csiph-web