Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1483056
| 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:00 +0200 |
| Message-ID | <shdgS-6sF-29@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> |
| Organization | linux.* mail to news gateway |
Hi Benjamin,
On Wed, Sep 14, 2016 at 09:36:03AM +0200, Benjamin Tissoires wrote:
> On Sep 05 2016 or thereabouts, Caesar Wang wrote:
> > diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> > index b3ec4f2..07cc7aa 100644
> > --- a/drivers/hid/i2c-hid/i2c-hid.c
> > +++ b/drivers/hid/i2c-hid/i2c-hid.c
> > @@ -38,6 +38,7 @@
> > #include <linux/acpi.h>
> > #include <linux/of.h>
> > #include <linux/gpio/consumer.h>
> > +#include <linux/regulator/consumer.h>
> >
> > #include <linux/i2c/i2c-hid.h>
> >
> > @@ -152,6 +153,7 @@ struct i2c_hid {
> >
> > bool irq_wake_enabled;
> > struct mutex reset_lock;
> > + struct regulator *supply;
> > };
> >
> > static int __i2c_hid_command(struct i2c_client *client,
> > @@ -968,6 +970,21 @@ static int i2c_hid_probe(struct i2c_client *client,
> > if (!ihid)
> > return -ENOMEM;
> >
> > + ihid->supply = devm_regulator_get(&client->dev, "power");
> > + if (IS_ERR(ihid->supply)) {
>
> I am not familiar with regulators, but what if (like 99% of the
> available i2c-hid devices) there is no regulator attached to the device?
>
> Will the pointer be null? Will there be a dummy regulator?
>
> It seems at first sight that you are adding a requirement on the devices
> which is not part of the spec, and which will break every existing
> systems but yours. Again, I might be wrong, so please provide more
> information.
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.
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