From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B7E9C433E0 for ; Fri, 25 Dec 2020 23:02:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEE60221F2 for ; Fri, 25 Dec 2020 23:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbgLYXCn (ORCPT ); Fri, 25 Dec 2020 18:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbgLYXCm (ORCPT ); Fri, 25 Dec 2020 18:02:42 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73668C061757 for ; Fri, 25 Dec 2020 15:02:02 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id o19so11985349lfo.1 for ; Fri, 25 Dec 2020 15:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W7kgYUPj5wyVPSjt7NtTM40G6jAIhR4GN3Ie87rla5k=; b=vaUTs5BujakkEV4Lxkldz/infgxH0RkRWSeL+vctTx9AvRHZdJJUBNb0FJntwIRlb1 K9zjqHFLyJe8Hj3WwhDi8tli7mUx6agsQVqrXAfKK4PZGF1i751snasvzJXrjRtP3N+j +VGRnIGEQo8dx2DgKml6s6YsYld79dV+er/jUncSAJ/OXjNFBUZnLoFcoFHWEAamI3TG +/Vk7Nb9Llk1ki//kL0PrtmURbhJqkxrGMPiuDgs7mAttgRXzkV8mGN/ZnLw+SiswG+l xuH2/1tJteQ22fqt03TG6F87p01HEYuKMUiutCDu6yeFBHC0/gpTMvWifjTGiIWpGaij RrSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W7kgYUPj5wyVPSjt7NtTM40G6jAIhR4GN3Ie87rla5k=; b=Mw/FWtuvDKuzJhm/U77OG51koFf7FLzci3QWt1ijEtOm8I3sqH8KXuPR9E1stP2ubB +J5LhLHe5MqDB4UB7vbkgT3QF/pBawcLxR7Fah0T6BOkBhWS9vGLIOv0FilUKEdw29UE p2o3ZYbHzQo22dNVmu/j1y+AexhOtsU/8RXCsyhDsfRUD0mZPvNUj0zGED61Sfqih3JA FZfKkzUrgfi8CosCVtWc57Ti4IKNk3bxDrnMCPegEKe31NMV0lUc+eoVgN+z2sDj8ZD+ /SVmwDyZLdm2Ht5oyCF7gXaZSPMFLY4NxWtyrVXReVI8O6Kc0dVT53XpXPuQprO7vimJ Ixsg== X-Gm-Message-State: AOAM533eI82ZR+OmBhcv/0s5CLZKtS+Alze/dX9IEEP1i8I4i4SupxBV 85kR/QLsVj2Gw0xMaF+C/gV2BNRCv2iuip3DmWKewQ== X-Google-Smtp-Source: ABdhPJwoHbDlFdgOO0TTuX060NKMOOgybjhfodifrEyR6nOxde9rkAKHRfgO3UMuJ0OvY3hKSbtY+qNvffZImBepJb4= X-Received: by 2002:a05:651c:205b:: with SMTP id t27mr17406796ljo.368.1608937320775; Fri, 25 Dec 2020 15:02:00 -0800 (PST) MIME-Version: 1.0 References: <20201224011607.1059534-1-linus.walleij@linaro.org> In-Reply-To: From: Linus Walleij Date: Sat, 26 Dec 2020 00:01:49 +0100 Message-ID: Subject: Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed To: Chris Lesiak Cc: Jean Delvare , Guenter Roeck , "linux-hwmon@vger.kernel.org" , Peter Rosin , Jonathan Cameron , "linux-iio@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org On Thu, Dec 24, 2020 at 4:15 AM Chris Lesiak wrote: > A closer reading of the "iio: inkern: pass through raw values if no scaling" > commit leads me to believe that even when the sensor provides no scale, > the returned value is expected to be in the correct units. > > If that is true, there was a bug in the commit. > It failed to apply the caller supplied scale that ntc_thermistor.c relies on > to convert from milliVolts to microVolts. > > Linus, would this change address your original problem? > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c > index fe30bcb6a57b..79787474d511 100644 > --- a/drivers/iio/inkern.c > +++ b/drivers/iio/inkern.c > @@ -587,7 +587,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, > * Just pass raw values as processed if no scaling is > * available. > */ > - *processed = raw; > + *processed = raw * scale; > return 0; > } I do not think the raw values have any obligation to be in e.g. millivolts. They may be, by chance. In my case, it is just an unscaled byte [0..255]. So it unfortunately does not solve my problem, because in my driver, that does not support scaling, the result will be the raw value * 1000 which is not going to be microvolts at all, because the raw values are not millivolts, rather a value 0..255. However if I used the processed values, the value will be adjusted non-linearly to millivolts. Yours, Linus Walleij