From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754316AbdEEUcK (ORCPT ); Fri, 5 May 2017 16:32:10 -0400 Received: from mga14.intel.com ([192.55.52.115]:25998 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbdEEUcI (ORCPT ); Fri, 5 May 2017 16:32:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,294,1491289200"; d="scan'208";a="83161910" Message-ID: <1494016323.30052.44.camel@linux.intel.com> Subject: Re: [PATCH v3] iio: adc: Add support for TI ADC108S102 and ADC128S102 From: Andy Shevchenko To: Jan Kiszka , Jonathan Cameron Cc: linux-iio@vger.kernel.org, Linux Kernel Mailing List , Sascha Weisenberger , Mika Westerberg , Peter Meerwald-Stadler , Rob Herring Date: Fri, 05 May 2017 23:32:03 +0300 In-Reply-To: References: <6d6bf102-1bc9-7019-13fa-b8f86b002dc8@siemens.com> <1493978058.30052.26.camel@linux.intel.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-05-05 at 22:09 +0200, Jan Kiszka wrote: > On 2017-05-05 20:52, Jonathan Cameron wrote: > > On 05/05/17 11:39, Jan Kiszka wrote: > > > On 2017-05-05 11:54, Andy Shevchenko wrote: > > > > On Fri, 2017-05-05 at 08:31 +0200, Jan Kiszka wrote: >>>>> + if (st->reg) > > > > > + *val = > > > > > regulator_get_voltage(st->reg)  > > > > > / 1000; > > > > > + else > > > > > + *val = st->va_millivolt; > > > > > + > > > > > > > > Another way is to not just hard code the value, but create a > > > > fixed > > > > voltage regulator out of it. In this case you will have one way > > > > to get > > > > its value. > > > > > > That's a good idea. > > > > Agreed. Make sure to cc Mark Brown though as I'll need an ack from > > him > > to have a fixed reg hiding in here. > > After diving deeper, it not longer appears to be a good idea: > > - pulls in a non-obvious requirement for CONFIG_REGULATOR on platforms >   that otherwise do not need it Why is it a problem? > - requires complex life-cycle management so that the fixed regulator > is >   instantiated on the first device creation and removed with the last >   one Who cares if you register more than one? > We better go with the static value assignment. > > I'll move that regulator_get_voltage into the probing function which > will simplify things further (va_millivolt will carry the value for > both > cases). Yes, it would be the way, if system has it's fixed. But in this case you need to threat regulator as optional if we are going to enable/disable them for PM. -- Andy Shevchenko Intel Finland Oy