linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <briannorris-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Benjamin Tissoires
	<benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Jiri Kosina <jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
	Dmitry Torokhov <dtor-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	Douglas Anderson
	<dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Guohua Zhong
	<ghzhong-COaM65pZ/3cNIbNsV2NXlwC/G2K4zDHf@public.gmane.org>,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Benson Leung <bleung-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"Zhonghui\""
	<zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Caesar Wang <wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Subject: Re: [PATCH 2/2] HID: i2c-hid: support the regulator
Date: Wed, 14 Sep 2016 15:55:06 +0800	[thread overview]
Message-ID: <20160914075505.GA14271@localhost> (raw)
In-Reply-To: <20160914073603.GH25951-/m+UfqrgI5QNLKR9yMNcA1aTQe2KTcn/@public.gmane.org>

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

  parent reply	other threads:[~2016-09-14  7:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-04 22:11 [PATCH 1/2] dt-bindings: add the regulator optional properties Caesar Wang
     [not found] ` <1473027116-13892-1-git-send-email-wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-09-04 22:11   ` [PATCH 2/2] HID: i2c-hid: support the regulator Caesar Wang
2016-09-14  7:36     ` Benjamin Tissoires
     [not found]       ` <20160914073603.GH25951-/m+UfqrgI5QNLKR9yMNcA1aTQe2KTcn/@public.gmane.org>
2016-09-14  7:55         ` Brian Norris [this message]
2016-09-14  8:02           ` Brian Norris
2016-09-14 14:31             ` Benjamin Tissoires
2016-09-12 16:16 ` [PATCH 1/2] dt-bindings: add the regulator optional properties Rob Herring

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=20160914075505.GA14271@localhost \
    --to=briannorris-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=bleung-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=dtor-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=ghzhong-COaM65pZ/3cNIbNsV2NXlwC/G2K4zDHf@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).