From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbbIWHkF (ORCPT ); Wed, 23 Sep 2015 03:40:05 -0400 Received: from mail.lysator.liu.se ([130.236.254.3]:53673 "EHLO mail.lysator.liu.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbbIWHkD (ORCPT ); Wed, 23 Sep 2015 03:40:03 -0400 Subject: Re: [PATCH v4 2/2] iio: mcp4531: Driver for Microchip digital potentiometers To: Jonathan Cameron , linux-iio@vger.kernel.org References: <1442936209-27057-1-git-send-email-peda@lysator.liu.se> <1442936209-27057-3-git-send-email-peda@lysator.liu.se> Cc: Peter Rosin , Crt Mori , Daniel Baluta , Andreas Dannenberg , Greg Kroah-Hartman , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-kernel@vger.kernel.org From: Peter Rosin Message-ID: <5602574B.5020205@lysator.liu.se> Date: Wed, 23 Sep 2015 09:39:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015-09-22 20:22, Jonathan Cameron wrote: > On 22 September 2015 16:36:49 BST, Peter Rosin wrote: *snip* lots of cosmetics that I'll fix in the next spin... >> + >> +static int mcp4531_read_raw(struct iio_dev *indio_dev, >> + struct iio_chan_spec const *chan, >> + int *val, int *val2, long mask) >> +{ >> + int err; >> + >> + switch (mask) { >> + case IIO_CHAN_INFO_RAW: >> + err = mcp4531_get_value(indio_dev, chan->address, val); >> + if (err < 0) >> + return err; >> + return IIO_VAL_INT; >> + } > No scale known? Be nice to relate to real world values. I gather this may need > platform data of some type (can't open data sheet on phone for some reason) ...but I need more input on this. Yes, it would be nice and yes it requires platform data, as there is no way to retrieve if the driver is dealing with a 5, 10, 50 or 100 kOhms pot/rheostat. You would also have to expose both the resistance between A to W and between W to B, as you have no way to know how it's been connected (or you'd need more platform data). Ok, for rheostats you know how it's connected, since A isn't available, but for pots there are two resistance values controlled with a single value X i.e. X*scale/max and (max-X)*scale/max (ignoring the 75 Ohm wiper resistance). But, I'd rather not go there, as I don't need any of it. Is it Ok to not provide scaling? Cheers, Peter