Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4127306imm; Sat, 21 Jul 2018 10:46:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe2XTycdGw0CYcEtju5/3exGVaRvK0fjxcUGIG4jlHsyWPem4YfE0dGSEtnml6/DDxSlGhp X-Received: by 2002:a63:555:: with SMTP id 82-v6mr6448002pgf.25.1532195201172; Sat, 21 Jul 2018 10:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532195201; cv=none; d=google.com; s=arc-20160816; b=p+mZV/UuY62wXNNUt7BT1BoxEBrF+r3e4iMqBMDi9AIAszDL+aaEdltOdI1fldSVsN CpiuIkLI0kTx1R4XZUo1JgQkvzrOOHqVun9SXRYCzTCuxdJO+4ilSbCAlLjDdC8ySZtD eGOJCjpvFLptY6fOFZV89dxShUSPDf+73yaSnIcMB6H8CCn6iKsiaBejKlwPVEzXriD0 bkinyOoa5tBp0AZQKHBBtTxZS1wSopA/j11Cds/pt6m50RwlpjFiCklhVq8GgI8lWCvI 9J/HbabjqoEyiOxqefQFcL5auHwdWYr3GhmL9QZrf/MVvAJ52AbWrpOQpxWblX9sgj73 ee4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=/SDmpWRaJ7ZZJzlqvAMCPoOZ6jKA4QMalM/VbUk7DBQ=; b=x2Xk66xXRkvEKRd7jwbxOyp4hZ6sDYYuE+hleT/FRtJU20fe9HKI7dvJySDM2EBvvQ Ii94TVPqRHSiBJMpPsipGuFHQ85znAx7EAtoq3aoVMbY94BBYgSpq7U3uj5o9xez+r4M GqsyPqkrVwo7LKSis0PfRHRsO5pkA4xQYhUPwhxhsH3kFtSaEXvwnJ4a2IgdQuMt7ZQR pg9txJ6IgRzW2OHbz2QAzYBkZqMz7bJAKEc38uGp3eCyGAGLYCI0B2TqOx0iwpoimY8M c8BQfulzChQb2iAy6Ys7vgBgu10aiqu7uxymtjJx0n0PnnUAsqDzkcS8kDbNDeThWU6C D7xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fbtv+11r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si3985420plk.225.2018.07.21.10.46.26; Sat, 21 Jul 2018 10:46:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fbtv+11r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728130AbeGUSjH (ORCPT + 99 others); Sat, 21 Jul 2018 14:39:07 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46403 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727542AbeGUSjG (ORCPT ); Sat, 21 Jul 2018 14:39:06 -0400 Received: by mail-ed1-f66.google.com with SMTP id o8-v6so12195837edt.13; Sat, 21 Jul 2018 10:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/SDmpWRaJ7ZZJzlqvAMCPoOZ6jKA4QMalM/VbUk7DBQ=; b=Fbtv+11rJb9yWXsASYjxzqXi21gZqBN7by9kS+ctEYGOUDV6h8o5MKtZVch94KXMEV yIPgf3pcsTeR4x383u/Je9TtyMIWSn2jxXRv3EcNT8Ikcyilcm/R2tCIwWJ0d/E7+LZB efgiJmMEaPi+rCB6n+KuwFAztRjEoLh7vr3PzFFw7hsXFHZJOVRQhTU2Fylrq0MEBffl BwOJ9XaR8xGMgm9bBvYh3IY2eRy7pduoPgPkXexgS1CuK1vJBHvfKNrgscWC7//DJbe4 eblg+m0JrTAcfgSfsGBo0htEZcIFjhDLuTV+dvjZapYmsKYyU6GQO/a8WspUrAuTh5vk tgfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/SDmpWRaJ7ZZJzlqvAMCPoOZ6jKA4QMalM/VbUk7DBQ=; b=pHKj9Z/mVEfFUaXBhOhLQ3i5ZcxNW9UVhLXIlPJU7NEjaIJlZLRCMeN65KOM747aTZ YjvGUAB+W01DB+D3t4OjNnFFaSeYYAQUeRTAmhs6OucKmYycn7rl1fOcv7WAXc6h8V3h HEggigLeqj+D/iSHLpQ9oK0eBrSl7drywfsgQy0Hg63vXU+ylf/LWC+oHePgVm/CydY3 KYcE+c6i7hYWWV2L20R7szczatLOBs6YUJfzRty0CIwvXd3O2vqJBWGtxukRTgk/SASm L4cKLTgoK34sv/TsFmWadtXHOBXp9MMhyL8GnFzgkyGsOLtDH0XO4MwtPzZkZbPHqe4R BJsw== X-Gm-Message-State: AOUpUlFe7nFVTH6TsDG+gMQ/xjX/cP241q07ojLFHFQ4zDdUTtTqP0OW 2pzbgZSJsl//q7V5kiZQO5Pe0Up8NK1tZy89jqg= X-Received: by 2002:a50:ec89:: with SMTP id e9-v6mr3651483edr.258.1532195135127; Sat, 21 Jul 2018 10:45:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:e844:0:0:0:0:0 with HTTP; Sat, 21 Jul 2018 10:45:34 -0700 (PDT) In-Reply-To: References: <1532122284-19602-1-git-send-email-himanshujha199640@gmail.com> <20180721161934.75066d97@archlinux> <20180721153607.GA11127@himanshu-Vostro-3559> From: Daniel Baluta Date: Sat, 21 Jul 2018 20:45:34 +0300 Message-ID: Subject: Re: [PATCH v4] iio: chemical: Add support for Bosch BME680 sensor To: Andy Shevchenko Cc: Himanshu Jha , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Linux Kernel Mailing List , linux-iio Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 21, 2018 at 6:43 PM, Andy Shevchenko wrote: > On Sat, Jul 21, 2018 at 6:36 PM, Himanshu Jha > wrote: > >>> > + /* Look up table 1 for the possible gas range values */ >>> > + u32 lookupTable1[16] = {2147483647u, 2147483647u, 2147483647u, >>> > + 2147483647u, 2147483647u, 2126008810u, >>> > + 2147483647u, 2130303777u, 2147483647u, >>> > + 2147483647u, 2143188679u, 2136746228u, >>> > + 2147483647u, 2126008810u, 2147483647u, >>> > + 2147483647u}; > > This one needs perhaps a bit of though, but... > >>> > + /* Look up table 2 for the possible gas range values */ >>> > + u32 lookupTable2[16] = {4096000000u, 2048000000u, 1024000000u, >>> > + 512000000u, 255744255u, 127110228u, 64000000u, >>> > + 32258064u, 16016016u, 8000000u, 4000000u, >>> > + 2000000u, 1000000u, 500000u, 250000u, 125000u}; > > ...this one obviously just a not needed one. You may replace it with a > one constant and simple calculation to get either value (index from > value, or value from index). Indeed this can be reduce to: 125.000 << (15 - idx). The real question here is if we approximate 255.744.255u to 256.00.00u how much different is the result. Being a gas sensor I think it is very hard to appreciate. We can go with this formula + adding a comment with the table with the exact coefficients. thanks, Daniel.