Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp608709ybc; Sat, 23 Nov 2019 05:01:16 -0800 (PST) X-Google-Smtp-Source: APXvYqznwVtMH2eQKA/7J/mpqsPGKnRA7nulimIqnCcqrKtZgeiTsRNDiSnz/cNQk+XqGV969nNj X-Received: by 2002:a50:c305:: with SMTP id a5mr6824905edb.136.1574514075876; Sat, 23 Nov 2019 05:01:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574514075; cv=none; d=google.com; s=arc-20160816; b=BsmlKfUDL8fCNjjfmtkupKlZogYeyRq/ibm8s4wHjtbqV2X1FOS1Cnp77VLjBUFpSu L8+1ianeBz7wig4z0xFc9OOLZ0Ji5P9eWCMvpe+dkhBsyfuKIFxy549bHQ9H379QHo3s odQ8tgenXOL8pYcS/cKvQmnogPHVmBNCPF+5XZVtsc/0Dtzw/mEBhouENQcAi1LAJpwR 9SHQ97a3+KUH122WN8I/YHtRAWyUKQbY4OPBU8eY+tSRT1bNEVGqOI+ng29gfCcmAjYv RjLW67LD8TbOKRkYcJND/66KpBEYzl+8ZIjI2XhhrcZfUSKWO336kLd/53yHCrlDhgaR UIig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=uYjuyCYqVvEzW+mNzLg6TWkaH/KwhnGoopIJ8NHjGpc=; b=fHc52ie4jbk3WBjWNa1wVy89lD46cItTfnxUgFW4MiossmFFruz6gGjj/kmyp6Yruq YD73d5Qbmxe4tFvk9U3/FpzQsK6w2/qKZcfgMAEyI9sRXoTR5R8PNjYNr+qgqhFcF+Bz 0B/3WAgISiOQZ3vOsUFuXIv0OvRrQeVsVT69jswhGAw87hvE+T7L54yAknimPKcNl7Nb t+TVReTZ5Ii0WNPUJya4G56zzWZt6tw+fIXaqygx/Gi8NBCfIWNy2DvyupQ+mizFtzBT +zW0ZIe8TLNtNV47NeEhn69eK/7QE274gfL8547KtE5n636mrX0kyOpfJ+P02//sEojG IbKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i7flcV81; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si364016edx.47.2019.11.23.05.00.10; Sat, 23 Nov 2019 05:01:15 -0800 (PST) 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=@kernel.org header.s=default header.b=i7flcV81; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbfKWMvl (ORCPT + 99 others); Sat, 23 Nov 2019 07:51:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:34384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfKWMvl (ORCPT ); Sat, 23 Nov 2019 07:51:41 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFF9D20658; Sat, 23 Nov 2019 12:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574513500; bh=VcQqBg6GDNAXOn4fAhOKNH28W07HsOtsOWrG/Qk4LGo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=i7flcV814pcX83luI7s0sZh/Nn3WTIhDkvVjsjr7mE8pW5x7bN/WcV1duu1OuvWmz 78iyCoYx0ROh1GKPt5Bqy4/PklM2o88tOZ67AYbG0BC6icJzm8QCinNh9oHmqI9K4r e/WkKWqMAFHryuBiYvFT2HKkRNEAobUttnQyK1fQ= Date: Sat, 23 Nov 2019 12:51:35 +0000 From: Jonathan Cameron To: Dan Robertson Cc: Andy Shevchenko , linux-iio , Peter Meerwald-Stadler , devicetree , Hartmut Knaack , Rob Herring , Mark Rutland , Linux Kernel Mailing List , Randy Dunlap Subject: Re: [PATCH v4 2/2] iio: (bma400) add driver for the BMA400 Message-ID: <20191123125135.4c7efcb0@archlinux> In-Reply-To: <20191118002504.GA29469@nessie> References: <20191018031848.18538-1-dan@dlrobertson.com> <20191018031848.18538-3-dan@dlrobertson.com> <20191019024351.GB8593@nessie> <20191021162016.531e6a2e@archlinux> <20191118002504.GA29469@nessie> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Nov 2019 00:25:04 +0000 Dan Robertson wrote: > Sorry for the incredibly late reply. Before I submit the next patchset version, > I have a question from the last set of reviews. > > On Mon, Oct 21, 2019 at 04:20:16PM +0100, Jonathan Cameron wrote: > > On Sat, 19 Oct 2019 02:43:51 +0000 > > Dan Robertson wrote: > > > On Fri, Oct 18, 2019 at 10:23:38AM +0300, Andy Shevchenko wrote: > > > > On Fri, Oct 18, 2019 at 6:44 AM Dan Robertson wrote: > > > > > +static const int bma400_osr_table[] = { 0, 1, 3 }; > > > > > > > > > +/* See the ACC_CONFIG1 section of the datasheet */ > > > > > +static const int bma400_sample_freqs[] = { > > > > > + 12, 500000, > > > > > + 25, 0, > > > > > + 50, 0, > > > > > + 100, 0, > > > > > + 200, 0, > > > > > + 400, 0, > > > > > + 800, 0, > > > > > +}; > > > > > > > > This can be replaced by a formula(s). > > > > > > Yeah I think I can implement the get, set, and read functions for sample_freq > > > with a formula, but the scale and sample frequency tables are needed by the > > > implementation of read_avail. A implementation of read_avail with a range and > > > a step would be ideal, but I couldn't find any documentation on implementing > > > read_avail where the step value of the range is a multiple. Please correct > > > me if I've missed something. > > > > Indeed. We've only defined it as being fixed intervals. > > I'm not keen to expand the options for the userspace interface any > > further. > > > > You could compute the values at startup and store it in your state structure > > I think (or compute them on demand, but you'd need to have the space somewhere > > non volatile). > > > > I ended up writing an implementation that uses a formula for the get/set > functions of the sample frequency and scale, but uses a table for the > implementation of the read_avail function. While it does work, I worry > that this makes the driver less maintainable and would make it harder to > add support for a new hypothetical future BMA4xx device. Also, the majority > of drivers seem to use a table for the raw value to user input conversion, > so a move from this might make the code less "familiar". > > If we do stick with the translation table, would it be better to have two > tables (a translation table and a read_avail table) so that we do not have > a step distance of two? This would mean we would need to maintain two > tables, but would simplify the code. If a function is your preferred route you could also just use it to compute the values for the available table at startup? Otherwise, its fine to just use a table for both. > > Random workflow question: > > The sampling ratio, frequency, etc code seems to be the most complicated part > of the driver. Is it typically recommended to upstream a more minimal driver > that might assume the defaults? Often people upstream a first version that just uses defaults, then follow up (if they care) with later series adding the more fiddly elements. Sometimes those more fiddly bits never come as a particular author never needed them. That's absolutely fine. It's a rare driver that supports all the features on a non trivial device! Thanks, Jonathan > > Cheers, > > - Dan >