Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4582378pxt; Wed, 11 Aug 2021 09:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwTxWoDoiFUDpMabGFwqzrTI9VoSbJdQ7Fjg9d+yWsSUMRpAw2zdRpqSA4ukynNafM7LYS X-Received: by 2002:a05:6e02:2147:: with SMTP id d7mr241736ilv.179.1628698215788; Wed, 11 Aug 2021 09:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628698215; cv=none; d=google.com; s=arc-20160816; b=B1Nrr7f9/xXubFnqDfTD1ZnkA21MbxuHUtXusjmYiPoaZswWndbMa0Kw5WxowPxa2J BIEOZRPMNY/Fzgus/t4LcJUeUxX6TPCcAA0ze5x73z7yYd8baC36BIdflESCVbedMHzq zylZmrSRwp83A48WCPs+Blv0z4C917eO5kdN+dt+1jBY1W/pSvBvANDlJkEVjBg8p4Ek +5WBp4mPTk+5Y6EkmMMmsJs8IkwM5NvovgS1w4cL0eqk+rJAZ0uTqqi9qAQSolgjFOPy mCvc2X5m9m0mCfIWCaDzJkb8TqaRDlXq5NGy5B/7U6u6Y4f2Jwtr9Uvm4wuw0sCt8rF7 5ILQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KffArpOyUib3xLvmma0gw4eoYf5u08GOHiGqQNefyKY=; b=lM5V8R4Az0NfDpPI5iHxSPrn3CLl1yf2rL1tZzIgGr7pY7S5aqR36+ZBlt3P+B8bG4 +uAQGnp09gwvkIbW01jcnKyBvBt+JQEx5gNo5KzxwL25ua68Ax6CpcyKKKoPidUXrERB B23KOkorGlkCwqPL5Ss/403mSKbwGOCxfjoySrkWGpiTbEfxpSDetu+fx0g8UfNvZCJB JuVC/egwrhLRD8GkbnR2Oe0366z3sKRT/o9/rWIlT0hsy6HIiEt5FSJSPV9rvbyxhsYk LnW6LFUiVnS6z4oT5QUFOz4QeDrPH4cw6+isjzpTJ1y4tkDjTSRpnN69qFplRUUB242e j4Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HPsATQBC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si2116429ioo.72.2021.08.11.09.10.03; Wed, 11 Aug 2021 09:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HPsATQBC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbhHKQHs (ORCPT + 99 others); Wed, 11 Aug 2021 12:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhHKQHr (ORCPT ); Wed, 11 Aug 2021 12:07:47 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE00C061765; Wed, 11 Aug 2021 09:07:24 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id u15so1159430ple.2; Wed, 11 Aug 2021 09:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KffArpOyUib3xLvmma0gw4eoYf5u08GOHiGqQNefyKY=; b=HPsATQBC1TxP9YXDvO6/HpnceepixH7+UmUBemM9O8th0lKUu49VkCwyUE7hgiKJu+ E1iB419oPuAm3guuO9cghFv2L5raN/td2TeRpx8iWqYlB8ywGC7lulfVrCfIzTtYgb9+ MuIW3p2ylatMLkI/DzZAxcCcacf6cU7voMhmWY+fGW/Jz+DlqTUZ9Ol7crc//34rGb3z nGCYRTyyJt4n2ndvZkeSY32nfSc8EjljyrDblJ9asrt2s17SgPkWVeXs9U9XsYHhLpX9 It0+K+mdbanfy+JZ79Rgb7JcHhAiMr4T4hk9bED+aVJ15CHQ6vK5lEMicRCC5Sr04DiG 2ZlA== 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=KffArpOyUib3xLvmma0gw4eoYf5u08GOHiGqQNefyKY=; b=TFMm101y16MTRkM1ztaLpyNkb4gBRKtT7PAmWSWjuHjGa+Ooi/RPrZdppqCnQ95DDh sKlxJKDm+Zx2pb0tWWTc6VDxL2tmoD/TZ8AnIxY6H19gfsFDzQ5HrOi+rJb7UELE9a4l NhhG1J+2rlGH66VZHMowkDuBEpBJccImWP7Dnxr2j+Srz4saCUgWr0Qmbe3mhid4oYNs h/rdrzcqsrPGfLLKvmt/16tbHHx/CFZvYg6LTKz1ERfPPFob+lwPnzHszh7Bq6Pvgi88 kji1Sa2afDcPjsjEGOBHmLdlIfqKisq2GTjROHfHhcd3gGs7d7IitoT4XPy09O/23vsy VLcw== X-Gm-Message-State: AOAM531yrmRZkDmEchEh35eMmC7QHO6o6HzqF+camIMlYjEujgcyUMad jtLnpx5kLmD3sZbT/YTId7HPSl/kMPqnXf5tkmg= X-Received: by 2002:a17:902:e786:b029:12d:2a7:365f with SMTP id cp6-20020a170902e786b029012d02a7365fmr4813354plb.21.1628698043540; Wed, 11 Aug 2021 09:07:23 -0700 (PDT) MIME-Version: 1.0 References: <20210809075745.160042-1-dmugil2000@gmail.com> <20210809075745.160042-3-dmugil2000@gmail.com> <013bcb79-c496-44d8-2e93-57eb57834ee0@metafoo.de> In-Reply-To: <013bcb79-c496-44d8-2e93-57eb57834ee0@metafoo.de> From: Andy Shevchenko Date: Wed, 11 Aug 2021 19:06:43 +0300 Message-ID: Subject: Re: [PATCH v2 2/2] iio: potentiometer: Add driver support for AD5110 To: Lars-Peter Clausen Cc: Mugilraj Dhavachelvan , "Bogdan, Dragos" , Darius , Rob Herring , Jonathan Cameron , Michael Hennerich , Guenter Roeck , Chris Packham , Slawomir Stepien , Krzysztof Kozlowski , Alexandre Belloni , Alexandru Ardelean , devicetree , Linux Kernel Mailing List , linux-iio Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 11, 2021 at 11:15 AM Lars-Peter Clausen wrote: > On 8/10/21 2:49 PM, Andy Shevchenko wrote: > > > >> + data->tol = data->cfg->kohms * (val & GENMASK(6, 0)) * 10 / 8; > >> + if (!(val & BIT(7))) > >> + data->tol *= -1; > > Shouldn't you simple use corresponding sign_extend*()? > The data is encoded a sign-magnitude. sign_extend() works for two's > complement numbers. Good catch! I'm wondering if it's a good idea to have a sign_magnitude_to_int() helper or so? -- With Best Regards, Andy Shevchenko