Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp92748ybz; Tue, 21 Apr 2020 05:23:36 -0700 (PDT) X-Google-Smtp-Source: APiQypJP9nhmpgMum2hn7eUWkBwejx5nff0211KKF282tgSTgqZC+mRuhKT0VI8n/n7QoIbtX8Hi X-Received: by 2002:aa7:d311:: with SMTP id p17mr18853577edq.73.1587471815935; Tue, 21 Apr 2020 05:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587471815; cv=none; d=google.com; s=arc-20160816; b=dgfrnR9OL4AhjydCer+c5xNR4mg0aWIV2sYptJk0Y09j2Y3uR2n4PeZPTepxtLDiXY qAm4FrNk26e2pXeeLFMHiypz9246WicYSdsxDXOWZEqgwdU9tlfWzJDjRm+ZG2KICg48 uRtvXrg6OWDRTqIbdSATTh7yqxo8T+i7M1xgo9OGCr914i2T92ve3/8FtkRK8NA8gCVM ot4DldbcSkjb081cd/iA2bRlnSwsTMy5Tzry/SKe1wxTL6tEENtyoxIgzUTRLQp53RGq mD5VIYTviJH97pBRg1g9OMM2LjdmvIprsttRWSO3SLiLJJ3875eDYhEBim+M9J1fkS5S Tcow== 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 :in-reply-to:references:mime-version:dkim-signature; bh=8sHt8rACV0yZYLyEpCbUse20aIl7fEUIoxUsoOswD+k=; b=PwteQYlHRYg4YVh7JDrQyz7dMPhG8xOnolukkuhPSwyZmm3uDnU3ru/bP/xyNohVSZ CWoqaR7vt9Sp+DPecgI0RiLzIANlFvV/Dz6S+R5qvS9ocKVU1Nd4DPgOTs0xR7Mp/Th3 51Q6b+bz+1QWri37jBT2m5DO72i61CLoX9YsZ2nbe5vcPMFnroM+sKHG8/4pQqQpQ7wj NwKj5UVywqnyNcsGGIsZVF9fQxSkldzdYVXwFP+5rSZi9W5IuVerDxr5fPNPKyF98Bzb kNuBXau6JzAcypaTSubqM9gXt0NZhV2qGMlFC9FjAlFj86StTGvfSWs4DRuYml2JFE1q /2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ndBQEhgY; 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 h59si1370358edc.222.2020.04.21.05.23.12; Tue, 21 Apr 2020 05:23:35 -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=ndBQEhgY; 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 S1728761AbgDUMWT (ORCPT + 99 others); Tue, 21 Apr 2020 08:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726018AbgDUMWS (ORCPT ); Tue, 21 Apr 2020 08:22:18 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D96E0C061A10; Tue, 21 Apr 2020 05:22:18 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id f8so5193398plt.2; Tue, 21 Apr 2020 05:22:18 -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=8sHt8rACV0yZYLyEpCbUse20aIl7fEUIoxUsoOswD+k=; b=ndBQEhgYJd0zICtRgs6Yy/gHJhOtx99YjM4TK0LBPLlYCsmWLAJwk8TcSSr6FtNZPg TiHeBhW9XaMym13AhQnMws+4s/5/TDA72yp8R9ebMQmdeQggvpkaEw3mh8kb72ZX1YOO d+/koVewepSFYmOG2Q+EhNG+MQfa8zgcdLvxLU3HoDcFfSl1A46l4rdqsQrcQuKtpQ1X SNkNePwjuRPsjnMEc8Aqw8VVHPPhb5O31X0igg5S6RoUTt76owjtGITaAMMTimiTAr9l LLBHnHN53qJhgduZlWCbpYfcei3wNocFxmH6Sg6IoKV52uiJJzJfIUT3Zo/6IGK/g5Ye 6XBQ== 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=8sHt8rACV0yZYLyEpCbUse20aIl7fEUIoxUsoOswD+k=; b=eLV6Yi6XAaqmVno1mVmg+uZgjMAhQceb8UVvFh+sL4jkLE0jP64qTLK2zvQV6XTbMI 8WF0AK6gMlk0vMoX8yLzIB9esLOi27+aqrulpm7lRyR48xnLu41l2EXH77e86CPl7/zy OpHQpeSnccCzqUHkdMd1a7MZwmxiGY+XEaaz2OCDFckQec8X4hd62bouN1PEw8GX7dks nZZLF7PIolmf8IhauDFoT/fwMTiGvQ4nxTqBlxqh6vT8M4Q+MKM/pYoB714JTWilmozI w4IZQPkSnUcWKUwpilLLKEjxKJNzjWjYxL9DcxMoBBEfosNzS/L80mzZ881rKcwF5+Y+ x3mA== X-Gm-Message-State: AGi0Puack588qPRxo0WO+zSz7VMXNlL2SYhORvajNCQmn8B/pXXFPp6y 98yqWy8yiZAJiOBsV6ARJBa1XuT158hf9CAYrZCT5tiyusbPtQ== X-Received: by 2002:a17:90a:364c:: with SMTP id s70mr5171704pjb.143.1587471738292; Tue, 21 Apr 2020 05:22:18 -0700 (PDT) MIME-Version: 1.0 References: <20200421075532.19192-1-m.othacehe@gmail.com> <20200421075532.19192-4-m.othacehe@gmail.com> In-Reply-To: <20200421075532.19192-4-m.othacehe@gmail.com> From: Andy Shevchenko Date: Tue, 21 Apr 2020 15:22:11 +0300 Message-ID: Subject: Re: [PATCH v4 3/4] iio: vcnl4000: Add sampling frequency support for VCNL4010/20. To: Mathieu Othacehe Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio , Linux Kernel Mailing List 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 Tue, Apr 21, 2020 at 10:56 AM Mathieu Othacehe wrote: > > Add sampling frequency support for proximity data on VCNL4010 and VCNL4020 > chips. Couple of nitpicks below. ... > +static const int vcnl4010_prox_sampling_frequency[][2] = { > + {1, 950000}, > + {3, 906250}, > + {7, 812500}, > + {16, 625000}, > + {31, 250000}, > + {62, 500000}, > + {125, 0}, > + {250, 0} Leave comma here, potentially helpful if it will be extended. > +}; ... > +static int vcnl4010_write_proxy_samp_freq(struct vcnl4000_data *data, int val, > + int val2) > +{ > + int i; > + const int len = ARRAY_SIZE(vcnl4010_prox_sampling_frequency); > + > + for (i = 0; i < len; i++) { > + if (val <= vcnl4010_prox_sampling_frequency[i][0]) > + break; > + } > + > + if (i == len) > + return -EINVAL; I would refactor this unsigned int i = ARRAY_SIZE(vcnl4010_prox_sampling_frequency); do { if (val > vcnl4010_prox_sampling_frequency[i][0]) break; } while (--i); You won't need to go full array to return error in this case. > + return i2c_smbus_write_byte_data(data->client, VCNL4010_PROX_RATE, i); > +} -- With Best Regards, Andy Shevchenko