From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763493AbcINObP (ORCPT ); Wed, 14 Sep 2016 10:31:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758575AbcINObL (ORCPT ); Wed, 14 Sep 2016 10:31:11 -0400 Date: Wed, 14 Sep 2016 16:31:02 +0200 From: Benjamin Tissoires To: Brian Norris Cc: Caesar Wang , Jiri Kosina , linux-rockchip@lists.infradead.org, dbasehore@chromium.org, Douglas Anderson , Heiko Stuebner , linux-input@vger.kernel.org, Mika Westerberg , Dmitry Torokhov , Benson Leung , Guohua Zhong , "Zhonghui\"" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] HID: i2c-hid: support the regulator Message-ID: <20160914143102.GK25951@mail.corp.redhat.com> References: <1473027116-13892-1-git-send-email-wxt@rock-chips.com> <1473027116-13892-2-git-send-email-wxt@rock-chips.com> <20160914073603.GH25951@mail.corp.redhat.com> <20160914075505.GA14271@localhost> <20160914080241.GA14576@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160914080241.GA14576@localhost> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Sep 2016 14:31:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sep 14 2016 or thereabouts, Brian Norris wrote: > 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. Well, all the other regulator calls are either regulator_enable() or regulator_disable(), which in this case (CONFIG_REGULATOR=n) are returning 0. So I think the whole patch is safe in its current form. Thanks for the explanations. Acked-by: Benjamin Tissoires Cheers, Benjamin > > Brian